[amd64/tramp] hide interpreter specific trampoline behind ifdef
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / DesignerPerfEventProvider.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4
5 namespace System.Activities.Presentation
6 {
7     using System;
8     using System.Collections.Generic;
9     using System.Text;
10     using System.Diagnostics.Eventing;
11
12     class DesignerPerfEventProvider
13     {
14         EventProvider provider = null;
15
16         public DesignerPerfEventProvider()
17         {
18             try
19             {
20                 this.provider = new EventProvider(new Guid("{B5697126-CBAF-4281-A983-7851DAF56454}"));
21             }
22             catch (PlatformNotSupportedException)
23             {
24                 this.provider = null;
25             }
26         }
27
28         public void WorkflowDesignerApplicationIdleAfterLoad()
29         {
30             if (this.IsEnabled())
31             {
32                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerApplicationIdleAfterLoad);
33             }
34         }
35
36         public void WorkflowDesignerDeserializeEnd()
37         {
38             if (this.IsEnabled())
39             {
40                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerDeserializeEnd);
41             }
42         }
43
44         public void WorkflowDesignerDeserializeStart()
45         {
46             if (this.IsEnabled())
47             {
48                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerDeserializeStart);
49             }
50         }
51
52         public void WorkflowDesignerDrop()
53         {
54             if (this.IsEnabled())
55             {
56                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerDrop);
57             }
58         }
59
60         public void WorkflowDesignerIdleAfterDrop()
61         {
62             if (this.IsEnabled())
63             {
64                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerIdleAfterDrop);
65             }
66         }
67
68         public void WorkflowDesignerLoadComplete()
69         {
70             if (this.IsEnabled())
71             {
72                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerLoadComplete);
73             }
74         }
75
76         public void WorkflowDesignerLoadStart()
77         {
78             if (this.IsEnabled())
79             {
80                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerLoadStart);
81             }
82         }
83
84         public void WorkflowDesignerSerializeEnd()
85         {
86             if (this.IsEnabled())
87             {
88                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerSerializeEnd);
89             }
90         }
91
92         public void WorkflowDesignerSerializeStart()
93         {
94             if (this.IsEnabled())
95             {
96                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerSerializeStart);
97             }
98         }
99
100         public void WorkflowDesignerExpressionEditorCompilationEnd()
101         {
102             if (this.IsEnabled())
103             {
104                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerExpressionEditorCompilationEnd);
105             }
106         }
107
108         public void WorkflowDesignerExpressionEditorCompilationStart()
109         {
110             if (this.IsEnabled())
111             {
112                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerExpressionEditorCompilationStart);
113             }
114         }
115
116         public void WorkflowDesignerExpressionEditorLoaded()
117         {
118             if (this.IsEnabled())
119             {
120                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerExpressionEditorLoaded);
121             }
122         }
123
124         public void WorkflowDesignerExpressionEditorLoadStart()
125         {
126             if (this.IsEnabled())
127             {
128                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerExpressionEditorLoadStart);
129             }
130         }
131
132         public void WorkflowDesignerValidationEnd()
133         {
134             if (this.IsEnabled())
135             {
136                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerValidationEnd);
137             }
138         }
139
140         public void WorkflowDesignerValidationStart()
141         {
142             if (this.IsEnabled())
143             {
144                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerValidationStart);
145             }
146         }
147
148         public void FlowchartDesignerLoadEnd()
149         {
150             if (this.IsEnabled())
151             {
152                 WriteEventHelper((int)DesignerPerfEvents.FlowchartDesignerLoadEnd);
153             }
154         }
155
156         public void FlowchartDesignerLoadStart()
157         {
158             if (this.IsEnabled())
159             {
160                 WriteEventHelper((int)DesignerPerfEvents.FlowchartDesignerLoadStart);
161             }
162         }
163
164         public void FreeFormPanelMeasureEnd()
165         {
166             if (this.IsEnabled())
167             {
168                 WriteEventHelper((int)DesignerPerfEvents.FreeFormPanelMeasureEnd);
169             }
170         }
171
172         public void FreeFormPanelMeasureStart()
173         {
174             if (this.IsEnabled())
175             {
176                 WriteEventHelper((int)DesignerPerfEvents.FreeFormPanelMeasureStart);
177             }
178         }
179
180         public void WorkflowDesignerCopyStart()
181         {
182             if (this.IsEnabled())
183             {
184                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerCopyStart);
185             }
186         }
187
188         public void WorkflowDesignerCopyEnd()
189         {
190             if (this.IsEnabled())
191             {
192                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerCopyEnd);
193             }
194         }
195
196         public void WorkflowDesignerPasteStart()
197         {
198             if (this.IsEnabled())
199             {
200                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerPasteStart);
201             }
202         }
203
204         public void WorkflowDesignerPasteEnd()
205         {
206             if (this.IsEnabled())
207             {
208                 WriteEventHelper((int)DesignerPerfEvents.WorkflowDesignerPasteEnd);
209             }
210         }
211
212         public void DesignerTreeViewLoadChildrenStart()
213         {
214             if (this.IsEnabled())
215             {
216                 WriteEventHelper((int)DesignerPerfEvents.DesignerTreeViewLoadChildrenStart);
217             }
218         }
219
220         public void DesignerTreeViewLoadChildrenEnd()
221         {
222             if (this.IsEnabled())
223             {
224                 WriteEventHelper((int)DesignerPerfEvents.DesignerTreeViewLoadChildrenEnd);
225             }
226         }
227
228         public void DesignerTreeViewUpdateStart()
229         {
230             if (this.IsEnabled())
231             {
232                 WriteEventHelper((int)DesignerPerfEvents.DesignerTreeViewUpdateStart);
233             }
234         }
235
236         public void DesignerTreeViewUpdateEnd()
237         {
238             if (this.IsEnabled())
239             {
240                 WriteEventHelper((int)DesignerPerfEvents.DesignerTreeViewUpdateEnd);
241             }
242         }
243
244         public void DesignerTreeViewExpandStart()
245         {
246             if (this.IsEnabled())
247             {
248                 WriteEventHelper((int)DesignerPerfEvents.DesignerTreeViewExpandStart);
249             }
250         }
251
252         public void DesignerTreeViewExpandEnd()
253         {
254             if (this.IsEnabled())
255             {
256                 WriteEventHelper((int)DesignerPerfEvents.DesignerTreeViewExpandEnd);
257             }
258         }
259
260         public void TypeBrowserApplicationIdleAfterShowDialog()
261         {
262             if (this.IsEnabled())
263             {
264                 WriteEventHelper((int)DesignerPerfEvents.TypeBrowserApplicationIdleAfterShowDialog);
265             }
266         }
267
268         public void TypeBrowserOkPressed()
269         {
270             if (this.IsEnabled())
271             {
272                 WriteEventHelper((int)DesignerPerfEvents.TypeBrowserOkPressed);
273             }
274         }
275
276         public void SelectionChangedStart()
277         {
278             if (this.IsEnabled())
279             {
280                 WriteEventHelper((int)DesignerPerfEvents.SelectionChangedStart);
281             }
282         }
283
284         public void PropertyInspectorUpdatePropertyListStart()
285         {
286             if (this.IsEnabled())
287             {
288                 WriteEventHelper((int)DesignerPerfEvents.PropertyInspectorUpdatePropertyListStart);
289             }
290         }
291
292         public void PropertyInspectorUpdatePropertyListEnd()
293         {
294             if (this.IsEnabled())
295             {
296                 WriteEventHelper((int)DesignerPerfEvents.PropertyInspectorUpdatePropertyListEnd);
297             }
298         }
299
300         private bool IsEnabled()
301         {
302             bool isEnabled = false;
303             if (this.provider != null)
304             {
305                 isEnabled = this.provider.IsEnabled();
306             }
307             return isEnabled;
308         }
309
310         private void WriteEventHelper(int eventId)
311         {
312             if (this.provider != null)
313             {
314                 EventDescriptor descriptor = new EventDescriptor(eventId, 0, 0, 0, 0, 0, 0);
315                 this.provider.WriteEvent(ref descriptor);
316             }
317         }
318     }
319 }