Пример #1
0
        public void Paint(Graphics g)
        {
            var rc      = Area;
            var rcInner = Rectangle.Inflate(rc, -2, -2);

            ControlPaint.DrawSelectionFrame(g, true, rc, rcInner, Color.Green);
        }
Пример #2
0
        /// <summary>
        /// Draws the frame selection if Selected property is true.
        /// </summary>
        /// <param name="document">Informations transferred from DrawingPanel.</param>
        /// <param name="e">PaintEventArgs.</param>
        virtual protected void DrawSelection(IDocument document, PaintEventArgs e)
        {
            if (!_shape.Selected || !IsValidGeometric(_shape.Geometric))
            {
                return;
            }

            Rectangle outside = Rectangle.Round(_shape.Geometric.GetBounds());
            Rectangle inside  = outside;

            outside.Inflate(_grabberDimension / 2, _grabberDimension / 2);
            inside.Inflate(-_grabberDimension / 2, -_grabberDimension / 2);

            ControlPaint.DrawSelectionFrame(e.Graphics, true, outside, inside, document.DrawingControl.BackColor);

            Color color = Color.Black;

            if (Jx.Drawing.Common.Select.LastSelectedShape == _shape)
            {
                color = ControlPaint.LightLight(color);
            }

            using (SolidBrush solidBrush = new SolidBrush(color))
            {
                Rectangle[] grabbers = _shape.GetGrabbers();

                foreach (Rectangle grabber in grabbers)
                {
                    e.Graphics.FillRectangle(solidBrush, grabber);
                }
            }
        }
Пример #3
0
 protected virtual void DrawSelection(IDocument document, PaintEventArgs e)
 {
     if (this._shape.Selected && this.IsValidGeometric(this._shape.Geometric))
     {
         Rectangle rectangle  = Rectangle.Round(this._shape.Geometric.GetBounds());
         Rectangle insideRect = rectangle;
         rectangle.Inflate(this._grabberDimension / 2, this._grabberDimension / 2);
         insideRect.Inflate(-this._grabberDimension / 2, -this._grabberDimension / 2);
         ControlPaint.DrawSelectionFrame(e.Graphics, true, rectangle, insideRect, document.DrawingControl.BackColor);
         Color color = Color.Green;
         if (Select.LastSelectedShape == this._shape)
         {
             color = ControlPaint.LightLight(color);
         }
         using (SolidBrush solidBrush = new SolidBrush(color))
         {
             Rectangle[] grabbers = this._shape.GetGrabbers();
             Rectangle[] array    = grabbers;
             for (int i = 0; i < array.Length; i++)
             {
                 Rectangle rect = array[i];
                 e.Graphics.FillRectangle(solidBrush, rect);
             }
         }
     }
 }
Пример #4
0
        private static void OnControlPaint(object sender, PaintEventArgs e)
        {
            var r     = ((Control)sender).ClientRectangle;
            var inner = r;

            inner.Inflate(-SelectionWidth, -SelectionWidth);
            ControlPaint.DrawSelectionFrame(e.Graphics, true, r, inner, Color.White);
        }
Пример #5
0
 void RasterPaintStack()
 {
     while (rasterstack.Count > 0)
     {
         Point[] p = (Point[])rasterstack.Pop();
         ControlPaint.DrawSelectionFrame(this.CreateGraphics(), true, new Rectangle(p[0].X, p[0].Y, p[1].X - p[0].X, p[1].Y - p[0].Y), new Rectangle(p[0].X, p[0].Y, p[1].X - p[0].X, p[1].Y - p[0].Y), this.BackColor);
         //Debug.WriteLine("Popped " + pre[0] + pre[1] + " " + rasterstack.Count);
     }
 }
Пример #6
0
        public void RenderSelection(CanvasPaintArgs e)
        {
            Rectangle obounds = shape.GetBounds();
            Rectangle ibounds = shape.GetBounds();

            obounds.Inflate(3, 3);
            ibounds.Inflate(-3, -3);

            ControlPaint.DrawSelectionFrame(e.g, true, obounds, ibounds, Color.Transparent);
        }
Пример #7
0
 protected override void OnPaintAdornments(PaintEventArgs pe)
 {
     base.OnPaintAdornments(pe);
     if (SelectedComponent == this.Control)          //paint selection frame
     {
         ControlPaint.DrawSelectionFrame(pe.Graphics, false,
                                         this.Control.ClientRectangle,
                                         Rectangle.Inflate(this.Control.ClientRectangle, -6, -6),
                                         this.Control.BackColor);
     }
 }
Пример #8
0
 protected override void DrawSelection(IDocument document, PaintEventArgs e)
 {
     if (base.Shape.Visible && base.IsValidGeometric(base.Shape.Geometric))
     {
         Rectangle rectangle  = Rectangle.Round(base.Shape.Geometric.GetBounds());
         Rectangle insideRect = rectangle;
         rectangle.Inflate(base.GrabberDimension / 2, base.GrabberDimension / 2);
         insideRect.Inflate(-base.GrabberDimension / 2, -base.GrabberDimension / 2);
         ControlPaint.DrawSelectionFrame(e.Graphics, true, rectangle, insideRect, document.DrawingControl.BackColor);
     }
 }
Пример #9
0
        public void RenderSelection(CanvasPaintArgs e)
        {
            Rectangle obounds = shape.GetBounds();
            Rectangle ibounds = shape.GetBounds();

            obounds.Inflate(1, 1);
            ibounds.Inflate(-1, -1);

            ControlPaint.DrawGrabHandle(e.g, new Rectangle((int)shape.X - 3, (int)shape.Y - 3, 6, 6), true, true);
            ControlPaint.DrawGrabHandle(e.g, new Rectangle((int)shape.X2 - 3, (int)shape.Y2 - 3, 6, 6), true, true);
            ControlPaint.DrawSelectionFrame(e.g, true, obounds, ibounds, Color.Transparent);
        }
Пример #10
0
        void RasterPaintFrame(int x, int y, int xs, int ys)
        {
            Point p1 = new Point(xs, ys);
            Point p2 = new Point(x, y);

            p1 = this.PointToScreen(p1);
            p2 = this.PointToScreen(p2);

            ControlPaint.DrawSelectionFrame(this.CreateGraphics(), true, new Rectangle(p1.X, p1.Y, p2.X - p1.X, p2.Y - p1.Y), new Rectangle(p1.X - 1, p1.Y - 1, p2.X - p1.X + 1, p2.Y - p1.Y + 1), this.BackColor);

            rasterstack.Push(new Point[] { p1, p2 });
            //Debug.WriteLine("Pushed " + p1 + p2 + " " + rasterstack.Count);
        }
Пример #11
0
        /// <summary>
        /// </summary>
        public void DrawSurface(Graphics g)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            CalculatePaths(false);
            RecalcGitter();
            g.Clear(_colors[(int)Colors.BackColor]);
            // zeichnen beginnt
            if (_flags[(int)Flags.Grid])
            {
                DrawGrid(g);
            }
            if (_flags[(int)Flags.Axis])
            {
                DrawAxis(g);
            }
            if (_flags[(int)Flags.DescriptionX])
            {
                DrawDescriptionX(g);
            }
            if (_flags[(int)Flags.DescriptionY])
            {
                DrawDescriptionY(g);
            }
            if (_border)
            {
                ControlPaint.DrawSelectionFrame(g, true,
                                                this.ClientRectangle, InnerMargin, Color.White);
            }
            if (_flags[(int)Flags.AntiAlias])
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;
            }
            //translate
            g.TranslateTransform((float)_gitter.X, (float)_gitter.Y);
            g.RenderingOrigin = _gitter.Location;
            for (int i = 0; i < _formulas.Count; i++)
            {
                DrawPath(g, _formulas[i]);
            }
            DrawSelection(g);
            g.SmoothingMode = SmoothingMode.None;
            g.TranslateTransform(-(float)_gitter.X, -(float)_gitter.Y);
            if (_flags[(int)Flags.Rulers])
            {
                DrawRulers(g);
            }
        }
Пример #12
0
        /// <summary>
        /// Draws the frame selection if Selected property is true.
        /// </summary>
        /// <param name="document">Informations transferred from DrawingPanel.</param>
        /// <param name="e">PaintEventArgs.</param>
        protected override void DrawSelection(IDocument document, PaintEventArgs e)
        {
            if (!Shape.Visible || !IsValidGeometric(Shape.Geometric))
            {
                return;
            }

            System.Drawing.Rectangle outside = System.Drawing.Rectangle.Round(Shape.Geometric.GetBounds());
            System.Drawing.Rectangle inside  = outside;

            outside.Inflate(GrabberDimension / 2, GrabberDimension / 2);
            inside.Inflate(-GrabberDimension / 2, -GrabberDimension / 2);

            ControlPaint.DrawSelectionFrame(e.Graphics, true, outside, inside, document.DrawingControl.BackColor);
        }
Пример #13
0
        /// <summary>
        /// 绘制图片和任务名称;
        /// 如果选择了组件,它绘制选择框和抓取句柄
        /// </summary>
        /// <param name="e"></param>
        public void OnPaint(PaintEventArgs e)
        {
            e.Graphics.DrawIcon(icon, bounds.Left, bounds.Top);
            string displayName = TaskName;
            SizeF  sizeF       = e.Graphics.MeasureString(displayName, font);
            int    Namex       = bounds.Left - ((int)sizeF.Width) / 2 + bounds.Width / 2;

            e.Graphics.DrawString(displayName, font, Brushes.Black, Namex, bounds.Top + 40, alignVertically);
            if (!Selected)
            {
                return;
            }
            Rectangle outerRect = bounds; //paint the selection box

            outerRect.Inflate(SystemInformation.FrameBorderSize);
            ControlPaint.DrawSelectionFrame(e.Graphics, true, outerRect, bounds, SystemColors.ActiveBorder);
            grabHandles.OnPaint(e); //paint the grab handles
        }
Пример #14
0
        /// <summary>
        ///  this function does double duty:  it draws the tabs if fRegion is false, or it
        ///  computes control region rects if fRegion is true (both require that we essentially
        ///  "draw" the tabs)
        /// </summary>
        private void DrawTabs(IList tabs, Graphics gr, bool fRegion)
        {
            IEnumerator e    = tabs.GetEnumerator();
            int         iCtl = 0;
            Control     ctl;
            Control     parent;
            string      str;

            Font font = tabFont;

            if (fRegion)
            {
                region = new Region(new Rectangle(0, 0, 0, 0));
            }

            if (ctlHover != null)
            {
                Rectangle ctlInner = GetConvertedBounds(ctlHover);
                Rectangle ctlOuter = ctlInner;
                ctlOuter.Inflate(selSize, selSize);

                if (fRegion)
                {
                    region = new Region(ctlOuter);
                    region.Exclude(ctlInner);
                }
                else
                {
                    Control p = ctlHover.Parent;
                    Color   backColor;
                    backColor = p.BackColor;

                    Region clip = gr.Clip;
                    gr.ExcludeClip(ctlInner);
                    using (SolidBrush brush = new SolidBrush(backColor))
                    {
                        gr.FillRectangle(brush, ctlOuter);
                    }

                    ControlPaint.DrawSelectionFrame(gr, false, ctlOuter, ctlInner, backColor);
                    gr.Clip = clip;
                }
            }

            Rectangle rc;

            while (e.MoveNext())
            {
                ctl = (Control)e.Current;
                rc  = GetConvertedBounds(ctl);

                drawString.Length = 0;

                parent = GetSitedParent(ctl);
                Control baseControl = (Control)host.RootComponent;

                while (parent != baseControl && parent != null)
                {
                    drawString.Insert(0, decimalSep);
                    drawString.Insert(0, parent.TabIndex.ToString(CultureInfo.CurrentCulture));
                    parent = GetSitedParent(parent);
                }

                drawString.Insert(0, ' ');
                drawString.Append(ctl.TabIndex.ToString(CultureInfo.CurrentCulture));
                drawString.Append(' ');

                if (((PropertyDescriptor)tabProperties[ctl]).IsReadOnly)
                {
                    drawString.Append(SR.WindowsFormsTabOrderReadOnly);
                    drawString.Append(' ');
                }

                str = drawString.ToString();
                var sz = Size.Ceiling(gr.MeasureString(str, font));
                rc.Width  = sz.Width + 2;
                rc.Height = sz.Height + 2;

                tabGlyphs[iCtl++] = rc;

                Brush brush;
                Pen   pen;
                Color textColor;
                if (fRegion)
                {
                    region.Union(rc);
                }
                else
                {
                    if (tabComplete.IndexOf(ctl) != -1)
                    {
                        brush     = highlightTextBrush;
                        pen       = highlightPen;
                        textColor = SystemColors.Highlight;
                    }
                    else
                    {
                        brush     = SystemBrushes.Highlight;
                        pen       = SystemPens.HighlightText;
                        textColor = SystemColors.HighlightText;
                    }

                    gr.FillRectangle(brush, rc);
                    gr.DrawRectangle(pen, rc.X, rc.Y, rc.Width - 1, rc.Height - 1);

                    Brush foreBrush = new SolidBrush(textColor);
                    gr.DrawString(str, font, foreBrush, rc.X + 1, rc.Y + 1);
                    foreBrush.Dispose();
                }
            }

            if (fRegion)
            {
                ctl = (Control)host.RootComponent;
                rc  = GetConvertedBounds(ctl);
                region.Intersect(rc);
                Region = region;
            }
        }
Пример #15
0
 private void DrawSelectionFrame(Graphics gr, Rectangle bounds)
 {
     ControlPaint.DrawSelectionFrame(
         gr, false, bounds,
         Rectangle.Inflate(bounds, -3, -3), _owner.BackColor);
 }
        private void DrawTabs(IList tabs, Graphics gr, bool fRegion)
        {
            Control     current;
            IEnumerator enumerator = tabs.GetEnumerator();
            int         num        = 0;
            Rectangle   empty      = Rectangle.Empty;
            Size        size       = Size.Empty;
            Font        tabFont    = this.tabFont;

            if (fRegion)
            {
                this.region = new Region(new Rectangle(0, 0, 0, 0));
            }
            if (this.ctlHover != null)
            {
                Rectangle convertedBounds = this.GetConvertedBounds(this.ctlHover);
                Rectangle rect            = convertedBounds;
                rect.Inflate(this.selSize, this.selSize);
                if (fRegion)
                {
                    this.region = new Region(rect);
                    this.region.Exclude(convertedBounds);
                }
                else
                {
                    Color  backColor = this.ctlHover.Parent.BackColor;
                    Region clip      = gr.Clip;
                    gr.ExcludeClip(convertedBounds);
                    using (SolidBrush brush = new SolidBrush(backColor))
                    {
                        gr.FillRectangle(brush, rect);
                    }
                    ControlPaint.DrawSelectionFrame(gr, false, rect, convertedBounds, backColor);
                    gr.Clip = clip;
                }
            }
            while (enumerator.MoveNext())
            {
                current = (Control)enumerator.Current;
                empty   = this.GetConvertedBounds(current);
                this.drawString.Length = 0;
                Control sitedParent   = this.GetSitedParent(current);
                Control rootComponent = (Control)this.host.RootComponent;
                while ((sitedParent != rootComponent) && (sitedParent != null))
                {
                    this.drawString.Insert(0, this.decimalSep);
                    this.drawString.Insert(0, sitedParent.TabIndex.ToString(CultureInfo.CurrentCulture));
                    sitedParent = this.GetSitedParent(sitedParent);
                }
                this.drawString.Insert(0, ' ');
                this.drawString.Append(current.TabIndex.ToString(CultureInfo.CurrentCulture));
                this.drawString.Append(' ');
                if (((PropertyDescriptor)this.tabProperties[current]).IsReadOnly)
                {
                    this.drawString.Append(System.Design.SR.GetString("WindowsFormsTabOrderReadOnly"));
                    this.drawString.Append(' ');
                }
                string text = this.drawString.ToString();
                size                  = Size.Ceiling(gr.MeasureString(text, tabFont));
                empty.Width           = size.Width + 2;
                empty.Height          = size.Height + 2;
                this.tabGlyphs[num++] = empty;
                if (fRegion)
                {
                    this.region.Union(empty);
                }
                else
                {
                    Brush highlightTextBrush;
                    Pen   highlightPen;
                    Color highlight;
                    if (this.tabComplete.IndexOf(current) != -1)
                    {
                        highlightTextBrush = this.highlightTextBrush;
                        highlightPen       = this.highlightPen;
                        highlight          = SystemColors.Highlight;
                    }
                    else
                    {
                        highlightTextBrush = SystemBrushes.Highlight;
                        highlightPen       = SystemPens.HighlightText;
                        highlight          = SystemColors.HighlightText;
                    }
                    gr.FillRectangle(highlightTextBrush, empty);
                    gr.DrawRectangle(highlightPen, empty.X, empty.Y, empty.Width - 1, empty.Height - 1);
                    Brush brush3 = new SolidBrush(highlight);
                    gr.DrawString(text, tabFont, brush3, (float)(empty.X + 1), (float)(empty.Y + 1));
                    brush3.Dispose();
                }
            }
            if (fRegion)
            {
                current = (Control)this.host.RootComponent;
                empty   = this.GetConvertedBounds(current);
                this.region.Intersect(empty);
                base.Region = this.region;
            }
        }