1 namespace System.Workflow.ComponentModel.Design
2 {
3     using System;
4     using System.Drawing;
5     using System.Collections;
6     using System.Collections.ObjectModel;
7     using System.Collections.Generic;
8     using System.Collections.Specialized;
9     using System.Windows.Forms;
10     using System.Windows.Forms.Design;
11     using System.ComponentModel;
12     using System.ComponentModel.Design;
13     using System.CodeDom;
14     using System.IO;
15     using System.Reflection;
16     using System.Drawing.Printing;
17     using System.Drawing.Drawing2D;
18     using System.Runtime.InteropServices;
19     using System.Workflow.ComponentModel;
20     using System.Workflow.ComponentModel.Compiler;
21     using System.Security.Permissions;
22 
23     #region Workflow Interfaces
24 
25     #region Interface IIdentifierCreationService
26 
27     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
28     public interface IIdentifierCreationService
29     {
EnsureUniqueIdentifiers(CompositeActivity parentActivity, ICollection childActivities)30         void EnsureUniqueIdentifiers(CompositeActivity parentActivity, ICollection childActivities);
ValidateIdentifier(Activity activity, string identifier)31         void ValidateIdentifier(Activity activity, string identifier);
32     }
33 
34     #endregion
35 
36     #region Interface IMemberCreationService
37 
38     //Revisit the functions in this interface for consistency and performance
39     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
40     public interface IMemberCreationService
41     {
CreateField(string className, string fieldName, Type fieldType, Type[] genericParameterTypes, MemberAttributes attributes, CodeSnippetExpression initializationExpression, bool overwriteExisting)42         void CreateField(string className, string fieldName, Type fieldType, Type[] genericParameterTypes, MemberAttributes attributes, CodeSnippetExpression initializationExpression, bool overwriteExisting);
CreateProperty(string className, string propertyName, Type propertyType, AttributeInfo[] attributes, bool emitDependencyProperty, bool isMetaProperty, bool isAttached, Type ownerType, bool isReadOnly)43         void CreateProperty(string className, string propertyName, Type propertyType, AttributeInfo[] attributes, bool emitDependencyProperty, bool isMetaProperty, bool isAttached, Type ownerType, bool isReadOnly);
CreateEvent(string className, string eventName, Type eventType, AttributeInfo[] attributes, bool emitDependencyProperty)44         void CreateEvent(string className, string eventName, Type eventType, AttributeInfo[] attributes, bool emitDependencyProperty);
UpdateTypeName(string oldClassName, string newClassName)45         void UpdateTypeName(string oldClassName, string newClassName);
UpdateBaseType(string className, Type baseType)46         void UpdateBaseType(string className, Type baseType);
UpdateProperty(string className, string oldPropertyName, Type oldPropertyType, string newPropertyName, Type newPropertyType, AttributeInfo[] attributes, bool emitDependencyProperty, bool isMetaProperty)47         void UpdateProperty(string className, string oldPropertyName, Type oldPropertyType, string newPropertyName, Type newPropertyType, AttributeInfo[] attributes, bool emitDependencyProperty, bool isMetaProperty);
UpdateEvent(string className, string oldEventName, Type oldEventType, string newEventName, Type newEventType, AttributeInfo[] attributes, bool emitDependencyProperty, bool isMetaProperty)48         void UpdateEvent(string className, string oldEventName, Type oldEventType, string newEventName, Type newEventType, AttributeInfo[] attributes, bool emitDependencyProperty, bool isMetaProperty);
RemoveProperty(string className, string propertyName, Type propertyType)49         void RemoveProperty(string className, string propertyName, Type propertyType);
RemoveEvent(string className, string eventName, Type eventType)50         void RemoveEvent(string className, string eventName, Type eventType);
51 
ShowCode(Activity activity, string methodName, Type delegateType)52         void ShowCode(Activity activity, string methodName, Type delegateType);
ShowCode()53         void ShowCode();
54     }
55 
56     #endregion
57 
58     #region Interface IExtendedUIService
59     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
60     public interface IExtendedUIService
61     {
AddWebReference(out Uri url, out Type proxyClass)62         DialogResult AddWebReference(out Uri url, out Type proxyClass);
GetUrlForProxyClass(Type proxyClass)63         Uri GetUrlForProxyClass(Type proxyClass);
GetProxyClassForUrl(Uri url)64         Type GetProxyClassForUrl(Uri url);
65 
66         //Task provider related functionality
AddDesignerActions(DesignerAction[] actions)67         void AddDesignerActions(DesignerAction[] actions);
RemoveDesignerActions()68         void RemoveDesignerActions();
69 
70         //Property Grid related functionality
NavigateToProperty(string propName)71         bool NavigateToProperty(string propName);
72 
73         //Get the selected property context from property grid
GetSelectedPropertyContext()74         ITypeDescriptorContext GetSelectedPropertyContext();
75 
76         //Show the ToolsOptions
ShowToolsOptions()77         void ShowToolsOptions();
78 
79         //Retrieve Xsd project Item information
GetXsdProjectItemsInfo()80         Dictionary<string, Type> GetXsdProjectItemsInfo();
81 
82         //Add assembly reference (including dynamic assembly resolution)
AddAssemblyReference(AssemblyName assemblyName)83         void AddAssemblyReference(AssemblyName assemblyName);
84 
85 
86     }
87 
88     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
89     public interface IExtendedUIService2
90     {
91         //Get current project's target version
GetTargetFrameworkVersion()92         long GetTargetFrameworkVersion();
93 
94         //Get if the given type is supported in the current target framework
IsSupportedType(Type type)95         bool IsSupportedType(Type type);
96 
97         //Get the assembly loaded in reflection context for the current target framework.
GetReflectionAssembly(AssemblyName assemblyName)98         Assembly GetReflectionAssembly(AssemblyName assemblyName);
99 
100         //Get the current runtime type for the passed in reflection type. Reflection type is target framework type.
GetRuntimeType(Type reflectionType)101         Type GetRuntimeType(Type reflectionType);
102     }
103     #endregion
104 
105     #endregion
106 
107     #region Design Surface related classes and Interfaces
108 
109     #region Interface IWorkflowDesignerMessageSink
110     internal interface IWorkflowDesignerMessageSink
111     {
OnMouseDown(MouseEventArgs e)112         bool OnMouseDown(MouseEventArgs e);
OnMouseMove(MouseEventArgs e)113         bool OnMouseMove(MouseEventArgs e);
OnMouseUp(MouseEventArgs e)114         bool OnMouseUp(MouseEventArgs e);
OnMouseDoubleClick(MouseEventArgs e)115         bool OnMouseDoubleClick(MouseEventArgs e);
OnMouseEnter(MouseEventArgs e)116         bool OnMouseEnter(MouseEventArgs e);
OnMouseHover(MouseEventArgs e)117         bool OnMouseHover(MouseEventArgs e);
OnMouseLeave()118         bool OnMouseLeave();
OnMouseWheel(MouseEventArgs e)119         bool OnMouseWheel(MouseEventArgs e);
OnMouseCaptureChanged()120         bool OnMouseCaptureChanged();
OnMouseDragBegin(Point initialPoint, MouseEventArgs e)121         bool OnMouseDragBegin(Point initialPoint, MouseEventArgs e);
OnMouseDragMove(MouseEventArgs e)122         bool OnMouseDragMove(MouseEventArgs e);
OnMouseDragEnd()123         bool OnMouseDragEnd();
124 
OnDragEnter(DragEventArgs e)125         bool OnDragEnter(DragEventArgs e);
OnDragOver(DragEventArgs e)126         bool OnDragOver(DragEventArgs e);
OnDragLeave()127         bool OnDragLeave();
OnDragDrop(DragEventArgs e)128         bool OnDragDrop(DragEventArgs e);
OnGiveFeedback(GiveFeedbackEventArgs e)129         bool OnGiveFeedback(GiveFeedbackEventArgs e);
OnQueryContinueDrag(QueryContinueDragEventArgs e)130         bool OnQueryContinueDrag(QueryContinueDragEventArgs e);
131 
OnKeyDown(KeyEventArgs e)132         bool OnKeyDown(KeyEventArgs e);
OnKeyUp(KeyEventArgs e)133         bool OnKeyUp(KeyEventArgs e);
134 
OnScroll(ScrollBar sender, int value)135         bool OnScroll(ScrollBar sender, int value);
OnShowContextMenu(Point screenMenuPoint)136         bool OnShowContextMenu(Point screenMenuPoint);
ProcessMessage(Message message)137         bool ProcessMessage(Message message);
138 
OnLayout(LayoutEventArgs layoutEventArgs)139         void OnLayout(LayoutEventArgs layoutEventArgs);
OnLayoutPosition(Graphics graphics)140         void OnLayoutPosition(Graphics graphics);
OnLayoutSize(Graphics graphics)141         void OnLayoutSize(Graphics graphics);
OnThemeChange()142         void OnThemeChange();
143 
OnBeginResizing(DesignerEdges sizingEdge)144         void OnBeginResizing(DesignerEdges sizingEdge);
OnResizing(DesignerEdges sizingEdge, Rectangle bounds)145         void OnResizing(DesignerEdges sizingEdge, Rectangle bounds);
OnEndResizing()146         void OnEndResizing();
147 
OnPaint(PaintEventArgs e, Rectangle viewPort)148         bool OnPaint(PaintEventArgs e, Rectangle viewPort);
OnPaintWorkflowAdornments(PaintEventArgs e, Rectangle viewPort)149         bool OnPaintWorkflowAdornments(PaintEventArgs e, Rectangle viewPort);
150     }
151     #endregion
152 
153     #region Class ViewPortData
154     //
155 
156     internal sealed class ViewPortData
157     {
158         public Rectangle LogicalViewPort;
159         public Bitmap MemoryBitmap;
160         public SizeF Scaling = new SizeF(1.0f, 1.0f);
161         public Point Translation = Point.Empty;
162         public Size ShadowDepth = Size.Empty;
163         public Color TransparentColor = Color.White;
164         public Size ViewPortSize = Size.Empty;
165     }
166     #endregion
167 
168     #region Class ActivityDragEventArgs
169     /// <summary>
170     /// EventArgs passed to the ActivityDesigners when drag drop operation is in progress on workflow.
171     /// ActivityDesigners can access the information contained to influence the drag drop behavior.
172     /// </summary>
173     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
174     public class ActivityDragEventArgs : DragEventArgs
175     {
176         private Point snapPoint = Point.Empty;
177         private Point dragInitiationPoint = Point.Empty;
178         private List<Activity> draggedActivities;
179 
ActivityDragEventArgs(DragEventArgs dragEventArgs, Point dragInitiationPoint, Point point, List<Activity> draggedActivities)180         internal ActivityDragEventArgs(DragEventArgs dragEventArgs, Point dragInitiationPoint, Point point, List<Activity> draggedActivities)
181             : base(dragEventArgs.Data, dragEventArgs.KeyState, point.X, point.Y, dragEventArgs.AllowedEffect, dragEventArgs.Effect)
182         {
183             this.dragInitiationPoint = dragInitiationPoint;
184 
185             if (draggedActivities == null)
186                 this.draggedActivities = new List<Activity>();
187             else
188                 this.draggedActivities = new List<Activity>(draggedActivities);
189         }
190 
191         /// <summary>
192         /// Returns Activities being dragged drop
193         /// </summary>
194         public ReadOnlyCollection<Activity> Activities
195         {
196             get
197             {
198                 return this.draggedActivities.AsReadOnly();
199             }
200         }
201 
202         /// <summary>
203         /// WorkflowView creates drag image for the activities being dragged.
204         /// ActivityDesigners can choose to snap this image to a drop target to indicate that activities can be dropped at a particular location
205         /// </summary>
206         public Point DragImageSnapPoint
207         {
208             get
209             {
210                 return this.snapPoint;
211             }
212 
213             set
214             {
215                 this.snapPoint = value;
216             }
217         }
218 
219         /// <summary>
220         /// Returns point at which the drag drop operation was initiated in logical coordinates
221         /// </summary>
222         public Point DragInitiationPoint
223         {
224             get
225             {
226                 return this.dragInitiationPoint;
227             }
228         }
229     }
230     #endregion
231 
232     #endregion
233 
234     #region Classes, Interfaces and enums used by Designers
235 
236     #region Class ActivityChangeEventArgs
237     /// <summary>
238     /// Contains information about the changes made to the activity associated with the designer
239     /// </summary>
240     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
241     public class ActivityChangedEventArgs : EventArgs
242     {
243         private Activity activity;
244         private MemberDescriptor member;
245         private object oldValue;
246         private object newValue;
247 
ActivityChangedEventArgs(Activity activity, MemberDescriptor member, object oldValue, object newValue)248         public ActivityChangedEventArgs(Activity activity, MemberDescriptor member, object oldValue, object newValue)
249         {
250             this.activity = activity;
251             this.member = member;
252             this.oldValue = oldValue;
253             this.newValue = newValue;
254         }
255 
256         /// <summary>
257         /// Activity being changed
258         /// </summary>
259         public Activity Activity
260         {
261             get
262             {
263                 return this.activity;
264             }
265         }
266 
267         /// <summary>
268         /// Member of the activity being changed
269         /// </summary>
270         public MemberDescriptor Member
271         {
272             get
273             {
274                 return this.member;
275             }
276         }
277 
278         /// <summary>
279         /// OldValue of the member before the change
280         /// </summary>
281         public object OldValue
282         {
283             get
284             {
285                 return this.oldValue;
286             }
287         }
288 
289         /// <summary>
290         /// New value of the member after the change
291         /// </summary>
292         public object NewValue
293         {
294             get
295             {
296                 return this.newValue;
297             }
298         }
299     }
300     #endregion
301 
302     #region Class ActivityDesignerLayoutEventArgs
303     /// <summary>
304     /// Contains arguments passed to layout functions of ActivityDesigner
305     /// </summary>
306     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
307     public class ActivityDesignerLayoutEventArgs : EventArgs
308     {
309         private Graphics graphics;
310         private ActivityDesignerTheme designerTheme;
311 
ActivityDesignerLayoutEventArgs(Graphics graphics, ActivityDesignerTheme designerTheme)312         public ActivityDesignerLayoutEventArgs(Graphics graphics, ActivityDesignerTheme designerTheme)
313         {
314             this.graphics = graphics;
315             this.designerTheme = designerTheme;
316         }
317 
318         /// <summary>
319         /// Gets the ambient theme associated with workflow
320         /// </summary>
321         public AmbientTheme AmbientTheme
322         {
323             get
324             {
325                 return WorkflowTheme.CurrentTheme.AmbientTheme;
326             }
327         }
328 
329         /// <summary>
330         /// Gets the designet theme associated with activity designer
331         /// </summary>
332         public ActivityDesignerTheme DesignerTheme
333         {
334             get
335             {
336                 return this.designerTheme;
337             }
338         }
339 
340         /// <summary>
341         /// Gets the graphics object on which the activity designer will be drawn
342         /// </summary>
343         public Graphics Graphics
344         {
345             get
346             {
347                 return this.graphics;
348             }
349         }
350     }
351     #endregion
352 
353     #region Class ActivityDesignerPaintEventArgs
354     /// <summary>
355     /// Contains arguments passed to draw function of ActivityDesigner
356     /// </summary>
357     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
358     public class ActivityDesignerPaintEventArgs : EventArgs
359     {
360         private Graphics graphics;
361         private Rectangle clipRectangle;
362         private Rectangle viewPort;
363         private ActivityDesignerTheme designerTheme;
364 
ActivityDesignerPaintEventArgs(Graphics graphics, Rectangle clipRectangle, Rectangle viewPort, ActivityDesignerTheme designerTheme)365         public ActivityDesignerPaintEventArgs(Graphics graphics, Rectangle clipRectangle, Rectangle viewPort, ActivityDesignerTheme designerTheme)
366         {
367             this.graphics = graphics;
368             this.clipRectangle = Rectangle.Inflate(clipRectangle, 1, 1);
369             this.viewPort = viewPort;
370             this.designerTheme = designerTheme;
371         }
372 
373         /// <summary>
374         /// Graphics object associated with design surface on which the activity needs to draw
375         /// </summary>
376         public Graphics Graphics
377         {
378             get
379             {
380                 return this.graphics;
381             }
382         }
383 
384         /// <summary>
385         /// Bounding rectangle outside which the activity can not draw
386         /// </summary>
387         public Rectangle ClipRectangle
388         {
389             get
390             {
391                 return this.clipRectangle;
392             }
393         }
394 
395         /// <summary>
396         /// Gets the ambient theme associated with Workflow
397         /// </summary>
398         public AmbientTheme AmbientTheme
399         {
400             get
401             {
402                 return WorkflowTheme.CurrentTheme.AmbientTheme;
403             }
404         }
405 
406         /// <summary>
407         /// Gets the theme associated with designer
408         /// </summary>
409         public ActivityDesignerTheme DesignerTheme
410         {
411             get
412             {
413                 return this.designerTheme;
414             }
415         }
416 
417         internal Rectangle ViewPort
418         {
419             get
420             {
421                 return this.viewPort;
422             }
423         }
424     }
425     #endregion
426 
427     #region Class ActivityDesignerResizeEventArgs
428     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
429     public class ActivityDesignerResizeEventArgs : EventArgs
430     {
431         private DesignerEdges sizingEdge;
432         private Rectangle newBounds;
433 
ActivityDesignerResizeEventArgs(DesignerEdges sizingEdge, Rectangle newBounds)434         public ActivityDesignerResizeEventArgs(DesignerEdges sizingEdge, Rectangle newBounds)
435         {
436             this.sizingEdge = sizingEdge;
437             this.newBounds = newBounds;
438         }
439 
440         public DesignerEdges SizingEdge
441         {
442             get
443             {
444                 return this.sizingEdge;
445             }
446         }
447 
448         public Rectangle Bounds
449         {
450             get
451             {
452                 return this.newBounds;
453             }
454         }
455     }
456     #endregion
457 
458     #region Enum DesignerEdges
459     [Flags]
460     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
461     public enum DesignerEdges
462     {
463         None = 0,
464         Left = 1,
465         Top = 2,
466         Right = 4,
467         Bottom = 8,
468         All = 15
469     }
470     #endregion
471 
472     #region Interface IDesignerGlyphProvider
473     /// <summary>
474     /// Allows the user to add custom glyph providers.
475     /// Custom glyph providers are called to render the glyphs on designer.
476     /// </summary>
477     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
478     public interface IDesignerGlyphProviderService
479     {
AddGlyphProvider(IDesignerGlyphProvider glyphProvider)480         void AddGlyphProvider(IDesignerGlyphProvider glyphProvider);
RemoveGlyphProvider(IDesignerGlyphProvider glyphProvider)481         void RemoveGlyphProvider(IDesignerGlyphProvider glyphProvider);
482         ReadOnlyCollection<IDesignerGlyphProvider> GlyphProviders { get; }
483     }
484 
485     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
486     public interface IDesignerGlyphProvider
487     {
GetGlyphs(ActivityDesigner activityDesigner)488         ActivityDesignerGlyphCollection GetGlyphs(ActivityDesigner activityDesigner);
489     }
490     #endregion
491 
492     #region Interface IDesignerVerbProvider
493     /// <summary>
494     /// Allows the user to add custom verb providers.
495     /// Custom verb providers are called in order to return the set of verbs associated with the designer.
496     /// </summary>
497     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
498     public interface IDesignerVerbProviderService
499     {
AddVerbProvider(IDesignerVerbProvider verbProvider)500         void AddVerbProvider(IDesignerVerbProvider verbProvider);
RemoveVerbProvider(IDesignerVerbProvider verbProvider)501         void RemoveVerbProvider(IDesignerVerbProvider verbProvider);
502         ReadOnlyCollection<IDesignerVerbProvider> VerbProviders { get; }
503     }
504 
505     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
506     public interface IDesignerVerbProvider
507     {
GetVerbs(ActivityDesigner activityDesigner)508         ActivityDesignerVerbCollection GetVerbs(ActivityDesigner activityDesigner);
509     }
510     #endregion
511 
512     #region Interface IPersistUIState
513     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
514     public interface IPersistUIState
515     {
SaveViewState(BinaryWriter writer)516         void SaveViewState(BinaryWriter writer);
LoadViewState(BinaryReader reader)517         void LoadViewState(BinaryReader reader);
518     }
519     #endregion
520 
521     #region Interface IWorkflowRootDesigner
522     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
523     public interface IWorkflowRootDesigner : IRootDesigner
524     {
525         CompositeActivityDesigner InvokingDesigner { get; set; }
526         ReadOnlyCollection<WorkflowDesignerMessageFilter> MessageFilters { get; }
IsSupportedActivityType(Type activityType)527         bool IsSupportedActivityType(Type activityType);
528         bool SupportsLayoutPersistence { get; }
529     }
530     #endregion
531 
532     #region Used for keyboard navigation
533     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
534     public enum DesignerNavigationDirection
535     {
536         Down = 0, //Next
537         Up = 1, //Previous
538         Left = 2,
539         Right = 3
540     }
541     #endregion
542 
543     #region enum HitTestLocations
544     /// <summary>
545     /// Enumeration returning area of the designer which was under the point passed to hit test.
546     /// </summary>
547     [FlagsAttribute]
548     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
549     public enum HitTestLocations
550     {
551         None = 0,
552         Designer = 1,
553         ActionArea = 2,
554         Left = 4,
555         Top = 8,
556         Right = 16,
557         Bottom = 32,
558         Connector = 64
559     }
560     #endregion
561 
562     #region Class HitTestInfo
563     /// <summary>
564     /// Identifies the part of the designer at the specified location.
565     /// Used by various operation including drag-drop, cut-paste etc
566     /// </summary>
567     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
568     public class HitTestInfo
569     {
570         private static HitTestInfo nowhere;
571         private ActivityDesigner activityDesigner = null;
572         private HitTestLocations location = HitTestLocations.None;
573         private IDictionary userData;
574 
575         /// <summary>
576         /// Returns Empty HitTestInfo
577         /// </summary>
578         public static HitTestInfo Nowhere
579         {
580             get
581             {
582                 if (HitTestInfo.nowhere == null)
583                     HitTestInfo.nowhere = new HitTestInfo();
584                 return HitTestInfo.nowhere;
585             }
586         }
587 
HitTestInfo()588         internal HitTestInfo()
589         {
590         }
591 
592         /// <summary>
593         /// Constructs HitTestInfo with specified parameters
594         /// </summary>
595         /// <param name="designer">ActivityDesigner associated with HitTestInfo</param>
596         /// <param name="flags">HitTestLocations indicating where the hit happened</param>
HitTestInfo(ActivityDesigner designer, HitTestLocations location)597         public HitTestInfo(ActivityDesigner designer, HitTestLocations location)
598         {
599             if (designer == null)
600                 throw new ArgumentNullException("designer");
601 
602             this.activityDesigner = designer;
603             this.location = location;
604         }
605 
606         /// <summary>
607         /// Returns designer associated
608         /// </summary>
609         [Browsable(false)]
610         public ActivityDesigner AssociatedDesigner
611         {
612             get
613             {
614                 return this.activityDesigner;
615             }
616         }
617 
618         /// <summary>
619         /// Returns flags indicating where hit happened
620         /// </summary>
621         [Browsable(false)]
622         public HitTestLocations HitLocation
623         {
624             get
625             {
626                 return this.location;
627             }
628         }
629 
630         /// <summary>
631         /// Returns enclosing bounds for the hit area
632         /// </summary>
633         [Browsable(false)]
634         public virtual Rectangle Bounds
635         {
636             get
637             {
638                 if (this.activityDesigner != null)
639                     return this.activityDesigner.Bounds;
640                 else
641                     return Rectangle.Empty;
642             }
643         }
644 
645         /// <summary>
646         /// Returns selectable object associated with Hit Area
647         /// </summary>
648         [Browsable(false)]
649         public virtual object SelectableObject
650         {
651             get
652             {
653                 if (this.activityDesigner != null)
654                     return this.activityDesigner.Activity;
655                 else
656                     return null;
657             }
658         }
659 
660         /// <summary>
661         /// Returns UserData to associated with HitLocation
662         /// </summary>
663         [Browsable(false)]
664         public IDictionary UserData
665         {
666             get
667             {
668                 if (this.userData == null)
669                     this.userData = new HybridDictionary();
670                 return this.userData;
671             }
672         }
673 
674         /// <summary>
675         /// Maps Hit area to index using which designers are to be inserted.
676         /// </summary>
677         /// <returns></returns>
MapToIndex()678         public virtual int MapToIndex()
679         {
680             CompositeActivity compositeActivity = this.activityDesigner.Activity as CompositeActivity;
681             if (compositeActivity != null)
682                 return compositeActivity.Activities.Count;
683             else
684                 return 0;
685         }
686     }
687     #endregion
688 
689     #region Class ConnectorHitTestInfo
690     /// <summary>
691     /// Represents the hittest information for connectors within the designer, structured designers are expected to have connectors within them
692     /// </summary>
693     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
694     public class ConnectorHitTestInfo : HitTestInfo
695     {
696         private int connector = 0;
697 
698         /// <summary>
699         /// Constructor for ConnectorHitTestInfo
700         /// </summary>
701         /// <param name="structuredCompositeActivityDesigner">Designer associated with the HitTestInfo</param>
702         /// <param name="flags">Flags where HitTest occured</param>
703         /// <param name="connector">Index of the connector which was hit</param>
ConnectorHitTestInfo(CompositeActivityDesigner compositeActivityDesigner, HitTestLocations flags, int connector)704         public ConnectorHitTestInfo(CompositeActivityDesigner compositeActivityDesigner, HitTestLocations flags, int connector)
705             : base(compositeActivityDesigner, flags)
706         {
707             if (this.connector < 0)
708                 throw new ArgumentException(SR.GetString(SR.Error_InvalidConnectorValue), "connector");
709 
710             this.connector = connector;
711         }
712 
713         public override Rectangle Bounds
714         {
715             get
716             {
717                 //
718                 SequentialActivityDesigner sequentialActivityDesigner = AssociatedDesigner as SequentialActivityDesigner;
719                 if (sequentialActivityDesigner != null && sequentialActivityDesigner.Expanded)
720                 {
721                     Rectangle[] connectors = sequentialActivityDesigner.GetConnectors();
722                     if (connectors.Length > 0)
723                         return connectors[this.connector];
724                 }
725 
726                 return Rectangle.Empty;
727             }
728         }
729 
730         public override object SelectableObject
731         {
732             get
733             {
734                 return this;
735             }
736         }
737 
MapToIndex()738         public override int MapToIndex()
739         {
740             return this.connector;
741         }
742 
Equals(object obj)743         public override bool Equals(object obj)
744         {
745             ConnectorHitTestInfo destinationConnector = obj as ConnectorHitTestInfo;
746             if (destinationConnector != null)
747             {
748                 if (destinationConnector.AssociatedDesigner == AssociatedDesigner &&
749                     destinationConnector.HitLocation == HitLocation &&
750                     destinationConnector.MapToIndex() == MapToIndex())
751                     return true;
752             }
753 
754             return false;
755         }
756 
GetHashCode()757         public override int GetHashCode()
758         {
759             return base.GetHashCode() ^ ((AssociatedDesigner != null) ? AssociatedDesigner.GetHashCode() : 0) ^ MapToIndex().GetHashCode();
760         }
761     }
762     #endregion
763 
764     #region Class DesignerAction
765     //Public class as ActivityDesigners can provide their own DesignerActions
766     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
767     public sealed class DesignerAction
768     {
769         private ActivityDesigner activityDesigner;
770         private int actionId;
771         private string text;
772         private Image image;
773         private IDictionary userData;
774         private string propertyName = null;
775 
DesignerAction(ActivityDesigner activityDesigner, int actionId, string text)776         public DesignerAction(ActivityDesigner activityDesigner, int actionId, string text)
777         {
778             if (activityDesigner == null)
779                 throw new ArgumentNullException("activityDesigner");
780 
781             if (text == null || text.Length == 0)
782                 throw new ArgumentException(SR.GetString(SR.Error_NullOrEmptyValue), "text");
783 
784             this.activityDesigner = activityDesigner;
785             this.actionId = actionId;
786             this.text = text;
787         }
788 
DesignerAction(ActivityDesigner activityDesigner, int actionId, string text, Image image)789         public DesignerAction(ActivityDesigner activityDesigner, int actionId, string text, Image image)
790             : this(activityDesigner, actionId, text)
791         {
792             this.image = image;
793         }
794 
795         public string PropertyName
796         {
797             get
798             {
799                 return this.propertyName;
800             }
801             set
802             {
803                 this.propertyName = value;
804             }
805         }
806 
807         public int ActionId
808         {
809             get
810             {
811                 return this.actionId;
812             }
813         }
814 
815         public string Text
816         {
817             get
818             {
819                 return this.text;
820             }
821         }
822 
823         public Image Image
824         {
825             get
826             {
827                 return this.image;
828             }
829         }
830 
831         public IDictionary UserData
832         {
833             get
834             {
835                 if (this.userData == null)
836                     this.userData = new HybridDictionary();
837                 return this.userData;
838             }
839         }
840 
Invoke()841         public void Invoke()
842         {
843             this.activityDesigner.OnExecuteDesignerAction(this);
844         }
845     }
846     #endregion
847 
848     #region Enum DesignerVerbGroup
849     /// <summary>
850     /// Provides categories for grouping of similar verbs
851     /// </summary>
852     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
853     public enum DesignerVerbGroup
854     {
855         General = 0,
856         View = 1,
857         Edit = 2,
858         Options = 3,
859         Actions = 4,
860         Misc = 5
861     }
862     #endregion
863 
864     #region Class ActivityDesignerVerb
865     /// <summary>
866     /// DesignerVerb class specific to ActivityDesigners.
867     /// Allows user to group similar types of DesignerVerbs togather.
868     /// Provides user the ability to update the status of the verb.
869     /// </summary>
870     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
871     public class ActivityDesignerVerb : DesignerVerb
872     {
873         private ActivityDesigner activityDesigner = null;
874         private EventHandler invokeHandler = null;
875         private EventHandler statusHandler = null;
876         private DesignerVerbGroup verbGroup;
877         private int id = 0;
878 
ActivityDesignerVerb(ActivityDesigner activityDesigner, DesignerVerbGroup verbGroup, string text, EventHandler invokeHandler)879         public ActivityDesignerVerb(ActivityDesigner activityDesigner, DesignerVerbGroup verbGroup, string text, EventHandler invokeHandler)
880             : base(text, new EventHandler(OnExecuteDesignerVerb), new CommandID(WorkflowMenuCommands.MenuGuid, 0))
881         {
882             if (text == null || text.Length == 0)
883                 throw new ArgumentNullException("text");
884 
885             if (invokeHandler == null)
886                 throw new ArgumentNullException("invokeHandler");
887 
888             this.verbGroup = verbGroup;
889             this.invokeHandler = invokeHandler;
890             this.activityDesigner = activityDesigner;
891         }
892 
ActivityDesignerVerb(ActivityDesigner activityDesigner, DesignerVerbGroup verbGroup, string text, EventHandler invokeHandler, EventHandler statusHandler)893         public ActivityDesignerVerb(ActivityDesigner activityDesigner, DesignerVerbGroup verbGroup, string text, EventHandler invokeHandler, EventHandler statusHandler)
894             : this(activityDesigner, verbGroup, text, invokeHandler)
895         {
896             this.statusHandler = statusHandler;
897         }
898 
899         public override int OleStatus
900         {
901             get
902             {
903                 if (statusHandler != null)
904                 {
905                     try
906                     {
907                         statusHandler(this, EventArgs.Empty);
908                     }
909                     catch
910                     {
911                     }
912                 }
913 
914                 return base.OleStatus;
915             }
916         }
917 
918         public override CommandID CommandID
919         {
920             get
921             {
922                 return new CommandID(WorkflowMenuCommands.MenuGuid, this.id);
923             }
924         }
925 
926         public DesignerVerbGroup Group
927         {
928             get
929             {
930                 return this.verbGroup;
931             }
932         }
933 
934         internal int Id
935         {
936             get
937             {
938                 return this.id;
939             }
940 
941             set
942             {
943                 this.id = value;
944             }
945         }
946 
947         internal ActivityDesigner ActivityDesigner
948         {
949             get
950             {
951                 return this.activityDesigner;
952             }
953         }
954 
OnExecuteDesignerVerb(object sender, EventArgs e)955         private static void OnExecuteDesignerVerb(object sender, EventArgs e)
956         {
957             ActivityDesignerVerb activityDesignerVerb = sender as ActivityDesignerVerb;
958             if (activityDesignerVerb != null)
959             {
960                 if (activityDesignerVerb.invokeHandler != null)
961                     activityDesignerVerb.invokeHandler(sender, e);
962 
963                 int status = activityDesignerVerb.OleStatus;
964                 status = 0;
965 
966                 if (activityDesignerVerb.activityDesigner != null)
967                 {
968                     foreach (DesignerVerb verb in ((IDesigner)activityDesignerVerb.activityDesigner).Verbs)
969                     {
970                         if (verb is ActivityDesignerVerb)
971                         {
972                             //Update the status of the
973                             status = verb.OleStatus;
974                             status = 0;
975                         }
976                     }
977                 }
978             }
979         }
980     }
981     #endregion
982 
983     #region Class ActivityDesignerVerbCollection
984     /// <summary>
985     /// Maintains collection of ActivityDesignerVerbs.
986     /// Groups verbs belonging to the same veb groups and ensures that their identifiers are consecutive.
987     /// </summary>
988     [PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
989     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
990     public sealed class ActivityDesignerVerbCollection : DesignerVerbCollection
991     {
ActivityDesignerVerbCollection()992         public ActivityDesignerVerbCollection()
993         {
994         }
995 
ActivityDesignerVerbCollection(IEnumerable<ActivityDesignerVerb> verbs)996         public ActivityDesignerVerbCollection(IEnumerable<ActivityDesignerVerb> verbs)
997         {
998             if (verbs == null)
999                 throw new ArgumentNullException("verbs");
1000 
1001             foreach (ActivityDesignerVerb verb in verbs)
1002                 Add(verb);
1003         }
1004 
OnValidate(object value)1005         protected override void OnValidate(object value)
1006         {
1007             if (!(value is ActivityDesignerVerb))
1008                 throw new InvalidOperationException(SR.GetString(SR.Error_InvalidDesignerVerbValue));
1009         }
1010 
1011         /// <summary>
1012         /// Returns a collection that is consumable by MenuCommandService. Verbs in the
1013         /// safe collection have Ids in the range of VerbFirst.ID to VerbLast.ID. Also,
1014         /// the items are sorted, and the first item ID == VerbFirst.ID
1015         /// </summary>
1016         internal ActivityDesignerVerbCollection SafeCollection
1017         {
1018             get
1019             {
1020                 if (this.Count == 0)
1021                     return this;
1022 
1023                 Dictionary<DesignerVerbGroup, List<ActivityDesignerVerb>> activityDesignerVerbs = new Dictionary<DesignerVerbGroup, List<ActivityDesignerVerb>>();
1024                 ArrayList safeCollection = new ArrayList(this);
1025 
1026                 // set Ids
1027                 foreach (ActivityDesignerVerb verb in safeCollection)
1028                 {
1029                     List<ActivityDesignerVerb> verbList = null;
1030                     if (!activityDesignerVerbs.ContainsKey(verb.Group))
1031                     {
1032                         verbList = new List<ActivityDesignerVerb>();
1033                         activityDesignerVerbs.Add(verb.Group, verbList);
1034                     }
1035                     else
1036                     {
1037                         verbList = activityDesignerVerbs[verb.Group];
1038                     }
1039 
1040                     if (!verbList.Contains(verb))
1041                     {
1042                         verb.Id = ConvertGroupToId(verb.Group) + verbList.Count;
1043                         verbList.Add(verb);
1044                     }
1045                 }
1046 
1047                 //items should be sorted by verb id
1048                 safeCollection.Sort(new ActivityDesignerVerbComparer());
1049 
1050                 // add first dummy verb if needed
1051                 if (((ActivityDesignerVerb)safeCollection[0]).Id != MenuCommands.VerbFirst.ID)
1052                 {
1053                     safeCollection.Insert(0, new ActivityDesignerVerb(null, DesignerVerbGroup.General, "Dummy", new EventHandler(OnDummyVerb)));
1054                     ((ActivityDesignerVerb)safeCollection[0]).Visible = false;
1055                 }
1056 
1057                 ActivityDesignerVerbCollection verbs = new ActivityDesignerVerbCollection();
1058                 foreach (ActivityDesignerVerb verb in safeCollection)
1059                     verbs.Add(verb);
1060 
1061                 return verbs;
1062             }
1063         }
1064 
OnDummyVerb(object sender, EventArgs e)1065         private void OnDummyVerb(object sender, EventArgs e)
1066         {
1067             // Should never be called
1068         }
1069 
ConvertGroupToId(DesignerVerbGroup group)1070         private int ConvertGroupToId(DesignerVerbGroup group)
1071         {
1072             if (group == DesignerVerbGroup.General)
1073                 return WorkflowMenuCommands.VerbGroupGeneral;
1074             else if (group == DesignerVerbGroup.View)
1075                 return WorkflowMenuCommands.VerbGroupView;
1076             else if (group == DesignerVerbGroup.Edit)
1077                 return WorkflowMenuCommands.VerbGroupEdit;
1078             else if (group == DesignerVerbGroup.Options)
1079                 return WorkflowMenuCommands.VerbGroupOptions;
1080             else if (group == DesignerVerbGroup.Actions)
1081                 return WorkflowMenuCommands.VerbGroupActions;
1082             else
1083                 return WorkflowMenuCommands.VerbGroupMisc;
1084         }
1085         #region class ActivityDesignerVerbComparer
1086 
1087         private class ActivityDesignerVerbComparer : IComparer
1088         {
1089             #region IComparer Members
1090 
Compare(object x, object y)1091             public int Compare(object x, object y)
1092             {
1093                 ActivityDesignerVerb verb1 = x as ActivityDesignerVerb;
1094                 ActivityDesignerVerb verb2 = y as ActivityDesignerVerb;
1095 
1096                 if (verb1.Id == verb2.Id)
1097                     return 0;
1098                 else if (verb1.Id > verb2.Id)
1099                     return 1;
1100                 else
1101                     return -1;
1102             }
1103             #endregion
1104         }
1105 
1106         #endregion
1107 
1108     }
1109     #endregion
1110 
1111     #endregion
1112 
1113     #region ITypeFilterProvider Interface
1114     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
1115     public interface ITypeFilterProvider
1116     {
CanFilterType(Type type, bool throwOnError)1117         bool CanFilterType(Type type, bool throwOnError);
1118         string FilterDescription { get; }
1119     }
1120     #endregion
1121 
1122     #region TypeFilterProviderAttribute
1123     [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false)]
1124     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
1125     public sealed class TypeFilterProviderAttribute : Attribute
1126     {
1127         private string typeName = null;
1128 
TypeFilterProviderAttribute(Type type)1129         public TypeFilterProviderAttribute(Type type)
1130         {
1131             if (type == null)
1132                 throw new ArgumentNullException("type");
1133 
1134             this.typeName = type.AssemblyQualifiedName;
1135         }
1136 
TypeFilterProviderAttribute(string typeName)1137         public TypeFilterProviderAttribute(string typeName)
1138         {
1139             this.typeName = typeName;
1140         }
1141 
1142         public string TypeFilterProviderTypeName
1143         {
1144             get
1145             {
1146                 return this.typeName;
1147             }
1148         }
1149     }
1150     #endregion
1151 
1152     #region ITypeProviderCreator Interface
1153     [Guid("0E6DF9D7-B4B5-4af7-9647-FC335CCE393F")]
1154     [ComVisible(true)]
1155     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
1156     public interface ITypeProviderCreator
1157     {
GetTypeProvider(object obj)1158         ITypeProvider GetTypeProvider(object obj);
GetLocalAssembly(object obj)1159         Assembly GetLocalAssembly(object obj);
GetTransientAssembly(AssemblyName assemblyName)1160         Assembly GetTransientAssembly(AssemblyName assemblyName);
GetTypeResolutionService(object obj)1161         ITypeResolutionService GetTypeResolutionService(object obj);
1162     }
1163     #endregion
1164 }
1165