public OverlayCPView(OverlayControlPoint ocp) : base(ocp) { Width = 10; Height = 10; Fill = Brushes.Gray; SetStdColor(); Canvas.SetZIndex(lineToOrigin1, -1); Canvas.SetZIndex(lineToOrigin2, -1); var sp1 = BindingFactory.CreateProvider(ocp, "Origin1", oc => oc.Origin1, false); var sp2 = BindingFactory.CreateProvider(ocp, "Origin2", oc => oc.Origin2, false); MyBindings.Add(sp1); MyBindings.Add(sp2); MyBindings.Add(BindingFactory.CreateBindingSP(sp1, "BB", vm => UpdateLinePos(lineToOrigin1, vm.Center), () => lineToOrigin1.Visibility = Visibility.Collapsed, false)); MyBindings.Add(BindingFactory.CreateBindingSP(sp2, "BB", vm => UpdateLinePos(lineToOrigin2, vm.Center), () => lineToOrigin2.Visibility = Visibility.Collapsed, false)); MyBindings.Add(BindingFactory.CreateBinding(ocp, "BB", vm => { if (vm.Origin1 != null) { UpdateLinePos(lineToOrigin1, vm.Origin1.Center); } if (vm.Origin2 != null) { UpdateLinePos(lineToOrigin2, vm.Origin2.Center); } }, null, false)); }
OverlayCPView NewCPView(OverlayControlPoint ocp) { OverlayCPView v = new OverlayCPView(ocp); canvas1.Children.Add(v); canvas1.Children.Add(v.lineToOrigin1); canvas1.Children.Add(v.lineToOrigin2); return(v); }
public static void Draw(this OverlayControlPoint ocp, Graphics dc, int Height) { Pen p = ocp.IsSelected ? PensAndBrushes.OverlayNodeSelPen : PensAndBrushes.OverlayNodePen; RectangleF lBB = ocp.BB.UpsideDown(Height).ToRectangleF(); // draw lines if (ocp.Origin1 != null) { var L1Origin = ocp.Origin1.Center.UpsideDown(Height); dc.DrawLine(PensAndBrushes.DashedPen, L1Origin.ToPointF(), lBB.Center()); } if (ocp.Origin2 != null) { var L2Origin = ocp.Origin2.Center.UpsideDown(Height); dc.DrawLine(PensAndBrushes.DashedPen, L2Origin.ToPointF(), lBB.Center()); } // draw CP dc.FillEllipse(Brushes.Gray, lBB); dc.DrawEllipse(p, lBB); }