protected override Size ArrangeOverride(Size finalSize) { double height = 0; double width = 0; for (int i = 0; i < Children.Count; i++) { Point pt = new Point(0, 0); Size size = Children[i].DesiredSize; if (Children[i].GetType() == typeof(Connector)) { ((UIElement)Children[i]).Arrange(new Rect(pt, size)); } else { pt = FreeFormPanel.GetLocation(Children[i]); ((UIElement)Children[i]).Arrange(new Rect(pt, size)); } if (width < (size.Width + pt.X)) { width = size.Width + pt.X; } if (height < (size.Height + pt.Y)) { height = size.Height + pt.Y; } } width = (width < this.MinWidth) ? this.MinWidth : width; width = (width < this.Width) ? (this.Width < Double.MaxValue ? this.Width : width) : width; height = (height < this.MinHeight) ? this.MinHeight : height; height = (height < this.Height) ? (this.Height < Double.MaxValue ? this.Height : height) : height; return(new Size(width, height)); }
protected override void OnRender(DrawingContext drawingContext) { SolidColorBrush renderBrush; Pen renderPen; if (this.isParentShapeSelected) { renderBrush = new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementSelectedBackgroundColor); renderPen = new Pen(new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementSelectedBorderColor), 1.0); } else { renderBrush = new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementBackgroundColor); renderPen = new Pen(new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementBorderColor), 1.0); } Point actualPoint; Point origin = FreeFormPanel.GetLocation(AdornedElement); Thickness margin = ((FrameworkElement)AdornedElement).Margin; origin.X += margin.Left; origin.Y += margin.Top; foreach (ConnectionPoint connPoint in connectionPoints) { actualPoint = new Point(connPoint.Location.X - origin.X, connPoint.Location.Y - origin.Y); DrawConnectionPoint(connPoint, actualPoint, renderBrush, renderPen, drawingContext); } base.OnRender(drawingContext); }
void SetIsHitTestVisibleForOverlappingStartDots(bool hitTestVisible) { ConnectionPoint srcConnectionPoint = FreeFormPanel.GetSourceConnectionPoint(this.Connector); foreach (Connector overlappingConnector in srcConnectionPoint.AttachedConnectors) { overlappingConnector.startDotGrid.IsHitTestVisible = hitTestVisible; } }
//Calls the Line routing algorithm and populates the points collection of the connector. void RoutePolyLine(Connector connector) { Point[] pts = ConnectorRouter.Route(this, FreeFormPanel.GetSourceConnectionPoint(connector), FreeFormPanel.GetDestinationConnectionPoint(connector)); List <Point> points = new List <Point>(pts); if (pts != null) { UpdateConnectorPoints(connector, points); } }
//The Connector editor is to be destroyed. Remove the adorners on the editor. activeEditPoint=null sets BeingEdited property to false. public void Remove() { this.activeEditPoint = null; RemoveAdorners(); this.EditPoints.Clear(); this.Connector.IsSelected = false; // Restore the IsHitTestVisible property this.SetIsHitTestVisibleForOverlappingStartDots(true); this.Connector = null; this.parentPanel = null; }
static public List <Point> GetEdgeRelativeToOutmostPanel(ConnectionPoint connectionPoint) { FreeFormPanel parentPanel = StateContainerEditor.GetVisualAncestor <FreeFormPanel>(connectionPoint.ParentDesigner); List <Point> edge = new List <Point>(); foreach (Point point in connectionPoint.Edge) { edge.Add(parentPanel.GetLocationRelativeToOutmostPanel(point)); } return(edge); }
public ConnectorEditor(FreeFormPanel panel, Connector connector) { if (panel == null) { throw new ArgumentNullException("panel"); } if (connector == null) { throw new ArgumentNullException("connector"); } this.editPoints = new List<EditPoint>(); this.parentPanel = panel; this.editedConnector = connector; this.activeEditPoint = null; connector.IsSelected = true; // When the ConnectorEditor is active, we allow reconnecting the start point of the Connector instead // of creating a new transition that shares the same trigger. So we need to disable tooltips and // highlighting effects for all overlapping start dots. this.SetIsHitTestVisibleForOverlappingStartDots(false); DisplayEditPoints(); }
public ConnectorEditor(FreeFormPanel panel, Connector connector) { if (panel == null) { throw new ArgumentNullException("panel"); } if (connector == null) { throw new ArgumentNullException("connector"); } this.editPoints = new List <EditPoint>(); this.parentPanel = panel; this.editedConnector = connector; this.activeEditPoint = null; connector.IsSelected = true; // When the ConnectorEditor is active, we allow reconnecting the start point of the Connector instead // of creating a new transition that shares the same trigger. So we need to disable tooltips and // highlighting effects for all overlapping start dots. this.SetIsHitTestVisibleForOverlappingStartDots(false); DisplayEditPoints(); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.stateContainerEditor = ((Wxwinter.BPM.Machine.Design.StateContainerEditor)(target)); return; case 2: this.stateContainerGrid = ((System.Windows.Controls.Grid)(target)); #line 27 "..\..\StateContainerEditor.xaml" this.stateContainerGrid.MouseLeave += new System.Windows.Input.MouseEventHandler(this.OnStateContainerGridMouseLeave); #line default #line hidden #line 27 "..\..\StateContainerEditor.xaml" this.stateContainerGrid.MouseMove += new System.Windows.Input.MouseEventHandler(this.OnStateContainerGridMouseMove); #line default #line hidden #line 27 "..\..\StateContainerEditor.xaml" this.stateContainerGrid.PreviewMouseMove += new System.Windows.Input.MouseEventHandler(this.OnStateContainerGridPreviewMouseMove); #line default #line hidden #line 28 "..\..\StateContainerEditor.xaml" this.stateContainerGrid.PreviewMouseUp += new System.Windows.Input.MouseButtonEventHandler(this.OnStateContainerGridPreviewMouseUp); #line default #line hidden #line 28 "..\..\StateContainerEditor.xaml" this.stateContainerGrid.KeyDown += new System.Windows.Input.KeyEventHandler(this.OnStateContainerGridKeyDown); #line default #line hidden #line 28 "..\..\StateContainerEditor.xaml" this.stateContainerGrid.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.OnStateContainerGridPreviewMouseDown); #line default #line hidden #line 29 "..\..\StateContainerEditor.xaml" this.stateContainerGrid.DragOver += new System.Windows.DragEventHandler(this.OnStateContainerGridDragOver); #line default #line hidden #line 29 "..\..\StateContainerEditor.xaml" this.stateContainerGrid.DragEnter += new System.Windows.DragEventHandler(this.OnStateContainerGridDragEnter); #line default #line hidden #line 29 "..\..\StateContainerEditor.xaml" this.stateContainerGrid.Drop += new System.Windows.DragEventHandler(this.OnStateContainerGridDrop); #line default #line hidden return; case 3: this.panel = ((Wxwinter.BPM.Machine.Design.FreeFormEditing.FreeFormPanel)(target)); return; } this._contentLoaded = true; }
private void MeasureChildren(out double height, out double width) { height = 0; width = 0; Point pt = new Point(0, 0); bool isOutmostPanel = this.IsOutmostPanel(); foreach (UIElement child in Children) { Connector connectorChild = child as Connector; if (connectorChild != null && isOutmostPanel) { pt = new Point(0, 0); if (measureConnectors) { Point srcPoint = FreeFormPanel.GetLocationRelativeToOutmostPanel(FreeFormPanel.GetSourceConnectionPoint(connectorChild)); Point destPoint = FreeFormPanel.GetLocationRelativeToOutmostPanel(FreeFormPanel.GetDestinationConnectionPoint(connectorChild)); if (connectorChild.Points.Count == 0 || (DesignerGeometryHelper.DistanceBetweenPoints(connectorChild.Points[0], srcPoint) > 1) || (DesignerGeometryHelper.DistanceBetweenPoints(connectorChild.Points[connectorChild.Points.Count - 1], destPoint) > 1)) { connectorChild.Points = new PointCollection(); RoutePolyLine(connectorChild); } connectorChild.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); } else { continue; } } else //Measure non-connector elements. { child.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); if (!child.DesiredSize.Equals(((Size)FreeFormPanel.GetChildSize(child)))) { FreeFormPanel.SetChildSize(child, child.DesiredSize); } pt = FreeFormPanel.GetLocation(child); if (pt.X == 0 && pt.Y == 0) { pt = new Point(LeftStackingMargin, lastYPosition); OnLocationChanged(child, new LocationChangedEventArgs(pt)); FreeFormPanel.SetLocation(child, pt); lastYPosition += child.DesiredSize.Height + VerticalStackingDistance; } } if (height < child.DesiredSize.Height + pt.Y) { height = child.DesiredSize.Height + pt.Y; } if (width < child.DesiredSize.Width + pt.X) { width = child.DesiredSize.Width + pt.X; } } width = (width < this.MinWidth) ? this.MinWidth : width; height = (height < this.MinHeight) ? this.MinHeight : height; }
static public Point GetLocationRelativeToOutmostPanel(ConnectionPoint connectionPoint) { FreeFormPanel parentPanel = StateContainerEditor.GetVisualAncestor <FreeFormPanel>(connectionPoint.ParentDesigner); return(parentPanel.GetLocationRelativeToOutmostPanel(connectionPoint.Location)); }