예제 #1
0
        /// <summary>
        /// Draw a plus/minus/zero inside a rectangle.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="view"></param>
        /// <remarks>
        /// If <see cref="P:Northwoods.Go.GoCollapsibleHandle.Bordered" /> is true, this draws a rounded rectangle.
        /// Then it calls <see cref="M:Northwoods.Go.GoCollapsibleHandle.PaintHandle(System.Drawing.Graphics,Northwoods.Go.GoView)" />.
        /// </remarks>
        public override void Paint(Graphics g, GoView view)
        {
            RectangleF bounds = Bounds;
            SizeF      corner = Corner;

            if (Bordered)
            {
                Pen pen = GoShape.NewPen(GoShape.GetPenColor(Pen, Color.Black), 1f);
                GoShape.DrawRoundedRectangle(g, view, pen, Brush, bounds.X, bounds.Y, bounds.Width, bounds.Height, corner.Width, corner.Height);
                pen.Dispose();
            }
            else
            {
                GoShape.DrawRoundedRectangle(g, view, null, Brush, bounds.X, bounds.Y, bounds.Width, bounds.Height, corner.Width, corner.Height);
            }
            PaintHandle(g, view);
        }
예제 #2
0
        /// <summary>
        /// Create and determine the appearance of a large handle around an object.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="selectedObj"></param>
        /// <returns></returns>
        /// <remarks>
        /// This method uses <see cref="M:Northwoods.Go.GoObject.CreateBoundingHandle" /> to
        /// actually allocate the handle and to set the size and location of the
        /// handle, as determined by the bounding rectangle of <paramref name="obj" />.
        /// The pen of the handle is determined by
        /// <see cref="P:Northwoods.Go.GoView.PrimarySelectionColor" /> and
        /// <see cref="P:Northwoods.Go.GoView.SecondarySelectionColor" />; the brush is set to null.
        /// The new handle is associated with the <paramref name="obj" /> and its
        /// <see cref="P:Northwoods.Go.IGoHandle.SelectedObject" /> property is set to
        /// <paramref name="selectedObj" />.
        /// </remarks>
        /// <seealso cref="M:Northwoods.Go.GoSelection.CreateResizeHandle(Northwoods.Go.GoObject,Northwoods.Go.GoObject,System.Drawing.PointF,System.Int32,System.Boolean)" />
        public virtual IGoHandle CreateBoundingHandle(GoObject obj, GoObject selectedObj)
        {
            IGoHandle goHandle = obj.CreateBoundingHandle();

            if (goHandle == null)
            {
                return(null);
            }
            goHandle.SelectedObject = selectedObj;
            GoObject goObject = goHandle.GoObject;

            if (goObject == null)
            {
                return(null);
            }
            goObject.Selectable = false;
            GoShape goShape = goObject as GoShape;

            if (goShape != null)
            {
                Color  color = Color.LightGray;
                GoView view  = View;
                if (view != null)
                {
                    color = ((!Focused) ? view.NoFocusSelectionColor : ((Primary == null || Primary.SelectionObject != obj) ? view.SecondarySelectionColor : view.PrimarySelectionColor));
                }
                float boundingHandlePenWidth = view.BoundingHandlePenWidth;
                float num = (boundingHandlePenWidth == 0f) ? 0f : (boundingHandlePenWidth / view.WorldScale.Width);
                if (myBoundingHandlePen == null || GoShape.GetPenColor(myBoundingHandlePen, color) != color || GoShape.GetPenWidth(myBoundingHandlePen) != num)
                {
                    myBoundingHandlePen = GoShape.NewPen(color, num);
                }
                goShape.Pen   = myBoundingHandlePen;
                goShape.Brush = null;
            }
            AddHandle(obj, goHandle);
            return(goHandle);
        }
예제 #3
0
        /// <summary>
        /// Create and determine the appearance of a small handle for an object.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="selectedObj"></param>
        /// <param name="loc"></param>
        /// <param name="handleid"></param>
        /// <param name="filled"></param>
        /// <returns></returns>
        /// <remarks>
        /// This method uses <see cref="M:Northwoods.Go.GoObject.CreateResizeHandle(System.Int32)" /> to
        /// actually allocate the handle.
        /// The size of the handle, if not already non-zero, is determined by
        /// <see cref="P:Northwoods.Go.GoView.ResizeHandleSize" />.
        /// The pen and brush of the handle are determined by
        /// <see cref="P:Northwoods.Go.GoView.PrimarySelectionColor" /> and <see cref="P:Northwoods.Go.GoView.SecondarySelectionColor" />.
        /// The new handle is associated with the <paramref name="obj" /> and its
        /// <see cref="P:Northwoods.Go.IGoHandle.SelectedObject" /> property is set to <paramref name="selectedObj" />.
        /// </remarks>
        /// <seealso cref="M:Northwoods.Go.GoSelection.CreateBoundingHandle(Northwoods.Go.GoObject,Northwoods.Go.GoObject)" />
        public virtual IGoHandle CreateResizeHandle(GoObject obj, GoObject selectedObj, PointF loc, int handleid, bool filled)
        {
            IGoHandle goHandle = obj.CreateResizeHandle(handleid);

            if (goHandle == null)
            {
                return(null);
            }
            goHandle.HandleID       = handleid;
            goHandle.SelectedObject = selectedObj;
            GoObject goObject = goHandle.GoObject;

            if (goObject == null)
            {
                return(null);
            }
            GoView view  = View;
            SizeF  sizeF = goObject.Size;

            if (sizeF.Width <= 0f || sizeF.Height <= 0f)
            {
                sizeF = (view?.ResizeHandleSize ?? new SizeF(6f, 6f));
            }
            if (view != null)
            {
                sizeF.Width  /= view.WorldScale.Width;
                sizeF.Height /= view.WorldScale.Height;
            }
            goObject.Bounds = new RectangleF(loc.X - sizeF.Width / 2f, loc.Y - sizeF.Height / 2f, sizeF.Width, sizeF.Height);
            if (handleid == 0)
            {
                goObject.Selectable = false;
            }
            else
            {
                goObject.Selectable = true;
            }
            GoShape goShape = goObject as GoShape;

            if (goShape != null)
            {
                Color color = Color.LightGray;
                if (view != null)
                {
                    color = ((!Focused) ? view.NoFocusSelectionColor : ((Primary == null || Primary.SelectionObject != obj) ? view.SecondarySelectionColor : view.PrimarySelectionColor));
                }
                if (filled)
                {
                    float resizeHandlePenWidth = view.ResizeHandlePenWidth;
                    float num = (resizeHandlePenWidth == 0f) ? 0f : (resizeHandlePenWidth / view.WorldScale.Width);
                    if (myResizeHandlePen == null || GoShape.GetPenColor(myResizeHandlePen, myResizeHandlePenColor) != myResizeHandlePenColor || GoShape.GetPenWidth(myResizeHandlePen) != num)
                    {
                        myResizeHandlePen = GoShape.NewPen(myResizeHandlePenColor, num);
                    }
                    goShape.Pen = myResizeHandlePen;
                    if (myResizeHandleBrush == null || myResizeHandleBrush.Color != color)
                    {
                        myResizeHandleBrush = new SolidBrush(color);
                    }
                    goShape.Brush = myResizeHandleBrush;
                }
                else
                {
                    float resizeHandlePenWidth2 = view.ResizeHandlePenWidth;
                    float num2 = (resizeHandlePenWidth2 == 0f) ? 0f : ((resizeHandlePenWidth2 + 1f) / view.WorldScale.Width);
                    if (myResizeHandlePen == null || GoShape.GetPenColor(myResizeHandlePen, color) != color || GoShape.GetPenWidth(myResizeHandlePen) != num2)
                    {
                        myResizeHandlePen = GoShape.NewPen(color, num2);
                    }
                    goShape.Pen   = myResizeHandlePen;
                    goShape.Brush = null;
                }
            }
            AddHandle(obj, goHandle);
            return(goHandle);
        }