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 bool OnMouseUp(MouseEventArgs eventArgs) { Point clientPoint = new Point(eventArgs.X, eventArgs.Y); if (!base.ParentView.IsClientPointInActiveLayout(clientPoint)) { if (this.currentActiveDesigner != null) { ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseLeave(); } this.currentActiveDesigner = null; return(true); } System.Workflow.ComponentModel.Design.HitTestInfo messageHitTestContext = base.MessageHitTestContext; if (this.currentActiveDesigner != messageHitTestContext.AssociatedDesigner) { if (this.currentActiveDesigner != null) { ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseLeave(); } this.currentActiveDesigner = messageHitTestContext.AssociatedDesigner; if (this.currentActiveDesigner != null) { ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseEnter(eventArgs); } } if (this.currentActiveDesigner != null) { ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseUp(eventArgs); } return(false); }
public override System.Workflow.ComponentModel.Design.HitTestInfo HitTest(Point point) { System.Workflow.ComponentModel.Design.HitTestInfo info = base.HitTest(point); ReadOnlyCollection <ActivityDesigner> containedDesigners = this.ContainedDesigners; WorkflowView parentView = base.ParentView; DragDropManager service = base.GetService(typeof(DragDropManager)) as DragDropManager; if ((((parentView != null) && (service != null)) && (parentView.DragDropInProgress && (info.AssociatedDesigner != null))) && (service.DraggedActivities.Contains(info.AssociatedDesigner.Activity) && info.AssociatedDesigner.Bounds.Contains(point))) { if (base.Activity == info.AssociatedDesigner.Activity) { return(System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere); } if (containedDesigners.Contains(info.AssociatedDesigner)) { return(new System.Workflow.ComponentModel.Design.HitTestInfo(this, HitTestLocations.Designer)); } } if (!(info is ConnectionPointHitTestInfo) && (((info.HitLocation == HitTestLocations.None) || (info.AssociatedDesigner == this)) || this.ShowConnectorsInForeground)) { for (int i = 0; i < this.connectors.Count; i++) { if (this.connectors[i].HitTest(point)) { return(new ConnectorHitTestInfo(this, HitTestLocations.Connector | HitTestLocations.Designer, i)); } } } return(info); }
public override bool CanInsertActivities(System.Workflow.ComponentModel.Design.HitTestInfo insertLocation, ReadOnlyCollection <Activity> activitiesToInsert) { if (insertLocation == null) { throw new ArgumentNullException("insertLocation"); } if (activitiesToInsert == null) { throw new ArgumentNullException("activitiesToInsert"); } ActivityDesigner designer = (this.ActiveView != null) ? this.ActiveView.AssociatedDesigner : null; if (designer != this) { return(false); } IList <System.Type> activityTypes = SecondaryViewProvider.GetActivityTypes(this); foreach (Activity activity in activitiesToInsert) { if (activity == null) { throw new ArgumentException("activitiesToInsert", SR.GetString("Error_CollectionHasNullEntry")); } if (activityTypes.Contains(activity.GetType())) { return(false); } } return(base.CanInsertActivities(this.GetUpdatedLocation(insertLocation), activitiesToInsert)); }
public override void MoveActivities(System.Workflow.ComponentModel.Design.HitTestInfo moveLocation, ReadOnlyCollection <Activity> activitiesToMove) { if (moveLocation == null) { throw new ArgumentNullException("moveLocation"); } if (activitiesToMove == null) { throw new ArgumentNullException("activitiesToMove"); } FreeformActivityDesigner connectorContainer = ConnectionManager.GetConnectorContainer(this); try { connectorContainer.MovingActivities.Clear(); if ((connectorContainer != null) && (connectorContainer.Connectors.Count > 0)) { foreach (Activity activity in activitiesToMove) { ActivityDesigner designer = ActivityDesigner.GetDesigner(activity); if (ConnectionManager.GetConnectorContainer(designer) == connectorContainer) { connectorContainer.MovingActivities.Add(designer); } } } base.MoveActivities(moveLocation, activitiesToMove); } finally { connectorContainer.MovingActivities.Clear(); } }
protected override bool OnMouseDown(MouseEventArgs eventArgs) { Point empty = Point.Empty; if ((eventArgs.Button & MouseButtons.Left) == MouseButtons.Left) { WorkflowView parentView = base.ParentView; Point clientPoint = new Point(eventArgs.X, eventArgs.Y); if ((parentView != null) && parentView.IsClientPointInActiveLayout(clientPoint)) { Point editPoint = parentView.ClientPointToLogical(clientPoint); if (this.CanBeginEditing(editPoint, base.MessageHitTestContext)) { this.initialDragPoint = new Point?(editPoint); this.dragPointHitInfo = base.MessageHitTestContext; } empty = editPoint; } } else { this.EndEditing(null); } return(this.initialDragPoint.HasValue | this.UpdateCursor(new Point?(empty))); }
private ConnectorEditor GetConnectorEditor(Point editPoint, System.Workflow.ComponentModel.Design.HitTestInfo messageContext) { Connector connectorEdited = null; ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService; if (service != null) { Connector connectorFromSelectedObject = Connector.GetConnectorFromSelectedObject(service.PrimarySelection); if (((connectorFromSelectedObject != null) && connectorFromSelectedObject.ParentDesigner.EnableUserDrawnConnectors) && new ConnectorEditor(connectorFromSelectedObject).HitTest(editPoint)) { connectorEdited = connectorFromSelectedObject; } } if (connectorEdited == null) { ConnectionPointHitTestInfo info = messageContext as ConnectionPointHitTestInfo; if ((info != null) && (info.ConnectionPoint != null)) { FreeformActivityDesigner connectorContainer = GetConnectorContainer(info.AssociatedDesigner); if ((connectorContainer != null) && connectorContainer.EnableUserDrawnConnectors) { connectorEdited = connectorContainer.CreateConnector(info.ConnectionPoint, info.ConnectionPoint); } } } if (connectorEdited == null) { return(null); } return(new ConnectorEditor(connectorEdited)); }
private void EndEditing(Point?editPoint) { WorkflowView parentView = base.ParentView; if (parentView != null) { if (this.EditingInProgress) { if (editPoint.HasValue) { if (this.connectorEditor.EditedConectionPoint != null) { ConnectionPoint sourceConnectionPoint = (this.connectorEditor.EditedConnector.Source == this.connectorEditor.EditedConectionPoint) ? this.connectorEditor.EditedConnector.Target : this.connectorEditor.EditedConnector.Source; GetSnappableConnectionPoints(editPoint.Value, sourceConnectionPoint, this.connectorEditor.EditedConectionPoint, base.MessageHitTestContext.AssociatedDesigner, out this.snappedConnectionPoint); } if (this.SnappedConnectionPoint != null) { editPoint = new Point?(this.SnappedConnectionPoint.Location); } } this.connectorEditor.OnEndEditing(editPoint.HasValue ? editPoint.Value : Point.Empty, editPoint.HasValue); } this.initialDragPoint = null; this.dragPointHitInfo = null; this.snappedConnectionPoint = null; this.ConnectablePoints = null; parentView.Capture = false; this.connectorEditor = null; } }
public override System.Workflow.ComponentModel.Design.HitTestInfo HitTest(Point point) { System.Workflow.ComponentModel.Design.HitTestInfo nowhere = System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere; if (this.Expanded && (base.ActiveDesigner == this)) { if ((this.ContainedDesigners.Count == 0) && this.HelpTextRectangle.Contains(point)) { return(new ConnectorHitTestInfo(this, HitTestLocations.Designer, 0)); } if (this.previewStrip.Bounds.Contains(point)) { System.Workflow.ComponentModel.Design.ItemInfo info2 = this.previewStrip.HitTest(point); ActivityDesigner designer = (info2 != null) ? ActivityDesigner.GetDesigner(info2.UserData[DesignerUserDataKeys.Activity] as Activity) : null; if (designer != null) { return(new System.Workflow.ComponentModel.Design.HitTestInfo(designer, HitTestLocations.Designer)); } return(new System.Workflow.ComponentModel.Design.HitTestInfo(this, HitTestLocations.ActionArea | HitTestLocations.Designer)); } if ((this.ShowPreview && this.previewWindow.Bounds.Contains(point)) && ((this.previewWindow.PreviewMode || (this.PreviewedDesigner == null)) || !this.PreviewedDesigner.Bounds.Contains(point))) { return(new System.Workflow.ComponentModel.Design.HitTestInfo(this, HitTestLocations.ActionArea | HitTestLocations.Designer)); } nowhere = base.HitTest(point); if ((this.ShowPreview && this.previewWindow.PreviewMode) && (nowhere.AssociatedDesigner != this)) { nowhere = System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere; } return(nowhere); } return(base.HitTest(point)); }
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()); } } }
public override void MoveActivities(System.Workflow.ComponentModel.Design.HitTestInfo moveLocation, ReadOnlyCollection <Activity> activitiesToMove) { if (moveLocation == null) { throw new ArgumentNullException("moveLocation"); } if (activitiesToMove == null) { throw new ArgumentNullException("activitiesToMove"); } base.MoveActivities(this.GetUpdatedLocation(moveLocation), activitiesToMove); }
public override void InsertActivities(System.Workflow.ComponentModel.Design.HitTestInfo insertLocation, ReadOnlyCollection <Activity> activitiesToInsert) { if (insertLocation == null) { throw new ArgumentNullException("insertLocation"); } if (activitiesToInsert == null) { throw new ArgumentNullException("activitiesToInsert"); } base.InsertActivities(this.GetUpdatedLocation(insertLocation), activitiesToInsert); }
private System.Workflow.ComponentModel.Design.HitTestInfo GetUpdatedLocation(System.Workflow.ComponentModel.Design.HitTestInfo location) { int num = 0; foreach (DesignerView view in this.Views) { if (((view.AssociatedDesigner != null) && (this != view.AssociatedDesigner)) && Helpers.IsActivityLocked(view.AssociatedDesigner.Activity)) { num++; } } return(new ConnectorHitTestInfo(this, location.HitLocation, num + location.MapToIndex())); }
public override void InsertActivities(System.Workflow.ComponentModel.Design.HitTestInfo insertLocation, ReadOnlyCollection <Activity> activitiesToInsert) { base.InsertActivities(insertLocation, activitiesToInsert); if (this.AutoSize) { Size autoSizeMargin = this.AutoSizeMargin; Point location = this.Location; foreach (Activity activity in activitiesToInsert) { ActivityDesigner designer = ActivityDesigner.GetDesigner(activity); if (designer.Location.IsEmpty) { designer.Location = new Point(location.X + autoSizeMargin.Width, location.Y + autoSizeMargin.Height); } } } }
protected override bool OnMouseDown(MouseEventArgs eventArgs) { Point clientPoint = new Point(eventArgs.X, eventArgs.Y); WorkflowView parentView = base.ParentView; if (!parentView.IsClientPointInActiveLayout(clientPoint)) { return(true); } object activity = null; System.Workflow.ComponentModel.Design.HitTestInfo messageHitTestContext = base.MessageHitTestContext; if (messageHitTestContext == System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere) { activity = parentView.RootDesigner.Activity; } else { activity = messageHitTestContext.SelectableObject; } if (activity != null) { ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService; if (service != null) { service.SetSelectedComponents(new object[] { activity }, SelectionTypes.Click); } } if (this.currentActiveDesigner != messageHitTestContext.AssociatedDesigner) { if (this.currentActiveDesigner != null) { ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseLeave(); } this.currentActiveDesigner = messageHitTestContext.AssociatedDesigner; if (this.currentActiveDesigner != null) { ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseEnter(eventArgs); } } if ((this.currentActiveDesigner != null) && ((Control.ModifierKeys & (Keys.Control | Keys.Shift)) == Keys.None)) { ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseDown(eventArgs); } return(false); }
protected override bool OnMouseMove(MouseEventArgs eventArgs) { WorkflowView parentView = base.ParentView; Point clientPoint = new Point(eventArgs.X, eventArgs.Y); if (!parentView.IsClientPointInActiveLayout(clientPoint)) { return(false); } if (eventArgs.Button == MouseButtons.Left) { Point point2 = parentView.ClientPointToLogical(clientPoint); System.Workflow.ComponentModel.Design.HitTestInfo messageHitTestContext = base.MessageHitTestContext; if (this.draggedDesigner != null) { ((IWorkflowDesignerMessageSink)this.draggedDesigner).OnMouseDragMove(eventArgs); } else if ((((parentView.RootDesigner != null) && this.dragStarted) && ((eventArgs.Button & MouseButtons.Left) > MouseButtons.None)) && ((Math.Abs((int)(this.dragInitiationPoint.X - point2.X)) > SystemInformation.DragSize.Width) || (Math.Abs((int)(this.dragInitiationPoint.Y - point2.Y)) > SystemInformation.DragSize.Height))) { ActivityDesigner associatedDesigner = messageHitTestContext.AssociatedDesigner; if (associatedDesigner != null) { if (this.CanInitiateDragDrop()) { this.InitiateDragDrop(); this.dragStarted = false; } else { this.draggedDesigner = associatedDesigner; ((IWorkflowDesignerMessageSink)this.draggedDesigner).OnMouseDragBegin(this.dragInitiationPoint, eventArgs); parentView.Capture = true; } } } } else { if (this.draggedDesigner != null) { ((IWorkflowDesignerMessageSink)this.draggedDesigner).OnMouseDragEnd(); } this.draggedDesigner = null; } return(this.draggedDesigner != null); }
internal static bool AreAssociatedDesignersMovable(ICollection components) { foreach (object obj2 in components) { Activity activity = obj2 as Activity; if (activity == null) { System.Workflow.ComponentModel.Design.HitTestInfo info = obj2 as System.Workflow.ComponentModel.Design.HitTestInfo; activity = ((info != null) && (info.AssociatedDesigner != null)) ? info.AssociatedDesigner.Activity : null; } ActivityDesigner designer = ActivityDesigner.GetDesigner(activity); if ((designer != null) && designer.IsLocked) { return(false); } } return(true); }
internal bool IsValidDropContext(System.Workflow.ComponentModel.Design.HitTestInfo dropLocation) { if (this.draggedActivities.Count == 0) { return(false); } if ((dropLocation == null) || (dropLocation.AssociatedDesigner == null)) { return(false); } CompositeActivityDesigner associatedDesigner = dropLocation.AssociatedDesigner as CompositeActivityDesigner; if (associatedDesigner == null) { return(false); } if (!associatedDesigner.IsEditable || !associatedDesigner.CanInsertActivities(dropLocation, new List <Activity>(this.draggedActivities).AsReadOnly())) { return(false); } if (!this.wasCtrlKeyPressed && (this.existingDraggedActivities.Count > 0)) { if (!DesignerHelpers.AreAssociatedDesignersMovable(this.draggedActivities)) { return(false); } if (this.IsRecursiveDropOperation(dropLocation.AssociatedDesigner)) { return(false); } foreach (DictionaryEntry entry in Helpers.PairUpCommonParentActivities(this.draggedActivities)) { CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(entry.Key as Activity) as CompositeActivityDesigner; Activity[] collection = (Activity[])((ArrayList)entry.Value).ToArray(typeof(Activity)); if ((designer != null) && !designer.CanMoveActivities(dropLocation, new List <Activity>(collection).AsReadOnly())) { return(false); } } } return(true); }
public WorkflowMessageDispatchData(WorkflowView workflowView, EventArgs e) { this.workflowView = workflowView; if ((this.workflowView.RootDesigner != null) && (this.workflowView.stockMessageFilters.Count > 0)) { Point empty = Point.Empty; if ((e is MouseEventArgs) || (e is DragEventArgs)) { if (e is MouseEventArgs) { empty = new Point(((MouseEventArgs) e).X, ((MouseEventArgs) e).Y); } else if (e is DragEventArgs) { empty = this.workflowView.PointToClient(new Point(((DragEventArgs) e).X, ((DragEventArgs) e).Y)); this.workflowView.UpdateLayout(); } Point point = this.workflowView.ClientPointToLogical(empty); System.Workflow.ComponentModel.Design.HitTestInfo info = this.workflowView.RootDesigner.HitTest(point); this.messageContext = (info != null) ? info : System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere; this.workflowView.messageHitTestContexts.Push(this.messageContext); } } }
public override System.Workflow.ComponentModel.Design.HitTestInfo HitTest(Point point) { System.Workflow.ComponentModel.Design.HitTestInfo nowhere = System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere; if (this.ExpandButtonRectangle.Contains(point)) { nowhere = new System.Workflow.ComponentModel.Design.HitTestInfo(this, HitTestLocations.ActionArea | HitTestLocations.Designer); } else if (this.Expanded && base.Bounds.Contains(point)) { ReadOnlyCollection<ActivityDesigner> containedDesigners = this.ContainedDesigners; for (int i = containedDesigners.Count - 1; i >= 0; i--) { ActivityDesigner designer = containedDesigners[i]; if ((designer != null) && designer.IsVisible) { nowhere = designer.HitTest(point); if (nowhere.HitLocation != HitTestLocations.None) { break; } } } } if (nowhere == System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere) { nowhere = base.HitTest(point); } if ((nowhere.AssociatedDesigner != null) && (nowhere.AssociatedDesigner.DrawingState != ActivityDesigner.DrawingStates.Valid)) { nowhere = new System.Workflow.ComponentModel.Design.HitTestInfo(nowhere.AssociatedDesigner, HitTestLocations.ActionArea | HitTestLocations.Designer); } return nowhere; }
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 OnDragDrop(DragEventArgs eventArgs) { WorkflowView parentView = base.ParentView; parentView.InvalidateClientRectangle(Rectangle.Empty); eventArgs.Effect = DragDropEffects.None; this.DestroyDragFeedbackImages(); Point clientPoint = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y)); Point point = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y)); if (!parentView.IsClientPointInActiveLayout(clientPoint)) { if (this.dropTargetDesigner != null) { ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave(); } this.wasCtrlKeyPressed = false; this.dropTargetDesigner = null; this.draggedActivities.Clear(); return(false); } this.wasCtrlKeyPressed = (eventArgs.KeyState & 8) == 8; ActivityDragEventArgs e = new ActivityDragEventArgs(eventArgs, this.dragInitiationPoint, point, this.draggedActivities); System.Workflow.ComponentModel.Design.HitTestInfo messageHitTestContext = base.MessageHitTestContext; if (this.dropTargetDesigner != messageHitTestContext.AssociatedDesigner) { if (this.dropTargetDesigner != null) { ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave(); this.dropTargetDesigner = null; } if (messageHitTestContext.AssociatedDesigner != null) { this.dropTargetDesigner = messageHitTestContext.AssociatedDesigner; if (this.dropTargetDesigner != null) { ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragEnter(e); } } } try { if (this.dropTargetDesigner != null) { if ((!this.wasCtrlKeyPressed && this.IsRecursiveDropOperation(this.dropTargetDesigner)) || ((this.dropTargetDesigner is CompositeActivityDesigner) && !((CompositeActivityDesigner)this.dropTargetDesigner).IsEditable)) { ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave(); e.Effect = DragDropEffects.None; } else { List <Activity> draggedActivities = new List <Activity>(); string description = SR.GetString("DragDropActivities"); if (!this.wasCtrlKeyPressed && (this.existingDraggedActivities.Count > 0)) { draggedActivities.AddRange(this.existingDraggedActivities); if (draggedActivities.Count > 1) { description = SR.GetString("MoveMultipleActivities", new object[] { draggedActivities.Count }); } else if (draggedActivities.Count == 1) { description = SR.GetString("MoveSingleActivity", new object[] { draggedActivities[0].GetType() }); } } else { draggedActivities.AddRange(CompositeActivityDesigner.DeserializeActivitiesFromDataObject(base.ParentView, eventArgs.Data, true)); if (draggedActivities.Count > 0) { description = SR.GetString("CreateActivityFromToolbox", new object[] { draggedActivities[0].GetType() }); } } IDesignerHost host = base.GetService(typeof(IDesignerHost)) as IDesignerHost; DesignerTransaction transaction = null; if (draggedActivities.Count > 0) { transaction = host.CreateTransaction(description); } e = new ActivityDragEventArgs(eventArgs, this.dragInitiationPoint, point, draggedActivities); try { ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragDrop(e); if (e.Effect == DragDropEffects.Move) { this.existingDraggedActivities.Clear(); } if (transaction != null) { transaction.Commit(); } } catch (Exception exception) { if (transaction != null) { transaction.Cancel(); } throw exception; } if (draggedActivities.Count > 0) { Stream data = eventArgs.Data.GetData("CF_WINOEDESIGNERCOMPONENTSSTATE") as Stream; if (data != null) { Helpers.DeserializeDesignersFromStream(draggedActivities, data); } ISelectionService service = (ISelectionService)base.GetService(typeof(ISelectionService)); if (service != null) { service.SetSelectedComponents(draggedActivities, SelectionTypes.Replace); } } if (host != null) { host.Activate(); } } } } catch (Exception exception2) { ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave(); e.Effect = DragDropEffects.None; string message = exception2.Message; if ((exception2.InnerException != null) && !string.IsNullOrEmpty(exception2.InnerException.Message)) { message = exception2.InnerException.Message; } string str3 = DR.GetString("Error_FailedToDeserializeComponents", new object[0]) + "\r\n" + DR.GetString("Error_Reason", new object[] { message }); DesignerHelpers.ShowError(base.ParentView, str3); if (exception2 != CheckoutException.Canceled) { throw new Exception(str3, exception2); } } finally { this.wasCtrlKeyPressed = false; this.draggedActivities.Clear(); this.dropTargetDesigner = null; this.exceptionInDragDrop = false; eventArgs.Effect = e.Effect; } return(true); }
private void EndEditing(Point? editPoint) { WorkflowView parentView = base.ParentView; if (parentView != null) { if (this.EditingInProgress) { if (editPoint.HasValue) { if (this.connectorEditor.EditedConectionPoint != null) { ConnectionPoint sourceConnectionPoint = (this.connectorEditor.EditedConnector.Source == this.connectorEditor.EditedConectionPoint) ? this.connectorEditor.EditedConnector.Target : this.connectorEditor.EditedConnector.Source; GetSnappableConnectionPoints(editPoint.Value, sourceConnectionPoint, this.connectorEditor.EditedConectionPoint, base.MessageHitTestContext.AssociatedDesigner, out this.snappedConnectionPoint); } if (this.SnappedConnectionPoint != null) { editPoint = new Point?(this.SnappedConnectionPoint.Location); } } this.connectorEditor.OnEndEditing(editPoint.HasValue ? editPoint.Value : Point.Empty, editPoint.HasValue); } this.initialDragPoint = null; this.dragPointHitInfo = null; this.snappedConnectionPoint = null; this.ConnectablePoints = null; parentView.Capture = false; this.connectorEditor = null; } }
protected override bool OnMouseDown(MouseEventArgs eventArgs) { Point empty = Point.Empty; if ((eventArgs.Button & MouseButtons.Left) == MouseButtons.Left) { WorkflowView parentView = base.ParentView; Point clientPoint = new Point(eventArgs.X, eventArgs.Y); if ((parentView != null) && parentView.IsClientPointInActiveLayout(clientPoint)) { Point editPoint = parentView.ClientPointToLogical(clientPoint); if (this.CanBeginEditing(editPoint, base.MessageHitTestContext)) { this.initialDragPoint = new Point?(editPoint); this.dragPointHitInfo = base.MessageHitTestContext; } empty = editPoint; } } else { this.EndEditing(null); } return (this.initialDragPoint.HasValue | this.UpdateCursor(new Point?(empty))); }
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); } }
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()); } } }