internal static EdgeLocation AutoConnectDirection2EdgeLocation(AutoConnectDirections direction) { EdgeLocation edgeLocation = EdgeLocation.Right; switch (direction) { case AutoConnectDirections.Left: edgeLocation = EdgeLocation.Left; break; case AutoConnectDirections.Right: edgeLocation = EdgeLocation.Right; break; case AutoConnectDirections.Top: edgeLocation = EdgeLocation.Top; break; case AutoConnectDirections.Bottom: edgeLocation = EdgeLocation.Bottom; break; } return(edgeLocation); }
public static void CalculateEntryExitEdges(Point mousePosition, Connector connector, out EdgeLocation entryEdge, out EdgeLocation exitEdge) { UIElement srcShape = FreeFormPanel.GetSourceConnectionPoint(connector).ParentDesigner; UIElement destShape = FreeFormPanel.GetDestinationConnectionPoint(connector).ParentDesigner; Point srcLocation = FreeFormPanel.GetLocation(srcShape); Point destLocation = FreeFormPanel.GetLocation(destShape); Size srcSize = FreeFormPanel.GetChildSize(srcShape); Size destSize = FreeFormPanel.GetChildSize(destShape); Point srcCenter = new Point(srcLocation.X + (srcSize.Width / 2), srcLocation.Y + (srcSize.Height / 2)); Point destCenter = new Point(destLocation.X + (destSize.Width / 2), destLocation.Y + (destSize.Height / 2)); entryEdge = CalculateEdgeLocation(mousePosition, srcCenter); exitEdge = CalculateEdgeLocation(mousePosition, destCenter); if (exitEdge == entryEdge) { switch (entryEdge) { case EdgeLocation.Top: exitEdge = EdgeLocation.Bottom; break; case EdgeLocation.Bottom: exitEdge = EdgeLocation.Top; break; case EdgeLocation.Left: exitEdge = EdgeLocation.Right; break; case EdgeLocation.Right: exitEdge = EdgeLocation.Left; break; } } }
public SetAutoSplitConnectionPointChange( ModelItem fcModelItem, ModelItem srcModelItem, ModelItem destModelItem, int srcIndex, int destIndex, EdgeLocation entryEdgeForAutoSplit, EdgeLocation exitEdgeForAutoSplit ) { this.Owner = fcModelItem; this.SrcModelItem = srcModelItem; this.DestModelItem = destModelItem; this.SrcConnPntIndex = srcIndex; this.DestConnPntIndex = destIndex; this.EntryEdgeForAutoSplit = entryEdgeForAutoSplit; this.ExitEdgeForAutoSplit = exitEdgeForAutoSplit; this.IsUndo = false; }
private static void SetAutoSplitDataWithUndo( ModelItem fcModelItem, ModelItem srcModelItem, ModelItem destModelItem, int srcIndex, int destIndex, EdgeLocation entryEdgeForAutoSplit, EdgeLocation exitEdgeForAutoSplit) { using (EditingScope es = (EditingScope)fcModelItem.BeginEdit(SR.AutoSplit, false)) { es.Changes.Add( new SetAutoSplitConnectionPointChange( fcModelItem, srcModelItem, destModelItem, srcIndex, destIndex, entryEdgeForAutoSplit, exitEdgeForAutoSplit )); es.Complete(); } }
private ConnectionPoint GetEmptyEdgeMidConnectionPointNotOfType(UIElement designer, EdgeLocation edgeLocation, ConnectionPointKind invalidType) { List<ConnectionPoint> connectionPoints = FlowchartDesigner.GetAllConnectionPoints(designer); connectionPoints = new List<ConnectionPoint>(connectionPoints.Where<ConnectionPoint>((p) => { return p != null && p.PointType != invalidType && p.AttachedConnectors.Count == 0 && p.EdgeLocation == edgeLocation; })); if (connectionPoints.Count > 0) { return connectionPoints[connectionPoints.Count / 2]; } return null; }
private ConnectionPoint GetSourceConnectionPointForAutoConnect(UIElement designer, EdgeLocation edgeLocation) { List<ConnectionPoint> connectionPoints = FlowchartDesigner.GetAllConnectionPoints(designer); connectionPoints = new List<ConnectionPoint>(connectionPoints.Where<ConnectionPoint>((p) => { return p != null && p.PointType != ConnectionPointKind.Incoming && p.EdgeLocation == edgeLocation; })); Fx.Assert(connectionPoints.Count > 0, "There should be at least one src connection point available"); return FlowchartDesigner.GetConnectionPointForAutoConnect(connectionPoints); }
//widthFraction, heightFraction determine location of connectionpoint on the shape. ConnectionPoint CreateConnectionPoint(UIElement element, double widthFraction, double heightFraction, EdgeLocation location) { ConnectionPoint connectionPoint = new ConnectionPoint(); connectionPoint.EdgeLocation = location; connectionPoint.PointType = ConnectionPointKind.Default; connectionPoint.ParentDesigner = element; BindingOperations.SetBinding(connectionPoint, ConnectionPoint.LocationProperty, GetConnectionPointBinding(element as FrameworkElement, widthFraction, heightFraction)); return connectionPoint; }
private string GetJSEdgeLocation() { return(EdgeLocation.Replace(@"\", @"\\")); }
public StoreAutoConnectorViewStateChange( ModelItem stateMachine, ModelItem srcModelItem, ModelItem desModelItem, ModelItem addedModelItem, EdgeLocation edgeLocatioin) { this.StateMachine = stateMachine; this.SrcModelItem = srcModelItem; this.DstModelItem = desModelItem; this.EdgeLocation = edgeLocatioin; this.ViewStateOwnerModelItem = addedModelItem; this.ShouldCreateConnector = true; }
static ConnectionPoint GetConnectionPointClosestToEdgeMidPoint(UIElement designer, List<ConnectionPoint> connectionPoints, EdgeLocation edgeLocation) { Point midPoint = new Point(-1, -1); Point location = FreeFormPanel.GetLocation(designer); Size size = FreeFormPanel.GetChildSize(designer); switch (edgeLocation) { case EdgeLocation.Left: midPoint = new Point(location.X, location.Y + size.Height / 2); break; case EdgeLocation.Right: midPoint = new Point(location.X + size.Width, location.Y + size.Height / 2); break; case EdgeLocation.Top: midPoint = new Point(location.X + size.Width / 2, location.Y); break; case EdgeLocation.Bottom: midPoint = new Point(location.X + size.Width / 2, location.Y + size.Height); break; } if (connectionPoints.Count > 0) { double dist; return ConnectionPoint.GetClosestConnectionPoint(connectionPoints, midPoint, out dist); } return null; }
private ConnectionPoint GetSourceConnectionPointForAutoConnect(UIElement designer, EdgeLocation edgeLocation) { List<ConnectionPoint> connectionPoints = this.GetAvailableConnectionPoint(designer); return GetConnectionPointClosestToEdgeMidPoint(designer, connectionPoints, edgeLocation); }
private Hex GetAdjacentHexFromEdgeDirection(EdgeLocation direction, out bool isCornerDirection) { if (neighbors.Length == 6) { switch (direction) { /// /// Points /// case EdgeLocation.Top: isCornerDirection = true; return(DetermineSideToReturn(4, 5)); case EdgeLocation.Bottom: isCornerDirection = true; return(DetermineSideToReturn(1, 2)); case EdgeLocation.BottomLeftCorner: isCornerDirection = true; return(DetermineSideToReturn(2, 3)); case EdgeLocation.BottomRightCorner: isCornerDirection = true; return(DetermineSideToReturn(0, 1)); case EdgeLocation.TopLeftCorner: isCornerDirection = true; return(DetermineSideToReturn(3, 4)); case EdgeLocation.TopRightCorner: isCornerDirection = true; return(DetermineSideToReturn(0, 5)); /// /// Sides /// case EdgeLocation.Right: isCornerDirection = false; return(neighbors[0]); case EdgeLocation.BottomRight: isCornerDirection = false; return(neighbors[1]); case EdgeLocation.BottomLeft: isCornerDirection = false; return(neighbors[2]); case EdgeLocation.Left: isCornerDirection = false; return(neighbors[3]); case EdgeLocation.TopLeft: isCornerDirection = false; return(neighbors[4]); case EdgeLocation.TopRight: isCornerDirection = false; return(neighbors[5]); } } Debug.LogError("Adjacent hex not found"); isCornerDirection = false; return(null); }
private Hex GetAdjacentHexFromEdgeDirection(EdgeLocation direction, out bool isCornerDirection) { if (neighbors.Length == 6) { switch (direction) { /// /// Points /// case EdgeLocation.Top: isCornerDirection = true; return DetermineSideToReturn(4, 5); case EdgeLocation.Bottom: isCornerDirection = true; return DetermineSideToReturn(1, 2); case EdgeLocation.BottomLeftCorner: isCornerDirection = true; return DetermineSideToReturn(2, 3); case EdgeLocation.BottomRightCorner: isCornerDirection = true; return DetermineSideToReturn(0, 1); case EdgeLocation.TopLeftCorner: isCornerDirection = true; return DetermineSideToReturn(3, 4); case EdgeLocation.TopRightCorner: isCornerDirection = true; return DetermineSideToReturn(0, 5); /// /// Sides /// case EdgeLocation.Right: isCornerDirection = false; return neighbors[0]; case EdgeLocation.BottomRight: isCornerDirection = false; return neighbors[1]; case EdgeLocation.BottomLeft: isCornerDirection = false; return neighbors[2]; case EdgeLocation.Left: isCornerDirection = false; return neighbors[3]; case EdgeLocation.TopLeft: isCornerDirection = false; return neighbors[4]; case EdgeLocation.TopRight: isCornerDirection = false; return neighbors[5]; } } Debug.LogError("Adjacent hex not found"); isCornerDirection = false; return null; }