public bool HasAdjacent(ClientLinkable next) { foreach (var e in _edges) if (e.GetLinkable1() == next || e.GetLinkable2() == next) return true; return false; }
public static Point GetAnchorCoords(ClientLinkable end, AnchorPoint anchorPoint) { var border = end.GetBounds(); border.Inflate(20, 20); switch (anchorPoint) { case AnchorPoint.TopLeft: return(border.TopLeft); case AnchorPoint.TopCenter: return(new Point(border.X + border.Width / 2, border.Y)); case AnchorPoint.TopRight: return(border.TopRight); case AnchorPoint.LeftCenter: return(new Point(border.X, border.Y + border.Height / 2)); case AnchorPoint.BottomLeft: return(border.BottomLeft); case AnchorPoint.BottomCenter: return(new Point(border.X + border.Width / 2, border.Y + border.Height)); case AnchorPoint.BottomRight: return(border.BottomRight); case AnchorPoint.RightCenter: return(new Point(border.X + border.Width, border.Y + border.Height / 2)); default: throw new NotSupportedException(); } }
public bool HasAdjacent(ClientLinkable next) { foreach (var e in _edges) { if (e.GetLinkable1() == next || e.GetLinkable2() == next) { return(true); } } return(false); }
VdClusterLink PlayLinkCreate(ClientLinkable end1, ClientLinkable end2, int shapeId, int initOwnerId, bool takeCursor) { ShapeIdGenerator.Instance.CorrectLowBound(initOwnerId, shapeId); var res = new VdClusterLink(end1, end2, shapeId, initOwnerId); end1.AddEdge(res); end2.AddEdge(res); //no post handler for cluster link this.Add(res); DocTools.SortScene(_scene); //no initial lock, as link is created in free state (no pressed buttons) return(res); }
public VdClusterLink(ClientLinkable end1, ClientLinkable end2, int shapeId, int owner) : base(owner, shapeId) { _end1 = end1; _end2 = end2; initLine(DaoUtils.UserIdToColor(owner)); //wait until actual size is set line.Dispatcher.BeginInvoke(new Action(() => { NotifyLinkableMoved(); }), System.Windows.Threading.DispatcherPriority.Background); RemoveFocus(); updateUserCursor(); }
public VdClusterLink(ClientLinkable end1, ClientLinkable end2, int shapeId, int owner): base(owner, shapeId) { _end1 = end1; _end2 = end2; initLine(DaoUtils.UserIdToColor(owner)); //wait until actual size is set line.Dispatcher.BeginInvoke(new Action(() => { NotifyLinkableMoved(); }), System.Windows.Threading.DispatcherPriority.Background); RemoveFocus(); updateUserCursor(); }
public static void GetLinkPoints(ClientLinkable s, ClientLinkable t, out double x1, out double y1, out double x2, out double y2) { x1 = 0; y1 = 0; x2 = 0; y2 = 0; var sBounds = s.GetBounds(); // sBounds.Inflate(10,10); // sBounds.X += 5; // sBounds.Y += 15; var tBounds = t.GetBounds(); // tBounds.Inflate(10,10); // tBounds.X += 5; // tBounds.Y += 15; //c is point center of <s-t>, lambda is in [0,1] var xs = sBounds.X + sBounds.Width / 2; var ys = sBounds.Y + sBounds.Height / 2; var xt = tBounds.X + tBounds.Width / 2; var yt = tBounds.Y + tBounds.Height / 2; var xc = (xs + xt) * 0.5; var yc = (ys + yt) * 0.5; //s-anchor EdgeFinder((double x, double y) => sBounds.Contains(x, y), xs, ys, xc, yc, 5, out x1, out y1); //t-anchor EdgeFinder((double x, double y) => tBounds.Contains(x, y), xt, yt, xc, yc, 5, out x2, out y2); }
private VdClusterLink PlayLinkCreate(ClientLinkable end1, ClientLinkable end2, int shapeId, int initOwnerId, bool takeCursor, LinkHeadType linkHead) { ShapeIdGenerator.Instance.CorrectLowBound(initOwnerId, shapeId); var res = new VdClusterLink(end1, end2, shapeId, initOwnerId, this, linkHead); _shapePostHandler(res, VdShapeType.ClusterLink); end1.AddEdge(res); end2.AddEdge(res); if (!_shapeVisibility) { res.Hide(); } //no post handler for cluster link this.Add(res); DocTools.SortScene(_scene); //no initial lock, as link is created in free state (no pressed buttons) return(res); }
VdClusterLink PlayLinkCreate(ClientLinkable end1, ClientLinkable end2, int shapeId, int initOwnerId, bool takeCursor) { ShapeIdGenerator.Instance.CorrectLowBound(initOwnerId, shapeId); var res = new VdClusterLink(end1, end2, shapeId, initOwnerId); end1.AddEdge(res); end2.AddEdge(res); //no post handler for cluster link this.Add(res); DocTools.SortScene(_scene); //no initial lock, as link is created in free state (no pressed buttons) return res; }
public static void GetLinkPoints(ClientLinkable s, ClientLinkable t, out double x1, out double y1, out double x2, out double y2) { x1 = 0; y1 = 0; x2 = 0; y2 = 0; var sBounds = s.GetBounds(); // sBounds.Inflate(10,10); // sBounds.X += 5; // sBounds.Y += 15; var tBounds = t.GetBounds(); // tBounds.Inflate(10,10); // tBounds.X += 5; // tBounds.Y += 15; //c is point center of <s-t>, lambda is in [0,1] var xs = sBounds.X + sBounds.Width/2; var ys = sBounds.Y + sBounds.Height/2; var xt = tBounds.X + tBounds.Width / 2; var yt = tBounds.Y + tBounds.Height / 2; var xc = (xs + xt) * 0.5; var yc = (ys + yt) * 0.5; //s-anchor EdgeFinder((double x, double y)=>sBounds.Contains(x, y), xs, ys, xc, yc, 5, out x1, out y1); //t-anchor EdgeFinder((double x, double y) => tBounds.Contains(x, y), xt, yt, xc, yc, 5, out x2, out y2); }
//returns anchor point on searchTarget nearest to pivot public static void NearestAnchor(Point pivot, ClientLinkable searchTarget, out AnchorPoint anchor, out Point anchorPoint, out double minDist) { anchor = AnchorPoint.RightCenter; minDist = double.MaxValue; //double d = Dist2(pivot, GetAnchorCoords(searchTarget, AnchorPoint.TopLeft)); //if (d < minDist) //{ // minDist = d; // anchor = AnchorPoint.TopLeft; //} var d = Dist2(pivot, GetAnchorCoords(searchTarget, AnchorPoint.TopCenter)); if (d < minDist) { minDist = d; anchor = AnchorPoint.TopCenter; } //d = Dist2(pivot, GetAnchorCoords(searchTarget, AnchorPoint.TopRight)); //if (d < minDist) //{ // minDist = d; // anchor = AnchorPoint.TopRight; //} d = Dist2(pivot, GetAnchorCoords(searchTarget, AnchorPoint.LeftCenter)); if (d < minDist) { minDist = d; anchor = AnchorPoint.LeftCenter; } //d = Dist2(pivot, GetAnchorCoords(searchTarget, AnchorPoint.BottomLeft)); //if (d < minDist) //{ // minDist = d; // anchor = AnchorPoint.BottomLeft; //} d = Dist2(pivot, GetAnchorCoords(searchTarget, AnchorPoint.BottomCenter)); if (d < minDist) { minDist = d; anchor = AnchorPoint.BottomCenter; } //d = Dist2(pivot, GetAnchorCoords(searchTarget, AnchorPoint.BottomRight)); //if (d < minDist) //{ // minDist = d; // anchor = AnchorPoint.BottomRight; //} d = Dist2(pivot, GetAnchorCoords(searchTarget, AnchorPoint.RightCenter)); if (d < minDist) { minDist = d; anchor = AnchorPoint.RightCenter; } minDist = Math.Sqrt(minDist); anchorPoint = GetAnchorCoords(searchTarget, anchor); }
public static Point GetAnchorCoords(ClientLinkable end, AnchorPoint anchorPoint) { var border = end.GetBounds(); border.Inflate(20,20); switch (anchorPoint) { case AnchorPoint.TopLeft: return border.TopLeft; case AnchorPoint.TopCenter: return new Point(border.X + border.Width / 2, border.Y); case AnchorPoint.TopRight: return border.TopRight; case AnchorPoint.LeftCenter: return new Point(border.X, border.Y + border.Height / 2); case AnchorPoint.BottomLeft: return border.BottomLeft; case AnchorPoint.BottomCenter: return new Point(border.X + border.Width / 2, border.Y + border.Height); case AnchorPoint.BottomRight: return border.BottomRight; case AnchorPoint.RightCenter: return new Point(border.X + border.Width, border.Y + border.Height / 2); default: throw new NotSupportedException(); } }
private VdClusterLink PlayLinkCreate(ClientLinkable end1, ClientLinkable end2, int shapeId, int initOwnerId, bool takeCursor, LinkHeadType linkHead) { ShapeIdGenerator.Instance.CorrectLowBound(initOwnerId, shapeId); var res = new VdClusterLink(end1, end2, shapeId, initOwnerId, this, linkHead); _shapePostHandler(res, VdShapeType.ClusterLink); end1.AddEdge(res); end2.AddEdge(res); if (!_shapeVisibility) res.Hide(); //no post handler for cluster link this.Add(res); DocTools.SortScene(_scene); //no initial lock, as link is created in free state (no pressed buttons) return res; }