예제 #1
0
		protected internal void SetHandles(Handles handles)
		{
			mHandles = handles;
		}
예제 #2
0
        //Create a list of handles
        protected override void CreateHandles()
        {
            if (Container == null)
            {
                return;
            }
            SetHandles(new Handles());

            IRender      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)Component.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 - Rectangle.X - halfRectangle.Width, point.Y - Rectangle.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)Component.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 - Rectangle.X - halfRectangle.Width, point.Y - Rectangle.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 - Rectangle.X - halfRectangle.Width, point.Y - Rectangle.Y - halfRectangle.Height);
            path.Transform(matrix);
            Handles.Add(new Handle(path, HandleType.Origin, true));
        }