コード例 #1
0
 public static void MoveItem(this IWorkFlowItem item, WorkFlowPoint point, double width, double height, Func <IConnector, WorkFlowPoint> getPosition)
 {
     foreach (var connector in item.Connectors.Where(z => z.Lines.Any()))
     {
         foreach (var line in connector.Lines)
         {
             point.X += width / 2;
             point.Y += height / 2;
             if (connector.Type == ConnectorType.In)
             {
                 line.End.Point = getPosition(connector);
                 line.DrawPath(line.Start.Point, line.End.Point);
             }
             else
             {
                 line.Start.Point = getPosition(connector);
                 line.DrawPath(line.Start.Point, line.End.Point);
             }
         }
     }
 }
コード例 #2
0
        public override void DrawPath(WorkFlowPoint source, WorkFlowPoint destination, float magic = 8)
        {
            var segments = new List <PathSegment>();

            if (destination.X > source.X)
            {
                WorkFlowPoint c1 = new WorkFlowPoint(source.X + (magic - 1) * (destination.X - source.X) / magic, source.Y + (destination.Y - source.Y) / magic);
                WorkFlowPoint c2 = new WorkFlowPoint(source.X + (destination.X - source.X) / magic, source.Y + (magic - 1) * (destination.Y - source.Y) / magic);
                var           bs = new BezierSegment();
                bs.Point1 = c1.CreateWindowsFoundationPoint();
                bs.Point2 = c2.CreateWindowsFoundationPoint();
                bs.Point3 = destination.CreateWindowsFoundationPoint();
                segments.Add(bs);
            }
            else
            {
                double        distanceX = Math.Abs(source.X - destination.X) / 3;
                WorkFlowPoint c1        = new WorkFlowPoint(source.X + Math.Min((magic - 1) * (source.X - destination.X) / magic, distanceX) + 20, source.Y + (magic - 1) * (destination.Y - source.Y) / magic);
                WorkFlowPoint c2        = new WorkFlowPoint(destination.X - Math.Min((magic - 1) * (source.X - destination.X) / magic, distanceX) - 20, destination.Y - (magic - 1) * (destination.Y - source.Y) / magic);
                var           bs        = new BezierSegment();
                bs.Point1 = c1.CreateWindowsFoundationPoint();
                bs.Point2 = c2.CreateWindowsFoundationPoint();
                bs.Point3 = destination.CreateWindowsFoundationPoint();
                segments.Add(bs);
            }

            var geo = new PathGeometry();
            var pf  = new PathFigure()
            {
                StartPoint = source.CreateWindowsFoundationPoint(), IsClosed = false
            };

            foreach (var s in segments)
            {
                pf.Segments.Add(s);
            }
            geo.Figures.Add(pf);
            _currentUIElement.Data = geo;
            Canvas.SetZIndex(_currentUIElement, -2);
        }
コード例 #3
0
        public void Move(WorkFlowPoint point)
        {
            UIElement.SetPosition(new WorkFlowPoint(point.X - UIElement.ItemWidth / 2, point.Y - UIElement.ItemHeight / 2));

            foreach (var connector in this.Connectors.Where(z => z.Lines.Any()))
            {
                foreach (var line in connector.Lines)
                {
                    var absolutePosition = connector.UIElement.GetPosition();
                    absolutePosition.X += connector.UIElement.ItemWidth / 2;
                    absolutePosition.Y += connector.UIElement.ItemHeight / 2;
                    if (connector.Type == ConnectorType.In)
                    {
                        line.End.Point = absolutePosition;
                        line.DrawPath(line.Start.Point, line.End.Point, this.magic);
                    }
                    else
                    {
                        line.Start.Point = absolutePosition;
                        line.DrawPath(line.Start.Point, line.End.Point, this.magic);
                    }
                }
            }
        }
コード例 #4
0
 public void SetPosition(WorkFlowPoint point)
 {
     Canvas.SetLeft(this, point.X);
     Canvas.SetTop(this, point.Y);
 }
コード例 #5
0
 public static Point CreateWindowsFoundationPoint(this WorkFlowPoint point)
 {
     return(new Point(point.X, point.Y));
 }
コード例 #6
0
 public void SetPosition(WorkFlowPoint point)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 public virtual void DrawPath(WorkFlowPoint source, WorkFlowPoint destination, float magic = 8)
 {
     throw new NotImplementedException();
 }