internal static bool AreComponentsRemovable(ICollection components) { if (components == null) { throw new ArgumentNullException("components"); } foreach (object obj2 in components) { Activity activity = obj2 as Activity; ConnectorHitTestInfo info = obj2 as ConnectorHitTestInfo; if ((activity == null) && (info == null)) { return(false); } if (activity != null) { ActivityDesigner designer = ActivityDesigner.GetDesigner(activity); if ((designer != null) && designer.IsLocked) { return(false); } } if ((info != null) && !(info.AssociatedDesigner is FreeformActivityDesigner)) { return(false); } } return(true); }
public override System.Workflow.ComponentModel.Design.HitTestInfo HitTest(Point point) { if (base.ActiveDesigner != this) { return(base.HitTest(point)); } System.Workflow.ComponentModel.Design.HitTestInfo nowhere = System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere; if (!this.Expanded) { return(base.HitTest(point)); } if ((this.ContainedDesigners.Count == 0) && this.HelpTextRectangle.Contains(point)) { return(new ConnectorHitTestInfo(this, HitTestLocations.Designer, 0)); } Rectangle[] connectors = this.GetConnectors(); for (int i = 0; i < connectors.Length; i++) { if (connectors[i].Contains(point)) { nowhere = new ConnectorHitTestInfo(this, HitTestLocations.Designer, i); break; } } if (nowhere.HitLocation == HitTestLocations.None) { nowhere = base.HitTest(point); } return(nowhere); }
internal SequentialConnectorAccessibleObject(SequentialActivityDesigner activityDesigner, int connectorIndex) { if (activityDesigner == null) { throw new ArgumentNullException("activityDesigner"); } this.connectorHitInfo = new ConnectorHitTestInfo(activityDesigner, HitTestLocations.Designer, connectorIndex); }
public override object GetNextSelectableObject(object obj, DesignerNavigationDirection direction) { if (base.ActiveDesigner != this) { return(base.GetNextSelectableObject(obj, direction)); } if ((direction != DesignerNavigationDirection.Down) && (direction != DesignerNavigationDirection.Up)) { return(null); } object activity = null; ReadOnlyCollection <ActivityDesigner> containedDesigners = this.ContainedDesigners; if (direction == DesignerNavigationDirection.Down) { if (obj is ConnectorHitTestInfo) { int num = ((ConnectorHitTestInfo)obj).MapToIndex(); if ((num >= 0) && (num < containedDesigners.Count)) { activity = containedDesigners[num].Activity; } return(activity); } if (obj is Activity) { ActivityDesigner designer = ActivityDesigner.GetDesigner(obj as Activity); int num2 = (designer != null) ? containedDesigners.IndexOf(designer) : -1; if ((num2 >= 0) && ((num2 + 1) < this.GetConnectors().Length)) { activity = new ConnectorHitTestInfo(this, HitTestLocations.Designer, num2 + 1); } } return(activity); } if (direction == DesignerNavigationDirection.Up) { if (obj is ConnectorHitTestInfo) { int num3 = ((ConnectorHitTestInfo)obj).MapToIndex(); if ((num3 > 0) && (num3 < this.GetConnectors().Length)) { activity = containedDesigners[num3 - 1].Activity; } return(activity); } if (obj is Activity) { ActivityDesigner designer2 = ActivityDesigner.GetDesigner(obj as Activity); int connector = (designer2 != null) ? containedDesigners.IndexOf(designer2) : -1; if ((connector >= 0) && (connector < this.GetConnectors().Length)) { activity = new ConnectorHitTestInfo(this, HitTestLocations.Designer, connector); } } } return(activity); }
public override object GetNextSelectableObject(object obj, DesignerNavigationDirection direction) { if (ActiveDesigner != this) { return(base.GetNextSelectableObject(obj, direction)); } if (direction != DesignerNavigationDirection.Down && direction != DesignerNavigationDirection.Up) { return(null); } object nextObject = null; ReadOnlyCollection <ActivityDesigner> containedDesigners = ContainedDesigners; if (direction == DesignerNavigationDirection.Down) { if (obj is ConnectorHitTestInfo) { int currentIndex = ((ConnectorHitTestInfo)obj).MapToIndex(); if (currentIndex >= 0 && currentIndex < containedDesigners.Count) { nextObject = ((ActivityDesigner)containedDesigners[currentIndex]).Activity; } } else if (obj is Activity) { ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(obj as Activity); int currentIndex = (activityDesigner != null) ? containedDesigners.IndexOf(activityDesigner) : -1; if (currentIndex >= 0 && (currentIndex + 1) < GetConnectors().Length) { nextObject = new ConnectorHitTestInfo(this, HitTestLocations.Designer, currentIndex + 1); } } } else if (direction == DesignerNavigationDirection.Up) { if (obj is ConnectorHitTestInfo) { int currentIndex = ((ConnectorHitTestInfo)obj).MapToIndex(); if (currentIndex > 0 && currentIndex < GetConnectors().Length) { nextObject = ((ActivityDesigner)containedDesigners[currentIndex - 1]).Activity; } } else if (obj is Activity) { ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(obj as Activity); int currentIndex = (activityDesigner != null) ? containedDesigners.IndexOf(activityDesigner) : -1; if (currentIndex >= 0 && currentIndex < GetConnectors().Length) { nextObject = new ConnectorHitTestInfo(this, HitTestLocations.Designer, currentIndex); } } } return(nextObject); }
private void OnStatusPaste(object sender, EventArgs e) { MenuCommand command = (MenuCommand)sender; command.Enabled = false; object primarySelection = this.selectionService.PrimarySelection; CompositeActivityDesigner parentDesigner = ActivityDesigner.GetDesigner(primarySelection as Activity) as CompositeActivityDesigner; if (parentDesigner == null) { parentDesigner = ActivityDesigner.GetParentDesigner(primarySelection); } if ((parentDesigner != null) && parentDesigner.IsEditable) { IDesignerHost host = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; IToolboxService service = (IToolboxService)this.serviceProvider.GetService(typeof(IToolboxService)); IDataObject dataObject = Clipboard.GetDataObject(); if (((dataObject != null) && (host != null)) && ((dataObject.GetDataPresent("CF_WINOEDESIGNERCOMPONENTS") || (service == null)) || service.IsSupported(dataObject, host))) { System.Workflow.ComponentModel.Design.HitTestInfo insertLocation = null; if (primarySelection is System.Workflow.ComponentModel.Design.HitTestInfo) { insertLocation = (System.Workflow.ComponentModel.Design.HitTestInfo)primarySelection; } else if (primarySelection is CompositeActivity) { insertLocation = new System.Workflow.ComponentModel.Design.HitTestInfo(parentDesigner, HitTestLocations.Designer); } else if (primarySelection is Activity) { Activity item = primarySelection as Activity; CompositeActivity parent = item.Parent; CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(parent) as CompositeActivityDesigner; if (designer != null) { insertLocation = new ConnectorHitTestInfo(designer, HitTestLocations.Designer, parent.Activities.IndexOf(item) + 1); } } ICollection activities = null; try { activities = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(this.serviceProvider, dataObject); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw exception; } } command.Enabled = ((activities != null) && (insertLocation != null)) && parentDesigner.CanInsertActivities(insertLocation, new List <Activity>(Helpers.GetTopLevelActivities(activities)).AsReadOnly()); } } }
internal static Connector GetConnectorFromSelectedObject(object selectedObject) { Connector connector = null; ConnectorHitTestInfo info = selectedObject as ConnectorHitTestInfo; if (info != null) { FreeformActivityDesigner associatedDesigner = info.AssociatedDesigner as FreeformActivityDesigner; int num = info.MapToIndex(); if (((associatedDesigner != null) && (num >= 0)) && (num < associatedDesigner.Connectors.Count)) { connector = associatedDesigner.Connectors[num]; } } return(connector); }
public override bool Equals(object obj) { ConnectorHitTestInfo destinationConnector = obj as ConnectorHitTestInfo; if (destinationConnector != null) { if (destinationConnector.AssociatedDesigner == AssociatedDesigner && destinationConnector.HitLocation == HitLocation && destinationConnector.MapToIndex() == MapToIndex()) { return(true); } } return(false); }
private int CanDrop(ActivityDragEventArgs e) { if (e.Activities.Count == 0) { return(-1); } Point dropPoint = new Point(e.X, e.Y); int dropIndex = -1; Rectangle[] dropTargets = GetDropTargets(dropPoint); for (int i = 0; i < dropTargets.Length; i++) { if (dropTargets[i].Contains(dropPoint)) { dropIndex = i; break; } } if (dropIndex >= 0 && !CanInsertActivities(new ConnectorHitTestInfo(this, HitTestLocations.Designer, dropIndex), e.Activities)) { dropIndex = -1; } bool ctrlKeyPressed = ((e.KeyState & 8) == 8); if (dropIndex >= 0 && !ctrlKeyPressed && (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) { ConnectorHitTestInfo moveLocation = new ConnectorHitTestInfo(this, HitTestLocations.Designer, dropIndex); foreach (Activity activity in e.Activities) { if (activity.Site != null) { ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(activity); if (activityDesigner == null || activityDesigner.ParentDesigner == null || !activityDesigner.ParentDesigner.CanMoveActivities(moveLocation, new List <Activity>(new Activity[] { activity }).AsReadOnly())) { dropIndex = -1; break; } } } } return(dropIndex); }
public override HitTestInfo HitTest(Point point) { HitTestInfo hitInfo = HitTestInfo.Nowhere; if (Expanded && ActiveDesigner == this) { if (ContainedDesigners.Count == 0 && HelpTextRectangle.Contains(point)) { hitInfo = new ConnectorHitTestInfo(this, HitTestLocations.Designer, 0); } else if (this.previewStrip.Bounds.Contains(point)) { ItemInfo itemInfo = this.previewStrip.HitTest(point); ActivityDesigner activityDesigner = (itemInfo != null) ? ActivityDesigner.GetDesigner(itemInfo.UserData[DesignerUserDataKeys.Activity] as Activity) : null; if (activityDesigner != null) { hitInfo = new HitTestInfo(activityDesigner, HitTestLocations.Designer); } else { hitInfo = new HitTestInfo(this, HitTestLocations.Designer | HitTestLocations.ActionArea); } } else if (ShowPreview && this.previewWindow.Bounds.Contains(point) && (this.previewWindow.PreviewMode || PreviewedDesigner == null || !PreviewedDesigner.Bounds.Contains(point))) { hitInfo = new HitTestInfo(this, HitTestLocations.Designer | HitTestLocations.ActionArea); } else { hitInfo = base.HitTest(point); if (ShowPreview && this.previewWindow.PreviewMode && hitInfo.AssociatedDesigner != this) { hitInfo = HitTestInfo.Nowhere; } } } else { hitInfo = base.HitTest(point); } return(hitInfo); }
public override AccessibleObject Navigate(AccessibleNavigation navdir) { if (navdir == AccessibleNavigation.FirstChild || navdir == AccessibleNavigation.LastChild) { return(base.Navigate(navdir)); } DesignerNavigationDirection navigate = default(DesignerNavigationDirection); if (navdir == AccessibleNavigation.Left) { navigate = DesignerNavigationDirection.Left; } else if (navdir == AccessibleNavigation.Right) { navigate = DesignerNavigationDirection.Right; } else if (navdir == AccessibleNavigation.Up || navdir == AccessibleNavigation.Previous) { navigate = DesignerNavigationDirection.Up; } else if (navdir == AccessibleNavigation.Down || navdir == AccessibleNavigation.Next) { navigate = DesignerNavigationDirection.Down; } object nextSelectableObj = ((CompositeActivityDesigner)this.connectorHitInfo.AssociatedDesigner).GetNextSelectableObject(this.connectorHitInfo, navigate); if (nextSelectableObj is ConnectorHitTestInfo) { ConnectorHitTestInfo nextConnector = nextSelectableObj as ConnectorHitTestInfo; return(new SequentialConnectorAccessibleObject(nextConnector.AssociatedDesigner as SequentialActivityDesigner, nextConnector.MapToIndex())); } else if (nextSelectableObj is Activity) { ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(nextSelectableObj as Activity); if (activityDesigner != null) { return(activityDesigner.AccessibilityObject); } } return(base.Navigate(navdir)); }
private int CanDrop(ActivityDragEventArgs e) { if (e.Activities.Count == 0) { return(-1); } Point dropPoint = new Point(e.X, e.Y); int connector = -1; Rectangle[] dropTargets = this.GetDropTargets(dropPoint); for (int i = 0; i < dropTargets.Length; i++) { if (dropTargets[i].Contains(dropPoint)) { connector = i; break; } } if ((connector >= 0) && !this.CanInsertActivities(new ConnectorHitTestInfo(this, HitTestLocations.Designer, connector), e.Activities)) { connector = -1; } bool flag = (e.KeyState & 8) == 8; if (((connector >= 0) && !flag) && ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move)) { ConnectorHitTestInfo moveLocation = new ConnectorHitTestInfo(this, HitTestLocations.Designer, connector); foreach (Activity activity in e.Activities) { if (activity.Site != null) { ActivityDesigner designer = ActivityDesigner.GetDesigner(activity); if (((designer == null) || (designer.ParentDesigner == null)) || !designer.ParentDesigner.CanMoveActivities(moveLocation, new List <Activity>(new Activity[] { activity }).AsReadOnly())) { return(-1); } } } } return(connector); }
private int CanDrop(ActivityDragEventArgs e) { if (e.Activities.Count == 0) { return -1; } Point dropPoint = new Point(e.X, e.Y); int connector = -1; Rectangle[] dropTargets = this.GetDropTargets(dropPoint); for (int i = 0; i < dropTargets.Length; i++) { if (dropTargets[i].Contains(dropPoint)) { connector = i; break; } } if ((connector >= 0) && !this.CanInsertActivities(new ConnectorHitTestInfo(this, HitTestLocations.Designer, connector), e.Activities)) { connector = -1; } bool flag = (e.KeyState & 8) == 8; if (((connector >= 0) && !flag) && ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move)) { ConnectorHitTestInfo moveLocation = new ConnectorHitTestInfo(this, HitTestLocations.Designer, connector); foreach (Activity activity in e.Activities) { if (activity.Site != null) { ActivityDesigner designer = ActivityDesigner.GetDesigner(activity); if (((designer == null) || (designer.ParentDesigner == null)) || !designer.ParentDesigner.CanMoveActivities(moveLocation, new List<Activity>(new Activity[] { activity }).AsReadOnly())) { return -1; } } } } return connector; }
public override HitTestInfo HitTest(Point point) { if (ActiveDesigner != this) { return(base.HitTest(point)); } HitTestInfo hitInfo = HitTestInfo.Nowhere; if (!Expanded) { hitInfo = base.HitTest(point); } else if (ContainedDesigners.Count == 0 && HelpTextRectangle.Contains(point)) { hitInfo = new ConnectorHitTestInfo(this, HitTestLocations.Designer, 0); } else { //Check if the hit is on any of the connectors Rectangle[] connectors = GetConnectors(); for (int i = 0; i < connectors.Length; i++) { if (connectors[i].Contains(point)) { hitInfo = new ConnectorHitTestInfo(this, HitTestLocations.Designer, i); break; } } if (hitInfo.HitLocation == HitTestLocations.None) { hitInfo = base.HitTest(point); } } return(hitInfo); }
public override AccessibleObject Navigate(AccessibleNavigation navdir) { if ((navdir != AccessibleNavigation.FirstChild) && (navdir != AccessibleNavigation.LastChild)) { DesignerNavigationDirection down = DesignerNavigationDirection.Down; if (navdir == AccessibleNavigation.Left) { down = DesignerNavigationDirection.Left; } else if (navdir == AccessibleNavigation.Right) { down = DesignerNavigationDirection.Right; } else if ((navdir == AccessibleNavigation.Up) || (navdir == AccessibleNavigation.Previous)) { down = DesignerNavigationDirection.Up; } else if ((navdir == AccessibleNavigation.Down) || (navdir == AccessibleNavigation.Next)) { down = DesignerNavigationDirection.Down; } object nextSelectableObject = ((CompositeActivityDesigner)this.connectorHitInfo.AssociatedDesigner).GetNextSelectableObject(this.connectorHitInfo, down); if (nextSelectableObject is ConnectorHitTestInfo) { ConnectorHitTestInfo info = nextSelectableObject as ConnectorHitTestInfo; return(new SequenceDesignerAccessibleObject.SequentialConnectorAccessibleObject(info.AssociatedDesigner as SequentialActivityDesigner, info.MapToIndex())); } if (nextSelectableObject is Activity) { ActivityDesigner designer = ActivityDesigner.GetDesigner(nextSelectableObject as Activity); if (designer != null) { return(designer.AccessibilityObject); } } } return(base.Navigate(navdir)); }
public override System.Workflow.ComponentModel.Design.HitTestInfo HitTest(Point point) { if (base.ActiveDesigner != this) { return base.HitTest(point); } System.Workflow.ComponentModel.Design.HitTestInfo nowhere = System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere; if (!this.Expanded) { return base.HitTest(point); } if ((this.ContainedDesigners.Count == 0) && this.HelpTextRectangle.Contains(point)) { return new ConnectorHitTestInfo(this, HitTestLocations.Designer, 0); } Rectangle[] connectors = this.GetConnectors(); for (int i = 0; i < connectors.Length; i++) { if (connectors[i].Contains(point)) { nowhere = new ConnectorHitTestInfo(this, HitTestLocations.Designer, i); break; } } if (nowhere.HitLocation == HitTestLocations.None) { nowhere = base.HitTest(point); } return nowhere; }
protected override void OnKeyDown(KeyEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService; if (((service != null) ? service.PrimarySelection : null) != null) { List <Activity> list = new List <Activity>(Helpers.GetTopLevelActivities(service.GetSelectedComponents())); if (((e.KeyCode == Keys.Left) || (e.KeyCode == Keys.Right)) || ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Down))) { Size empty = Size.Empty; if (e.KeyCode == Keys.Left) { empty = new Size(-5, 0); } else if (e.KeyCode == Keys.Right) { empty = new Size(5, 0); } else if (e.KeyCode == Keys.Up) { empty = new Size(0, -5); } else if (e.KeyCode == Keys.Down) { empty = new Size(0, 5); } foreach (Activity activity in list) { ActivityDesigner designer = ActivityDesigner.GetDesigner(activity); if (designer != null) { base.ParentView.InvalidateClientRectangle(new Rectangle(designer.Location, designer.Size)); designer.Location += empty; base.ParentView.InvalidateClientRectangle(new Rectangle(designer.Location, designer.Size)); } } base.PerformLayout(); e.Handled = true; } else if (e.KeyCode == Keys.Delete) { foreach (object obj3 in service.GetSelectedComponents()) { ConnectorHitTestInfo info = obj3 as ConnectorHitTestInfo; if (info != null) { FreeformActivityDesigner associatedDesigner = info.AssociatedDesigner as FreeformActivityDesigner; if (associatedDesigner != null) { ReadOnlyCollection <Connector> connectors = associatedDesigner.Connectors; int num = info.MapToIndex(); if (num < connectors.Count) { service.SetSelectedComponents(new object[] { info }, SelectionTypes.Remove); associatedDesigner.RemoveConnector(connectors[num]); object obj4 = associatedDesigner; if (connectors.Count > 0) { obj4 = new ConnectorHitTestInfo(associatedDesigner, HitTestLocations.Connector | HitTestLocations.Designer, (num > 0) ? (num - 1) : num); } service.SetSelectedComponents(new object[] { obj4 }, SelectionTypes.Replace); } } } } e.Handled = true; } if (!e.Handled) { base.OnKeyDown(e); } } }
private void OnMenuPaste(object sender, EventArgs e) { object selectedObject = this.selectionService.PrimarySelection; CompositeActivityDesigner compositeDesigner = ActivityDesigner.GetDesigner(selectedObject as Activity) as CompositeActivityDesigner; if (compositeDesigner == null) compositeDesigner = ActivityDesigner.GetParentDesigner(selectedObject); if (compositeDesigner == null || !compositeDesigner.IsEditable) return; // deserialize activities IDataObject dataObj = Clipboard.GetDataObject(); ICollection components = null; try { components = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(this.serviceProvider, dataObj, true); } catch (Exception ex) { if (ex != CheckoutException.Canceled) throw new Exception(DR.GetString(DR.ActivityInsertError) + "\n" + ex.Message, ex); } if (components == null) throw new InvalidOperationException(DR.GetString(DR.InvalidOperationBadClipboardFormat)); // get the drop target HitTestInfo hitInfo = null; if (selectedObject is HitTestInfo) { hitInfo = (HitTestInfo)selectedObject; } else if (selectedObject is CompositeActivity) { hitInfo = new HitTestInfo(compositeDesigner, HitTestLocations.Designer); } else if (selectedObject is Activity) { Activity selectedActivity = selectedObject as Activity; CompositeActivity parentActivity = selectedActivity.Parent; CompositeActivityDesigner parentDesigner = ActivityDesigner.GetDesigner(parentActivity) as CompositeActivityDesigner; if (parentDesigner != null) hitInfo = new ConnectorHitTestInfo(parentDesigner, HitTestLocations.Designer, parentActivity.Activities.IndexOf(selectedActivity) + 1); } List<Activity> topLevelActivities = new List<Activity>(Helpers.GetTopLevelActivities(components)); // check if we can insert or not // I know I should have disabled the paste menu it-self, but doing status check for paste gives a big performance hit. I am working on it. if (hitInfo == null || !compositeDesigner.CanInsertActivities(hitInfo, topLevelActivities.AsReadOnly())) throw new Exception(SR.GetString(SR.Error_NoPasteSupport)); // Make sure the project has references to all inserted activities (in the case // where an activity is copied from another project IExtendedUIService extendedUIService = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService; if (extendedUIService != null) { foreach (Activity pastedActivity in components) extendedUIService.AddAssemblyReference(pastedActivity.GetType().Assembly.GetName()); } CompositeActivityDesigner.InsertActivities(compositeDesigner, hitInfo, topLevelActivities.AsReadOnly(), SR.GetString(SR.PastingActivities)); Stream componentStateStream = dataObj.GetData(CF_DESIGNERSTATE) as Stream; if (componentStateStream != null) Helpers.DeserializeDesignersFromStream(components, componentStateStream); // set something on selections service this.selectionService.SetSelectedComponents(topLevelActivities.ToArray(), SelectionTypes.Replace); this.workflowView.EnsureVisible(this.selectionService.PrimarySelection); }
public override object GetNextSelectableObject(object obj, DesignerNavigationDirection direction) { if (base.ActiveDesigner != this) { return base.GetNextSelectableObject(obj, direction); } if ((direction != DesignerNavigationDirection.Down) && (direction != DesignerNavigationDirection.Up)) { return null; } object activity = null; ReadOnlyCollection<ActivityDesigner> containedDesigners = this.ContainedDesigners; if (direction == DesignerNavigationDirection.Down) { if (obj is ConnectorHitTestInfo) { int num = ((ConnectorHitTestInfo) obj).MapToIndex(); if ((num >= 0) && (num < containedDesigners.Count)) { activity = containedDesigners[num].Activity; } return activity; } if (obj is Activity) { ActivityDesigner designer = ActivityDesigner.GetDesigner(obj as Activity); int num2 = (designer != null) ? containedDesigners.IndexOf(designer) : -1; if ((num2 >= 0) && ((num2 + 1) < this.GetConnectors().Length)) { activity = new ConnectorHitTestInfo(this, HitTestLocations.Designer, num2 + 1); } } return activity; } if (direction == DesignerNavigationDirection.Up) { if (obj is ConnectorHitTestInfo) { int num3 = ((ConnectorHitTestInfo) obj).MapToIndex(); if ((num3 > 0) && (num3 < this.GetConnectors().Length)) { activity = containedDesigners[num3 - 1].Activity; } return activity; } if (obj is Activity) { ActivityDesigner designer2 = ActivityDesigner.GetDesigner(obj as Activity); int connector = (designer2 != null) ? containedDesigners.IndexOf(designer2) : -1; if ((connector >= 0) && (connector < this.GetConnectors().Length)) { activity = new ConnectorHitTestInfo(this, HitTestLocations.Designer, connector); } } } return activity; }
private void OnStatusPaste(object sender, EventArgs e) { MenuCommand command = (MenuCommand) sender; command.Enabled = false; object primarySelection = this.selectionService.PrimarySelection; CompositeActivityDesigner parentDesigner = ActivityDesigner.GetDesigner(primarySelection as Activity) as CompositeActivityDesigner; if (parentDesigner == null) { parentDesigner = ActivityDesigner.GetParentDesigner(primarySelection); } if ((parentDesigner != null) && parentDesigner.IsEditable) { IDesignerHost host = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; IToolboxService service = (IToolboxService) this.serviceProvider.GetService(typeof(IToolboxService)); IDataObject dataObject = Clipboard.GetDataObject(); if (((dataObject != null) && (host != null)) && ((dataObject.GetDataPresent("CF_WINOEDESIGNERCOMPONENTS") || (service == null)) || service.IsSupported(dataObject, host))) { System.Workflow.ComponentModel.Design.HitTestInfo insertLocation = null; if (primarySelection is System.Workflow.ComponentModel.Design.HitTestInfo) { insertLocation = (System.Workflow.ComponentModel.Design.HitTestInfo) primarySelection; } else if (primarySelection is CompositeActivity) { insertLocation = new System.Workflow.ComponentModel.Design.HitTestInfo(parentDesigner, HitTestLocations.Designer); } else if (primarySelection is Activity) { Activity item = primarySelection as Activity; CompositeActivity parent = item.Parent; CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(parent) as CompositeActivityDesigner; if (designer != null) { insertLocation = new ConnectorHitTestInfo(designer, HitTestLocations.Designer, parent.Activities.IndexOf(item) + 1); } } ICollection activities = null; try { activities = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(this.serviceProvider, dataObject); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw exception; } } command.Enabled = ((activities != null) && (insertLocation != null)) && parentDesigner.CanInsertActivities(insertLocation, new List<Activity>(Helpers.GetTopLevelActivities(activities)).AsReadOnly()); } } }
private void OnStatusPaste(object sender, EventArgs e) { MenuCommand cmd = (MenuCommand)sender; cmd.Enabled = false; //Check if we are in writtable context object selectedObject = this.selectionService.PrimarySelection; CompositeActivityDesigner compositeDesigner = ActivityDesigner.GetDesigner(selectedObject as Activity) as CompositeActivityDesigner; if (compositeDesigner == null) compositeDesigner = ActivityDesigner.GetParentDesigner(selectedObject); if (compositeDesigner == null || !compositeDesigner.IsEditable) return; //Check if data object format is valid IDesignerHost designerHost = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; IToolboxService ts = (IToolboxService)this.serviceProvider.GetService(typeof(IToolboxService)); IDataObject dataObj = Clipboard.GetDataObject(); if (dataObj == null || designerHost == null || (!dataObj.GetDataPresent(CF_DESIGNER) && (ts != null && !ts.IsSupported(dataObj, designerHost)))) return; //Get the drop target and check if it is valid HitTestInfo hitInfo = null; if (selectedObject is HitTestInfo) { hitInfo = (HitTestInfo)selectedObject; } else if (selectedObject is CompositeActivity) { hitInfo = new HitTestInfo(compositeDesigner, HitTestLocations.Designer); } else if (selectedObject is Activity) { Activity selectedActivity = selectedObject as Activity; CompositeActivity parentActivity = selectedActivity.Parent; CompositeActivityDesigner parentDesigner = ActivityDesigner.GetDesigner(parentActivity) as CompositeActivityDesigner; if (parentDesigner != null) hitInfo = new ConnectorHitTestInfo(parentDesigner, HitTestLocations.Designer, parentActivity.Activities.IndexOf(selectedActivity) + 1); } //Deserialize activities ICollection components = null; try { components = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(this.serviceProvider, dataObj); } catch (CheckoutException ex) { if (ex != CheckoutException.Canceled) throw ex; } cmd.Enabled = (components != null && hitInfo != null && compositeDesigner.CanInsertActivities(hitInfo, new List<Activity>(Helpers.GetTopLevelActivities(components)).AsReadOnly())); }
private void OnMenuPaste(object sender, EventArgs e) { object primarySelection = this.selectionService.PrimarySelection; CompositeActivityDesigner parentDesigner = ActivityDesigner.GetDesigner(primarySelection as Activity) as CompositeActivityDesigner; if (parentDesigner == null) { parentDesigner = ActivityDesigner.GetParentDesigner(primarySelection); } if ((parentDesigner != null) && parentDesigner.IsEditable) { IDataObject dataObject = Clipboard.GetDataObject(); ICollection activities = null; try { activities = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(this.serviceProvider, dataObject, true); } catch (Exception exception) { if (exception != CheckoutException.Canceled) { throw new Exception(DR.GetString("ActivityInsertError", new object[0]) + "\n" + exception.Message, exception); } } if (activities == null) { throw new InvalidOperationException(DR.GetString("InvalidOperationBadClipboardFormat", new object[0])); } System.Workflow.ComponentModel.Design.HitTestInfo insertLocation = null; if (primarySelection is System.Workflow.ComponentModel.Design.HitTestInfo) { insertLocation = (System.Workflow.ComponentModel.Design.HitTestInfo) primarySelection; } else if (primarySelection is CompositeActivity) { insertLocation = new System.Workflow.ComponentModel.Design.HitTestInfo(parentDesigner, HitTestLocations.Designer); } else if (primarySelection is Activity) { Activity item = primarySelection as Activity; CompositeActivity parent = item.Parent; CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(parent) as CompositeActivityDesigner; if (designer != null) { insertLocation = new ConnectorHitTestInfo(designer, HitTestLocations.Designer, parent.Activities.IndexOf(item) + 1); } } List<Activity> list = new List<Activity>(Helpers.GetTopLevelActivities(activities)); if ((insertLocation == null) || !parentDesigner.CanInsertActivities(insertLocation, list.AsReadOnly())) { throw new Exception(SR.GetString("Error_NoPasteSupport")); } IExtendedUIService service = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService; if (service != null) { foreach (Activity activity3 in activities) { service.AddAssemblyReference(activity3.GetType().Assembly.GetName()); } } CompositeActivityDesigner.InsertActivities(parentDesigner, insertLocation, list.AsReadOnly(), SR.GetString("PastingActivities")); Stream data = dataObject.GetData("CF_WINOEDESIGNERCOMPONENTSSTATE") as Stream; if (data != null) { Helpers.DeserializeDesignersFromStream(activities, data); } this.selectionService.SetSelectedComponents(list.ToArray(), SelectionTypes.Replace); this.workflowView.EnsureVisible(this.selectionService.PrimarySelection); } }
public override object GetNextSelectableObject(object obj, DesignerNavigationDirection direction) { if (ActiveDesigner != this) return base.GetNextSelectableObject(obj, direction); if (direction != DesignerNavigationDirection.Down && direction != DesignerNavigationDirection.Up) return null; object nextObject = null; ReadOnlyCollection<ActivityDesigner> containedDesigners = ContainedDesigners; if (direction == DesignerNavigationDirection.Down) { if (obj is ConnectorHitTestInfo) { int currentIndex = ((ConnectorHitTestInfo)obj).MapToIndex(); if (currentIndex >= 0 && currentIndex < containedDesigners.Count) nextObject = ((ActivityDesigner)containedDesigners[currentIndex]).Activity; } else if (obj is Activity) { ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(obj as Activity); int currentIndex = (activityDesigner != null) ? containedDesigners.IndexOf(activityDesigner) : -1; if (currentIndex >= 0 && (currentIndex + 1) < GetConnectors().Length) nextObject = new ConnectorHitTestInfo(this, HitTestLocations.Designer, currentIndex + 1); } } else if (direction == DesignerNavigationDirection.Up) { if (obj is ConnectorHitTestInfo) { int currentIndex = ((ConnectorHitTestInfo)obj).MapToIndex(); if (currentIndex > 0 && currentIndex < GetConnectors().Length) nextObject = ((ActivityDesigner)containedDesigners[currentIndex - 1]).Activity; } else if (obj is Activity) { ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(obj as Activity); int currentIndex = (activityDesigner != null) ? containedDesigners.IndexOf(activityDesigner) : -1; if (currentIndex >= 0 && currentIndex < GetConnectors().Length) nextObject = new ConnectorHitTestInfo(this, HitTestLocations.Designer, currentIndex); } } return nextObject; }
private void OnMenuPaste(object sender, EventArgs e) { object primarySelection = this.selectionService.PrimarySelection; CompositeActivityDesigner parentDesigner = ActivityDesigner.GetDesigner(primarySelection as Activity) as CompositeActivityDesigner; if (parentDesigner == null) { parentDesigner = ActivityDesigner.GetParentDesigner(primarySelection); } if ((parentDesigner != null) && parentDesigner.IsEditable) { IDataObject dataObject = Clipboard.GetDataObject(); ICollection activities = null; try { activities = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(this.serviceProvider, dataObject, true); } catch (Exception exception) { if (exception != CheckoutException.Canceled) { throw new Exception(DR.GetString("ActivityInsertError", new object[0]) + "\n" + exception.Message, exception); } } if (activities == null) { throw new InvalidOperationException(DR.GetString("InvalidOperationBadClipboardFormat", new object[0])); } System.Workflow.ComponentModel.Design.HitTestInfo insertLocation = null; if (primarySelection is System.Workflow.ComponentModel.Design.HitTestInfo) { insertLocation = (System.Workflow.ComponentModel.Design.HitTestInfo)primarySelection; } else if (primarySelection is CompositeActivity) { insertLocation = new System.Workflow.ComponentModel.Design.HitTestInfo(parentDesigner, HitTestLocations.Designer); } else if (primarySelection is Activity) { Activity item = primarySelection as Activity; CompositeActivity parent = item.Parent; CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(parent) as CompositeActivityDesigner; if (designer != null) { insertLocation = new ConnectorHitTestInfo(designer, HitTestLocations.Designer, parent.Activities.IndexOf(item) + 1); } } List <Activity> list = new List <Activity>(Helpers.GetTopLevelActivities(activities)); if ((insertLocation == null) || !parentDesigner.CanInsertActivities(insertLocation, list.AsReadOnly())) { throw new Exception(SR.GetString("Error_NoPasteSupport")); } IExtendedUIService service = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService; if (service != null) { foreach (Activity activity3 in activities) { service.AddAssemblyReference(activity3.GetType().Assembly.GetName()); } } CompositeActivityDesigner.InsertActivities(parentDesigner, insertLocation, list.AsReadOnly(), SR.GetString("PastingActivities")); Stream data = dataObject.GetData("CF_WINOEDESIGNERCOMPONENTSSTATE") as Stream; if (data != null) { Helpers.DeserializeDesignersFromStream(activities, data); } this.selectionService.SetSelectedComponents(list.ToArray(), SelectionTypes.Replace); this.workflowView.EnsureVisible(this.selectionService.PrimarySelection); } }
protected override bool OnKeyDown(KeyEventArgs eventArgs) { if (eventArgs != null && (eventArgs.KeyCode == Keys.PageUp || eventArgs.KeyCode == Keys.PageDown)) { UpdateViewOnPageUpDown(eventArgs.KeyCode == Keys.PageUp); } ISelectionService selectionService = ((IServiceProvider)this.ParentView).GetService(typeof(ISelectionService)) as ISelectionService; //enter key ( if (eventArgs.KeyCode == Keys.Enter) { // on enter key we want to do DoDefault of the designer IDesigner designer = ActivityDesigner.GetDesigner(selectionService.PrimarySelection as Activity) as IDesigner; if (designer != null) { designer.DoDefaultAction(); eventArgs.Handled = true; } } else if (eventArgs.KeyCode == Keys.Escape) { if (!eventArgs.Handled) { CompositeActivityDesigner parentDesigner = ActivityDesigner.GetParentDesigner(selectionService.PrimarySelection); if (parentDesigner != null) { selectionService.SetSelectedComponents(new object[] { parentDesigner.Activity }, SelectionTypes.Replace); } eventArgs.Handled = true; } } else if (eventArgs.KeyCode == Keys.Delete) { // check if we are cutting root component IDesignerHost designerHost = ((IServiceProvider)this.ParentView).GetService(typeof(IDesignerHost)) as IDesignerHost; if (!(designerHost == null || selectionService.GetComponentSelected(designerHost.RootComponent))) { //Check that we are cutting all activities //Check if we are in writable context ICollection components = selectionService.GetSelectedComponents(); if (DesignerHelpers.AreComponentsRemovable(components)) { // check if we can delete these List <Activity> topLevelActivities = new List <Activity>(Helpers.GetTopLevelActivities(selectionService.GetSelectedComponents())); bool needToDelete = (topLevelActivities.Count > 0); IDictionary commonParentActivities = Helpers.PairUpCommonParentActivities(topLevelActivities); foreach (DictionaryEntry entry in commonParentActivities) { CompositeActivityDesigner compositeActivityDesigner = ActivityDesigner.GetDesigner(entry.Key as Activity) as CompositeActivityDesigner; if (compositeActivityDesigner != null && !compositeActivityDesigner.CanRemoveActivities(new List <Activity>((Activity[])((ArrayList)entry.Value).ToArray(typeof(Activity))).AsReadOnly())) { needToDelete = false; } } if (needToDelete) { List <ConnectorHitTestInfo> connectors = new List <ConnectorHitTestInfo>(); foreach (object component in components) { ConnectorHitTestInfo connector = component as ConnectorHitTestInfo; if (connector != null) { connectors.Add(connector); } } //cache selcted connectors before calling this func CompositeActivityDesigner.RemoveActivities((IServiceProvider)this.ParentView, topLevelActivities.AsReadOnly(), SR.GetString(SR.DeletingActivities)); //add connectors back to the selection service if (selectionService != null && connectors.Count > 0) { selectionService.SetSelectedComponents(connectors, SelectionTypes.Add); } eventArgs.Handled = true; } } } } //navigation (left, right, up, down, tab, shift-tab) else if (eventArgs.KeyCode == Keys.Left || eventArgs.KeyCode == Keys.Right || eventArgs.KeyCode == Keys.Up || eventArgs.KeyCode == Keys.Down || eventArgs.KeyCode == Keys.Tab) { //we'll pass it to the parent designer of the primary selected designer //sequential designers just navigate between their children //free form designers may move their children on arrow keys and navigate on tab ActivityDesigner designer = ActivityDesigner.GetDesigner(selectionService.PrimarySelection as Activity) as ActivityDesigner; if (designer != null && designer.ParentDesigner != null) { //we will let the parent see if it wants to handle the event, //otherwise the selected designer itself will be called from a designer message filter below ((IWorkflowDesignerMessageSink)designer.ParentDesigner).OnKeyDown(eventArgs); eventArgs.Handled = true; } } if (!eventArgs.Handled) { ActivityDesigner designerWithFocus = GetDesignerWithFocus(); if (designerWithFocus != null) { ((IWorkflowDesignerMessageSink)designerWithFocus).OnKeyDown(eventArgs); } } return(eventArgs.Handled); }
public override bool Equals(object obj) { ConnectorHitTestInfo info = obj as ConnectorHitTestInfo; return(((info != null) && (info.AssociatedDesigner == base.AssociatedDesigner)) && ((info.HitLocation == base.HitLocation) && (info.MapToIndex() == this.MapToIndex()))); }
protected override void OnKeyDown(KeyEventArgs e) { if (e == null) throw new ArgumentNullException("e"); ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService; object selectedObject = (selectionService != null) ? selectionService.PrimarySelection : null; if (selectedObject == null) return; List<Activity> topLevelActivities = new List<Activity>(Helpers.GetTopLevelActivities(selectionService.GetSelectedComponents())); if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) { Size direction = Size.Empty; const int step = 5; if (e.KeyCode == Keys.Left) direction = new Size(-step, 0); else if (e.KeyCode == Keys.Right) direction = new Size(step, 0); else if (e.KeyCode == Keys.Up) direction = new Size(0, -step); else if (e.KeyCode == Keys.Down) direction = new Size(0, step); foreach (Activity selectedActivity in topLevelActivities) { //move designer by 'direction' ActivityDesigner designer = ActivityDesigner.GetDesigner(selectedActivity); if (designer != null) { //refresh designer area both before and after move ParentView.InvalidateClientRectangle(new Rectangle(designer.Location, designer.Size)); designer.Location += direction; ParentView.InvalidateClientRectangle(new Rectangle(designer.Location, designer.Size)); } } //update layout to grow the parent if needed after all designers have been moved // PerformLayout(); e.Handled = true; } else if (e.KeyCode == Keys.Delete) { //if there is a connector selected, delete it ICollection components = selectionService.GetSelectedComponents(); foreach (object component in components) { ConnectorHitTestInfo connector = component as ConnectorHitTestInfo; if (connector != null) { FreeformActivityDesigner freeformDesigner = connector.AssociatedDesigner as FreeformActivityDesigner; if (freeformDesigner != null) { ReadOnlyCollection<Connector> connectors = freeformDesigner.Connectors; int connectorIndex = connector.MapToIndex(); if (connectorIndex < connectors.Count) { selectionService.SetSelectedComponents(new object[] { connector }, SelectionTypes.Remove); freeformDesigner.RemoveConnector(connectors[connectorIndex]); object nextSelectableObject = freeformDesigner; if (connectors.Count > 0) nextSelectableObject = new ConnectorHitTestInfo(freeformDesigner, HitTestLocations.Connector | HitTestLocations.Designer, (connectorIndex > 0) ? connectorIndex - 1 : connectorIndex); selectionService.SetSelectedComponents(new object[] { nextSelectableObject }, SelectionTypes.Replace); } } } } e.Handled = true; } if (!e.Handled) { //let the base handle all other keys including tabs base.OnKeyDown(e); } }
public override HitTestInfo HitTest(Point point) { if (ActiveDesigner != this) return base.HitTest(point); HitTestInfo hitInfo = HitTestInfo.Nowhere; if (!Expanded) { hitInfo = base.HitTest(point); } else if (ContainedDesigners.Count == 0 && HelpTextRectangle.Contains(point)) { hitInfo = new ConnectorHitTestInfo(this, HitTestLocations.Designer, 0); } else { //Check if the hit is on any of the connectors Rectangle[] connectors = GetConnectors(); for (int i = 0; i < connectors.Length; i++) { if (connectors[i].Contains(point)) { hitInfo = new ConnectorHitTestInfo(this, HitTestLocations.Designer, i); break; } } if (hitInfo.HitLocation == HitTestLocations.None) hitInfo = base.HitTest(point); } return hitInfo; }
public override HitTestInfo HitTest(Point point) { HitTestInfo hitInfo = HitTestInfo.Nowhere; if (Expanded && ActiveDesigner == this) { if (ContainedDesigners.Count == 0 && HelpTextRectangle.Contains(point)) { hitInfo = new ConnectorHitTestInfo(this, HitTestLocations.Designer, 0); } else if (this.previewStrip.Bounds.Contains(point)) { ItemInfo itemInfo = this.previewStrip.HitTest(point); ActivityDesigner activityDesigner = (itemInfo != null) ? ActivityDesigner.GetDesigner(itemInfo.UserData[DesignerUserDataKeys.Activity] as Activity) : null; if (activityDesigner != null) hitInfo = new HitTestInfo(activityDesigner, HitTestLocations.Designer); else hitInfo = new HitTestInfo(this, HitTestLocations.Designer | HitTestLocations.ActionArea); } else if (ShowPreview && this.previewWindow.Bounds.Contains(point) && (this.previewWindow.PreviewMode || PreviewedDesigner == null || !PreviewedDesigner.Bounds.Contains(point))) { hitInfo = new HitTestInfo(this, HitTestLocations.Designer | HitTestLocations.ActionArea); } else { hitInfo = base.HitTest(point); if (ShowPreview && this.previewWindow.PreviewMode && hitInfo.AssociatedDesigner != this) hitInfo = HitTestInfo.Nowhere; } } else { hitInfo = base.HitTest(point); } return hitInfo; }
protected override void OnKeyDown(KeyEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService; if (((service != null) ? service.PrimarySelection : null) != null) { List<Activity> list = new List<Activity>(Helpers.GetTopLevelActivities(service.GetSelectedComponents())); if (((e.KeyCode == Keys.Left) || (e.KeyCode == Keys.Right)) || ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Down))) { Size empty = Size.Empty; if (e.KeyCode == Keys.Left) { empty = new Size(-5, 0); } else if (e.KeyCode == Keys.Right) { empty = new Size(5, 0); } else if (e.KeyCode == Keys.Up) { empty = new Size(0, -5); } else if (e.KeyCode == Keys.Down) { empty = new Size(0, 5); } foreach (Activity activity in list) { ActivityDesigner designer = ActivityDesigner.GetDesigner(activity); if (designer != null) { base.ParentView.InvalidateClientRectangle(new Rectangle(designer.Location, designer.Size)); designer.Location += empty; base.ParentView.InvalidateClientRectangle(new Rectangle(designer.Location, designer.Size)); } } base.PerformLayout(); e.Handled = true; } else if (e.KeyCode == Keys.Delete) { foreach (object obj3 in service.GetSelectedComponents()) { ConnectorHitTestInfo info = obj3 as ConnectorHitTestInfo; if (info != null) { FreeformActivityDesigner associatedDesigner = info.AssociatedDesigner as FreeformActivityDesigner; if (associatedDesigner != null) { ReadOnlyCollection<Connector> connectors = associatedDesigner.Connectors; int num = info.MapToIndex(); if (num < connectors.Count) { service.SetSelectedComponents(new object[] { info }, SelectionTypes.Remove); associatedDesigner.RemoveConnector(connectors[num]); object obj4 = associatedDesigner; if (connectors.Count > 0) { obj4 = new ConnectorHitTestInfo(associatedDesigner, HitTestLocations.Connector | HitTestLocations.Designer, (num > 0) ? (num - 1) : num); } service.SetSelectedComponents(new object[] { obj4 }, SelectionTypes.Replace); } } } } e.Handled = true; } if (!e.Handled) { base.OnKeyDown(e); } } }
private int CanDrop(ActivityDragEventArgs e) { if (e.Activities.Count == 0) return -1; Point dropPoint = new Point(e.X, e.Y); int dropIndex = -1; Rectangle[] dropTargets = GetDropTargets(dropPoint); for (int i = 0; i < dropTargets.Length; i++) { if (dropTargets[i].Contains(dropPoint)) { dropIndex = i; break; } } if (dropIndex >= 0 && !CanInsertActivities(new ConnectorHitTestInfo(this, HitTestLocations.Designer, dropIndex), e.Activities)) dropIndex = -1; bool ctrlKeyPressed = ((e.KeyState & 8) == 8); if (dropIndex >= 0 && !ctrlKeyPressed && (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) { ConnectorHitTestInfo moveLocation = new ConnectorHitTestInfo(this, HitTestLocations.Designer, dropIndex); foreach (Activity activity in e.Activities) { if (activity.Site != null) { ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(activity); if (activityDesigner == null || activityDesigner.ParentDesigner == null || !activityDesigner.ParentDesigner.CanMoveActivities(moveLocation, new List<Activity>(new Activity[] { activity }).AsReadOnly())) { dropIndex = -1; break; } } } } return dropIndex; }
protected override bool OnKeyDown(KeyEventArgs eventArgs) { if ((eventArgs != null) && ((eventArgs.KeyCode == Keys.PageUp) || (eventArgs.KeyCode == Keys.Next))) { this.UpdateViewOnPageUpDown(eventArgs.KeyCode == Keys.PageUp); } ISelectionService service = ((IServiceProvider)base.ParentView).GetService(typeof(ISelectionService)) as ISelectionService; if (eventArgs.KeyCode == Keys.Enter) { IDesigner designer = ActivityDesigner.GetDesigner(service.PrimarySelection as Activity); if (designer != null) { designer.DoDefaultAction(); eventArgs.Handled = true; } } else if (eventArgs.KeyCode == Keys.Escape) { if (!eventArgs.Handled) { CompositeActivityDesigner parentDesigner = ActivityDesigner.GetParentDesigner(service.PrimarySelection); if (parentDesigner != null) { service.SetSelectedComponents(new object[] { parentDesigner.Activity }, SelectionTypes.Replace); } eventArgs.Handled = true; } } else if (eventArgs.KeyCode == Keys.Delete) { IDesignerHost host = ((IServiceProvider)base.ParentView).GetService(typeof(IDesignerHost)) as IDesignerHost; if ((host != null) && !service.GetComponentSelected(host.RootComponent)) { ICollection selectedComponents = service.GetSelectedComponents(); if (DesignerHelpers.AreComponentsRemovable(selectedComponents)) { List <Activity> activities = new List <Activity>(Helpers.GetTopLevelActivities(service.GetSelectedComponents())); bool flag = activities.Count > 0; foreach (DictionaryEntry entry in Helpers.PairUpCommonParentActivities(activities)) { CompositeActivityDesigner designer3 = ActivityDesigner.GetDesigner(entry.Key as Activity) as CompositeActivityDesigner; if ((designer3 != null) && !designer3.CanRemoveActivities(new List <Activity>((Activity[])((ArrayList)entry.Value).ToArray(typeof(Activity))).AsReadOnly())) { flag = false; } } if (flag) { List <ConnectorHitTestInfo> components = new List <ConnectorHitTestInfo>(); foreach (object obj2 in selectedComponents) { ConnectorHitTestInfo item = obj2 as ConnectorHitTestInfo; if (item != null) { components.Add(item); } } CompositeActivityDesigner.RemoveActivities(base.ParentView, activities.AsReadOnly(), SR.GetString("DeletingActivities")); if ((service != null) && (components.Count > 0)) { service.SetSelectedComponents(components, SelectionTypes.Add); } eventArgs.Handled = true; } } } } else if (((eventArgs.KeyCode == Keys.Left) || (eventArgs.KeyCode == Keys.Right)) || (((eventArgs.KeyCode == Keys.Up) || (eventArgs.KeyCode == Keys.Down)) || (eventArgs.KeyCode == Keys.Tab))) { ActivityDesigner designer4 = ActivityDesigner.GetDesigner(service.PrimarySelection as Activity); if ((designer4 != null) && (designer4.ParentDesigner != null)) { ((IWorkflowDesignerMessageSink)designer4.ParentDesigner).OnKeyDown(eventArgs); eventArgs.Handled = true; } } if (!eventArgs.Handled) { ActivityDesigner designerWithFocus = this.GetDesignerWithFocus(); if (designerWithFocus != null) { ((IWorkflowDesignerMessageSink)designerWithFocus).OnKeyDown(eventArgs); } } return(eventArgs.Handled); }