Dispose() публичный Метод

public Dispose ( ) : void
Результат void
Пример #1
0
 /// <summary>
 /// Dispose scene
 /// </summary>
 public void Dispose()
 {
     _pen.Dispose();
     _brush.Dispose();
     foreach (var layer in Layers)
     {
         layer.Dispose();
     }
 }
Пример #2
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         _brush?.Dispose();
         _brush = null;
     }
 }
Пример #3
0
        private static void ReCreateBrush(ref Brush brush, Color color)
        {
            if (brush != null)
                brush.Dispose();

            brush = new SolidBrush(color);
        }
Пример #4
0
            /// <summary>
            /// Disposes the specified brush.
            /// </summary>
            public void DisposeBrush(System.Drawing.Brush brush)
            {
                if ((_format & Styles.Color) == 0)
                {
                    return;
                }

                brush.Dispose();
            }
Пример #5
0
        public override void childPaint(System.Drawing.Graphics g, Model.DataModel Data, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font FontText, System.Drawing.Font FontData)
        {
            //绘制Pie自定义标题
            if (IsDrawPieTiTle)
            {
                Brush pieTitleBrush = new SolidBrush(pieTitleColor);
                ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, pieTitle, pieTitleFont, pieTitleBrush, 0, 3, this.Width, padding);

                pieTitleBrush.Dispose();
            }

            int length = this.Height > this.Width ? (this.Width / 2) : (this.Height / 2);
            int startX = (this.Width - length) / 2;
            int startY = (this.Height - length) / 2;

            if (Data is DetailDataModel)
            {
                DetailDataModel data  = (DetailDataModel)Data;
                string[]        datas = data.TextAndData;
                linePen = new Pen(Color.FromArgb(180, 71, 85, 182), 60);
                //7/12的效果最好看
                piePenWidth = 7 * length / 12;
                Rectangle rectangle = new Rectangle(startX, startY, length, length);

                IsFirst    = true;
                sweepAngle = 0;
                float startAngle = 360;
                for (int i = 0; i < datas.Length / 2; i++)
                {
                    string str       = datas[2 * i + 1];
                    float  realAngle = 360 * int.Parse(str) * 1.0f / allNum;

                    linePen.Width = piePenWidth * int.Parse(str) / maxNum;
                    int realX      = startX + (int)(piePenWidth - linePen.Width + 0.5f) / 2;
                    int realY      = startY + (int)(piePenWidth - linePen.Width + 0.5f) / 2;
                    int realLength = length - (int)(piePenWidth - linePen.Width);

                    rectangle     = new Rectangle(realX, realY, realLength, realLength);
                    linePen.Color = ReportViewUtils.PerferColors[i % ReportViewUtils.PerferColors.Length];
                    startAngle   -= (realAngle - 0.5f);
                    g.DrawArc(linePen, rectangle, startAngle, realAngle + 0.7f);

                    if (IsDrawLineNote)
                    {
                        DrawLineNote(g, linePen.Color, data, 2 * i + 1, startAngle, realAngle, realLength / 2);
                    }
                }
            }

            linePen.Dispose();
            lineBrush.Dispose();
            TextBrush.Dispose();
            DataBrush.Dispose();
            FontText.Dispose();
            FontData.Dispose();
        }
        private void PaintTabBackground(System.Drawing.Graphics graph, int index, System.Drawing.Drawing2D.GraphicsPath path)
        {
            System.Drawing.Brush buttonBrush = (index == this.SelectedIndex)
                ? (System.Drawing.Brush) new System.Drawing.SolidBrush(SystemColors.ControlLightLight)
                : (System.Drawing.Brush) new LinearGradientBrush(this.GetTabRect(index),
                                                                 SystemColors.ControlLightLight,
                                                                 SystemColors.ControlLight,
                                                                 LinearGradientMode.Vertical);

            graph.FillPath(buttonBrush, path);
            buttonBrush.Dispose();
        }
Пример #7
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            MindFusion.FlowChartX.Brush brush =
                e.Value as MindFusion.FlowChartX.Brush;

            if (brush == null)
            {
                return;
            }

            System.Drawing.Brush gdiBrush = brush.CreateGDIBrush(e.Bounds);
            e.Graphics.FillRectangle(gdiBrush, e.Bounds);
            gdiBrush.Dispose();
        }
Пример #8
0
 /// <summary>
 /// Limpiar los recursos que se estén utilizando.
 /// </summary>
 /// <param name="disposing">true si los recursos administrados se deben eliminar; false en caso contrario, false.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (components != null)
         {
             components.Dispose();
         }
         if (SelectionBrush != null)
         {
             SelectionBrush.Dispose();
         }
     }
     base.Dispose(disposing);
 }
Пример #9
0
 protected override void OnPaint(PaintEventArgs pe)
 {
     this.brBack = new SolidBrush(BackColor);
     this.brCode = new SolidBrush(Color.Pink);
     this.brData = new SolidBrush(Color.LightBlue);
     try
     {
         Rectangle rcBody = CalculateLayout();
         RenderSelectionBar(pe.Graphics);
         RenderScrollControls(pe.Graphics, rcBody);
         RenderBody(pe.Graphics, rcBody);
     }
     finally
     {
         brData.Dispose();
         brCode.Dispose();
         brBack.Dispose();
     }
 }
Пример #10
0
        public static void FillRoundedRectangle(this Graphics gp, System.Drawing.Brush brush,
                                                float x, float y,
                                                float width, float height, float radius, float border, Color borderColor, Corner corner = Corner.All)
        {
            PointF basePoint = new PointF(x, y);

            //PointF[] roundedRectangle = new PointF[5];
            //roundedRectangle[0].X = basePoint.X;
            //roundedRectangle[0].Y = basePoint.Y;
            //roundedRectangle[1].X = basePoint.X + width;
            //roundedRectangle[1].Y = basePoint.Y;
            //roundedRectangle[2].X = basePoint.X + width;
            //roundedRectangle[2].Y = basePoint.Y + height;
            //roundedRectangle[3].X = basePoint.X;
            //roundedRectangle[3].Y = basePoint.Y + height;
            //roundedRectangle[4].X = basePoint.X;
            //roundedRectangle[4].Y = basePoint.Y;
            var border1 = 0f;
            var border2 = border;

            if (border2 > 1)
            {
                border1 = border2 / 2.0f - 1;
                border2 = border2 - 1;
            }

            var path = GetRoundedPath(x + border1, y + border1, width - border2, height - border2, radius, corner);

            gp.FillPath(brush, path);
            if (border > 0)
            {
                Pen pen = new Pen(borderColor, border);
                gp.DrawPath(pen, path);
                pen.Dispose();
            }

            brush.Dispose();
            //Pen pen = new Pen(System.Drawing.Color.Black,2);
            //gp.DrawPath(pen, path);
        }
Пример #11
0
        /// <summary>
        /// Renders the overviewed document.
        /// </summary>
        private void DrawContents(Graphics g)
        {
            document.SetRenderOptions(options);

            // fill the background
            if (options.EnableBackground)
            {
                if (document.BkgrImagePos >= ImageAlign.Document)
                {
                    // presume graphics is already set up
                    Point pt = DocToScreen(g, new PointF(0, 0));
                    g.RenderingOrigin = pt;

                    System.Drawing.Brush fillBrush = Document.BackBrush.CreateGDIBrush(
                        Document.DocExtents, -Document.DocExtents.Left, -Document.DocExtents.Top);
                    g.FillRectangle(fillBrush, Document.DocExtents);
                    fillBrush.Dispose();
                }
                else
                {
                    System.Drawing.SolidBrush back =
                        new System.Drawing.SolidBrush(Document.BackColor);
                    g.FillRectangle(back, document.DocExtents);
                    back.Dispose();
                }
            }

            g.SmoothingMode = smoothMode;

            // Draw background image
            if (document.BackgroundImage != null)
            {
                if (document.BkgrImagePos >= ImageAlign.Document)
                {
                    if (options.EnableBackgroundImage)
                    {
                        DrawPicture(g, document.BackgroundImage, document.DocExtents,
                                    (ImageAlign)(document.BkgrImagePos - ImageAlign.Document));
                    }
                }
            }

            // Pass for single level shadowing
            if (options.EnableShadows &&
                document.ShadowsStyle == ShadowsStyle.OneLevel)
            {
                foreach (ChartObject obj in document.Objects)
                {
                    obj.Draw(g, true);
                }
            }

            // Pass for objects
            foreach (ChartObject obj in document.Objects)
            {
                if (options.EnableBackground &&
                    Document.ShadowsStyle == ShadowsStyle.ZOrder)
                {
                    obj.Draw(g, true);
                }

                obj.Draw(g, false);
            }

            document.ResetRenderOptions();
        }
Пример #12
0
        private void panelDrawArea_Paint(object sender, PaintEventArgs e)
        {
            if(drawingProcess)
            {
                tempDrawingArea = (Bitmap)snapshotDrawArea.Clone();

                g = Graphics.FromImage(tempDrawingArea);

                drawingPen = new Pen(brushColor, lineWidth);
                drawigBrush = new SolidBrush(fillColor);

                switch (selectedTool)
                {
                    case GraphicTool.Dot:

                        drawigBrush = new SolidBrush(brushColor);

                        g.FillRectangle(drawigBrush, xStartPoint, yStartPoint, lineWidth, lineWidth);

                        e.Graphics.DrawImageUnscaled(tempDrawingArea, 0, 0);

                        xStartPoint = xEndPoint;
                        yStartPoint = yEndPoint;

                        snapshotDrawArea = (Bitmap)tempDrawingArea.Clone();

                        break;

                    case GraphicTool.Pencil:

                        g.DrawLine(drawingPen, xStartPoint, yStartPoint, xEndPoint, yEndPoint);

                        e.Graphics.DrawImageUnscaled(tempDrawingArea, 0, 0);

                        xStartPoint = xEndPoint;
                        yStartPoint = yEndPoint;

                        snapshotDrawArea = (Bitmap)tempDrawingArea.Clone();

                        break;

                    case GraphicTool.Line:

                        g.DrawLine(drawingPen, xStartPoint, yStartPoint, xEndPoint, yEndPoint);

                        e.Graphics.DrawImageUnscaled(tempDrawingArea, 0, 0);

                        break;

                    case GraphicTool.Rectangle:

                        //Realization of universal drawing of a rectangle. FillRectangle and DrawRectangle are doesn't understand negative values of the size.
                        if (xStartPoint < xEndPoint && yStartPoint < yEndPoint)
                            {

                                g.FillRectangle(drawigBrush, new Rectangle(xStartPoint, yStartPoint, xEndPoint - xStartPoint, yEndPoint - yStartPoint));
                                g.DrawRectangle(drawingPen, new Rectangle(xStartPoint, yStartPoint, xEndPoint - xStartPoint, yEndPoint - yStartPoint));
                            }
                            else if (xStartPoint > xEndPoint && yStartPoint < yEndPoint)
                            {
                                g.FillRectangle(drawigBrush, new Rectangle(xStartPoint + (xEndPoint - xStartPoint), yStartPoint, Math.Abs(xEndPoint - xStartPoint), Math.Abs(yEndPoint - yStartPoint)));
                                g.DrawRectangle(drawingPen, new Rectangle(xStartPoint + (xEndPoint - xStartPoint), yStartPoint, Math.Abs(xEndPoint - xStartPoint), Math.Abs(yEndPoint - yStartPoint)));
                            }
                            else if (xStartPoint < xEndPoint && yStartPoint > yEndPoint)
                            {
                                g.FillRectangle(drawigBrush, new Rectangle(xStartPoint, yStartPoint + (yEndPoint - yStartPoint), Math.Abs(xEndPoint - xStartPoint), Math.Abs(yEndPoint - yStartPoint)));
                                g.DrawRectangle(drawingPen, new Rectangle(xStartPoint, yStartPoint + (yEndPoint - yStartPoint), Math.Abs(xEndPoint - xStartPoint), Math.Abs(yEndPoint - yStartPoint)));
                            }
                            else
                            {
                                g.FillRectangle(drawigBrush, new Rectangle(xEndPoint, yEndPoint, Math.Abs(xEndPoint - xStartPoint), Math.Abs(yEndPoint - yStartPoint)));
                                g.DrawRectangle(drawingPen, new Rectangle(xEndPoint, yEndPoint, Math.Abs(xEndPoint - xStartPoint), Math.Abs(yEndPoint - yStartPoint)));

                            }

                            e.Graphics.DrawImageUnscaled(tempDrawingArea, 0, 0);

                        break;

                    case GraphicTool.Ellipse:

                            g.DrawEllipse(drawingPen, new Rectangle(xStartPoint, yStartPoint, xEndPoint - xStartPoint, yEndPoint - yStartPoint));

                            g.FillEllipse(drawigBrush, new Rectangle(xStartPoint, yStartPoint, xEndPoint - xStartPoint, yEndPoint - yStartPoint));

                            e.Graphics.DrawImageUnscaled(tempDrawingArea, 0, 0);

                        break;

                    default:
                        break;
                }

                drawingPen.Dispose();
                drawigBrush.Dispose();
                g.Dispose();
            }
        }
Пример #13
0
        /// <summary>This method will paint the group title.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintGroupText(System.Drawing.Graphics g)
        {
            //Check if string has something-------------
            if (this.GroupTitle == string.Empty)
            {
                return;
            }
            //------------------------------------------

            //Set Graphics smoothing mode to Anit-Alias--
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //-------------------------------------------

            //Declare Variables------------------
            SizeF StringSize  = g.MeasureString(this.GroupTitle, this.Font);
            Size  StringSize2 = StringSize.ToSize();

            if (this.GroupImage != null)
            {
                StringSize2.Width += 18;
            }
            int ArcWidth  = this.RoundCorners;
            int ArcHeight = this.RoundCorners;
            int ArcX1     = 20;
            int ArcX2     = (StringSize2.Width + 34) - (ArcWidth + 1);
            int ArcY1     = 0;
            int ArcY2     = 24 - (ArcHeight + 1);

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             TextColorBrush  = new SolidBrush(this.ForeColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;
            //-----------------------------------

            //Check if shadow is needed----------
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle);        // Top Left
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle);        //Top Right
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle);        //Bottom Right
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle);         //Bottom Left
                ShadowPath.CloseAllFigures();

                //Paint Rounded Rectangle------------
                g.FillPath(ShadowBrush, ShadowPath);
                //-----------------------------------
            }
            //-----------------------------------

            //Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle);            // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle);            //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle);            //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle);             //Bottom Left
            path.CloseAllFigures();
            //-----------------------------------

            //Check if Gradient Mode is enabled--
            if (this.PaintGroupBox)
            {
                //Paint Rounded Rectangle------------
                g.FillPath(BackgroundBrush, path);
                //-----------------------------------
            }
            else
            {
                if (this.BackgroundGradientMode == GroupBoxGradientMode.None)
                {
                    //Paint Rounded Rectangle------------
                    g.FillPath(BackgroundBrush, path);
                    //-----------------------------------
                }
                else
                {
                    BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), this.BackgroundColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);

                    //Paint Rounded Rectangle------------
                    g.FillPath(BackgroundGradientBrush, path);
                    //-----------------------------------
                }
            }
            //-----------------------------------

            //Paint Borded-----------------------
            g.DrawPath(BorderPen, path);
            //-----------------------------------

            //Paint Text-------------------------
            int CustomStringWidth = (this.GroupImage != null) ? 44 : 28;

            g.DrawString(this.GroupTitle, this.Font, TextColorBrush, CustomStringWidth, 5);
            //-----------------------------------

            //Draw GroupImage if there is one----
            if (this.GroupImage != null)
            {
                g.DrawImage(this.GroupImage, 28, 4, 16, 16);
            }
            //-----------------------------------

            //Destroy Graphic Objects------------
            if (path != null)
            {
                path.Dispose();
            }
            if (BorderBrush != null)
            {
                BorderBrush.Dispose();
            }
            if (BorderPen != null)
            {
                BorderPen.Dispose();
            }
            if (BackgroundGradientBrush != null)
            {
                BackgroundGradientBrush.Dispose();
            }
            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
            }
            if (TextColorBrush != null)
            {
                TextColorBrush.Dispose();
            }
            if (ShadowBrush != null)
            {
                ShadowBrush.Dispose();
            }
            if (ShadowPath != null)
            {
                ShadowPath.Dispose();
            }
            //-----------------------------------
        }
Пример #14
0
        /// <summary>This method will paint the group title.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintGroupText(System.Drawing.Graphics g)
        {
            //Check if string has something-------------
            if (this.GroupTitle == string.Empty)
            {
                return;
            }
            //------------------------------------------

            //Set Graphics smoothing mode to Anit-Alias--
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //-------------------------------------------

            //Declare Variables------------------
            SizeF StringSize  = g.MeasureString(this.GroupTitle, this.Font);
            Size  StringSize2 = StringSize.ToSize();

            if (this.GroupImage != null)
            {
                StringSize2.Width += 18;
            }
            int ArcWidth  = this.RoundCorners;
            int ArcHeight = this.RoundCorners;
            int ArcX1     = 28 + GroupTitleOffset.X - 4;
            int ArcX2     = (StringSize2.Width + 34) - (ArcWidth + 1) + GroupTitleOffset.X;
            int ArcY1     = GroupTitleOffset.Y + 3;
            int ArcY2     = 24 - (ArcHeight + 1) + GroupTitleOffset.Y - 2;

            if (this.GroupTitleType == GroupTitleRenderType.Fill)
            {
                ArcX1 = 0 + GroupTitleOffset.X;                    // 20;
                ArcX2 = this.Width - 3 + GroupTitleOffset.X;       // (StringSize2.Width + 34) - (ArcWidth + 1);
                ArcY1 = GroupTitleOffset.Y;                        // 0
                ArcY2 = 24 - (ArcHeight + 7) + GroupTitleOffset.Y; // + 1
            }
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             TextColorBrush  = new SolidBrush(this.ForeColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;
            //-----------------------------------

            //Check if shadow is needed----------
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 180, SweepAngle);        // Top Left
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 270, SweepAngle);        //Top Right
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 360, SweepAngle);        //Bottom Right
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 90, SweepAngle);         //Bottom Left
                ShadowPath.CloseAllFigures();

                //Paint Rounded Rectangle------------
                g.FillPath(ShadowBrush, ShadowPath);
                //-----------------------------------
            }
            //-----------------------------------

            //Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, SweepAngle);            // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, SweepAngle);            //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, SweepAngle);            //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, SweepAngle);             //Bottom Left
            path.CloseAllFigures();
            //-----------------------------------

            //Check if Gradient Mode is enabled--
            if (this.PaintGroupBox)
            {
                //Paint Rounded Rectangle------------
                g.FillPath(BackgroundBrush, path);
                //-----------------------------------
            }
            else
            {
                if (this.BackgroundGradientMode == GroupBoxGradientMode.None)
                {
                    //Paint Rounded Rectangle------------
                    g.FillPath(BackgroundBrush, path);
                    //-----------------------------------
                }
                else
                {
                    BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), this.BackgroundColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);

                    //Paint Rounded Rectangle------------
                    g.FillPath(BackgroundGradientBrush, path);
                    //-----------------------------------
                }
            }
            //-----------------------------------

            //Paint Borded-----------------------
            if (this.GroupBoxBorder == GroupBoxBorderType.Full)
            {
                g.DrawPath(BorderPen, path);
            }
            else if (this.GroupBoxBorder == GroupBoxBorderType.HalfTop)
            {
                System.Drawing.Drawing2D.GraphicsPath halfPath2 = new System.Drawing.Drawing2D.GraphicsPath();
                halfPath2.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, SweepAngle);                          // Top Left
                halfPath2.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, SweepAngle);                          //Top Right
                halfPath2.AddArc(ArcX2, ArcY1 + (ArcY2 - ArcY1) * 0.5f, ArcWidth, ArcHeight, 360, SweepAngle); //Bottom Right
                halfPath2.AddArc(ArcX1, ArcY1 + (ArcY2 - ArcY1) * 0.5f, ArcWidth, ArcHeight, 90, SweepAngle);  //Bottom Left
                halfPath2.CloseAllFigures();

                g.DrawPath(BorderPen, halfPath2);
                g.FillRectangle(BackgroundBrush, ArcX1 - 1, ArcY1 + (ArcY2 - ArcY1) * 0.5f + 1, ArcX2, this.BorderThickness + 2);
            }
            //-----------------------------------

            //Paint Text-------------------------
            int CustomStringWidth = (this.GroupImage != null) ? 46 : 28;

            if (this.GroupTitleType == GroupTitleRenderType.Fill)
            {
                g.DrawString(this.GroupTitle, this.Font, TextColorBrush, (int)((this.Width * 0.5) - (StringSize2.Width * 0.5)) + GroupTitleOffset.X, 1 + GroupTitleOffset.Y); // 5
            }
            else if (this.GroupTitleType == GroupTitleRenderType.Standard)
            {
                g.DrawString(this.GroupTitle, this.Font, TextColorBrush, CustomStringWidth + GroupTitleOffset.X, 5 + GroupTitleOffset.Y - 1);
            }
            //-----------------------------------

            //Draw GroupImage if there is one----
            if (this.GroupImage != null)
            {
                g.DrawImage(this.GroupImage, 30 + GroupTitleOffset.X, 4 + GroupTitleOffset.Y, 16, 16);
            }
            //-----------------------------------

            //Destroy Graphic Objects------------
            if (path != null)
            {
                path.Dispose();
            }
            if (BorderBrush != null)
            {
                BorderBrush.Dispose();
            }
            if (BorderPen != null)
            {
                BorderPen.Dispose();
            }
            if (BackgroundGradientBrush != null)
            {
                BackgroundGradientBrush.Dispose();
            }
            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
            }
            if (TextColorBrush != null)
            {
                TextColorBrush.Dispose();
            }
            if (ShadowBrush != null)
            {
                ShadowBrush.Dispose();
            }
            if (ShadowPath != null)
            {
                ShadowPath.Dispose();
            }
            //-----------------------------------
        }
Пример #15
0
        /// <summary>This method will paint the group title.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintGroupText(System.Drawing.Graphics g)
        {
            //Check if string has something-------------
            if (this.GroupTitle == string.Empty)
            {
                return;
            }
            //------------------------------------------

            //Set Graphics smoothing mode to Anit-Alias--
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //-------------------------------------------

            //Declare Variables------------------
            SizeF stringSize  = g.MeasureString(this.GroupTitle, this.Font);
            Size  stringSize2 = stringSize.ToSize();


            if (this.GroupImage != null)
            {
                stringSize2.Width += 18;
            }
            //int ArcWidth = this.RoundCorners;
            //int ArcHeight = this.RoundCorners;
            int arcWidth  = this.HeaderRoundCorners;
            int arcHeight = this.HeaderRoundCorners;
            //int intX1 = 0;
            //int intX2 = 0;

            //int ArcX1 = 10;
            //int ArcX2 = (StringSize2.Width + 34) - (ArcWidth + 1);
            int ArcX1 = 20;
            int ArcX2 = (stringSize2.Width + 34) - (arcWidth + 1);
            int ArcY1 = 2;
            int ArcY2 = 22 - (arcHeight + 1);

            //Add by WZW 2008-12-16 增加GroupTitleBox对齐方式 ===Start
            int intMidX           = this.Size.Width / 2;
            int intMidX1          = (ArcX2 - ArcX1) / 2;
            int CustomStringWidth = (this.GroupImage != null) ? 44 : 28;

            _vXTrans = intMidX - intMidX1 - ArcX1;//X坐标平移距离
            int intTitleTextSpace = CustomStringWidth - ArcX1;

            //中间对齐
            if (this._vGroupBoxAlignMode == GroupBoxAlignMode.Center)
            {
                ArcX1             = intMidX - intMidX1;
                ArcX2             = intMidX + intMidX1;
                CustomStringWidth = ArcX1 + intTitleTextSpace;
            }
            else if (this._vGroupBoxAlignMode == GroupBoxAlignMode.Right)
            {
                ArcX1             = intMidX + intMidX - ArcX2;
                ArcX2             = ArcX1 + intMidX1 + intMidX1;
                CustomStringWidth = ArcX1 + intTitleTextSpace;
            }
            //标题与左边线距离
            ArcX1 -= this.TitleLeftSpace;
            ArcX2 -= this.TitleLeftSpace;

            //Add by WZW 2008-12-16 增加GroupTitleBox对齐方式 ===End
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             TextColorBrush  = new SolidBrush(this.ForeColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;
            //-----------------------------------

            //Check if shadow is needed----------
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), arcWidth, arcHeight, 180, GroupBoxConstants.SweepAngle); // Top Left
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), arcWidth, arcHeight, 270, GroupBoxConstants.SweepAngle); //Top Right
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), arcWidth, arcHeight, 360, GroupBoxConstants.SweepAngle); //Bottom Right
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), arcWidth, arcHeight, 90, GroupBoxConstants.SweepAngle);  //Bottom Left
                ShadowPath.CloseAllFigures();

                //Paint Rounded Rectangle------------
                g.FillPath(new SolidBrush(Color.Transparent), ShadowPath);
                //g.FillPath(ShadowBrush, ShadowPath);
                //-----------------------------------
            }
            //-----------------------------------
            //Edit BY WZW 2008-12-16
            //是否显示标题边框------
            if (this._vShowTileRectangle)
            {
                //创建title边框路径
                path.AddArc(ArcX1, ArcY1, arcWidth, arcHeight, 180, GroupBoxConstants.SweepAngle); // Top Left
                path.AddArc(ArcX2, ArcY1, arcWidth, arcHeight, 270, GroupBoxConstants.SweepAngle); //Top Right
                path.AddArc(ArcX2, ArcY2, arcWidth, arcHeight, 360, GroupBoxConstants.SweepAngle); //Bottom Right
                path.AddArc(ArcX1, ArcY2, arcWidth, arcHeight, 90, GroupBoxConstants.SweepAngle);  //Bottom Left
                path.CloseAllFigures();
                //画Title边框
                g.DrawPath(BorderPen, path);
            }

            //-----------------------------------

            //Check if Gradient Mode is enabled--
            if (this.PaintGroupBox)
            {
                //Paint Rounded Rectangle------------
                g.FillPath(BackgroundBrush, path);
                //-----------------------------------
            }
            else
            {
                if (this.BackgroundGradientMode == GroupBoxGradientMode.None)
                {
                    //Paint Rounded Rectangle------------
                    g.FillPath(BackgroundBrush, path);
                    //-----------------------------------
                }
                else
                {
                    BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), this.BackgroundColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);

                    //Paint Rounded Rectangle------------
                    g.FillPath(BackgroundGradientBrush, path);
                    //-----------------------------------
                }
            }
            //-----------------------------------

            //绘制title文字-------------------------
            //int CustomStringWidth = (this.GroupImage != null) ? 44 : 28;
            //if(this.GroupImage!=null)
            //{
            //    CustomStringWidth += 2;
            //}

            //g.DrawString(this.GroupTitle, this.Font, TextColorBrush, CustomStringWidth, 5);

            // g.DrawString(this.GroupTitle, this.Font, TextColorBrush, CustomStringWidth-this.TitleLeftSpace-2, 5);
            g.DrawString(this.GroupTitle, this.Font, TextColorBrush, CustomStringWidth - this.TitleLeftSpace, 5);
            //-----------------------------------

            //Draw GroupImage if there is one----
            if (this.GroupImage != null)
            {
                //因增加了标题对齐功能,需修改X坐标值 By  WZW 2008-12-17
                g.DrawImage(this.GroupImage, ArcX1 + 5, 4, 16, 16);
            }

            //释放资源------------
            if (path != null)
            {
                path.Dispose();
            }
            if (BorderBrush != null)
            {
                BorderBrush.Dispose();
            }
            if (BorderPen != null)
            {
                BorderPen.Dispose();
            }
            if (BackgroundGradientBrush != null)
            {
                BackgroundGradientBrush.Dispose();
            }
            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
            }
            if (TextColorBrush != null)
            {
                TextColorBrush.Dispose();
            }
            if (ShadowBrush != null)
            {
                ShadowBrush.Dispose();
            }
            if (ShadowPath != null)
            {
                ShadowPath.Dispose();
            }
        }
Пример #16
0
 // Dispose of a brush
 public static void DisposeBrush(Brush brush)
 {
     #if true
     brush.Dispose();
     #endif
 }
Пример #17
0
 private Brush CacheBrush(ref Brush brInstance, Brush brNew)
 {
     if (brInstance != null)
         brInstance.Dispose();
     brInstance = brNew;
     return brNew;
 }
Пример #18
0
 internal static void DrawBackground(Graphics g, RectangleF rect, Brush fillBrush, CornerShape bShape,
     int cornerRadius, Region excRegion)
 {
     if (excRegion != null)
     {
         g.ExcludeClip(excRegion);
     }
     var path = GetDrawingPath(rect, bShape, cornerRadius);
     g.FillPath(fillBrush, path);
     fillBrush.Dispose();
     path.Dispose();
 }
Пример #19
0
 public void Dispose()
 {
     b.Dispose();
 }
Пример #20
0
        /// <summary>
        /// Render the filled <see cref="Symbol"/> to the specified <see cref="Graphics"/>
        /// device at the specified location.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="x">The x position of the center of the symbol in
        /// pixel units</param>
        /// <param name="y">The y position of the center of the symbol in
        /// pixel units</param>
        /// <param name="scaleFactor">
        /// The scaling factor for the features of the graph based on the <see cref="GraphPane.BaseDimension"/>.  This
        /// scaling factor is calculated by the <see cref="GraphPane.CalcScaleFactor"/> method.  The scale factor
        /// represents a linear multiple to be applied to font sizes, symbol sizes, etc.
        /// </param>		
        /// <param name="pen">A pen with attributes of <see cref="Color"/> and
        /// <see cref="ZedGraph.Border.PenWidth"/> for this symbol</param>
        /// <param name="brush">A brush with the <see cref="Color"/> attribute
        /// for this symbol</param>
        public void FillPoint( Graphics g, float x, float y, double scaleFactor,
			Pen pen, Brush brush )
        {
            float	scaledSize = (float) ( this.size * scaleFactor ),
                hsize = scaledSize / 2,
                hsize4 = scaledSize / 3,
                hsize41 = hsize4 + 1,
                hsize1 = hsize + 1;

            PointF[]	polyPt = new PointF[5];
            RectangleF	rect = new RectangleF( x-hsize, y-hsize, scaledSize, scaledSize );
            if ( this.fill.Type == FillType.Brush )
                brush = this.fill.MakeBrush( rect );

            switch( this.type == SymbolType.Default ? Default.Type : this.type )
            {
                case SymbolType.Square:
                    g.FillRectangle( brush, rect );
                    break;
                case SymbolType.Diamond:
                    polyPt[0].X = x;
                    polyPt[0].Y = y-hsize;
                    polyPt[1].X = x+hsize;
                    polyPt[1].Y = y;
                    polyPt[2].X = x;
                    polyPt[2].Y = y+hsize;
                    polyPt[3].X = x-hsize;
                    polyPt[3].Y = y;
                    polyPt[4] = polyPt[0];
                    g.FillPolygon( brush, polyPt );
                    break;
                case SymbolType.Triangle:
                    polyPt[0].X = x;
                    polyPt[0].Y = y-hsize;
                    polyPt[1].X = x+hsize;
                    polyPt[1].Y = y+hsize;
                    polyPt[2].X = x-hsize;
                    polyPt[2].Y = y+hsize;
                    polyPt[3] = polyPt[0];
                    g.FillPolygon( brush, polyPt );
                    break;
                case SymbolType.Circle:
                    g.FillEllipse( brush, rect );
                    break;
                case SymbolType.XCross:
                    g.FillRectangle( brush, x-hsize4, y-hsize4,
                        hsize4+hsize41, hsize4+hsize41 );
                    g.DrawLine( pen, x-hsize, y-hsize, x+hsize1, y+hsize1 );
                    g.DrawLine( pen, x+hsize, y-hsize, x-hsize1, y+hsize1 );
                    break;
                case SymbolType.Plus:
                    g.FillRectangle( brush, x-hsize4, y-hsize4,
                        hsize4+hsize41, hsize4+hsize41 );
                    g.DrawLine( pen, x, y-hsize, x, y+hsize1 );
                    g.DrawLine( pen, x-hsize, y, x+hsize1, y );
                    break;
                case SymbolType.Star:
                    g.FillRectangle( brush, x-hsize4, y-hsize4,
                        hsize4+hsize41, hsize4+hsize41 );
                    g.DrawLine( pen, x, y-hsize, x, y+hsize1 );
                    g.DrawLine( pen, x-hsize, y, x+hsize1, y );
                    g.DrawLine( pen, x-hsize, y-hsize, x+hsize1, y+hsize1 );
                    g.DrawLine( pen, x+hsize, y-hsize, x-hsize1, y+hsize1 );
                    break;
                case SymbolType.TriangleDown:
                    polyPt[0].X = x;
                    polyPt[0].Y = y+hsize;
                    polyPt[1].X = x+hsize;
                    polyPt[1].Y = y-hsize;
                    polyPt[2].X = x-hsize;
                    polyPt[2].Y = y-hsize;
                    polyPt[3] = polyPt[0];
                    g.FillPolygon( brush, polyPt );
                    break;
            }

            if ( this.fill.Type == FillType.Brush )
                brush.Dispose();
        }
 void DrawString(Graphics g, Font font, Brush brush, string s, int x, int y)
 {
     foreach (char ch in s)
     {
         g.DrawString(ch.ToString(), font, brush, x, y);
         x += _charWidth;
     }
     brush.Dispose();
 }
Пример #22
0
        /// <summary>
        /// 重绘控件
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (BackImg == null)
            {
                base.OnPaint(e);
                return;
            }

            int i = (int)state;
            if (this.Focused && state != State.MouseDown && _IsTabFocus==true) i = 5;
            if (!this.Enabled) i = 4;
            Rectangle rc = this.ClientRectangle;
            Graphics g = e.Graphics;

            base.InvokePaintBackground(this, new PaintEventArgs(e.Graphics, base.ClientRectangle));
            try
            {
                if (BackImg != null)
                {
                    if (_BacklightLTRB !=Rectangle.Empty)
                    {

                        ImageDrawRect.DrawRect(g, BackImg, rc, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height),i,5);
                    }
                    else
                    {
                        ImageDrawRect.DrawRect(g, BackImg, rc, Rectangle.FromLTRB(10, 10, 10, 10), i, 5);
                    }

                }
            }
            catch
            { }

            Image img = null;
            Size txts, imgs;

            txts = Size.Empty;
            imgs = Size.Empty;

            if (this.Image != null)
            {
                img = this.Image;
            }
            else if (this.ImageList != null && this.ImageIndex != -1)
            {
                img = this.ImageList.Images[this.ImageIndex];
            }

            if (img != null)
            {
                imgs.Width = img.Width;
                imgs.Height = img.Height;
            }

            StringFormat format1;
            using (format1 = new StringFormat())
            {
                format1.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
                SizeF ef1 = g.MeasureString(this.Text, this.Font, new SizeF((float)rc.Width, (float)rc.Height), format1);
                txts = Size.Ceiling(ef1);
            }

            rc.Inflate(-4, -4);
            if (imgs.Width * imgs.Height != 0)
            {
                Rectangle imgr = rc;
                imgr = AlClass.ImageDrawRect.HAlignWithin(imgs, imgr, this.ImageAlign);
                imgr = AlClass.ImageDrawRect.VAlignWithin(imgs, imgr, this.ImageAlign);
                if (!this.Enabled)
                {
                    ControlPaint.DrawImageDisabled(g, img, imgr.Left, imgr.Top, this.BackColor);
                }
                else
                {
                    g.DrawImage(img, imgr.Left, imgr.Top, img.Width, img.Height);
                }
            }

            Rectangle txtr = rc;
            txtr = AlClass.ImageDrawRect.HAlignWithin(txts, txtr, this.TextAlign);
            txtr = AlClass.ImageDrawRect.VAlignWithin(txts, txtr, this.TextAlign);

            format1 = new StringFormat();
            format1.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;

            if (this.RightToLeft == RightToLeft.Yes)
            {
                format1.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
            }
            brush = new SolidBrush(this.ForeColor);
            g.DrawString(this.Text, this.Font, brush, (RectangleF)txtr, format1);
            brush.Dispose();
        }
Пример #23
0
 //*************************************************************************
 //  Method: DisposeBrush()
 //
 /// <summary>
 /// Disposes of a brush.
 /// </summary>
 ///
 /// <param name="oBrush">
 /// Brush to dispose.  Can be null.  Gets set to null.
 /// </param>
 ///
 /// <remarks>
 /// If <paramref name="oBrush" /> isn't null, this method calls the Dispose
 /// method on <paramref name="oBrush" />, then sets it to null.
 /// </remarks>
 //*************************************************************************
 public static void DisposeBrush(
     ref Brush oBrush
     )
 {
     if (oBrush != null)
     {
     oBrush.Dispose();
     oBrush = null;
     }
 }
Пример #24
0
 private static void CleanBrush(ref Brush brush, Color color)
 {
     if (brush != null)
     {
         if (!color.IsSystemColor)
         {
             brush.Dispose();
             brush = null;
         }
     }
 }
Пример #25
0
 DisposeBrush
 (
     ref Brush oBrush
 )
 {
     if (oBrush != null)
     {
         oBrush.Dispose();
         oBrush = null;
     }
 }
Пример #26
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);
            Graphics g = pevent.Graphics;
            _paintBrush = new LinearGradientBrush(this.ClientRectangle, this.StartColor, this.EndColor, lgm);

            g.FillRectangle(_paintBrush, this.ClientRectangle);
            _paintBrush = new SolidBrush(this.ForeColor);

            SizeF size = pevent.Graphics.MeasureString(Text, Font);
            PointF pt = new PointF((Width - size.Width) / 2, (Height - size.Height) / 2);
            if (clicked)
            {
                pt.X += 2;
                pt.Y += 2;
            }
            pevent.Graphics.DrawString(Text, Font, _paintBrush, pt);
            _paintBrush.Dispose();
               // this._centerPoint = new PointF(this.Width / 2, this.Height / 2);
            //g.DrawString(this.Text, this.Font, _paintBrush, _centerPoint.X, _centerPoint.Y - 5, _sf);
            //paint_Border(pevent);
        }