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);
        }
Example #2
0
        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));
        }
Example #3
0
        void SetIsHitTestVisibleForOverlappingStartDots(bool hitTestVisible)
        {
            ConnectionPoint srcConnectionPoint = FreeFormPanel.GetSourceConnectionPoint(this.Connector);

            foreach (Connector overlappingConnector in srcConnectionPoint.AttachedConnectors)
            {
                overlappingConnector.startDotGrid.IsHitTestVisible = hitTestVisible;
            }
        }
Example #4
0
        //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);
            }
        }
Example #5
0
 //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;
 }
Example #6
0
        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);
        }
Example #7
0
 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();
 }
Example #8
0
        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;
        }
Example #9
0
        static public Point GetLocationRelativeToOutmostPanel(ConnectionPoint connectionPoint)
        {
            FreeFormPanel parentPanel = StateContainerEditor.GetVisualAncestor <FreeFormPanel>(connectionPoint.ParentDesigner);

            return(parentPanel.GetLocationRelativeToOutmostPanel(connectionPoint.Location));
        }