public ConnectionPoint AddAnotherConnectionPointAt(SideOfShape side, double position) { var item = new ConnectionPoint(this, side, position); _ConnectionPoints.Add(item); item.AddToSurface(Surface); return(item); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { double left = System.Convert.ToDouble(values[0]); double top = System.Convert.ToDouble(values[1]); double width = System.Convert.ToDouble(values[2]); double height = System.Convert.ToDouble(values[3]); SideOfShape side = (SideOfShape)values[4]; double position = System.Convert.ToDouble(values[5]); //return bindingStrategy.Convert(left, top, actualWidth, actualHeight); return(Convert(left, top, width, height, side, position)); }
public Point Convert(double left, double top, double width, double height, SideOfShape side, double position) { switch (side) { case SideOfShape.Top: var convert = new Point(left + width * position, top); return convert; case SideOfShape.Bottom: return new Point(left + width * position, top + height); case SideOfShape.Left: return new Point(left, top + height * position); case SideOfShape.Right: return new Point(left + width, top + height * position); default: throw new ArgumentOutOfRangeException(); } }
public ConnectionPoint(DiagramShape parent, SideOfShape side, double position) { UID = Guid.NewGuid().ToString(); Side = side; Position = position; ParentShape = parent; SetBinding(LocationProperty, CreateLeftTopWidthHeightBinding(parent)); // The Fill property must be set to a Brush in order for the shape to be considered solid. // Otherwise only the edges are considered part of it. Fill = Brushes.Transparent; MouseEnter += ConnectionPoint_MouseEnter; MouseLeave += ConnectionPoint_MouseLeave; }
private static Dictionary <SideOfShape, List <Connection> > GetConnectionsBySide(DiagramShape shape) { Dictionary <SideOfShape, List <Connection> > connectionsBySide = new Dictionary <SideOfShape, List <Connection> >(); foreach (SideOfShape side in Enum.GetValues(typeof(SideOfShape))) { connectionsBySide[side] = new List <Connection>(); } // Split connections into groups based on the side they are closest to. foreach (var connection in shape.Connections) { DiagramShape otherShape = connection.Source == shape ? connection.Target : connection.Source; SideOfShape closestSide = GetClosestSideTo(shape, otherShape); connectionsBySide[closestSide].Add(connection); } return(connectionsBySide); }
/// <summary> /// Returns a normalized Vector representing a line parallel to /// an imaginary wall. /// _____ /// | . | /// |_____| /// The vectors for each side are determined by the line that points /// clockwise in this diagram. /// </summary> /// <param name="side"></param> /// <returns></returns> public static Vector LineParallelTo(this SideOfShape side) { switch (side) { case SideOfShape.Top: return(new Vector(1, 0)); case SideOfShape.Bottom: return(new Vector(-1, 0)); case SideOfShape.Left: return(new Vector(0, -1)); case SideOfShape.Right: return(new Vector(0, 1)); default: throw new ArgumentOutOfRangeException(); } }
public Point Convert(double left, double top, double width, double height, SideOfShape side, double position) { switch (side) { case SideOfShape.Top: var convert = new Point(left + width * position, top); return(convert); case SideOfShape.Bottom: return(new Point(left + width * position, top + height)); case SideOfShape.Left: return(new Point(left, top + height * position)); case SideOfShape.Right: return(new Point(left + width, top + height * position)); default: throw new ArgumentOutOfRangeException(); } }
public Point Convert(DiagramShape shape, SideOfShape side, double position) { return(Convert(Canvas.GetLeft(shape), Canvas.GetTop(shape), shape.ActualWidth, shape.ActualHeight, side, position)); }
public Point Convert(DiagramShape shape, SideOfShape side, double position) { return Convert(Canvas.GetLeft(shape), Canvas.GetTop(shape), shape.ActualWidth, shape.ActualHeight, side, position); }
private static List <ConnectionPoint> CreateNewConnectionPointsOn(DiagramShape shape, SideOfShape side, int numConnections) { var list = new List <ConnectionPoint>(); double spacing = 1.0 / (numConnections + 1); for (int i = 1; i <= numConnections; i++) { var cp = shape.AddAnotherConnectionPointAt(side, spacing * i); list.Add(cp); } return(list); }
private static Point GetCenterOfSide(DiagramShape shape, SideOfShape side) { return(converter.Convert(shape, side, 0.5)); }
public ConnectionPoint AddAnotherConnectionPointAt(SideOfShape side, double position) { var item = new ConnectionPoint(this, side, position); _ConnectionPoints.Add(item); item.AddToSurface(Surface); return item; }