예제 #1
0
        /// <summary>
        /// Draw this handle according to the handle's style.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="view"></param>
        /// <remarks>
        /// Handles never have shadows, but their outlines and fills
        /// can be specified by the <see cref="P:Northwoods.Go.GoShape.Pen" /> and
        /// <see cref="P:Northwoods.Go.GoShape.Brush" /> properties.
        /// Hollow handles (those with a <see cref="P:Northwoods.Go.GoHandle.GoObject" />.<c>NoHandle</c>
        /// <see cref="P:Northwoods.Go.GoHandle.HandleID" />), should have no <see cref="P:Northwoods.Go.GoShape.Brush" />.
        /// </remarks>
        public override void Paint(Graphics g, GoView view)
        {
            RectangleF bounds = Bounds;

            switch (Style)
            {
            case GoHandleStyle.None:
                break;

            default:
                GoShape.DrawRectangle(g, view, Pen, Brush, bounds.X, bounds.Y, bounds.Width, bounds.Height);
                break;

            case GoHandleStyle.Ellipse:
                GoShape.DrawEllipse(g, view, Pen, Brush, bounds.X, bounds.Y, bounds.Width, bounds.Height);
                break;

            case GoHandleStyle.Diamond:
            {
                PointF[] array2 = view.AllocTempPointArray(4);
                array2[0].X = bounds.X + bounds.Width / 2f;
                array2[0].Y = bounds.Y;
                array2[1].X = bounds.X + bounds.Width;
                array2[1].Y = bounds.Y + bounds.Height / 2f;
                array2[2].X = array2[0].X;
                array2[2].Y = bounds.Y + bounds.Height;
                array2[3].X = bounds.X;
                array2[3].Y = array2[1].Y;
                GoShape.DrawPolygon(g, view, Pen, Brush, array2);
                view.FreeTempPointArray(array2);
                break;
            }

            case GoHandleStyle.TriangleTopLeft:
            case GoHandleStyle.TriangleTopRight:
            case GoHandleStyle.TriangleBottomRight:
            case GoHandleStyle.TriangleBottomLeft:
            case GoHandleStyle.TriangleMiddleTop:
            case GoHandleStyle.TriangleMiddleRight:
            case GoHandleStyle.TriangleMiddleBottom:
            case GoHandleStyle.TriangleMiddleLeft:
            {
                PointF[] array = view.AllocTempPointArray(3);
                ComputeTrianglePoints(array);
                GoShape.DrawPolygon(g, view, Pen, Brush, array);
                view.FreeTempPointArray(array);
                break;
            }
            }
        }
예제 #2
0
        /// <summary>
        /// The appearance of this handle depends on the <see cref="P:Northwoods.Go.IGoCollapsible.Collapsible" />
        /// and <see cref="P:Northwoods.Go.IGoCollapsible.IsExpanded" /> properties.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="view"></param>
        /// <remarks>
        /// If the parent is not <see cref="P:Northwoods.Go.IGoCollapsible.Collapsible" />,
        /// this draws a circle inside the rectangle.
        /// Otherwise, the appearance depends on the value of <see cref="P:Northwoods.Go.GoCollapsibleHandle.Style" />.
        /// </remarks>
        protected virtual void PaintHandle(Graphics g, GoView view)
        {
            IGoCollapsible goCollapsible = FindCollapsible();

            if (goCollapsible == null)
            {
                return;
            }
            RectangleF bounds = Bounds;

            if (goCollapsible.Collapsible)
            {
                float num  = bounds.X + bounds.Width / 2f;
                float num2 = bounds.Y + bounds.Height / 2f;
                switch (Style)
                {
                case GoCollapsibleHandleStyle.PlusMinus:
                {
                    float num9  = Bordered ? (bounds.Width / 4f) : 0f;
                    float num10 = Bordered ? (bounds.Height / 4f) : 0f;
                    GoShape.DrawLine(g, view, Pen, bounds.X + num9, num2, bounds.X + bounds.Width - num9, num2);
                    if (!goCollapsible.IsExpanded)
                    {
                        GoShape.DrawLine(g, view, Pen, num, bounds.Y + num10, num, bounds.Y + bounds.Height - num10);
                    }
                    break;
                }

                case GoCollapsibleHandleStyle.TriangleRight:
                {
                    float    num7   = Bordered ? (bounds.Width / 6f) : 0f;
                    float    num8   = Bordered ? (bounds.Height / 6f) : 0f;
                    PointF[] array3 = view.AllocTempPointArray(3);
                    if (goCollapsible.IsExpanded)
                    {
                        array3[0].X = bounds.X + num7;
                        array3[0].Y = bounds.Y + num8;
                        array3[1].X = bounds.X + bounds.Width - num7;
                        array3[1].Y = num2;
                        array3[2].X = bounds.X + num7;
                        array3[2].Y = bounds.Y + bounds.Height - num8;
                    }
                    else
                    {
                        array3[0].X = bounds.X + num7;
                        array3[0].Y = bounds.Y + num8;
                        array3[1].X = bounds.X + bounds.Width - num7;
                        array3[1].Y = bounds.Y + num8;
                        array3[2].X = num;
                        array3[2].Y = bounds.Y + bounds.Height - num8;
                    }
                    SolidBrush solidBrush2 = new SolidBrush(GoShape.GetPenColor(Pen, Color.Black));
                    GoShape.DrawPolygon(g, view, null, solidBrush2, array3);
                    solidBrush2.Dispose();
                    view.FreeTempPointArray(array3);
                    break;
                }

                case GoCollapsibleHandleStyle.TriangleUp:
                {
                    float    num5   = Bordered ? (bounds.Width / 6f) : 0f;
                    float    num6   = Bordered ? (bounds.Height / 6f) : 0f;
                    PointF[] array2 = view.AllocTempPointArray(3);
                    if (goCollapsible.IsExpanded)
                    {
                        array2[0].X = bounds.X + num5;
                        array2[0].Y = bounds.Y + bounds.Height - num6;
                        array2[1].X = bounds.X + bounds.Width - num5;
                        array2[1].Y = bounds.Y + bounds.Height - num6;
                        array2[2].X = num;
                        array2[2].Y = bounds.Y + num6;
                    }
                    else
                    {
                        array2[0].X = bounds.X + num5;
                        array2[0].Y = bounds.Y + num6;
                        array2[1].X = bounds.X + bounds.Width - num5;
                        array2[1].Y = bounds.Y + num6;
                        array2[2].X = num;
                        array2[2].Y = bounds.Y + bounds.Height - num6;
                    }
                    SolidBrush solidBrush = new SolidBrush(GoShape.GetPenColor(Pen, Color.Black));
                    GoShape.DrawPolygon(g, view, null, solidBrush, array2);
                    solidBrush.Dispose();
                    view.FreeTempPointArray(array2);
                    break;
                }

                case GoCollapsibleHandleStyle.ChevronUp:
                {
                    float    num3  = Bordered ? (bounds.Width / 6f) : 0f;
                    float    num4  = Bordered ? (bounds.Height / 6f) : 0f;
                    PointF[] array = view.AllocTempPointArray(3);
                    if (goCollapsible.IsExpanded)
                    {
                        array[0].X = bounds.X + num3;
                        array[0].Y = num2;
                        array[1].X = num;
                        array[1].Y = bounds.Y + num4;
                        array[2].X = bounds.X + bounds.Width - num3;
                        array[2].Y = num2;
                        GoShape.DrawLines(g, view, Pen, array);
                        array[0].X = bounds.X + num3;
                        array[0].Y = bounds.Y + bounds.Height - num4;
                        array[1].X = num;
                        array[1].Y = num2;
                        array[2].X = bounds.X + bounds.Width - num3;
                        array[2].Y = bounds.Y + bounds.Height - num4;
                        GoShape.DrawLines(g, view, Pen, array);
                    }
                    else
                    {
                        array[0].X = bounds.X + num3;
                        array[0].Y = bounds.Y + num4;
                        array[1].X = num;
                        array[1].Y = num2;
                        array[2].X = bounds.X + bounds.Width - num3;
                        array[2].Y = bounds.Y + num4;
                        GoShape.DrawLines(g, view, Pen, array);
                        array[0].X = bounds.X + num3;
                        array[0].Y = num2;
                        array[1].X = num;
                        array[1].Y = bounds.Y + bounds.Height - num4;
                        array[2].X = bounds.X + bounds.Width - num3;
                        array[2].Y = num2;
                        GoShape.DrawLines(g, view, Pen, array);
                    }
                    view.FreeTempPointArray(array);
                    break;
                }
                }
            }
            else
            {
                GoShape.DrawEllipse(g, view, Pen, null, bounds.X + bounds.Width / 4f, bounds.Y + bounds.Height / 4f, bounds.Width / 2f, bounds.Height / 2f);
            }
        }
예제 #3
0
        /// <summary>
        /// This method is called by <see cref="M:Northwoods.Go.GoButton.Paint(System.Drawing.Graphics,Northwoods.Go.GoView)" /> to display any button state,
        /// such as whether it is "pressed".
        /// </summary>
        /// <param name="g"></param>
        /// <param name="view"></param>
        protected virtual void PaintButton(Graphics g, GoView view)
        {
            RectangleF bounds = Bounds;
            Pen        pen;
            Pen        pen2;
            Pen        pen3;
            Pen        pen4;

            if (ActionActivated)
            {
                pen  = GoShape.SystemPens_ControlDarkDark;
                pen2 = GoShape.SystemPens_ControlLightLight;
                pen3 = GoShape.SystemPens_ControlDark;
                pen4 = GoShape.SystemPens_Control;
            }
            else
            {
                pen  = GoShape.SystemPens_ControlLightLight;
                pen2 = GoShape.SystemPens_ControlDarkDark;
                pen3 = GoShape.SystemPens_Control;
                pen4 = GoShape.SystemPens_ControlDark;
            }
            PointF[] array = view.AllocTempPointArray(3);
            float    num   = 0.5f;
            float    num2  = 0.5f;

            if (base.Document != null)
            {
                num  /= base.Document.WorldScale.Width;
                num2 /= base.Document.WorldScale.Height;
            }
            PointF pointF  = new PointF(bounds.X + num, bounds.Y + num2);
            PointF pointF2 = new PointF(bounds.X + bounds.Width - num, bounds.Y + num2);
            PointF pointF3 = new PointF(bounds.X + num, bounds.Y + bounds.Height - num2);
            PointF pointF4 = new PointF(bounds.X + bounds.Width - num, bounds.Y + bounds.Height - num2);

            array[0] = pointF2;
            array[1] = pointF;
            array[2] = pointF3;
            GoShape.DrawLines(g, view, pen3, array);
            array[0].Y -= num2;
            array[1]    = pointF4;
            array[2].X -= num;
            GoShape.DrawLines(g, view, pen4, array);
            pointF.X  -= num * 2f;
            pointF.Y  -= num2 * 2f;
            pointF2.X += num * 2f;
            pointF2.Y -= num2 * 2f;
            pointF4.X += num * 2f;
            pointF4.Y += num2 * 2f;
            pointF3.X -= num * 2f;
            pointF3.Y += num2 * 2f;
            array[0]   = pointF2;
            array[1]   = pointF;
            array[2]   = pointF3;
            GoShape.DrawLines(g, view, pen, array);
            array[0].Y -= num2;
            array[1]    = pointF4;
            array[2].X -= num;
            GoShape.DrawLines(g, view, pen2, array);
            view.FreeTempPointArray(array);
        }