public List <ConnectorRouter.ConnectorSegment> GetCovers(Point p, DesignerEdges side) { List <ConnectorRouter.ConnectorSegment> list = new List <ConnectorRouter.ConnectorSegment>(); if ((side == DesignerEdges.Left) || (side == DesignerEdges.Right)) { for (int j = 0; j < this.verticalCovers.Count; j++) { ConnectorRouter.ConnectorSegment item = this.verticalCovers[j]; int num2 = (side == DesignerEdges.Left) ? (p.X - item.A.X) : (item.A.X - p.X); if ((num2 > 0) && item.Covers(p)) { list.Add(item); } } return(list); } for (int i = 0; i < this.horizontalCovers.Count; i++) { ConnectorRouter.ConnectorSegment segment2 = this.horizontalCovers[i]; int num4 = (side == DesignerEdges.Bottom) ? (p.Y - segment2.A.Y) : (segment2.A.Y - p.Y); if ((num4 > 0) && segment2.Covers(p)) { list.Add(segment2); } } return(list); }
private DesignerEdges GetSizingEdge(ActivityDesigner designer, Point point) { DesignerEdges none = DesignerEdges.None; Size selectionSize = WorkflowTheme.CurrentTheme.AmbientTheme.SelectionSize; Rectangle bounds = designer.Bounds; Point[] line = new Point[] { new Point(bounds.Left, bounds.Top), new Point(bounds.Left, bounds.Bottom) }; if (Math.Floor(DesignerGeometryHelper.DistanceFromPointToLineSegment(point, line)) <= (selectionSize.Width + 1)) { none |= DesignerEdges.Left; } Point[] pointArray2 = new Point[] { new Point(bounds.Left, bounds.Top), new Point(bounds.Right, bounds.Top) }; if (Math.Floor(DesignerGeometryHelper.DistanceFromPointToLineSegment(point, pointArray2)) <= (selectionSize.Height + 1)) { none |= DesignerEdges.Top; } Point[] pointArray3 = new Point[] { new Point(bounds.Right, bounds.Top), new Point(bounds.Right, bounds.Bottom) }; if (Math.Floor(DesignerGeometryHelper.DistanceFromPointToLineSegment(point, pointArray3)) <= (selectionSize.Width + 1)) { none |= DesignerEdges.Right; } Point[] pointArray4 = new Point[] { new Point(bounds.Left, bounds.Bottom), new Point(bounds.Right, bounds.Bottom) }; if (Math.Floor(DesignerGeometryHelper.DistanceFromPointToLineSegment(point, pointArray4)) <= (selectionSize.Height + 1)) { none |= DesignerEdges.Bottom; } return(none); }
protected override bool OnMouseMove(MouseEventArgs eventArgs) { WorkflowView workflowView = ParentView; if (workflowView == null) { throw new InvalidOperationException(DR.GetString(DR.WorkflowViewNull)); } bool handledMessage = false; Point clientPoint = new Point(eventArgs.X, eventArgs.Y); Point logicalPoint = workflowView.ClientPointToLogical(clientPoint); DesignerEdges sizingEdge = DesignerEdges.None; if (this.designerToResize != null) { sizingEdge = this.designerSizingEdge; UpdateDesignerSize(logicalPoint, this.designerToResize, this.designerSizingEdge); handledMessage = true; } else if (eventArgs.Button == MouseButtons.None) { ActivityDesigner designer = GetDesignerToResize(logicalPoint, out sizingEdge); if (designer != null && sizingEdge != DesignerEdges.None && CanResizeDesigner(designer)) { handledMessage = true; } } UpdateCursor(sizingEdge); return(handledMessage); }
public ConnectorRouter.ConnectorSegment GetCover(Point p, DesignerEdges side) { ConnectorRouter.ConnectorSegment segment = null; int num = 0; if ((side == DesignerEdges.Left) || (side == DesignerEdges.Right)) { for (int j = 0; j < this.verticalCovers.Count; j++) { ConnectorRouter.ConnectorSegment segment2 = this.verticalCovers[j]; int num3 = (side == DesignerEdges.Left) ? (p.X - segment2.A.X) : (segment2.A.X - p.X); if (((num3 > 0) && segment2.Covers(p)) && ((segment == null) || (num > num3))) { segment = segment2; num = num3; } } return(segment); } for (int i = 0; i < this.horizontalCovers.Count; i++) { ConnectorRouter.ConnectorSegment segment3 = this.horizontalCovers[i]; int num5 = (side == DesignerEdges.Bottom) ? (p.Y - segment3.A.Y) : (segment3.A.Y - p.Y); if (((num5 > 0) && segment3.Covers(p)) && ((segment == null) || (num > num5))) { segment = segment3; num = num5; } } return(segment); }
private DesignerEdges GetSizingEdge(ActivityDesigner designer, Point point) { DesignerEdges sizingEdge = DesignerEdges.None; Size selectionSize = WorkflowTheme.CurrentTheme.AmbientTheme.SelectionSize; Rectangle designerBounds = designer.Bounds; if (Math.Floor(DesignerGeometryHelper.DistanceFromPointToLineSegment(point, new Point[] { new Point(designerBounds.Left, designerBounds.Top), new Point(designerBounds.Left, designerBounds.Bottom) })) <= selectionSize.Width + 1) { sizingEdge |= DesignerEdges.Left; } if (Math.Floor(DesignerGeometryHelper.DistanceFromPointToLineSegment(point, new Point[] { new Point(designerBounds.Left, designerBounds.Top), new Point(designerBounds.Right, designerBounds.Top) })) <= selectionSize.Height + 1) { sizingEdge |= DesignerEdges.Top; } if (Math.Floor(DesignerGeometryHelper.DistanceFromPointToLineSegment(point, new Point[] { new Point(designerBounds.Right, designerBounds.Top), new Point(designerBounds.Right, designerBounds.Bottom) })) <= selectionSize.Width + 1) { sizingEdge |= DesignerEdges.Right; } if (Math.Floor(DesignerGeometryHelper.DistanceFromPointToLineSegment(point, new Point[] { new Point(designerBounds.Left, designerBounds.Bottom), new Point(designerBounds.Right, designerBounds.Bottom) })) <= selectionSize.Height + 1) { sizingEdge |= DesignerEdges.Bottom; } return(sizingEdge); }
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 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 ActivityDesigner GetDesignerToResize(Point point, out DesignerEdges sizingEdge) { ActivityDesigner designer = null; sizingEdge = DesignerEdges.None; ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService; if (service != null) { ArrayList list = new ArrayList(service.GetSelectedComponents()); for (int i = 0; (i < list.Count) && (designer == null); i++) { Activity activity = list[i] as Activity; if (activity != null) { ActivityDesigner designer2 = ActivityDesigner.GetDesigner(activity); if (designer2 != null) { SelectionGlyph glyph = designer2.Glyphs[typeof(SelectionGlyph)] as SelectionGlyph; if (glyph != null) { foreach (Rectangle rectangle in glyph.GetGrabHandles(designer2)) { if (rectangle.Contains(point)) { designer = designer2; sizingEdge = this.GetSizingEdge(designer, point); break; } } } } } } } return designer; }
public DesignerLayoutConnectionPoint(ActivityDesigner associatedDesigner, int connectionIndex, CompositeActivity eventHandler, DesignerEdges designerEdges) : base(associatedDesigner, designerEdges, connectionIndex) { Debug.Assert(designerEdges == DesignerEdges.Left || designerEdges == DesignerEdges.Right); _eventHandler = eventHandler; _designerEdges = designerEdges; }
protected override ReadOnlyCollection <Point> GetInnerConnections(DesignerEdges edges) { List <Point> connectionPoints = new List <Point>(base.GetInnerConnections(edges)); if (connectionPoints.Count > 0 && Footer != null && (edges & DesignerEdges.Bottom) > 0) { connectionPoints[connectionPoints.Count - 1] = new Point(connectionPoints[connectionPoints.Count - 1].X, connectionPoints[connectionPoints.Count - 1].Y - Footer.Bounds.Height); } return(connectionPoints.AsReadOnly()); }
/// <summary> /// Returns the collection of points which represents the inner connections of the designer. The designer can have connectors /// within it, the points returned are the connection points used for connectable designer. /// </summary> /// <param name="edges">Designer Edge along which the connection point lies</param> /// <returns>List of connection Points</returns> protected virtual ReadOnlyCollection <Point> GetInnerConnections(DesignerEdges edges) { List <Point> connectionPoints = new List <Point>(GetConnections(edges)); if (connectionPoints.Count > 0 && (edges & DesignerEdges.Top) > 0) { connectionPoints[0] = new Point(connectionPoints[0].X, connectionPoints[0].Y + TitleHeight); } return(connectionPoints.AsReadOnly()); }
protected override ReadOnlyCollection<Point> GetInnerConnections(DesignerEdges edges) { List<Point> list = new List<Point>(base.GetInnerConnections(edges)); if (((list.Count > 0) && (this.Footer != null)) && ((edges & DesignerEdges.Bottom) > DesignerEdges.None)) { Point point = list[list.Count - 1]; Point point2 = list[list.Count - 1]; list[list.Count - 1] = new Point(point.X, point2.Y - this.Footer.Bounds.Height); } return list.AsReadOnly(); }
protected override ReadOnlyCollection <Point> GetInnerConnections(DesignerEdges edges) { List <Point> list = new List <Point>(base.GetInnerConnections(edges)); if (((list.Count > 0) && (this.Footer != null)) && ((edges & DesignerEdges.Bottom) > DesignerEdges.None)) { Point point = list[list.Count - 1]; Point point2 = list[list.Count - 1]; list[list.Count - 1] = new Point(point.X, point2.Y - this.Footer.Bounds.Height); } return(list.AsReadOnly()); }
protected virtual ReadOnlyCollection <Point> GetInnerConnections(DesignerEdges edges) { List <Point> list = new List <Point>(this.GetConnections(edges)); if ((list.Count > 0) && ((edges & DesignerEdges.Top) > DesignerEdges.None)) { Point point = list[0]; Point point2 = list[0]; list[0] = new Point(point.X, point2.Y + this.TitleHeight); } return(list.AsReadOnly()); }
private void SetResizableDesigner(ActivityDesigner designer, DesignerEdges sizingEdge) { if (this.designerToResize == designer) { return; } if (designer != null && !CanResizeDesigner(designer)) { Debug.Assert(false); return; } WorkflowView workflowView = ParentView; if (workflowView == null) { throw new InvalidOperationException(DR.GetString(DR.WorkflowViewNull)); } if (designer != null) { if (this.designerTransaction != null) { this.designerTransaction.Cancel(); } IDesignerHost designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost; if (designerHost != null) { this.designerTransaction = designerHost.CreateTransaction(DR.GetString(DR.ResizeUndoDescription, designer.Text)); } ((IWorkflowDesignerMessageSink)designer).OnBeginResizing(sizingEdge); } else { if (this.designerTransaction != null) { this.designerTransaction.Commit(); this.designerTransaction = null; } ((IWorkflowDesignerMessageSink)this.designerToResize).OnEndResizing(); } this.designerToResize = designer; this.designerSizingEdge = sizingEdge; workflowView.Capture = (this.designerToResize != null); UpdateCursor(this.designerSizingEdge); }
protected override object CreateInstance(WorkflowMarkupSerializationManager serializationManager, Type type) { if (serializationManager == null) { throw new ArgumentNullException("serializationManager"); } if (type == null) { throw new ArgumentNullException("type"); } Connector connector = null; IReferenceService service = serializationManager.GetService(typeof(IReferenceService)) as IReferenceService; FreeformActivityDesigner designer = serializationManager.Context[typeof(FreeformActivityDesigner)] as FreeformActivityDesigner; if ((designer != null) && (service != null)) { ConnectionPoint source = null; ConnectionPoint target = null; try { Dictionary <string, string> connectorConstructionArguments = this.GetConnectorConstructionArguments(serializationManager, type); if ((connectorConstructionArguments.ContainsKey("SourceActivity") && connectorConstructionArguments.ContainsKey("SourceConnectionIndex")) && connectorConstructionArguments.ContainsKey("SourceConnectionEdge")) { ActivityDesigner associatedDesigner = ActivityDesigner.GetDesigner(service.GetReference(connectorConstructionArguments["SourceActivity"]) as Activity); DesignerEdges designerEdge = (DesignerEdges)Enum.Parse(typeof(DesignerEdges), connectorConstructionArguments["SourceConnectionEdge"]); int connectionIndex = Convert.ToInt32(connectorConstructionArguments["SourceConnectionIndex"], CultureInfo.InvariantCulture); if (((associatedDesigner != null) && (designerEdge != DesignerEdges.None)) && (connectionIndex >= 0)) { source = new ConnectionPoint(associatedDesigner, designerEdge, connectionIndex); } } if ((connectorConstructionArguments.ContainsKey("TargetActivity") && connectorConstructionArguments.ContainsKey("TargetConnectionIndex")) && connectorConstructionArguments.ContainsKey("TargetConnectionEdge")) { ActivityDesigner designer3 = ActivityDesigner.GetDesigner(service.GetReference(connectorConstructionArguments["TargetActivity"]) as Activity); DesignerEdges edges2 = (DesignerEdges)Enum.Parse(typeof(DesignerEdges), connectorConstructionArguments["TargetConnectionEdge"]); int num2 = Convert.ToInt32(connectorConstructionArguments["TargetConnectionIndex"], CultureInfo.InvariantCulture); if (((designer3 != null) && (edges2 != DesignerEdges.None)) && (num2 >= 0)) { target = new ConnectionPoint(designer3, edges2, num2); } } } catch { } if ((source != null) && (target != null)) { connector = designer.AddConnector(source, target); } } return(connector); }
public ConnectionPoint(ActivityDesigner associatedDesigner, DesignerEdges designerEdge, int connectionIndex) { if (associatedDesigner == null) { throw new ArgumentNullException("associatedDesigner"); } if ((connectionIndex < 0) || (connectionIndex >= associatedDesigner.GetConnections(designerEdge).Count)) { throw new ArgumentException(DR.GetString("Error_ConnectionPoint", new object[0]), "connectionIndex"); } this.associatedDesigner = associatedDesigner; this.designerEdge = designerEdge; this.connectionIndex = connectionIndex; }
public bool IsEscapePoint(Point origin, Point escape, DesignerEdges side) { int num; ConnectorRouter.ConnectorSegment cover = this.GetCover(origin, side); if ((side == DesignerEdges.Left) || (side == DesignerEdges.Right)) { num = cover.A.X - escape.X; } else { num = cover.A.Y - escape.Y; } if (cover.Covers(escape)) { return(false); } List <ConnectorRouter.ConnectorSegment> covers = this.GetCovers(escape, side); for (int i = 0; i < covers.Count; i++) { int num3; ConnectorRouter.ConnectorSegment segment2 = covers[i]; if (segment2 == cover) { return(false); } if ((side == DesignerEdges.Left) || (side == DesignerEdges.Right)) { num3 = Math.Abs((int)(segment2.A.X - escape.X)); } else { num3 = Math.Abs((int)(segment2.A.Y - escape.Y)); } if ((Math.Sign(num3) == Math.Sign(num)) && (Math.Abs(num3) < Math.Abs(num))) { return(false); } } return(true); }
protected override bool OnMouseDown(MouseEventArgs eventArgs) { if (eventArgs.Button == MouseButtons.Left) { WorkflowView parentView = base.ParentView; if (parentView == null) { throw new InvalidOperationException(DR.GetString("WorkflowViewNull", new object[0])); } Point clientPoint = new Point(eventArgs.X, eventArgs.Y); Point point = parentView.ClientPointToLogical(clientPoint); DesignerEdges none = DesignerEdges.None; ActivityDesigner designerToResize = this.GetDesignerToResize(point, out none); if (((designerToResize != null) && (none != DesignerEdges.None)) && this.CanResizeDesigner(designerToResize)) { this.SetResizableDesigner(designerToResize, none); } } return(this.designerToResize != null); }
private void UpdateCursor(DesignerEdges sizingEdge) { WorkflowView workflowView = ParentView; if (workflowView == null) { throw new InvalidOperationException(DR.GetString(DR.WorkflowViewNull)); } Cursor cursorToSet = workflowView.Cursor; if (((sizingEdge & DesignerEdges.Left) > 0 && (sizingEdge & DesignerEdges.Top) > 0) || ((sizingEdge & DesignerEdges.Right) > 0 && (sizingEdge & DesignerEdges.Bottom) > 0)) { cursorToSet = Cursors.SizeNWSE; } else if (((sizingEdge & DesignerEdges.Right) > 0 && (sizingEdge & DesignerEdges.Top) > 0) || ((sizingEdge & DesignerEdges.Left) > 0 && (sizingEdge & DesignerEdges.Bottom) > 0)) { cursorToSet = Cursors.SizeNESW; } else if ((sizingEdge & DesignerEdges.Top) > 0 || (sizingEdge & DesignerEdges.Bottom) > 0) { cursorToSet = Cursors.SizeNS; } else if ((sizingEdge & DesignerEdges.Left) > 0 || (sizingEdge & DesignerEdges.Right) > 0) { cursorToSet = Cursors.SizeWE; } else if (sizingEdge == DesignerEdges.None && (workflowView.Cursor == Cursors.SizeNWSE || workflowView.Cursor == Cursors.SizeNESW || workflowView.Cursor == Cursors.SizeNS || workflowView.Cursor == Cursors.SizeWE)) { cursorToSet = Cursors.Default; } if (workflowView.Cursor != cursorToSet) { workflowView.Cursor = cursorToSet; } }
internal static DesignerEdges ClosestEdgeToPoint(Point point, Rectangle rect, DesignerEdges edgesToConsider) { List<double> list = new List<double>(); List<DesignerEdges> list2 = new List<DesignerEdges>(); if ((edgesToConsider & DesignerEdges.Left) > DesignerEdges.None) { Point[] line = new Point[] { new Point(rect.Left, rect.Top), new Point(rect.Left, rect.Bottom) }; list.Add(DistanceFromPointToLineSegment(point, line)); list2.Add(DesignerEdges.Left); } if ((edgesToConsider & DesignerEdges.Top) > DesignerEdges.None) { Point[] pointArray2 = new Point[] { new Point(rect.Left, rect.Top), new Point(rect.Right, rect.Top) }; list.Add(DistanceFromPointToLineSegment(point, pointArray2)); list2.Add(DesignerEdges.Top); } if ((edgesToConsider & DesignerEdges.Right) > DesignerEdges.None) { Point[] pointArray3 = new Point[] { new Point(rect.Right, rect.Top), new Point(rect.Right, rect.Bottom) }; list.Add(DistanceFromPointToLineSegment(point, pointArray3)); list2.Add(DesignerEdges.Right); } if ((edgesToConsider & DesignerEdges.Bottom) > DesignerEdges.None) { Point[] pointArray4 = new Point[] { new Point(rect.Left, rect.Bottom), new Point(rect.Right, rect.Bottom) }; list.Add(DistanceFromPointToLineSegment(point, pointArray4)); list2.Add(DesignerEdges.Bottom); } if (list.Count <= 0) { return DesignerEdges.None; } double num = list[0]; for (int i = 1; i < list.Count; i++) { num = Math.Min(num, list[i]); } return list2[list.IndexOf(num)]; }
private ActivityDesigner GetDesignerToResize(Point point, out DesignerEdges sizingEdge) { ActivityDesigner designerToResize = null; sizingEdge = DesignerEdges.None; ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService; if (selectionService != null) { ArrayList selectedComponents = new ArrayList(selectionService.GetSelectedComponents()); for (int i = 0; i < selectedComponents.Count && designerToResize == null; i++) { Activity activity = selectedComponents[i] as Activity; if (activity != null) { ActivityDesigner potentialResizableDesigner = ActivityDesigner.GetDesigner(activity); if (potentialResizableDesigner != null) { SelectionGlyph selectionGlyph = potentialResizableDesigner.Glyphs[typeof(SelectionGlyph)] as SelectionGlyph; if (selectionGlyph != null) { foreach (Rectangle grabHandle in selectionGlyph.GetGrabHandles(potentialResizableDesigner)) { if (grabHandle.Contains(point)) { designerToResize = potentialResizableDesigner; sizingEdge = GetSizingEdge(designerToResize, point); break; } } } } } } } return(designerToResize); }
protected override bool OnMouseDown(MouseEventArgs eventArgs) { if (eventArgs.Button == MouseButtons.Left) { WorkflowView workflowView = ParentView; if (workflowView == null) { throw new InvalidOperationException(DR.GetString(DR.WorkflowViewNull)); } Point clientPoint = new Point(eventArgs.X, eventArgs.Y); Point logicalPoint = workflowView.ClientPointToLogical(clientPoint); DesignerEdges sizingEdge = DesignerEdges.None; ActivityDesigner designer = GetDesignerToResize(logicalPoint, out sizingEdge); if (designer != null && sizingEdge != DesignerEdges.None && CanResizeDesigner(designer)) { SetResizableDesigner(designer, sizingEdge); } } return(this.designerToResize != null); }
private ActivityDesigner GetDesignerToResize(Point point, out DesignerEdges sizingEdge) { ActivityDesigner designer = null; sizingEdge = DesignerEdges.None; ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService; if (service != null) { ArrayList list = new ArrayList(service.GetSelectedComponents()); for (int i = 0; (i < list.Count) && (designer == null); i++) { Activity activity = list[i] as Activity; if (activity != null) { ActivityDesigner designer2 = ActivityDesigner.GetDesigner(activity); if (designer2 != null) { SelectionGlyph glyph = designer2.Glyphs[typeof(SelectionGlyph)] as SelectionGlyph; if (glyph != null) { foreach (Rectangle rectangle in glyph.GetGrabHandles(designer2)) { if (rectangle.Contains(point)) { designer = designer2; sizingEdge = this.GetSizingEdge(designer, point); break; } } } } } } } return(designer); }
private void SetResizableDesigner(ActivityDesigner designer, DesignerEdges sizingEdge) { if ((this.designerToResize != designer) && ((designer == null) || this.CanResizeDesigner(designer))) { WorkflowView parentView = base.ParentView; if (parentView == null) { throw new InvalidOperationException(DR.GetString("WorkflowViewNull", new object[0])); } if (designer != null) { if (this.designerTransaction != null) { this.designerTransaction.Cancel(); } IDesignerHost service = base.GetService(typeof(IDesignerHost)) as IDesignerHost; if (service != null) { this.designerTransaction = service.CreateTransaction(DR.GetString("ResizeUndoDescription", new object[] { designer.Text })); } ((IWorkflowDesignerMessageSink)designer).OnBeginResizing(sizingEdge); } else { if (this.designerTransaction != null) { this.designerTransaction.Commit(); this.designerTransaction = null; } ((IWorkflowDesignerMessageSink)this.designerToResize).OnEndResizing(); } this.designerToResize = designer; this.designerSizingEdge = sizingEdge; parentView.Capture = this.designerToResize != null; this.UpdateCursor(this.designerSizingEdge); } }
internal static DesignerEdges ClosestEdgeToPoint(Point point, Rectangle rect, DesignerEdges edgesToConsider) { List <double> list = new List <double>(); List <DesignerEdges> list2 = new List <DesignerEdges>(); if ((edgesToConsider & DesignerEdges.Left) > DesignerEdges.None) { Point[] line = new Point[] { new Point(rect.Left, rect.Top), new Point(rect.Left, rect.Bottom) }; list.Add(DistanceFromPointToLineSegment(point, line)); list2.Add(DesignerEdges.Left); } if ((edgesToConsider & DesignerEdges.Top) > DesignerEdges.None) { Point[] pointArray2 = new Point[] { new Point(rect.Left, rect.Top), new Point(rect.Right, rect.Top) }; list.Add(DistanceFromPointToLineSegment(point, pointArray2)); list2.Add(DesignerEdges.Top); } if ((edgesToConsider & DesignerEdges.Right) > DesignerEdges.None) { Point[] pointArray3 = new Point[] { new Point(rect.Right, rect.Top), new Point(rect.Right, rect.Bottom) }; list.Add(DistanceFromPointToLineSegment(point, pointArray3)); list2.Add(DesignerEdges.Right); } if ((edgesToConsider & DesignerEdges.Bottom) > DesignerEdges.None) { Point[] pointArray4 = new Point[] { new Point(rect.Left, rect.Bottom), new Point(rect.Right, rect.Bottom) }; list.Add(DistanceFromPointToLineSegment(point, pointArray4)); list2.Add(DesignerEdges.Bottom); } if (list.Count <= 0) { return(DesignerEdges.None); } double num = list[0]; for (int i = 1; i < list.Count; i++) { num = Math.Min(num, list[i]); } return(list2[list.IndexOf(num)]); }
protected override object CreateInstance(WorkflowMarkupSerializationManager serializationManager, Type type) { if (serializationManager == null) { throw new ArgumentNullException("serializationManager"); } if (type == null) { throw new ArgumentNullException("type"); } StateDesignerConnector connector = null; IReferenceService referenceService = serializationManager.GetService(typeof(IReferenceService)) as IReferenceService; FreeformActivityDesigner freeformDesigner = serializationManager.Context[typeof(FreeformActivityDesigner)] as FreeformActivityDesigner; if (freeformDesigner != null && referenceService != null) { StateDesigner.DesignerLayoutConnectionPoint sourceConnection = null; ConnectionPoint targetConnection = null; StateDesigner.TransitionInfo transitionInfo = null; StateDesigner rootStateDesigner = null; try { Dictionary <string, string> constructionArguments = GetConnectorConstructionArguments(serializationManager, type); if (constructionArguments.ContainsKey("EventHandlerName") && constructionArguments.ContainsKey("SetStateName") && constructionArguments.ContainsKey("TargetStateName")) { CompositeActivity eventHandler = (CompositeActivity)referenceService.GetReference(constructionArguments["EventHandlerName"] as string); SetStateActivity setState = (SetStateActivity)referenceService.GetReference(constructionArguments["SetStateName"] as string); StateActivity targetState = (StateActivity)referenceService.GetReference(constructionArguments["TargetStateName"] as string); transitionInfo = new StateDesigner.TransitionInfo(setState, eventHandler); transitionInfo.TargetState = targetState; } if (constructionArguments.ContainsKey("SourceActivity") && constructionArguments.ContainsKey("SourceConnectionIndex") && constructionArguments.ContainsKey("SourceConnectionEdge") && constructionArguments.ContainsKey("EventHandlerName")) { StateDesigner sourceDesigner = (StateDesigner)StateDesigner.GetDesigner(referenceService.GetReference(constructionArguments["SourceActivity"] as string) as Activity); CompositeActivity eventHandler = (CompositeActivity)referenceService.GetReference(constructionArguments["EventHandlerName"] as string); rootStateDesigner = sourceDesigner.RootStateDesigner; DesignerEdges sourceEdge = (DesignerEdges)Enum.Parse(typeof(DesignerEdges), constructionArguments["SourceConnectionEdge"] as string); int sourceIndex = Convert.ToInt32(constructionArguments["SourceConnectionIndex"] as string, System.Globalization.CultureInfo.InvariantCulture); if (sourceDesigner != null && eventHandler != null && sourceEdge != DesignerEdges.None && sourceIndex >= 0) { sourceConnection = new StateDesigner.DesignerLayoutConnectionPoint(sourceDesigner, sourceIndex, eventHandler, sourceEdge); } } if (constructionArguments.ContainsKey("TargetActivity") && constructionArguments.ContainsKey("TargetConnectionIndex") && constructionArguments.ContainsKey("TargetConnectionEdge")) { ActivityDesigner targetDesigner = StateDesigner.GetDesigner(referenceService.GetReference(constructionArguments["TargetActivity"] as string) as Activity); DesignerEdges targetEdge = (DesignerEdges)Enum.Parse(typeof(DesignerEdges), constructionArguments["TargetConnectionEdge"] as string); int targetIndex = Convert.ToInt32(constructionArguments["TargetConnectionIndex"] as string, System.Globalization.CultureInfo.InvariantCulture); if (targetDesigner != null && targetEdge != DesignerEdges.None && targetIndex >= 0) { targetConnection = new ConnectionPoint(targetDesigner, targetEdge, targetIndex); } } } catch { } if (transitionInfo != null && sourceConnection != null && targetConnection != null) { connector = rootStateDesigner.FindConnector(transitionInfo); if (connector == null) { rootStateDesigner.AddingSetState = false; try { connector = freeformDesigner.AddConnector(sourceConnection, targetConnection) as StateDesignerConnector; } finally { rootStateDesigner.AddingSetState = true; } } else { connector.Source = sourceConnection; connector.Target = targetConnection; connector.ClearConnectorSegments(); } } } return(connector); }
/// <summary> /// Get the points used to connect the designer. Points are in logical coordinates. /// </summary> protected internal virtual ReadOnlyCollection<Point> GetConnections(DesignerEdges edges) { Rectangle bounds = Bounds; List<Point> connections = new List<Point>(); if ((edges & DesignerEdges.Left) > 0) connections.Add(new Point(bounds.Left, bounds.Top + bounds.Height / 2)); if ((edges & DesignerEdges.Top) > 0) connections.Add(new Point(bounds.Left + bounds.Width / 2, bounds.Top)); if ((edges & DesignerEdges.Right) > 0) connections.Add(new Point(bounds.Right, bounds.Top + bounds.Height / 2)); if ((edges & DesignerEdges.Bottom) > 0) connections.Add(new Point(bounds.Left + bounds.Width / 2, bounds.Bottom)); return connections.AsReadOnly(); }
void IWorkflowDesignerMessageSink.OnResizing(DesignerEdges sizingEdge, Rectangle bounds) { try { OnResizing(new ActivityDesignerResizeEventArgs(sizingEdge, bounds)); } catch { } }
void IWorkflowDesignerMessageSink.OnBeginResizing(DesignerEdges sizingEdge) { }
protected override object CreateInstance(WorkflowMarkupSerializationManager serializationManager, Type type) { if (serializationManager == null) { throw new ArgumentNullException("serializationManager"); } if (type == null) { throw new ArgumentNullException("type"); } Connector connector = null; IReferenceService referenceService = serializationManager.GetService(typeof(IReferenceService)) as IReferenceService; FreeformActivityDesigner freeformDesigner = serializationManager.Context[typeof(FreeformActivityDesigner)] as FreeformActivityDesigner; if (freeformDesigner != null && referenceService != null) { ConnectionPoint sourceConnection = null; ConnectionPoint targetConnection = null; try { Dictionary <string, string> constructionArguments = GetConnectorConstructionArguments(serializationManager, type); if (constructionArguments.ContainsKey("SourceActivity") && constructionArguments.ContainsKey("SourceConnectionIndex") && constructionArguments.ContainsKey("SourceConnectionEdge")) { ActivityDesigner sourceDesigner = ActivityDesigner.GetDesigner(referenceService.GetReference(constructionArguments["SourceActivity"] as string) as Activity); DesignerEdges sourceEdge = (DesignerEdges)Enum.Parse(typeof(DesignerEdges), constructionArguments["SourceConnectionEdge"] as string); int sourceIndex = Convert.ToInt32(constructionArguments["SourceConnectionIndex"] as string, System.Globalization.CultureInfo.InvariantCulture); if (sourceDesigner != null && sourceEdge != DesignerEdges.None && sourceIndex >= 0) { sourceConnection = new ConnectionPoint(sourceDesigner, sourceEdge, sourceIndex); } } if (constructionArguments.ContainsKey("TargetActivity") && constructionArguments.ContainsKey("TargetConnectionIndex") && constructionArguments.ContainsKey("TargetConnectionEdge")) { ActivityDesigner targetDesigner = ActivityDesigner.GetDesigner(referenceService.GetReference(constructionArguments["TargetActivity"] as string) as Activity); DesignerEdges targetEdge = (DesignerEdges)Enum.Parse(typeof(DesignerEdges), constructionArguments["TargetConnectionEdge"] as string); int targetIndex = Convert.ToInt32(constructionArguments["TargetConnectionIndex"] as string, System.Globalization.CultureInfo.InvariantCulture); if (targetDesigner != null && targetEdge != DesignerEdges.None && targetIndex >= 0) { targetConnection = new ConnectionPoint(targetDesigner, targetEdge, targetIndex); } } } catch { } if (sourceConnection != null && targetConnection != null) { connector = freeformDesigner.AddConnector(sourceConnection, targetConnection); } } return(connector); }
private static IList <Point> GetDesignerEscapeCover(ActivityDesigner designer, ICollection <object> escapeLocations) { Rectangle bounds = designer.Bounds; Dictionary <DesignerEdges, List <Point> > dictionary = new Dictionary <DesignerEdges, List <Point> >(); foreach (object obj2 in escapeLocations) { DesignerEdges none = DesignerEdges.None; Point empty = Point.Empty; if (obj2 is ConnectionPoint) { none = ((ConnectionPoint)obj2).ConnectionEdge; empty = ((ConnectionPoint)obj2).Location; } else if (obj2 is Point) { empty = (Point)obj2; none = DesignerGeometryHelper.ClosestEdgeToPoint((Point)obj2, bounds, DesignerEdges.All); } if (none != DesignerEdges.None) { List <Point> list = null; if (!dictionary.ContainsKey(none)) { list = new List <Point>(); dictionary.Add(none, list); } else { list = dictionary[none]; } list.Add(empty); } } Size margin = WorkflowTheme.CurrentTheme.AmbientTheme.Margin; bounds.Inflate(margin); Dictionary <DesignerEdges, Point[]> dictionary2 = new Dictionary <DesignerEdges, Point[]>(); Point[] pointArray2 = new Point[] { new Point(bounds.Left, bounds.Top), new Point(bounds.Left, bounds.Bottom) }; dictionary2.Add(DesignerEdges.Left, pointArray2); Point[] pointArray3 = new Point[] { new Point(bounds.Left, bounds.Top), new Point(bounds.Right, bounds.Top) }; dictionary2.Add(DesignerEdges.Top, pointArray3); Point[] pointArray4 = new Point[] { new Point(bounds.Right, bounds.Top), new Point(bounds.Right, bounds.Bottom) }; dictionary2.Add(DesignerEdges.Right, pointArray4); Point[] pointArray5 = new Point[] { new Point(bounds.Left, bounds.Bottom), new Point(bounds.Right, bounds.Bottom) }; dictionary2.Add(DesignerEdges.Bottom, pointArray5); List <Point> list2 = new List <Point>(); foreach (DesignerEdges edges2 in dictionary2.Keys) { if (dictionary.ContainsKey(edges2)) { Point[] pointArray = dictionary2[edges2]; List <Point> list3 = dictionary[edges2]; List <Point> list4 = new List <Point>(); switch (edges2) { case DesignerEdges.Left: list4.Add(new Point(pointArray[0].X, pointArray[0].Y)); for (int j = 0; j < list3.Count; j++) { Point point2 = list3[j]; if (((point2.X > pointArray[0].X) && (point2.Y > pointArray[0].Y)) && (point2.Y < pointArray[1].Y)) { list4.Add(new Point(pointArray[0].X, point2.Y - 1)); list4.Add(new Point(point2.X + 1, point2.Y - 1)); list4.Add(new Point(point2.X + 1, point2.Y + 1)); list4.Add(new Point(pointArray[0].X, point2.Y + 1)); } } list4.Add(new Point(pointArray[0].X, pointArray[1].Y)); break; case DesignerEdges.Right: list4.Add(new Point(pointArray[0].X, pointArray[0].Y)); for (int k = 0; k < list3.Count; k++) { Point point3 = list3[k]; if (((point3.X < pointArray[0].X) && (point3.Y > pointArray[0].Y)) && (point3.Y < pointArray[1].Y)) { list4.Add(new Point(pointArray[0].X, point3.Y - 1)); list4.Add(new Point(point3.X - 1, point3.Y - 1)); list4.Add(new Point(point3.X - 1, point3.Y + 1)); list4.Add(new Point(pointArray[0].X, point3.Y + 1)); } } list4.Add(new Point(pointArray[0].X, pointArray[1].Y)); break; case DesignerEdges.Top: list4.Add(new Point(pointArray[0].X, pointArray[0].Y)); for (int m = 0; m < list3.Count; m++) { Point point4 = list3[m]; if (((point4.Y > pointArray[0].Y) && (point4.X > pointArray[0].X)) && (point4.X < pointArray[1].X)) { list4.Add(new Point(point4.X - 1, pointArray[0].Y)); list4.Add(new Point(point4.X - 1, point4.Y + 1)); list4.Add(new Point(point4.X + 1, point4.Y + 1)); list4.Add(new Point(point4.X + 1, pointArray[0].Y)); } } list4.Add(new Point(pointArray[1].X, pointArray[0].Y)); break; case DesignerEdges.Bottom: list4.Add(new Point(pointArray[0].X, pointArray[0].Y)); for (int n = 0; n < list3.Count; n++) { Point point5 = list3[n]; if (((point5.Y < pointArray[0].Y) && (point5.X > pointArray[0].X)) && (point5.X < pointArray[1].X)) { list4.Add(new Point(point5.X - 1, pointArray[0].Y)); list4.Add(new Point(point5.X - 1, point5.Y - 1)); list4.Add(new Point(point5.X + 1, point5.Y - 1)); list4.Add(new Point(point5.X + 1, pointArray[0].Y)); } } list4.Add(new Point(pointArray[1].X, pointArray[0].Y)); break; } for (int i = 1; i < list4.Count; i++) { list2.Add(list4[i - 1]); list2.Add(list4[i]); } continue; } list2.AddRange(dictionary2[edges2]); } return(list2.AsReadOnly()); }
public override ReadOnlyCollection<ConnectionPoint> GetConnectionPoints(DesignerEdges edges) { List<ConnectionPoint> list = new List<ConnectionPoint>(); if (!this.HasActiveDesigner) { if (!this.IsRootStateDesigner) { if ((edges & DesignerEdges.Top) > DesignerEdges.None) { list.Add(new ConnectionPoint(this, DesignerEdges.Top, 0)); } if ((edges & DesignerEdges.Bottom) > DesignerEdges.None) { list.Add(new ConnectionPoint(this, DesignerEdges.Bottom, 0)); } } int connectionIndex = 0; int num2 = 0; foreach (DesignerLayout layout in this.DesignerLayouts.Values) { if ((!this.IsRootStateDesigner && ((edges & DesignerEdges.Left) > DesignerEdges.None)) && (layout.LeftConnectionPoint != Point.Empty)) { list.Add(new DesignerLayoutConnectionPoint(this, connectionIndex, (CompositeActivity) layout.ActivityDesigner.Activity, DesignerEdges.Left)); connectionIndex++; } if (((edges & DesignerEdges.Right) > DesignerEdges.None) && (layout.RightConnectionPoint != Point.Empty)) { list.Add(new DesignerLayoutConnectionPoint(this, num2, (CompositeActivity) layout.ActivityDesigner.Activity, DesignerEdges.Right)); num2++; } } } return list.AsReadOnly(); }
protected virtual ReadOnlyCollection<Point> GetInnerConnections(DesignerEdges edges) { List<Point> list = new List<Point>(this.GetConnections(edges)); if ((list.Count > 0) && ((edges & DesignerEdges.Top) > DesignerEdges.None)) { Point point = list[0]; Point point2 = list[0]; list[0] = new Point(point.X, point2.Y + this.TitleHeight); } return list.AsReadOnly(); }
protected override ReadOnlyCollection<Point> GetConnections(DesignerEdges edges) { List<Point> list = new List<Point>(); if ((edges & DesignerEdges.Top) > DesignerEdges.None) { list.Add(this.TopConnectionPoint); } if ((edges & DesignerEdges.Bottom) > DesignerEdges.None) { list.Add(this.BottomConnectionPoint); } foreach (DesignerLayout layout in this.DesignerLayouts.Values) { if ((!this.IsRootStateDesigner && ((edges & DesignerEdges.Left) > DesignerEdges.None)) && (layout.LeftConnectionPoint != Point.Empty)) { list.Add(layout.LeftConnectionPoint); } if (((edges & DesignerEdges.Right) > DesignerEdges.None) && (layout.RightConnectionPoint != Point.Empty)) { list.Add(layout.RightConnectionPoint); } } return list.AsReadOnly(); }
private void UpdateDesignerSize(Point point, ActivityDesigner designerToSize, DesignerEdges sizingEdge) { if (base.ParentView == null) { throw new InvalidOperationException(DR.GetString("WorkflowViewNull", new object[0])); } Rectangle empty = Rectangle.Empty; if (designerToSize.ParentDesigner != null) { empty = designerToSize.ParentDesigner.Bounds; Size selectionSize = WorkflowTheme.CurrentTheme.AmbientTheme.SelectionSize; empty.Inflate(-2 * selectionSize.Width, -2 * selectionSize.Height); } Rectangle bounds = designerToSize.Bounds; if ((sizingEdge & DesignerEdges.Left) > DesignerEdges.None) { int x = point.X; if (!empty.IsEmpty) { x = Math.Max(x, empty.X); } x = DesignerHelpers.SnapToGrid(new Point(x, 0)).X; bounds.Width += bounds.Left - x; int num2 = (bounds.Width < designerToSize.MinimumSize.Width) ? (bounds.Width - designerToSize.MinimumSize.Width) : 0; bounds.X = x + num2; } if ((sizingEdge & DesignerEdges.Top) > DesignerEdges.None) { int y = point.Y; if (!empty.IsEmpty) { y = Math.Max(y, empty.Y); } y = DesignerHelpers.SnapToGrid(new Point(0, y)).Y; bounds.Height += bounds.Top - y; int num4 = (bounds.Height < designerToSize.MinimumSize.Height) ? (bounds.Height - designerToSize.MinimumSize.Height) : 0; bounds.Y = y + num4; } if ((sizingEdge & DesignerEdges.Right) > DesignerEdges.None) { bounds.Width += point.X - bounds.Right; } if ((sizingEdge & DesignerEdges.Bottom) > DesignerEdges.None) { bounds.Height += point.Y - bounds.Bottom; } bounds.Width = Math.Max(bounds.Width, designerToSize.MinimumSize.Width); bounds.Height = Math.Max(bounds.Height, designerToSize.MinimumSize.Height); if (!empty.IsEmpty) { bounds = Rectangle.Intersect(bounds, empty); } ((IWorkflowDesignerMessageSink) designerToSize).OnResizing(sizingEdge, bounds); }
protected override ReadOnlyCollection<Point> GetInnerConnections(DesignerEdges edges) { List<Point> connectionPoints = new List<Point>(base.GetInnerConnections(edges)); if (connectionPoints.Count > 0 && Footer != null && (edges & DesignerEdges.Bottom) > 0) connectionPoints[connectionPoints.Count - 1] = new Point(connectionPoints[connectionPoints.Count - 1].X, connectionPoints[connectionPoints.Count - 1].Y - Footer.Bounds.Height); return connectionPoints.AsReadOnly(); }
public ActivityDesignerResizeEventArgs(DesignerEdges sizingEdge, Rectangle newBounds) { this.sizingEdge = sizingEdge; this.newBounds = newBounds; }
public override ReadOnlyCollection<ConnectionPoint> GetConnectionPoints(DesignerEdges edges) { List<ConnectionPoint> connectionPoints = new List<ConnectionPoint>(); // In the EventDriven view we don't allow free form connectors if (!this.HasActiveDesigner) { if (!this.IsRootStateDesigner) { if ((edges & DesignerEdges.Top) > 0) connectionPoints.Add(new ConnectionPoint(this, DesignerEdges.Top, 0)); if ((edges & DesignerEdges.Bottom) > 0) connectionPoints.Add(new ConnectionPoint(this, DesignerEdges.Bottom, 0)); } int leftConnectionIndex = 0, rightConnectionIndex = 0; foreach (DesignerLayout layout in this.DesignerLayouts.Values) { if (!this.IsRootStateDesigner) { if ((edges & DesignerEdges.Left) > 0 && layout.LeftConnectionPoint != Point.Empty) { connectionPoints.Add(new DesignerLayoutConnectionPoint(this, leftConnectionIndex, (CompositeActivity)layout.ActivityDesigner.Activity, DesignerEdges.Left)); leftConnectionIndex += 1; } } if ((edges & DesignerEdges.Right) > 0 && layout.RightConnectionPoint != Point.Empty) { connectionPoints.Add(new DesignerLayoutConnectionPoint(this, rightConnectionIndex, (CompositeActivity)layout.ActivityDesigner.Activity, DesignerEdges.Right)); rightConnectionIndex += 1; } } } return connectionPoints.AsReadOnly(); }
private ConnectionPoint GetConnectionPoint(Activity activity, Int32 connectorIndex, DesignerEdges edge) { ActivityDesigner designer = null; if (activity != null && activity.Site != null) { IDesignerHost designerHost = activity.Site.GetService(typeof(IDesignerHost)) as IDesignerHost; if (designerHost != null) { designer = designerHost.GetDesigner(activity) as ActivityDesigner; } } return(new ConnectionPoint(designer, edge, connectorIndex)); }
private void UpdateDesignerSize(Point point, ActivityDesigner designerToSize, DesignerEdges sizingEdge) { if (base.ParentView == null) { throw new InvalidOperationException(DR.GetString("WorkflowViewNull", new object[0])); } Rectangle empty = Rectangle.Empty; if (designerToSize.ParentDesigner != null) { empty = designerToSize.ParentDesigner.Bounds; Size selectionSize = WorkflowTheme.CurrentTheme.AmbientTheme.SelectionSize; empty.Inflate(-2 * selectionSize.Width, -2 * selectionSize.Height); } Rectangle bounds = designerToSize.Bounds; if ((sizingEdge & DesignerEdges.Left) > DesignerEdges.None) { int x = point.X; if (!empty.IsEmpty) { x = Math.Max(x, empty.X); } x = DesignerHelpers.SnapToGrid(new Point(x, 0)).X; bounds.Width += bounds.Left - x; int num2 = (bounds.Width < designerToSize.MinimumSize.Width) ? (bounds.Width - designerToSize.MinimumSize.Width) : 0; bounds.X = x + num2; } if ((sizingEdge & DesignerEdges.Top) > DesignerEdges.None) { int y = point.Y; if (!empty.IsEmpty) { y = Math.Max(y, empty.Y); } y = DesignerHelpers.SnapToGrid(new Point(0, y)).Y; bounds.Height += bounds.Top - y; int num4 = (bounds.Height < designerToSize.MinimumSize.Height) ? (bounds.Height - designerToSize.MinimumSize.Height) : 0; bounds.Y = y + num4; } if ((sizingEdge & DesignerEdges.Right) > DesignerEdges.None) { bounds.Width += point.X - bounds.Right; } if ((sizingEdge & DesignerEdges.Bottom) > DesignerEdges.None) { bounds.Height += point.Y - bounds.Bottom; } bounds.Width = Math.Max(bounds.Width, designerToSize.MinimumSize.Width); bounds.Height = Math.Max(bounds.Height, designerToSize.MinimumSize.Height); if (!empty.IsEmpty) { bounds = Rectangle.Intersect(bounds, empty); } ((IWorkflowDesignerMessageSink)designerToSize).OnResizing(sizingEdge, bounds); }
void IWorkflowDesignerMessageSink.OnResizing(DesignerEdges sizingEdge, Rectangle bounds) { }
private void SetResizableDesigner(ActivityDesigner designer, DesignerEdges sizingEdge) { if (this.designerToResize == designer) return; if (designer != null && !CanResizeDesigner(designer)) { Debug.Assert(false); return; } WorkflowView workflowView = ParentView; if (workflowView == null) throw new InvalidOperationException(DR.GetString(DR.WorkflowViewNull)); if (designer != null) { if (this.designerTransaction != null) this.designerTransaction.Cancel(); IDesignerHost designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost; if (designerHost != null) this.designerTransaction = designerHost.CreateTransaction(DR.GetString(DR.ResizeUndoDescription, designer.Text)); ((IWorkflowDesignerMessageSink)designer).OnBeginResizing(sizingEdge); } else { if (this.designerTransaction != null) { this.designerTransaction.Commit(); this.designerTransaction = null; } ((IWorkflowDesignerMessageSink)this.designerToResize).OnEndResizing(); } this.designerToResize = designer; this.designerSizingEdge = sizingEdge; workflowView.Capture = (this.designerToResize != null); UpdateCursor(this.designerSizingEdge); }
void IWorkflowDesignerMessageSink.OnBeginResizing(DesignerEdges sizingEdge) { try { OnBeginResizing(new ActivityDesignerResizeEventArgs(sizingEdge, Bounds)); } catch { } }
private void SetResizableDesigner(ActivityDesigner designer, DesignerEdges sizingEdge) { if ((this.designerToResize != designer) && ((designer == null) || this.CanResizeDesigner(designer))) { WorkflowView parentView = base.ParentView; if (parentView == null) { throw new InvalidOperationException(DR.GetString("WorkflowViewNull", new object[0])); } if (designer != null) { if (this.designerTransaction != null) { this.designerTransaction.Cancel(); } IDesignerHost service = base.GetService(typeof(IDesignerHost)) as IDesignerHost; if (service != null) { this.designerTransaction = service.CreateTransaction(DR.GetString("ResizeUndoDescription", new object[] { designer.Text })); } ((IWorkflowDesignerMessageSink) designer).OnBeginResizing(sizingEdge); } else { if (this.designerTransaction != null) { this.designerTransaction.Commit(); this.designerTransaction = null; } ((IWorkflowDesignerMessageSink) this.designerToResize).OnEndResizing(); } this.designerToResize = designer; this.designerSizingEdge = sizingEdge; parentView.Capture = this.designerToResize != null; this.UpdateCursor(this.designerSizingEdge); } }
/// <summary> /// Get the points used to connect the designer. Points are in logical coordinates. /// </summary> public virtual ReadOnlyCollection<ConnectionPoint> GetConnectionPoints(DesignerEdges edges) { List<ConnectionPoint> connectionPoints = new List<ConnectionPoint>(); if ((edges & DesignerEdges.Left) > 0) { for (int i = 0; i < GetConnections(DesignerEdges.Left).Count; i++) connectionPoints.Add(new ConnectionPoint(this, DesignerEdges.Left, i)); } if ((edges & DesignerEdges.Right) > 0) { for (int i = 0; i < GetConnections(DesignerEdges.Right).Count; i++) connectionPoints.Add(new ConnectionPoint(this, DesignerEdges.Right, i)); } if ((edges & DesignerEdges.Top) > 0) { for (int i = 0; i < GetConnections(DesignerEdges.Top).Count; i++) connectionPoints.Add(new ConnectionPoint(this, DesignerEdges.Top, i)); } if ((edges & DesignerEdges.Bottom) > 0) { for (int i = 0; i < GetConnections(DesignerEdges.Bottom).Count; i++) connectionPoints.Add(new ConnectionPoint(this, DesignerEdges.Bottom, i)); } return connectionPoints.AsReadOnly(); }
internal static GraphicsPath GetDesignerPath(ActivityDesigner designer, Point offset, Size inflate, DesignerEdges edgeToInflate) { return GetDesignerPath(designer, offset, inflate, edgeToInflate, true); }
private void UpdateDesignerSize(Point point, ActivityDesigner designerToSize, DesignerEdges sizingEdge) { WorkflowView workflowView = ParentView; if (workflowView == null) throw new InvalidOperationException(DR.GetString(DR.WorkflowViewNull)); Rectangle clipBounds = Rectangle.Empty; if (designerToSize.ParentDesigner != null) { clipBounds = designerToSize.ParentDesigner.Bounds; Size selectionSize = WorkflowTheme.CurrentTheme.AmbientTheme.SelectionSize; clipBounds.Inflate(-2 * selectionSize.Width, -2 * selectionSize.Height); } Rectangle designerBounds = designerToSize.Bounds; if ((sizingEdge & DesignerEdges.Left) > 0) { int x = point.X; if (!clipBounds.IsEmpty) x = Math.Max(x, clipBounds.X); x = DesignerHelpers.SnapToGrid(new Point(x, 0)).X; designerBounds.Width += (designerBounds.Left - x); int delta = (designerBounds.Width < designerToSize.MinimumSize.Width) ? designerBounds.Width - designerToSize.MinimumSize.Width : 0; designerBounds.X = x + delta; } if ((sizingEdge & DesignerEdges.Top) > 0) { int y = point.Y; if (!clipBounds.IsEmpty) y = Math.Max(y, clipBounds.Y); y = DesignerHelpers.SnapToGrid(new Point(0, y)).Y; designerBounds.Height += (designerBounds.Top - y); int delta = (designerBounds.Height < designerToSize.MinimumSize.Height) ? designerBounds.Height - designerToSize.MinimumSize.Height : 0; designerBounds.Y = y + delta; } if ((sizingEdge & DesignerEdges.Right) > 0) designerBounds.Width += (point.X - designerBounds.Right); if ((sizingEdge & DesignerEdges.Bottom) > 0) designerBounds.Height += (point.Y - designerBounds.Bottom); //Clip to lower bounds and upper bounds designerBounds.Width = Math.Max(designerBounds.Width, designerToSize.MinimumSize.Width); designerBounds.Height = Math.Max(designerBounds.Height, designerToSize.MinimumSize.Height); if (!clipBounds.IsEmpty) designerBounds = Rectangle.Intersect(designerBounds, clipBounds); ((IWorkflowDesignerMessageSink)designerToSize).OnResizing(sizingEdge, designerBounds); }
internal static GraphicsPath GetDesignerPath(ActivityDesigner designer, Point offset, Size inflate, DesignerEdges edgeToInflate, bool enableRoundedCorners) { GraphicsPath path = new GraphicsPath(); Rectangle bounds = designer.Bounds; bounds.Offset(offset); if ((edgeToInflate & DesignerEdges.Left) > DesignerEdges.None) { bounds.X -= inflate.Width; bounds.Width += inflate.Width; } if ((edgeToInflate & DesignerEdges.Right) > DesignerEdges.None) { bounds.Width += inflate.Width; } if ((edgeToInflate & DesignerEdges.Top) > DesignerEdges.None) { bounds.Y -= inflate.Height; bounds.Height += inflate.Height; } if ((edgeToInflate & DesignerEdges.Bottom) > DesignerEdges.None) { bounds.Height += inflate.Height; } if ((designer == ActivityDesigner.GetSafeRootDesigner(designer.Activity.Site)) && (((IWorkflowRootDesigner) designer).InvokingDesigner == null)) { path.AddRectangle(bounds); return path; } ActivityDesignerTheme designerTheme = designer.DesignerTheme; if ((enableRoundedCorners && (designerTheme != null)) && (designerTheme.DesignerGeometry == DesignerGeometry.RoundedRectangle)) { path.AddPath(GetRoundedRectanglePath(bounds, 8), true); return path; } path.AddRectangle(bounds); return path; }
protected override ReadOnlyCollection<Point> GetConnections(DesignerEdges edges) { List<Point> connections = new List<Point>(); if ((edges & DesignerEdges.Top) > 0) connections.Add(this.TopConnectionPoint); if ((edges & DesignerEdges.Bottom) > 0) connections.Add(this.BottomConnectionPoint); foreach (DesignerLayout layout in this.DesignerLayouts.Values) { if (!this.IsRootStateDesigner) { if ((edges & DesignerEdges.Left) > 0 && layout.LeftConnectionPoint != Point.Empty) connections.Add(layout.LeftConnectionPoint); } if ((edges & DesignerEdges.Right) > 0 && layout.RightConnectionPoint != Point.Empty) connections.Add(layout.RightConnectionPoint); } return connections.AsReadOnly(); }
private void UpdateCursor(DesignerEdges sizingEdge) { WorkflowView workflowView = ParentView; if (workflowView == null) throw new InvalidOperationException(DR.GetString(DR.WorkflowViewNull)); Cursor cursorToSet = workflowView.Cursor; if (((sizingEdge & DesignerEdges.Left) > 0 && (sizingEdge & DesignerEdges.Top) > 0) || ((sizingEdge & DesignerEdges.Right) > 0 && (sizingEdge & DesignerEdges.Bottom) > 0)) { cursorToSet = Cursors.SizeNWSE; } else if (((sizingEdge & DesignerEdges.Right) > 0 && (sizingEdge & DesignerEdges.Top) > 0) || ((sizingEdge & DesignerEdges.Left) > 0 && (sizingEdge & DesignerEdges.Bottom) > 0)) { cursorToSet = Cursors.SizeNESW; } else if ((sizingEdge & DesignerEdges.Top) > 0 || (sizingEdge & DesignerEdges.Bottom) > 0) { cursorToSet = Cursors.SizeNS; } else if ((sizingEdge & DesignerEdges.Left) > 0 || (sizingEdge & DesignerEdges.Right) > 0) { cursorToSet = Cursors.SizeWE; } else if (sizingEdge == DesignerEdges.None && (workflowView.Cursor == Cursors.SizeNWSE || workflowView.Cursor == Cursors.SizeNESW || workflowView.Cursor == Cursors.SizeNS || workflowView.Cursor == Cursors.SizeWE)) { cursorToSet = Cursors.Default; } if (workflowView.Cursor != cursorToSet) workflowView.Cursor = cursorToSet; }
private ActivityDesigner GetDesignerToResize(Point point, out DesignerEdges sizingEdge) { ActivityDesigner designerToResize = null; sizingEdge = DesignerEdges.None; ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService; if (selectionService != null) { ArrayList selectedComponents = new ArrayList(selectionService.GetSelectedComponents()); for (int i = 0; i < selectedComponents.Count && designerToResize == null; i++) { Activity activity = selectedComponents[i] as Activity; if (activity != null) { ActivityDesigner potentialResizableDesigner = ActivityDesigner.GetDesigner(activity); if (potentialResizableDesigner != null) { SelectionGlyph selectionGlyph = potentialResizableDesigner.Glyphs[typeof(SelectionGlyph)] as SelectionGlyph; if (selectionGlyph != null) { foreach (Rectangle grabHandle in selectionGlyph.GetGrabHandles(potentialResizableDesigner)) { if (grabHandle.Contains(point)) { designerToResize = potentialResizableDesigner; sizingEdge = GetSizingEdge(designerToResize, point); break; } } } } } } } return designerToResize; }
/// <summary> /// Returns the collection of points which represents the inner connections of the designer. The designer can have connectors /// within it, the points returned are the connection points used for connectable designer. /// </summary> /// <param name="edges">Designer Edge along which the connection point lies</param> /// <returns>List of connection Points</returns> protected virtual ReadOnlyCollection<Point> GetInnerConnections(DesignerEdges edges) { List<Point> connectionPoints = new List<Point>(GetConnections(edges)); if (connectionPoints.Count > 0 && (edges & DesignerEdges.Top) > 0) connectionPoints[0] = new Point(connectionPoints[0].X, connectionPoints[0].Y + TitleHeight); return connectionPoints.AsReadOnly(); }
internal static DesignerEdges ClosestEdgeToPoint(Point point, Rectangle rect, DesignerEdges edgesToConsider) { List<double> distances = new List<double>(); List<DesignerEdges> edges = new List<DesignerEdges>(); if ((edgesToConsider & DesignerEdges.Left) > 0) { distances.Add(DistanceFromPointToLineSegment(point, new Point[] { new Point(rect.Left, rect.Top), new Point(rect.Left, rect.Bottom) })); edges.Add(DesignerEdges.Left); } if ((edgesToConsider & DesignerEdges.Top) > 0) { distances.Add(DistanceFromPointToLineSegment(point, new Point[] { new Point(rect.Left, rect.Top), new Point(rect.Right, rect.Top) })); edges.Add(DesignerEdges.Top); } if ((edgesToConsider & DesignerEdges.Right) > 0) { distances.Add(DistanceFromPointToLineSegment(point, new Point[] { new Point(rect.Right, rect.Top), new Point(rect.Right, rect.Bottom) })); edges.Add(DesignerEdges.Right); } if ((edgesToConsider & DesignerEdges.Bottom) > 0) { distances.Add(DistanceFromPointToLineSegment(point, new Point[] { new Point(rect.Left, rect.Bottom), new Point(rect.Right, rect.Bottom) })); edges.Add(DesignerEdges.Bottom); } if (distances.Count > 0) { double minDistance = distances[0]; for (int i = 1; i < distances.Count; i++) minDistance = Math.Min(minDistance, distances[i]); return edges[distances.IndexOf(minDistance)]; } else { return DesignerEdges.None; } }