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))); }
protected override bool OnDragLeave() { //Invalidate so that we can clear the drag image and active placement glyphs WorkflowView parentView = ParentView; parentView.InvalidateClientRectangle(Rectangle.Empty); DestroyDragFeedbackImages(); //Clear the control key flag this.wasCtrlKeyPressed = false; //Now we fire the drag leave event if (this.dropTargetDesigner != null) { ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave(); } //Clear the buffered designer as the drag drop has ended this.dropTargetDesigner = null; this.draggedActivities.Clear(); this.exceptionInDragDrop = false; return(true); }
protected override bool OnMouseMove(MouseEventArgs eventArgs) { WorkflowView parentView = base.ParentView; if (parentView == null) { throw new InvalidOperationException(DR.GetString("WorkflowViewNull", new object[0])); } bool flag = false; Point clientPoint = new Point(eventArgs.X, eventArgs.Y); Point point = parentView.ClientPointToLogical(clientPoint); DesignerEdges none = DesignerEdges.None; if (this.designerToResize != null) { none = this.designerSizingEdge; this.UpdateDesignerSize(point, this.designerToResize, this.designerSizingEdge); flag = true; } else if (eventArgs.Button == MouseButtons.None) { ActivityDesigner designerToResize = this.GetDesignerToResize(point, out none); if (((designerToResize != null) && (none != DesignerEdges.None)) && this.CanResizeDesigner(designerToResize)) { flag = true; } } this.UpdateCursor(none); return(flag); }
private DesignerGlyph[] CreateConnectorDragDropGlyphs() { WorkflowView parentView = base.ParentView; DragDropManager service = base.GetService(typeof(DragDropManager)) as DragDropManager; if (((parentView == null) || (service == null)) || (!parentView.DragDropInProgress || (base.DrawingState != ActivityDesigner.DrawingStates.Valid))) { return(new DesignerGlyph[0]); } List <DesignerGlyph> list = new List <DesignerGlyph>(); Rectangle rectangle = parentView.ClientRectangleToLogical(new Rectangle(Point.Empty, parentView.ViewPortSize)); AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme; Rectangle[] connectors = this.GetConnectors(); Rectangle helpTextRectangle = this.HelpTextRectangle; for (int i = 0; i < connectors.Length; i++) { if ((rectangle.IntersectsWith(connectors[i]) && (i != this.CurrentDropTarget)) && service.IsValidDropContext(new ConnectorHitTestInfo(this, HitTestLocations.Designer, i))) { Point empty = Point.Empty; if (helpTextRectangle.IsEmpty) { empty = new Point((connectors[i].Location.X + (connectors[i].Size.Width / 2)) + 1, connectors[i].Location.Y + (connectors[i].Size.Height / 2)); } else { empty = new Point((helpTextRectangle.Left + (helpTextRectangle.Width / 2)) + 1, helpTextRectangle.Top - (ambientTheme.DropIndicatorSize.Height / 2)); } list.Add(new ConnectorDragDropGlyph(i, empty)); } } return(list.ToArray()); }
private void DrawScrollIndicators(Graphics graphics) { Image scrollIndicatorImage = AmbientTheme.ScrollIndicatorImage; if (scrollIndicatorImage != null) { WorkflowView parentView = base.ParentView; Size viewPortSize = parentView.ViewPortSize; Point scrollPosition = parentView.ScrollPosition; Rectangle[] scrollIndicatorRectangles = this.ScrollIndicatorRectangles; if (scrollPosition.X > 0) { ActivityDesignerPaint.DrawImage(graphics, AmbientTheme.ScrollIndicatorImage, scrollIndicatorRectangles[0], (float)0.7f); } if (scrollPosition.X < (parentView.HScrollBar.Maximum - viewPortSize.Width)) { scrollIndicatorImage.RotateFlip(RotateFlipType.RotateNoneFlipX); ActivityDesignerPaint.DrawImage(graphics, scrollIndicatorImage, scrollIndicatorRectangles[1], (float)0.7f); scrollIndicatorImage.RotateFlip(RotateFlipType.RotateNoneFlipX); } if (scrollPosition.Y > 0) { scrollIndicatorImage.RotateFlip(RotateFlipType.Rotate90FlipX); ActivityDesignerPaint.DrawImage(graphics, scrollIndicatorImage, scrollIndicatorRectangles[2], (float)0.7f); scrollIndicatorImage.RotateFlip(RotateFlipType.Rotate90FlipX); } if (scrollPosition.Y < (parentView.VScrollBar.Maximum - viewPortSize.Height)) { scrollIndicatorImage.RotateFlip(RotateFlipType.Rotate270FlipNone); ActivityDesignerPaint.DrawImage(graphics, scrollIndicatorImage, scrollIndicatorRectangles[3], (float)0.7f); scrollIndicatorImage.RotateFlip(RotateFlipType.Rotate90FlipNone); } } }
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); }
protected override bool OnScroll(ScrollBar sender, int value) { if (this.draggedDesignerImages != null) { Point[] previousLocations = GetDesignerLocations(DragInitiationPoint, this.movedDesignerImagePoint, DraggedActivities); InvalidateDraggedImages(previousLocations); } bool retVal = base.OnScroll(sender, value); if (this.draggedDesignerImages != null) { WorkflowView parentView = ParentView; Point clientPoint = parentView.PointToClient(Control.MousePosition); Point logicalPoint = parentView.ScreenPointToLogical(Control.MousePosition); if (parentView.IsClientPointInActiveLayout(clientPoint)) { this.movedDesignerImagePoint = logicalPoint; } else { this.movedDesignerImagePoint = DragInitiationPoint; } //Invalidate the new locations where the image is shown Point[] newLocations = GetDesignerLocations(DragInitiationPoint, this.movedDesignerImagePoint, DraggedActivities); InvalidateDraggedImages(newLocations); } return(retVal); }
protected override bool OnScroll(ScrollBar sender, int value) { if (this.draggedDesignerImages != null) { Point[] locations = GetDesignerLocations(base.DragInitiationPoint, this.movedDesignerImagePoint, base.DraggedActivities); this.InvalidateDraggedImages(locations); } bool flag = base.OnScroll(sender, value); if (this.draggedDesignerImages != null) { WorkflowView parentView = base.ParentView; Point clientPoint = parentView.PointToClient(Control.MousePosition); Point point2 = parentView.ScreenPointToLogical(Control.MousePosition); if (parentView.IsClientPointInActiveLayout(clientPoint)) { this.movedDesignerImagePoint = point2; } else { this.movedDesignerImagePoint = base.DragInitiationPoint; } Point[] pointArray2 = GetDesignerLocations(base.DragInitiationPoint, this.movedDesignerImagePoint, base.DraggedActivities); this.InvalidateDraggedImages(pointArray2); } return(flag); }
/// <summary> /// Display the specified workflow type. /// </summary> /// <param name="root">Type of the workflow.</param> public void DisplayType(Type root) { if (!typeof(Activity).IsAssignableFrom(root)) { throw new ArgumentException("WorkflowViewPanel only supports displaying Activity objects.", "root"); } this.surface = new DesignSurface(); this.host = this.surface.GetService(typeof(IDesignerHost)) as IDesignerHost; TypeProvider provider = new TypeProvider(this.surface); provider.AddAssembly(typeof(string).Assembly); IServiceContainer container = this.surface.GetService(typeof(IServiceContainer)) as IServiceContainer; container.AddService(typeof(ITypeProvider), provider); if (this.host == null) { throw new ApplicationException("Cannot work with a null host."); } Queue <Activity> toProcess = new Queue <Activity>(); try { toProcess.Enqueue((Activity)root.InvokeMember(string.Empty, System.Reflection.BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture)); } catch (Exception exc) { MessageBox.Show("Could not load workflow type: " + exc.ToString()); this.surface = null; this.host = null; return; } // Do a non-recursive walk of the activity // tree to display all activities. while (toProcess.Count > 0) { Activity activity = toProcess.Dequeue(); host.Container.Add(activity, activity.QualifiedName); if (activity is CompositeActivity) { foreach (Activity child in ((CompositeActivity)activity).Activities) { toProcess.Enqueue(child); } } } this.surface.BeginLoad(new WorkflowLoader()); workflowView = new MouseDisabledWorkflowView(host as IServiceProvider); workflowView.Dock = DockStyle.Fill; this.Controls.Add(workflowView); }
private void SetDraggedButton(int actionIndex, int buttonIndex) { if (this.draggedActionIndex == actionIndex && this.draggedButtonIndex == buttonIndex) { return; } WorkflowView parentView = ParentView; if (this.draggedActionIndex >= 0 && this.draggedButtonIndex >= 0) { if (this.draggedActionIndex < this.actions.Count) { this.actions[this.draggedActionIndex].Buttons[this.draggedButtonIndex].State = ActionButton.States.Highlight; } this.draggedActionIndex = -1; this.draggedButtonIndex = -1; parentView.Capture = false; UpdateTransparency(parentView.PointToClient(Control.MousePosition)); } this.draggedActionIndex = actionIndex; this.draggedButtonIndex = buttonIndex; if (this.draggedActionIndex >= 0 && this.draggedButtonIndex >= 0) { parentView.Capture = true; } }
protected override bool OnDragOver(DragEventArgs eventArgs) { if (this.draggedDesignerImages != null) { Point[] locations = GetDesignerLocations(base.DragInitiationPoint, this.movedDesignerImagePoint, base.DraggedActivities); this.InvalidateDraggedImages(locations); } bool flag = base.OnDragOver(eventArgs); if (this.draggedDesignerImages != null) { WorkflowView parentView = base.ParentView; Point clientPoint = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y)); Point point2 = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y)); if (parentView.IsClientPointInActiveLayout(clientPoint)) { this.movedDesignerImagePoint = point2; } else { this.movedDesignerImagePoint = base.DragInitiationPoint; } Point[] pointArray2 = GetDesignerLocations(base.DragInitiationPoint, this.movedDesignerImagePoint, base.DraggedActivities); this.InvalidateDraggedImages(pointArray2); } return(flag); }
private void RefreshActiveGlyph(Point point) { WorkflowView parentView = base.ParentView; if (parentView != null) { DesignerGlyph activeGlyph = this.activeGlyph; if ((this.activeGlyph == null) || !this.activeGlyph.GetBounds(this.activeDesigner, true).Contains(point)) { ActivityDesigner activityDesigner = null; DesignerGlyph glyph2 = this.GlyphFromPoint(point, out activityDesigner); if (this.activeGlyph != null) { parentView.InvalidateLogicalRectangle(this.activeGlyph.GetBounds(this.activeDesigner, true)); } this.activeGlyph = glyph2; this.activeDesigner = activityDesigner; if (this.activeGlyph != null) { parentView.InvalidateLogicalRectangle(this.activeGlyph.GetBounds(this.activeDesigner, true)); } } if (activeGlyph != this.activeGlyph) { if ((this.activeGlyph != null) && this.activeGlyph.CanBeActivated) { parentView.Cursor = Cursors.Hand; } else if (parentView.Cursor == Cursors.Hand) { parentView.Cursor = Cursors.Default; } } } }
private DesignerGlyph GlyphFromPoint(Point point, out ActivityDesigner activityDesigner) { activityDesigner = null; WorkflowView parentView = base.ParentView; if (parentView != null) { RectangleCollection rectangles = new RectangleCollection(); foreach (ActivityDesigner designer in this.GetActivityDesigners(parentView.ClientRectangleToLogical(new Rectangle(Point.Empty, parentView.ViewPortSize)))) { if (!rectangles.IsPointInsideAnyRectangle(point)) { foreach (DesignerGlyph glyph in this.GetDesignerGlyphs(designer)) { if (glyph.GetBounds(designer, false).Contains(point) && glyph.CanBeActivated) { activityDesigner = designer; return(glyph); } } } rectangles.AddRectangle(designer.Bounds); } } return(null); }
protected override bool OnMouseMove(MouseEventArgs eventArgs) { Point empty = Point.Empty; WorkflowView parentView = base.ParentView; Point clientPoint = new Point(eventArgs.X, eventArgs.Y); if ((parentView != null) && parentView.IsClientPointInActiveLayout(clientPoint)) { Point editPoint = parentView.ClientPointToLogical(clientPoint); if ((eventArgs.Button & MouseButtons.Left) == MouseButtons.Left) { if ((!this.EditingInProgress && this.initialDragPoint.HasValue) && ((Math.Abs((int)(this.initialDragPoint.Value.X - editPoint.X)) > SystemInformation.DragSize.Width) || (Math.Abs((int)(this.initialDragPoint.Value.Y - editPoint.Y)) > SystemInformation.DragSize.Height))) { ConnectorEditor connectorEditor = this.GetConnectorEditor(this.initialDragPoint.Value, this.dragPointHitInfo); this.BeginEditing(connectorEditor, this.initialDragPoint.Value); } if (this.EditingInProgress) { this.ContinueEditing(editPoint); if (this.SnappedConnectionPoint != null) { editPoint = this.SnappedConnectionPoint.Location; } } } else { FreeformActivityDesigner connectorContainer = GetConnectorContainer(base.MessageHitTestContext.AssociatedDesigner); this.ConnectablePoints = ((connectorContainer != null) && connectorContainer.EnableUserDrawnConnectors) ? GetHighlightableConnectionPoints(editPoint, base.MessageHitTestContext.AssociatedDesigner) : null; } empty = editPoint; } return(this.EditingInProgress | this.UpdateCursor(new Point?(empty))); }
private bool IsRecursiveDropOperation(ActivityDesigner dropTargetDesigner) { if (dropTargetDesigner == null) return false; ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService)); CompositeActivity dropTargetComponent = dropTargetDesigner.Activity as CompositeActivity; if (dropTargetComponent == null || selectionService == null) return false; // First check for activity designer specific recursion - possible recursion when drag-n-drop from outside the current // designer such toolbox or other activity designers. WorkflowView workflowView = GetService(typeof(WorkflowView)) as WorkflowView; IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; WorkflowDesignerLoader loader = GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader; // When drag-n-drop within the same designer, if the drag drop is not within designer or no valid droptarget, we do not do anything if (this.draggedActivities.Count == 0 || this.existingDraggedActivities.Count == 0) return false; //Go thru all the components in dragged components and check for recursive dragdrop //Get all the top level activities being dragged dropped ArrayList topLevelActivities = new ArrayList(Helpers.GetTopLevelActivities(selectionService.GetSelectedComponents())); CompositeActivity parentActivity = dropTargetComponent; while (parentActivity != null) { if (topLevelActivities.Contains(parentActivity)) return true; parentActivity = parentActivity.Parent; } return false; }
// Loads precreated workflow. The function is similar to the above function except // instead of creating an empty workflow we create workflow with contents internal void LoadDefaultWorkflow() { Clear(); this.designSurface = new WorkflowDesignSurface(this); WorkflowLoader loader = new WorkflowLoader(); this.designSurface.BeginLoad(loader); this.designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost; if (this.designerHost != null) { this.rootActivity = (SequentialWorkflowActivity)this.designerHost.CreateComponent(typeof(SequentialWorkflowActivity)); this.rootActivity.Name = "Service1"; CodeActivity codeActivity1 = new CodeActivity(); this.rootActivity.Activities.Add(codeActivity1); this.designerHost.RootComponent.Site.Container.Add(codeActivity1); this.workflowView = new WorkflowView(this.designSurface as IServiceProvider); this.workflowView.AddDesignerMessageFilter(new CustomMessageFilter(this.designSurface as IServiceProvider, this.workflowView, loader)); Controls.Add(this.workflowView); this.designerHost.Activate(); ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService)); if (selectionService != null) { selectionService.SelectionChanged += new EventHandler(OnSelectionChanged); IComponent[] selection = new IComponent[] { rootActivity }; selectionService.SetSelectedComponents(selection); } } }
protected override void OnLayout(LayoutEventArgs eventArgs) { WorkflowView parentView = ParentView; using (Graphics graphics = parentView.CreateGraphics()) { if (parentView.RootDesigner != null) { try { ((IWorkflowDesignerMessageSink)parentView.RootDesigner).OnLayoutSize(graphics); } catch (Exception e) { //Eat the exception thrown Debug.WriteLine(e); } try { ((IWorkflowDesignerMessageSink)parentView.RootDesigner).OnLayoutPosition(graphics); } catch (Exception e) { //Eat the exception thrown Debug.WriteLine(e); } } } }
protected override void Initialize(WorkflowView parentView) { base.Initialize(parentView); StoreUIState(); RefreshUIState(); }
protected override bool OnMouseMove(MouseEventArgs eventArgs) { Point point = new Point(eventArgs.X, eventArgs.Y); this.Refresh(); this.UpdateTransparency(point); string text = string.Empty; bool isButtonDragged = this.IsButtonDragged; if (!this.IsButtonDragged) { for (int i = this.actions.Count - 1; i >= 0; i--) { DynamicAction action = this.actions[i]; Rectangle actionBounds = this.GetActionBounds(i); for (int j = 0; j < action.Buttons.Count; j++) { ActionButton button = action.Buttons[j]; if (actionBounds.Contains(point)) { bool flag2 = this.GetButtonBounds(i, j).Contains(point); if (flag2 && (text.Length == 0)) { text = button.Description; } if ((button.State != ActionButton.States.Disabled) && (button.State != ActionButton.States.Pressed)) { if (flag2) { button.State = ActionButton.States.Highlight; } else { button.State = ActionButton.States.Normal; } } isButtonDragged = true; } else if (button.State == ActionButton.States.Highlight) { button.State = ActionButton.States.Normal; } } } } WorkflowView parentView = base.ParentView; if (text.Length > 0) { this.infoTipSet = true; parentView.ShowInfoTip(text); return(isButtonDragged); } if (this.infoTipSet) { parentView.ShowInfoTip(string.Empty); this.infoTipSet = false; } return(isButtonDragged); }
protected override bool OnMouseUp(MouseEventArgs eventArgs) { if ((Control.ModifierKeys & Keys.Shift) > 0) { base.OnMouseUp(eventArgs); //Select all the shapes WorkflowView parentView = ParentView; if (!DragRectangle.IsEmpty && parentView.RootDesigner != null) { ActivityDesigner[] intersectingDesigners = CompositeActivityDesigner.GetIntersectingDesigners(parentView.RootDesigner, DragRectangle); ArrayList selectableComponents = new ArrayList(); foreach (ActivityDesigner activityDesigner in intersectingDesigners) { selectableComponents.Add(activityDesigner.Activity); } ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService; if (selectableComponents.Count > 0 && selectionService != null) { selectionService.SetSelectedComponents((object[])selectableComponents.ToArray(typeof(object)), SelectionTypes.Replace); } } return(true); } return(false); }
protected override bool OnDragOver(DragEventArgs eventArgs) { //Invalidate the dragged images if (this.draggedDesignerImages != null) { Point[] previousLocations = GetDesignerLocations(DragInitiationPoint, this.movedDesignerImagePoint, DraggedActivities); InvalidateDraggedImages(previousLocations); } bool retVal = base.OnDragOver(eventArgs); if (this.draggedDesignerImages != null) { WorkflowView parentView = ParentView; Point clientPoint = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y)); Point logicalPoint = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y)); if (parentView.IsClientPointInActiveLayout(clientPoint)) { this.movedDesignerImagePoint = logicalPoint; } else { this.movedDesignerImagePoint = DragInitiationPoint; } //Invalidate the new locations where the image is shown Point[] newLocations = GetDesignerLocations(DragInitiationPoint, this.movedDesignerImagePoint, DraggedActivities); InvalidateDraggedImages(newLocations); } return(retVal); }
protected override bool OnMouseMove(MouseEventArgs eventArgs) { WorkflowView parentView = ParentView; Point logicalPoint = parentView.ClientPointToLogical(new Point(eventArgs.X, eventArgs.Y)); //We do nothing if the logical coordinate is not in the active layout // float dragMultiply = 2.0f / (float)parentView.Zoom * 100.0f; if (!this.dragStarted && (eventArgs.Button & MouseButtons.Left) > 0 && (Math.Abs(this.startDrag.X - logicalPoint.X) > (int)(dragMultiply * (float)SystemInformation.DragSize.Width) || Math.Abs(this.startDrag.Y - logicalPoint.Y) > (int)(dragMultiply * (float)SystemInformation.DragSize.Height))) { DragStarted = true; } if (this.dragStarted) { if (!DragRectangle.IsEmpty) { parentView.InvalidateLogicalRectangle(DragRectangle); } this.endDrag = logicalPoint; if (!DragRectangle.IsEmpty) { parentView.InvalidateLogicalRectangle(DragRectangle); } } return(this.dragStarted); }
protected override bool OnMouseUp(MouseEventArgs eventArgs) { if ((Control.ModifierKeys & Keys.Shift) <= Keys.None) { return(false); } base.OnMouseUp(eventArgs); WorkflowView parentView = base.ParentView; if (!base.DragRectangle.IsEmpty && (parentView.RootDesigner != null)) { ActivityDesigner[] intersectingDesigners = CompositeActivityDesigner.GetIntersectingDesigners(parentView.RootDesigner, base.DragRectangle); ArrayList list = new ArrayList(); foreach (ActivityDesigner designer in intersectingDesigners) { list.Add(designer.Activity); } ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService; if ((list.Count > 0) && (service != null)) { service.SetSelectedComponents((object[])list.ToArray(typeof(object)), SelectionTypes.Replace); } } return(true); }
protected override bool OnMouseUp(MouseEventArgs eventArgs) { if (this.dragStarted) { WorkflowView parentView = ParentView; //Invalidate the old rectangle so that we state the drag is complete if (!DragRectangle.IsEmpty) { parentView.InvalidateLogicalRectangle(DragRectangle); } //End the actual drag/drop this.endDrag = parentView.ClientPointToLogical(new Point(eventArgs.X, eventArgs.Y)); DragStarted = false; //Send the notification of successful drag if (this.DragComplete != null) { this.DragComplete(this, EventArgs.Empty); } return(true); } return(false); }
void IDisposable.Dispose() { WorkflowView view = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView; if (view != null) { if (this.refreshTypesHandler != null) { view.Idle -= this.refreshTypesHandler; } if (this.refreshDesignerActionsHandler != null) { view.Idle -= this.refreshDesignerActionsHandler; } if (this.refreshTasksHandler != null) { view.Idle -= this.refreshTasksHandler; } } this.refreshTypesHandler = null; this.refreshDesignerActionsHandler = null; this.refreshTasksHandler = null; IExtendedUIService service = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService; if (service != null) { service.RemoveDesignerActions(); } IPropertyValueUIService service2 = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService; if (service2 != null) { service2.RemovePropertyValueUIHandler(new PropertyValueUIHandler(this.OnPropertyGridAdornments)); } IComponentChangeService service3 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; if (service3 != null) { service3.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged); } ISelectionService service4 = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService; if (service4 != null) { service4.SelectionChanged -= new EventHandler(this.OnSelectionChanged); } ITypeProvider provider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider; if (provider != null) { provider.TypesChanged -= new EventHandler(this.OnTypeSystemTypesChanged); } IDesignerEventService service5 = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService; if (service5 != null) { service5.ActiveDesignerChanged -= new ActiveDesignerEventHandler(this.OnActiveDesignerChanged); } this.serviceProvider.LoadComplete -= new EventHandler(this.OnDesignerReloaded); }
private void UnloadWorkflow() { IDesignerHost designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost; if (designerHost != null && designerHost.Container.Components.Count > 0) { WorkflowLoader.DestroyObjectGraphFromDesignerHost(designerHost, designerHost.RootComponent as Activity); } ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService; if (selectionService != null) { selectionService.SelectionChanged -= new EventHandler(OnSelectionChanged); } if (this.designSurface != null) { this.designSurface.Dispose(); this.designSurface = null; } if (this.workflowView != null) { Controls.Remove(this.workflowView); this.workflowView.Dispose(); this.workflowView = null; } }
private void InitiateDragDrop() { WorkflowView parentView = ParentView; ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService)); IDesignerHost designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); if (selectionService == null || designerHost == null) { return; } // check if we are cutting root component ICollection components = selectionService.GetSelectedComponents(); if (components == null || components.Count < 1 || selectionService.GetComponentSelected(designerHost.RootComponent) || !Helpers.AreAllActivities(components)) { return; } DragDropEffects effects = DragDropEffects.None; try { // get component serialization service this.existingDraggedActivities.AddRange(Helpers.GetTopLevelActivities(components)); //IMPORTANT: FOR WITHIN DESIGNER COMPONENT MOVE WE REMOVE THE ACTIVITIES BEFORE WE ADD THEM WHICH IS IN //ONDRAGDROP FUNCTION. ALTHOUGH THIS VIOLATES THE DODRAGDROP FUNCTION SIMANTICS, WE NEED TO DO THIS //SO THAT WE CAN USE THE SAME IDS FOR THE ACTIVITIES DragDropEffects allowedEffects = (DesignerHelpers.AreAssociatedDesignersMovable(this.existingDraggedActivities)) ? DragDropEffects.Move | DragDropEffects.Copy : DragDropEffects.Copy; IDataObject dataObject = CompositeActivityDesigner.SerializeActivitiesToDataObject(ParentView, this.existingDraggedActivities.ToArray()); effects = parentView.DoDragDrop(dataObject, allowedEffects); // } catch (Exception e) { DesignerHelpers.ShowError(ParentView, e.Message); } finally { //This means drag drop occurred across designer if (effects == DragDropEffects.Move && this.existingDraggedActivities.Count > 0) { string transactionDescription = String.Empty; if (this.existingDraggedActivities.Count > 1) { transactionDescription = SR.GetString(SR.MoveMultipleActivities, this.existingDraggedActivities.Count); } else { transactionDescription = SR.GetString(SR.MoveSingleActivity, this.existingDraggedActivities[0].GetType()); } CompositeActivityDesigner.RemoveActivities(ParentView, this.existingDraggedActivities.AsReadOnly(), transactionDescription); } this.existingDraggedActivities.Clear(); } }
protected override void OnLayout(LayoutEventArgs eventArgs) { WorkflowView parentView = base.ParentView; using (Graphics graphics = parentView.CreateGraphics()) { if (parentView.RootDesigner != null) { try { ((IWorkflowDesignerMessageSink)parentView.RootDesigner).OnLayoutSize(graphics); } catch (Exception) { } try { ((IWorkflowDesignerMessageSink)parentView.RootDesigner).OnLayoutPosition(graphics); } catch (Exception) { } } } }
private void UpdateCursor(DesignerEdges sizingEdge) { WorkflowView parentView = base.ParentView; if (parentView == null) { throw new InvalidOperationException(DR.GetString("WorkflowViewNull", new object[0])); } Cursor sizeNWSE = parentView.Cursor; if ((((sizingEdge & DesignerEdges.Left) > DesignerEdges.None) && ((sizingEdge & DesignerEdges.Top) > DesignerEdges.None)) || (((sizingEdge & DesignerEdges.Right) > DesignerEdges.None) && ((sizingEdge & DesignerEdges.Bottom) > DesignerEdges.None))) { sizeNWSE = Cursors.SizeNWSE; } else if ((((sizingEdge & DesignerEdges.Right) > DesignerEdges.None) && ((sizingEdge & DesignerEdges.Top) > DesignerEdges.None)) || (((sizingEdge & DesignerEdges.Left) > DesignerEdges.None) && ((sizingEdge & DesignerEdges.Bottom) > DesignerEdges.None))) { sizeNWSE = Cursors.SizeNESW; } else if (((sizingEdge & DesignerEdges.Top) > DesignerEdges.None) || ((sizingEdge & DesignerEdges.Bottom) > DesignerEdges.None)) { sizeNWSE = Cursors.SizeNS; } else if (((sizingEdge & DesignerEdges.Left) > DesignerEdges.None) || ((sizingEdge & DesignerEdges.Right) > DesignerEdges.None)) { sizeNWSE = Cursors.SizeWE; } else if ((sizingEdge == DesignerEdges.None) && (((parentView.Cursor == Cursors.SizeNWSE) || (parentView.Cursor == Cursors.SizeNESW)) || ((parentView.Cursor == Cursors.SizeNS) || (parentView.Cursor == Cursors.SizeWE)))) { sizeNWSE = Cursors.Default; } if (parentView.Cursor != sizeNWSE) { parentView.Cursor = sizeNWSE; } }
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; } }