Esempio n. 1
0
        private System.Drawing.Drawing2D.GraphicsPath GetOutline_ToolWindow(int index)
        {
            Rectangle tabRectangle = this.GetTabRectangle(index);

            tabRectangle.Intersect(this.TabsRectangle);
            tabRectangle = base.RectangleToScreen(DrawHelper.RtlTransform(this, tabRectangle));
            int       top        = tabRectangle.Top;
            Rectangle rectangle2 = base.DockPane.RectangleToScreen(base.DockPane.ClientRectangle);

            System.Drawing.Drawing2D.GraphicsPath path       = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Drawing2D.GraphicsPath addingPath = this.GetTabOutline(base.Tabs[index], true, true);
            path.AddPath(addingPath, true);
            path.AddLine(tabRectangle.Left, tabRectangle.Top, rectangle2.Left, tabRectangle.Top);
            path.AddLine(rectangle2.Left, tabRectangle.Top, rectangle2.Left, rectangle2.Top);
            path.AddLine(rectangle2.Left, rectangle2.Top, rectangle2.Right, rectangle2.Top);
            path.AddLine(rectangle2.Right, rectangle2.Top, rectangle2.Right, tabRectangle.Top);
            path.AddLine(rectangle2.Right, tabRectangle.Top, tabRectangle.Right, tabRectangle.Top);
            return(path);
        }
Esempio n. 2
0
        /// <summary>
        /// Draws a polygon filled.
        /// </summary>
        public void DrawFilled(C2DHoledPolyBase Poly, Graphics graphics, Brush brush)
        {
            if (Poly.Rim.Lines.Count == 0)
            {
                return;
            }

            System.Drawing.Drawing2D.GraphicsPath gp = CreatePath(Poly.Rim);

            for (int h = 0; h < Poly.HoleCount; h++)
            {
                if (Poly.GetHole(h).Lines.Count > 2)
                {
                    gp.AddPath(CreatePath(Poly.GetHole(h)), false);
                }
            }
            gp.FillMode = System.Drawing.Drawing2D.FillMode.Alternate;

            graphics.FillPath(brush, gp);
        }
        /// <summary>
        /// Draws labels in a specified rectangle
        /// </summary>
        /// <param name="g">The graphics object to draw to</param>
        /// <param name="labelText">The label text to draw</param>
        /// <param name="labelBounds">The rectangle of the label</param>
        /// <param name="symb">the Label Symbolizer to use when drawing the label</param>
        private static void DrawLabel(Graphics g, string labelText, RectangleF labelBounds, ILabelSymbolizer symb)
        {
            //Sets up the brushes and such for the labeling
            Brush foreBrush = new SolidBrush(symb.FontColor);
            Font textFont = symb.GetFont();
            StringFormat format = new StringFormat();
            format.Alignment = symb.Alignment;
            Pen borderPen = new Pen(symb.BorderColor);
            Brush backBrush = new SolidBrush(symb.BackColor);
            Brush haloBrush = new SolidBrush(symb.HaloColor);
            Pen haloPen = new Pen(symb.HaloColor);
            haloPen.Width = 2;
            haloPen.Alignment = System.Drawing.Drawing2D.PenAlignment.Outset;
            Brush shadowBrush = new SolidBrush(symb.DropShadowColor);

            //Text graphics path
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            gp.AddString(labelText, textFont.FontFamily, (int)textFont.Style, textFont.SizeInPoints * 96F / 72F, labelBounds, format);

            //Draws the text outline
            if (symb.BackColorEnabled && symb.BackColor != Color.Transparent)
            {
                if (symb.FontColor == Color.Transparent)
                {
                    System.Drawing.Drawing2D.GraphicsPath backgroundGP = new System.Drawing.Drawing2D.GraphicsPath();
                    backgroundGP.AddRectangle(labelBounds);
                    backgroundGP.FillMode = System.Drawing.Drawing2D.FillMode.Alternate;
                    backgroundGP.AddPath(gp, true);
                    g.FillPath(backBrush, backgroundGP);
                    backgroundGP.Dispose();
                }
                else
                {
                    g.FillRectangle(backBrush, labelBounds);
                }
            }

            //Draws the border if its enabled
            if (symb.BorderVisible && symb.BorderColor != Color.Transparent)
                g.DrawRectangle(borderPen, labelBounds.X, labelBounds.Y, labelBounds.Width, labelBounds.Height);

            //Draws the drop shadow                      
            if (symb.DropShadowEnabled && symb.DropShadowColor != Color.Transparent)
            {
                System.Drawing.Drawing2D.Matrix gpTrans = new System.Drawing.Drawing2D.Matrix();
                gpTrans.Translate(symb.DropShadowPixelOffset.X, symb.DropShadowPixelOffset.Y);
                gp.Transform(gpTrans);
                g.FillPath(shadowBrush, gp);
                gpTrans = new System.Drawing.Drawing2D.Matrix();
                gpTrans.Translate(-symb.DropShadowPixelOffset.X, -symb.DropShadowPixelOffset.Y);
                gp.Transform(gpTrans);
            }

            //Draws the text halo
            if (symb.HaloEnabled && symb.HaloColor != Color.Transparent)
                g.DrawPath(haloPen, gp);

            //Draws the text if its not transparent
            if (symb.FontColor != Color.Transparent)
                g.FillPath(foreBrush, gp);

            //Cleans up the rest of the drawing objects
            shadowBrush.Dispose();
            borderPen.Dispose();
            foreBrush.Dispose();
            backBrush.Dispose();
            haloBrush.Dispose();
            haloPen.Dispose();
        }
Esempio n. 4
0
        /// <summary>
        /// Repaints the form with cool background and stuff
        /// </summary>
        /// <param name="graph">The graphics object to paint to, the element will be drawn to 0,0</param>
        public virtual void Paint(Graphics graph)
        {
            //Sets up the colors to use
            Pen outlinePen = new Pen(MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 0.6 * Highlight), 1.75F);
            Color gradientTop = MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 0.7 * Highlight);
            Color gradientBottom = MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 1.0 * Highlight);

            //The path used for drop shadows
            System.Drawing.Drawing2D.GraphicsPath shadowPath = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Drawing2D.ColorBlend colorBlend = new System.Drawing.Drawing2D.ColorBlend(3);
            colorBlend.Colors = new Color[] { Color.Transparent, Color.FromArgb(180, Color.DarkGray), Color.FromArgb(180, Color.DimGray) };
            colorBlend.Positions = new float[] { 0f, 0.125f,1f};

            //Draws Rectangular Shapes
            if (Shape == ModelShapes.Rectangle)
            {
                //Draws the shadow
                shadowPath.AddPath(GetRoundedRect(new Rectangle(5, 5, this.Width, this.Height), 10), true);
                System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath);
                shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                shadowBrush.InterpolationColors = colorBlend;
                graph.FillPath(shadowBrush, shadowPath);

                //Draws the basic shape
                System.Drawing.Rectangle fillRectange = new Rectangle(0, 0, this.Width - 5, this.Height - 5);
                System.Drawing.Drawing2D.GraphicsPath fillArea = GetRoundedRect(fillRectange, 5);
                System.Drawing.Drawing2D.LinearGradientBrush myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(fillRectange, gradientBottom, gradientTop, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                graph.FillPath(myBrush, fillArea);
                graph.DrawPath(outlinePen, fillArea);
                
                //Draws the status light
                drawStatusLight(graph);
                
                //Draws the text
                SizeF textSize = graph.MeasureString(Name, Font, this.Width);
                RectangleF textRect;
                if ((textSize.Width < this.Width) || (textSize.Height < this.Height))
                    textRect = new RectangleF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2, textSize.Width, textSize.Height);
                else
                    textRect = new RectangleF(0, (this.Height - textSize.Height) / 2, this.Width, textSize.Height);
                graph.DrawString(Name, Font, new SolidBrush(Color.FromArgb(50, Color.Black)), textRect);
                textRect.X = textRect.X - 1;
                textRect.Y = textRect.Y - 1;
                graph.DrawString(Name, Font, System.Drawing.Brushes.Black, textRect);

                //Garbage collection
                fillArea.Dispose();
                myBrush.Dispose();
            }

            //Draws Ellipse Shapes
            if (_shape == ModelShapes.Ellipse)
            {
                //Draws the shadow
                shadowPath.AddEllipse(0, 5, this.Width+5, this.Height);
                System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath);
                shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                shadowBrush.InterpolationColors = colorBlend;
                graph.FillPath(shadowBrush, shadowPath);

                //Draws the Ellipse
                System.Drawing.Rectangle fillArea = new Rectangle(0, 0, this.Width, this.Height);
                System.Drawing.Drawing2D.LinearGradientBrush myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(fillArea, gradientBottom, gradientTop, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                graph.FillEllipse(myBrush, 1, 1, this.Width - 5, this.Height - 5);
                graph.DrawEllipse(outlinePen, 1, 1, this.Width - 5, this.Height - 5);

                //Draws the text
                SizeF textSize = graph.MeasureString(_name, _font, this.Width);
                RectangleF textRect;
                if ((textSize.Width < this.Width) || (textSize.Height < this.Height))
                    textRect = new RectangleF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2, textSize.Width, textSize.Height);
                else
                    textRect = new RectangleF(0, (this.Height - textSize.Height) / 2, this.Width, textSize.Height);
                graph.DrawString(Name, Font, new SolidBrush(Color.FromArgb(50, Color.Black)), textRect);
                textRect.X = textRect.X - 1;
                textRect.Y = textRect.Y - 1;
                graph.DrawString(Name, Font, System.Drawing.Brushes.Black, textRect);

                //Garbage collection
                myBrush.Dispose();
            }

            //Draws Triangular Shapes
            if (_shape == ModelShapes.Triangle)
            {
                //Draws the shadow
                Point[] ptShadow = new Point[4];
                ptShadow[0] = new Point(5, 5);
                ptShadow[1] = new Point(this.Width + 5, ((this.Height - 5) / 2) + 5);
                ptShadow[2] = new Point(5, this.Height+2);
                ptShadow[3] = new Point(5, 5);
                shadowPath.AddLines(ptShadow);
                System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath);
                shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                shadowBrush.InterpolationColors = colorBlend;
                graph.FillPath(shadowBrush, shadowPath);

                //Draws the shape
                Point[] pt = new Point[4];
                pt[0] = new Point(0, 0);
                pt[1] = new Point(this.Width - 5, (this.Height-5) / 2);
                pt[2] = new Point(0, this.Height-5);
                pt[3] = new Point(0, 0);
                System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath();
                myPath.AddLines(pt);
                System.Drawing.Rectangle fillArea = new Rectangle(1, 1, this.Width - 5, this.Height - 5);
                System.Drawing.Drawing2D.LinearGradientBrush myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(fillArea, gradientBottom, gradientTop, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                graph.FillPath(myBrush, myPath);
                graph.DrawPath(outlinePen, myPath);

                //Draws the text
                SizeF textSize = graph.MeasureString(Name, Font, this.Width);
                RectangleF textRect;
                if ((textSize.Width < this.Width) || (textSize.Height < this.Height))
                    textRect = new RectangleF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2, textSize.Width, textSize.Height);
                else
                    textRect = new RectangleF(0, (this.Height - textSize.Height) / 2, this.Width, textSize.Height);
                graph.DrawString(Name, Font, System.Drawing.Brushes.Black, textRect);

                //Garbage collection
                myBrush.Dispose();
            }
            
            //Garbage collection
            shadowPath.Dispose();
            outlinePen.Dispose();
        }