protected override void CreateHandles() { if (Container == null) { return; } SetHandles(new Handles()); //Get the default graphics path and scale it IRender render = RenderFromContainer(); GraphicsPath defaultPath = (GraphicsPath)Component.Instance.DefaultHandlePath.Clone(); Matrix matrix = new Matrix(); matrix.Scale(render.ZoomFactor, render.ZoomFactor); defaultPath.Transform(matrix); RectangleF pathRectangle = defaultPath.GetBounds(); RectangleF halfRectangle = new RectangleF(0, 0, pathRectangle.Width / 2, pathRectangle.Height / 2); //Loop through each point and add an offset handle GraphicsPath path; foreach (PointF point in Points) { path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(point.X - Rectangle.X - halfRectangle.Width, point.Y - Rectangle.Y - halfRectangle.Height); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.Origin)); } Handles[0].CanDock = true; Handles[Handles.Count - 1].CanDock = true; }
//Create a list of handles protected internal override void CreateHandles() { if (Model == null) { return; } if (Points == null) { return; } SetHandles(new Handles()); //Get the default graphics path and scale it //Render render = RenderFromContainer(); GraphicsPath defaultPath = (GraphicsPath)Singleton.Instance.DefaultHandlePath.Clone(); Matrix matrix = new Matrix(); //matrix.Scale(render.ZoomFactor,render.ZoomFactor); //defaultPath.Transform(matrix); RectangleF pathRectangle = defaultPath.GetBounds(); RectangleF halfRectangle = new RectangleF(0, 0, pathRectangle.Width / 2, pathRectangle.Height / 2); //Loop through each point and add an offset handle GraphicsPath path; PointF point = (PointF)Points[0]; path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(point.X - Bounds.X - halfRectangle.Width, point.Y - Bounds.Y - halfRectangle.Height); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.Origin, true)); point = (PointF)Points[Points.Count - 1]; path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(point.X - Bounds.X - halfRectangle.Width, point.Y - Bounds.Y - halfRectangle.Height); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.Origin, true)); }
//Create a list of handles protected internal override void CreateHandles() { if (Model == null) { return; } if (Points == null) { return; } SetHandles(new Handles()); //Render render = RenderFromContainer(); GraphicsPath defaultPath; GraphicsPath path; Matrix matrix = new Matrix(); RectangleF pathRectangle; RectangleF halfRectangle; PointF point; //Add any other handles if (Points.Count > 3) { //Get the default graphics path and scale it defaultPath = (GraphicsPath)Singleton.Instance.DefaultLargeHandlePath.Clone(); //matrix.Scale(render.ZoomFactor,render.ZoomFactor); //defaultPath.Transform(matrix); pathRectangle = defaultPath.GetBounds(); halfRectangle = new RectangleF(0, 0, pathRectangle.Width / 2, pathRectangle.Height / 2); //Loop through each point and add an orthogonal handle for (int i = 0; i < Points.Count; i++) { if (i > 1 && i < Points.Count - 1) { //get the middle point for this segment PointF current = (PointF)Points[i]; PointF previous = (PointF)Points[i - 1]; point = Geometry.GetMiddlePoint(current, previous); //Determine which kind of handle HandleType handleType = (current.X == previous.X) ? HandleType.LeftRight : HandleType.UpDown; path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); //Offset the path to the points location //matrix.Translate(point.X - Rectangle.X - halfRectangle.Width,point.Y - Rectangle.Y - halfRectangle.Height); matrix.Translate(point.X - Bounds.X - halfRectangle.Width, point.Y - Bounds.Y - halfRectangle.Height); //Rotate the handle 90 degrees if left right handle if (handleType == HandleType.LeftRight) { matrix.RotateAt(90, new PointF(pathRectangle.Width / 2, pathRectangle.Height / 2)); } path.Transform(matrix); Handles.Add(new ConnectorHandle(path, handleType, i)); } } } defaultPath = (GraphicsPath)Singleton.Instance.DefaultHandlePath.Clone(); matrix = new Matrix(); //matrix.Scale(render.ZoomFactor,render.ZoomFactor); //defaultPath.Transform(matrix); pathRectangle = defaultPath.GetBounds(); halfRectangle = new RectangleF(0, 0, pathRectangle.Width / 2, pathRectangle.Height / 2); //Add first and last points point = (PointF)Points[0]; path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(point.X - Bounds.X - halfRectangle.Width, point.Y - Bounds.Y - halfRectangle.Height); path.Transform(matrix); Handles.Insert(0, new Handle(path, HandleType.Origin, true)); point = (PointF)Points[Points.Count - 1]; path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(point.X - Bounds.X - halfRectangle.Width, point.Y - Bounds.Y - halfRectangle.Height); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.Origin, true)); }
//Create a list of handles protected internal override void CreateHandles() { if (Model == null) { return; } SetHandles(new Handles()); //Get the default graphics path and scale it //Render render = RenderFromContainer(); GraphicsPath defaultPath = (GraphicsPath)Singleton.Instance.DefaultHandlePath.Clone(); Matrix matrix = new Matrix(); //matrix.Scale(render.ZoomFactor,render.ZoomFactor); //defaultPath.Transform(matrix); RectangleF pathRectangle = defaultPath.GetBounds(); RectangleF halfRectangle = new RectangleF(0, 0, pathRectangle.Width / 2, pathRectangle.Height / 2); float onePixel = 1; //* render.ZoomFactor; //Add top left GraphicsPath path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(-pathRectangle.Width - onePixel, -pathRectangle.Height - onePixel); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.TopLeft)); //Add top right path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(TransformRectangle.Width, -pathRectangle.Height - onePixel); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.TopRight)); //Add bottom left path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(-pathRectangle.Width - onePixel, TransformRectangle.Height + onePixel); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.BottomLeft)); //Add bottom right path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(TransformRectangle.Width + onePixel, TransformRectangle.Height + onePixel); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.BottomRight)); if (!KeepAspect) { //Add top middle path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate((TransformRectangle.Width / 2) - halfRectangle.Width, -pathRectangle.Height - onePixel); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.Top)); //Add left path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(-pathRectangle.Width - onePixel, (TransformRectangle.Height / 2) - halfRectangle.Height); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.Left)); //Add right path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(TransformRectangle.Width + onePixel, (TransformRectangle.Height / 2) - halfRectangle.Height); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.Right)); //Add bottom path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate((TransformRectangle.Width / 2) - halfRectangle.Width, TransformRectangle.Height + onePixel); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.Bottom)); } //Add rotation handle if (AllowRotate) { //Add top middle path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate((TransformRectangle.Width / 2) - halfRectangle.Width, (TransformRectangle.Height / 2) - halfRectangle.Height); path.Transform(matrix); Handles.Add(new Handle(path, HandleType.Rotate)); } }
protected override void CreateHandles() { if (Container == null) { return; } if (Points == null) { return; } SetHandles(new Handles()); //Get the default graphics path and scale it IRender render = RenderFromContainer(); GraphicsPath defaultPath = (GraphicsPath)Component.Instance.DefaultHandlePath.Clone(); Matrix matrix = new Matrix(); matrix.Scale(render.ZoomFactor, render.ZoomFactor); defaultPath.Transform(matrix); RectangleF pathRectangle = defaultPath.GetBounds(); RectangleF halfRectangle = new RectangleF(0, 0, pathRectangle.Width / 2, pathRectangle.Height / 2); //Loop through each point and add an offset handle GraphicsPath path; int count = 0; PointF previous = new PointF(); foreach (PointF point in Points) { //Add the split segment if (count > 0 && AllowExpand) { path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(previous.X - Rectangle.X - halfRectangle.Width + ((point.X - previous.X) / 2), previous.Y - Rectangle.Y - halfRectangle.Height + ((point.Y - previous.Y) / 2)); path.Transform(matrix); //Create a new expand handle ExpandHandle expand = new ExpandHandle(Segments[count - 1]); expand.Path = path; expand.Index = count - 1; expand.CanDock = false; Handles.Add(expand); } path = (GraphicsPath)defaultPath.Clone(); matrix.Reset(); matrix.Translate(point.X - Rectangle.X - halfRectangle.Width, point.Y - Rectangle.Y - halfRectangle.Height); path.Transform(matrix); //Create handle Handle handle = new Handle(path, HandleType.Origin); handle.CanDock = false; Handles.Add(handle); count++; previous = point; } //Set up the docking Handles[0].CanDock = true; Handles[Handles.Count - 1].CanDock = true; }