Ejemplo n.º 1
0
 private void clearButton_Click(object sender, System.EventArgs e)
 {
     // Clear the Panel display.
     mousePath.Dispose();
     mousePath = new System.Drawing.Drawing2D.GraphicsPath();
     panel1.Invalidate();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 划圆角边框
        /// </summary>
        /// <param name="g">绘制的图形</param>
        /// <param name="p">颜色和粗细</param>
        /// <param name="X">绘制图形的初始X</param>
        /// <param name="Y">绘制图形的初始Y</param>
        /// <param name="width">绘制图形的宽度</param>
        /// <param name="height">绘制图形的高度</param>
        /// <param name="radius">绘制图形的弧度</param>
        public void DrawRoundRect(Graphics g, Pen p, float X, float Y, float width, float height, float radius)
        {
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

            gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);

            gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);

            gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));

            gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);

            gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);

            gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);

            gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);

            gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);

            gp.CloseFigure();

            g.DrawPath(p, gp);

            gp.Dispose();
        }
Ejemplo n.º 3
0
        public List <Point> ToPoints(
            float angle,
            Rectangle rect)
        {
            // Create a GraphicsPath.
            System.Drawing.Drawing2D.GraphicsPath path =
                new System.Drawing.Drawing2D.GraphicsPath();

            path.AddRectangle(rect);

            // Declare a matrix that will be used to rotate the text.
            System.Drawing.Drawing2D.Matrix rotateMatrix =
                new System.Drawing.Drawing2D.Matrix();

            // Set the rotation angle and starting point for the text.
            rotateMatrix.RotateAt(180.0F, new PointF(10.0F, 100.0F));

            // Transform the text with the matrix.
            path.Transform(rotateMatrix);

            List <Point> results = new List <Point>();

            foreach (PointF p in path.PathPoints)
            {
                results.Add(new Point((int)p.X, (int)p.Y));
            }

            path.Dispose();

            return(results);
        }
Ejemplo n.º 4
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

            SolidBrush brushWhite = new SolidBrush(Color.White);
            //e.Graphics.FillRectangle(brushWhite, 0, 0,
            //this.ClientSize.Width, this.ClientSize.Height);

            FontFamily   fontFamily = new FontFamily("Arial");
            StringFormat strformat  = new StringFormat();
            string       szbuf      = txtbTrans.Text.ToString();

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddString(szbuf, fontFamily,
                           (int)FontStyle.Regular, 36.0f, new Point(10, 10), strformat);
            Pen pen = new Pen(Color.FromArgb(0, 0, 0), 6);

            pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
            e.Graphics.DrawPath(pen, path);
            SolidBrush brush = new SolidBrush(Color.FromArgb(255, 255, 0));

            e.Graphics.FillPath(brush, path);

            brushWhite.Dispose();
            fontFamily.Dispose();
            path.Dispose();
            pen.Dispose();
            brush.Dispose();
            e.Graphics.Dispose();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 绘制圆角
        /// </summary>
        /// <param name="g"></param>
        /// <param name="p"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="radius"></param>
        public static void DrawRoundRect(Graphics g, Pen p, Brush brush,float X, float Y, float width, float height, float radius)
        {
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

            gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);

            gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);

            gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));

            gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);

            gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);

            gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);

            gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);

            gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);

            gp.CloseFigure();

            g.DrawPath(p, gp);

            g.FillPath(brush, gp);

            gp.Dispose();
        }
Ejemplo n.º 6
0
 public override void Dispose()
 {
     if (p != null)
     {
         p.Dispose();
         p = null;
     }
 }
Ejemplo n.º 7
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            MindFusion.FlowChartX.ShapeTemplate shape =
                e.Value as MindFusion.FlowChartX.ShapeTemplate;

            if (shape == null)
            {
                return;
            }

            // Draw the shape
            RectangleF rect = new RectangleF(
                (float)e.Bounds.Left, (float)e.Bounds.Top,
                (float)e.Bounds.Width - 1, (float)e.Bounds.Height - 1);

            rect.Inflate(-2, -2);
            MindFusion.FlowChartX.ShapeTemplate.PathData data =
                shape.initData(rect, 0);
            System.Drawing.Brush brush =
                new System.Drawing.SolidBrush(Color.LightSteelBlue);
            System.Drawing.Pen pen =
                new System.Drawing.Pen(Color.Black);

            System.Drawing.Drawing2D.SmoothingMode mode =
                e.Graphics.SmoothingMode;
            e.Graphics.SmoothingMode =
                System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            System.Drawing.Drawing2D.GraphicsPath path =
                shape.getPath(data, 0);
            e.Graphics.FillPath(brush, path);
            e.Graphics.DrawPath(pen, path);
            path.Dispose();

            path = shape.getDecorationPath(data, 0);
            if (path != null)
            {
                e.Graphics.DrawPath(pen, path);
                path.Dispose();
            }

            e.Graphics.SmoothingMode = mode;

            pen.Dispose();
            brush.Dispose();
        }
Ejemplo n.º 8
0
 public void Dispose()
 {
     if (_path != null)
     {
         _path.Dispose();
         _path = null;
     }
 }
Ejemplo n.º 9
0
        void DefaultPaintCell(GB_GridView.CellPaintEventArgs e)
        {
            if (m_cellPaint != null)
            {
                m_cellPaint(this, e);
                if (e.Handled)
                {
                    return;
                }
            }
            GDI.Brush brush = m_background;

            if (e.ColumnIndex == m_mouseColumn)
            {
                brush = m_hoverbackground;
            }

            e.Graphics.FillRectangle(brush, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1);
            //e.Graphics.DrawRectangle(System.Drawing.Pens.Black, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1);
            // 判断下有没有SortGraph
            System.Windows.Forms.SortOrder so = GetColumnSortGraph(e.ColumnIndex);
            if (so != System.Windows.Forms.SortOrder.None)
            {
                GDI.Drawing2D.GraphicsPath path = new GDI.Drawing2D.GraphicsPath();
                // 创建一个5*9的三角形
                GDI.Point[] ptList = null;

                if (so == System.Windows.Forms.SortOrder.Ascending) // 箭头朝上
                {
                    ptList = new GDI.Point[] {
                        new GDI.Point(5, 0), new GDI.Point(0, 5), new GDI.Point(9, 5)
                    };
                }
                else
                {
                    ptList = new GDI.Point[] {
                        new GDI.Point(4, 5), new GDI.Point(0, 0), new GDI.Point(9, 0)
                    };
                }
                GDI.Size offset = new GDI.Size(e.Bounds.Right - e.Bounds.Width / 2 - 5, e.Bounds.Top);
                path.AddLines(new GDI.Point[] { GDI.Point.Add(ptList[0], offset), GDI.Point.Add(ptList[1], offset), GDI.Point.Add(ptList[2], offset) });
                e.Graphics.FillPath(m_foreground, path);
                path.Dispose();
            }

            if (e.Value != null)
            {
                GDI.StringFormat sf = new System.Drawing.StringFormat();
                sf.Alignment     = System.Drawing.StringAlignment.Center;
                sf.FormatFlags   = System.Drawing.StringFormatFlags.NoWrap;
                sf.LineAlignment = System.Drawing.StringAlignment.Center;
                sf.Trimming      = System.Drawing.StringTrimming.EllipsisCharacter;
                System.Drawing.Text.TextRenderingHint hint = e.Graphics.TextRenderingHint;
                e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
                e.Graphics.DrawString(e.Value.ToString(), Font, m_foreground, e.Bounds, sf);
                e.Graphics.TextRenderingHint = hint;
            }
        }
Ejemplo n.º 10
0
        public override void Draw(System.Drawing.Rectangle renderingRect, System.Drawing.Graphics g, ICoordinateMapper coordinateMapper)
        {
            if (g == null)
            {
                throw new System.ArgumentNullException("g");
            }
            if (coordinateMapper == null)
            {
                throw new System.ArgumentNullException("coordinateMapper");
            }

            System.Drawing.Drawing2D.GraphicsPath drawPath = CreateViewportPath(coordinateMapper);
            System.Drawing.Pen pen = CreateViewportPen(coordinateMapper);

            System.Drawing.Drawing2D.SmoothingMode oldSmoothingMode = g.SmoothingMode;
            try
            {
                switch (base.DrawMode)
                {
                case VObjectDrawMode.Draft:
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
                    break;

                case VObjectDrawMode.Normal:
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    break;

                default:
                    throw new Aurigma.GraphicsMill.UnexpectedException(StringResources.GetString("ExStrUnexpectedDrawMode"));
                }

                if (_brush != null)
                {
                    AdaptBrushToViewport(coordinateMapper);
                    try
                    {
                        g.FillPath(_brush, drawPath);
                    }
                    finally
                    {
                        RestoreBrush();
                    }
                }
                if (pen != null)
                {
                    g.DrawPath(pen, drawPath);
                }
            }
            finally
            {
                if (pen != null)
                {
                    pen.Dispose();
                }
                drawPath.Dispose();
                g.SmoothingMode = oldSmoothingMode;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Render plot view region of line chart component.
        /// </summary>
        /// <param name="dc">Platform no-associated drawing context.</param>
        protected override void OnPaint(DrawingContext dc)
        {
            var axisChart = base.Chart as AxisChart;

            if (axisChart == null)
            {
                return;
            }

            var ds = Chart.DataSource;

            var g          = dc.Graphics;
            var clientRect = this.ClientBounds;


            var path = new System.Drawing.Drawing2D.GraphicsPath();

            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style     = axisChart.DataSerialStyles[r];
                var lastPoint = new System.Drawing.PointF(axisChart.PlotColumnPoints[0], axisChart.ZeroHeight);

                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    var pt = axisChart.PlotDataPoints[r][c];

                    System.Drawing.PointF point;

                    if (pt.hasValue)
                    {
                        point = new System.Drawing.PointF(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight - pt.value);
                    }
                    else
                    {
                        point = new System.Drawing.PointF(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight);
                    }

                    path.AddLine(lastPoint, point);
                    lastPoint = point;
                }

                var endPoint = new System.Drawing.PointF(axisChart.PlotColumnPoints[ds.CategoryCount - 1], axisChart.ZeroHeight);

                if (lastPoint != endPoint)
                {
                    path.AddLine(lastPoint, endPoint);
                }

                path.CloseFigure();

                g.FillPath(style.FillColor, path);

                path.Reset();
            }

            path.Dispose();
        }
Ejemplo n.º 12
0
 //根据验证字符串生成最终图象
 public void CreateImage(string str_ValidateCode)
 {
     //int int_ImageWidth = str_ValidateCode.Length * 13;
     //int width = int_ImageWidth;
     int int_ImageWidth = this.Width;
     int width = int_ImageWidth;
     int height = this.Height;
     string filePath = Server.MapPath(imgDir);
     Bitmap bgImg = (Bitmap)Bitmap.FromFile(GetRandomFile(filePath));
     Random newRandom = new Random();
     // 图高20px
     Bitmap theBitmap = new Bitmap(width, height);
     Graphics theGraphics = Graphics.FromImage(theBitmap);
     theGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
     theGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
     theGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     theGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
     // 白色背景
     //theGraphics.Clear(Color.White);
     theGraphics.DrawImage(bgImg, new Rectangle(0, 0, width, height), new Rectangle(0, 0, bgImg.Width, bgImg.Height), GraphicsUnit.Pixel);
     // 灰色边框
     //theGraphics.DrawRectangle(new Pen(Color.LightGray, 1), 0, 0, int_ImageWidth - 1, height - 1);
     //13pt的字体
     float fontSize = this.Height * 1.0f / 1.38f;
     float fontSpace = fontSize / 7f;
     Font theFont = new Font("Arial", fontSize);
     System.Drawing.Drawing2D.GraphicsPath gp = null;
     System.Drawing.Drawing2D.Matrix matrix;
     for (int int_index = 0; int_index < str_ValidateCode.Length; int_index++)
     {
         string str_char = str_ValidateCode.Substring(int_index, 1);
         Brush newBrush = new SolidBrush(GetRandomColor());
         Point thePos = new Point((int)(int_index * (fontSize + fontSpace) + newRandom.Next(3)), 1 + newRandom.Next(3));
         gp = new System.Drawing.Drawing2D.GraphicsPath();
         gp.AddString(str_char, theFont.FontFamily, 0, fontSize, thePos, new StringFormat());
         matrix = new System.Drawing.Drawing2D.Matrix();
         int angle = GetRandomAngle();
         PointF centerPoint = new PointF(thePos.X + fontSize / 2, thePos.Y + fontSize / 2);
         matrix.RotateAt(angle, centerPoint);
         theGraphics.Transform = matrix;
         theGraphics.DrawPath(new Pen(Color.White, 2f), gp);
         //theGraphics.FillPath(new SolidBrush(Color.Black), gp);
         theGraphics.FillPath(new SolidBrush(GetRandomColor()), gp);
         theGraphics.ResetTransform();
     }
     if (gp != null) gp.Dispose();
     // 将生成的图片发回客户端
     MemoryStream ms = new MemoryStream();
     theBitmap.Save(ms, ImageFormat.Png);
     Response.ClearContent(); //需要输出图象信息 要修改HTTP头 
     Response.ContentType = "image/gif";
     Response.BinaryWrite(ms.ToArray());
     theGraphics.Dispose();
     theBitmap.Dispose();
     Response.End();
 }
Ejemplo n.º 13
0
        private void rectangleShape2_MouseDown(object sender,
                                               System.Windows.Forms.MouseEventArgs e)
        {
            Point mouseDownLocation = new Point(e.X + rectangleShape2.Left,
                                                e.Y + rectangleShape2.Top);

            // Clear the previous line.
            mousePath.Dispose();
            mousePath = new System.Drawing.Drawing2D.GraphicsPath();
            rectangleShape2.Invalidate();
            // Add a line to the graphics path.
            mousePath.AddLine(mouseDownLocation, mouseDownLocation);
        }
Ejemplo n.º 14
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         penGraph.Dispose();
         penLine.Dispose();
         brushGraph.Dispose();
         brushText.Dispose();
         pathGraph.Dispose();
         if (components != null)
         {
             components.Dispose();
         }
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 15
0
 public static void DrawRoundedRectangleOutlined(Graphics gfxObj, Pen penObj, float X, float Y, float RectWidth, float RectHeight, float CornerRadius)
 {
     RectWidth--;
     RectHeight--;
     System.Drawing.Drawing2D.GraphicsPath gfxPath = new System.Drawing.Drawing2D.GraphicsPath();
     gfxPath.AddLine(X + CornerRadius, Y, X + RectWidth - (CornerRadius * 2), Y);
     gfxPath.AddArc(X + RectWidth - (CornerRadius * 2), Y, CornerRadius * 2, CornerRadius * 2, 270, 90);
     gfxPath.AddLine(X + RectWidth, Y + CornerRadius, X + RectWidth, Y + RectHeight - (CornerRadius * 2));
     gfxPath.AddArc(X + RectWidth - (CornerRadius * 2), Y + RectHeight - (CornerRadius * 2), CornerRadius * 2, CornerRadius * 2, 0, 90);
     gfxPath.AddLine(X + RectWidth - (CornerRadius * 2), Y + RectHeight, X + CornerRadius, Y + RectHeight);
     gfxPath.AddArc(X, Y + RectHeight - (CornerRadius * 2), CornerRadius * 2, CornerRadius * 2, 90, 90);
     gfxPath.AddLine(X, Y + RectHeight - (CornerRadius * 2), X, Y + CornerRadius);
     gfxPath.AddArc(X, Y, CornerRadius * 2, CornerRadius * 2, 180, 90);
     gfxPath.CloseFigure();
     gfxObj.DrawPath(penObj, gfxPath);
     gfxPath.Dispose();
 }
Ejemplo n.º 16
0
 private void Form1_Load(object sender, EventArgs e)
 {
     timer1.Start();
     timer2.Start();
     timer3.Start();
     ball           = new PictureBox();
     ball.Location  = new Point(20, 150);
     ball.Size      = new Size(10, 10);
     ball.BackColor = Color.Red;
     System.Drawing.Drawing2D.GraphicsPath g = new System.Drawing.Drawing2D.GraphicsPath();
     g.AddEllipse(new Rectangle(0, 0, 10, 10));
     ball.Region = new Region(g);
     g.Dispose();
     this.Controls.Add(ball);
     toolStripStatusLabel1.Text = "  ";
     toolStripStatusLabel2.Text = "Playing";
 }
Ejemplo n.º 17
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            _theGame.Draw(e.Graphics, _interp);

            // draw fps
            var path = new System.Drawing.Drawing2D.GraphicsPath();
            Pen p = new Pen(Color.Black, 2.0f);
            path.AddString(String.Format("FPS: {0}", _fpsCalc.Fps),
                           FontFamily.GenericSansSerif, 0, 24f,
                           Point.Empty, StringFormat.GenericTypographic);
            e.Graphics.DrawPath(p, path);
            e.Graphics.FillPath(Brushes.White, path);
            p.Dispose();
            path.Dispose();

            _fpsCalc.DrawFrame(); // used for calculating FPS
        }
Ejemplo n.º 18
0
 private void DrawCurvedPanel(System.Windows.Forms.PaintEventArgs pevent)
 {
     pevent.Graphics.Clear(GetColorBehindCurve());
     pevent.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
     pevent.Graphics.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.High;
     pevent.Graphics.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
     pevent.Graphics.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     System.Drawing.Drawing2D.GraphicsPath graphicsPath = GetCurvedPath();
     System.Drawing.Brush brush = GetBackgroundBrush(pevent);
     pevent.Graphics.FillPath(brush, graphicsPath);
     brush.Dispose();
     if ((_BorderStyle == System.Windows.Forms.BorderStyle.FixedSingle) && (_BorderWidth > 0))
     {
         System.Drawing.Pen pen = GetBorderPen(_BorderColour, _BorderWidth);
         pevent.Graphics.DrawPath(pen, graphicsPath);
         pen.Dispose();
     }
     graphicsPath.Dispose();
 }
Ejemplo n.º 19
0
        private void set_jimaku()
        {
            System.Drawing.Drawing2D.GraphicsPath path =
                new System.Drawing.Drawing2D.GraphicsPath();

            int style = 0;

            style += (text.Font.Bold) ? (int)FontStyle.Bold : (int)FontStyle.Regular;
            style += (text.Font.Italic) ? (int)FontStyle.Italic : (int)FontStyle.Regular;
            style += (text.Font.Underline) ? (int)FontStyle.Underline : (int)FontStyle.Regular;
            style += (text.Font.Strikeout) ? (int)FontStyle.Strikeout : (int)FontStyle.Regular;
            path.AddString(text.Text, text.Font.FontFamily,
                           style,
                           (float)(text.Font.SizeInPoints / 0.75), new Point(0, 0),
                           StringFormat.GenericDefault);
            myForm.Region    = new Region(path);
            myForm.BackColor = text.ForeColor;
            path.Dispose();
        }
Ejemplo n.º 20
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            _theGame.Draw(e.Graphics, _interp);

            // draw fps
            var path = new System.Drawing.Drawing2D.GraphicsPath();
            Pen p    = new Pen(Color.Black, 2.0f);

            path.AddString(String.Format("FPS: {0}", _fpsCalc.Fps),
                           FontFamily.GenericSansSerif, 0, 24f,
                           Point.Empty, StringFormat.GenericTypographic);
            e.Graphics.DrawPath(p, path);
            e.Graphics.FillPath(Brushes.White, path);
            p.Dispose();
            path.Dispose();

            _fpsCalc.DrawFrame(); // used for calculating FPS
        }
Ejemplo n.º 21
0
        private void DrawCharactorsOutLines(ref Graphics g)
        {
            System.Drawing.Drawing2D.GraphicsPath oOutline = new System.Drawing.Drawing2D.GraphicsPath();
            int iSymbolIndex = 0;

            g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    string sCharactor = new string(Convert.ToChar(iSymbolIndex++), 1);
                    oOutline = new System.Drawing.Drawing2D.GraphicsPath();
                    oOutline.AddString(sCharactor, this._curFont.FontFamily, (int)FontStyle.Regular, this._fontSize - 7, new Point(j * this._fontSize, i * this._fontSize), StringFormat.GenericDefault);
                    g.FillPath(new SolidBrush(Color.Black), oOutline);
                    oOutline.Dispose();
                    //g.DrawString(sCharactor, this._curFont, new SolidBrush(Color.Black), new RectangleF(j * this._fontSize , i * this._fontSize, this._fontSize, this._fontSize), StringFormat.GenericTypographic);
                }
            }
        }
Ejemplo n.º 22
0
        private void DrawRoundRect(Graphics g, float x, float y, float width, float height, float radius, Color color)
        {
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            gp.AddLine(x + radius, y, x + width - (radius * 2), y);                  //追加线段
            gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); //追加椭圆弧
            gp.AddLine(x + width, y + radius, x + width, y + height - (radius * 2));
            gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
            gp.AddLine(x + width - (radius * 2), y + height, x + radius, y + height);
            gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
            gp.AddLine(x, y + height - (radius * 2), x, y + radius);
            gp.AddArc(x, y, radius * 2, radius * 2, 180, 90);
            gp.CloseFigure();
            Pen pen = new System.Drawing.Pen(ColorTranslator.FromHtml("#CCCCCC"), 1);

            g.DrawPath(pen, gp);
            Rectangle rec   = new Rectangle((int)x, (int)y, (int)width, (int)height);
            Brush     brush = new System.Drawing.SolidBrush(color);

            g.FillPath(brush, gp);
            gp.Dispose();
        }
Ejemplo n.º 23
0
        public void DrawDottedCurve(List <System.Drawing.Point> points, int dotWidth, Color color, float thickness, float worldScale)
        {
            if (dotWidth < 1)
            {
                dotWidth = 1;
            }

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding);
            path.AddCurve(points.ToArray());
            path.Flatten();
            PointF[] finalPoints = path.PathPoints;
            path.Dispose();

            //Convert point to vector2
            if (finalPoints.Length < 2)
            {
                return;
            }

            float finalThickness = thickness * worldScale;

            if (finalThickness < 1)
            {
                finalThickness = 1;
            }

            Vector2D vectorThickNess = new Vector2D(finalThickness, finalThickness);

            for (int i = 1; i < finalPoints.Length; i++)
            {
                if (i % dotWidth == 0)
                {
                    Gorgon.CurrentRenderTarget.Line((int)((float)finalPoints[i - 1].X * worldScale), (int)((float)finalPoints[i - 1].Y * worldScale),
                                                    (int)(((float)finalPoints[i].X - (float)finalPoints[i - 1].X) * worldScale),
                                                    (int)(((float)finalPoints[i].Y - (float)finalPoints[i - 1].Y) * worldScale), color, vectorThickNess);
                }
            }
        }
Ejemplo n.º 24
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            System.Drawing.Point[] DropPoints  = new System.Drawing.Point[] { new Point(0, 0), new Point(11, 0), new Point(5, 6) };
            System.Drawing.Point[] ClosePoints = new System.Drawing.Point[] { new Point(0, 0), new Point(2, 0), new Point(5, 3), new Point(8, 0), new Point(10, 0), new Point(6, 4), new Point(10, 8), new Point(8, 8), new Point(5, 5), new Point(2, 8), new Point(0, 8), new Point(4, 4) };
            Rectangle rec = new Rectangle();

            rec.Size = new Size(this.Width - 1, this.Height - 1);
            if (m_hot)
            {
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                e.Graphics.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 0), new Point(0, this.Height), Helper.RenderColors.ControlButtonBackHighColor(m_RenderMode, m_BackHighColor), Helper.RenderColors.ControlButtonBackLowColor(m_RenderMode, m_BackLowColor)), rec);
                e.Graphics.DrawRectangle(new Pen(Helper.RenderColors.ControlButtonBorderColor(m_RenderMode, m_BorderColor)), rec);
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
            }
            System.Drawing.Drawing2D.GraphicsPath g = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Drawing2D.Matrix       m = new System.Drawing.Drawing2D.Matrix();
            int x = (int)((this.Width - 11) / 2);
            int y = (int)((this.Height - 11) / 2 + 1);

            if (m_style == ButtonStyle.Drop)
            {
                e.Graphics.FillRectangle(new SolidBrush(ForeColor), x, y, 11, 2);
                g.AddPolygon(DropPoints);
                m.Translate(x, y + 3);
                g.Transform(m);
                e.Graphics.FillPolygon(new SolidBrush(ForeColor), g.PathPoints);
            }
            else
            {
                g.AddPolygon(ClosePoints);
                m.Translate(x, y);
                g.Transform(m);
                e.Graphics.DrawPolygon(new Pen(ForeColor), g.PathPoints);
                e.Graphics.FillPolygon(new SolidBrush(ForeColor), g.PathPoints);
            }
            g.Dispose();
            m.Dispose();
        }
Ejemplo n.º 25
0
        public Form1()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
            StreamReader read = new StreamReader("confi\\desk\\xuan.txt");

            beijing              = read.ReadLine();
            this.Cursor          = new Cursor(Properties.Resources.sb.GetHicon());
            this.BackgroundImage = Image.FromFile(beijing);
            readfromtxt();
            label1.Text = dqbf + " 什么也木有播放";
            label2.Text = "00:00|00:00";
            label3.Hide();
            webBrowser1.Hide();
            read.Close();
            read.Dispose();
            readtolist();//
            chushilist();

            /*
             * SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;
             * SpVoice Voice = new SpVoice();
             * Voice.Speak("欢迎来到 终了时MusicBox ", SpFlags);
             */
            for (int i = 0; i < 1000; i++)
            {
                circle[i]      = new PictureBox();
                circle[i].Size = new Size(60, 60);
                System.Drawing.Drawing2D.GraphicsPath g = new System.Drawing.Drawing2D.GraphicsPath();
                g.AddEllipse(new Rectangle(0, 0, 60, 60));
                circle[i].Region = new Region(g);
                g.Dispose();
                circle[i].Click += new EventHandler(this.makefen);
            }
//            Voice.WaitUntilDone(Timeout.Infinite);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Render plot view region of line chart component.
        /// </summary>
        /// <param name="dc">Platform no-associated drawing context.</param>
        protected override void OnPaint(DrawingContext dc)
        {
            var axisChart = Chart as AxisChart;

            var ai = axisChart.PrimaryAxisInfo;

            if (double.IsNaN(ai.Levels) || ai.Levels <= 0)
            {
                return;
            }

            var ds = Chart.DataSource;

            var g          = dc.Graphics;
            var clientRect = ClientBounds;

            double scaleX     = clientRect.Width / ds.CategoryCount;
            double scaleY     = clientRect.Height / (ai.Maximum - ai.Minimum);
            var    zeroHeight = (RGFloat)(ai.Minimum * scaleY + clientRect.Height);

#if WINFORM
            var path = new System.Drawing.Drawing2D.GraphicsPath();

            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style     = axisChart.DataSerialStyles[r];
                var lastPoint = new System.Drawing.PointF((RGFloat)(0.5 * scaleX), zeroHeight);

                var point = lastPoint;
                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    if (ds[r][c] is double value)
                    {
                        point.Y = zeroHeight - (RGFloat)(value * scaleY);
                    }
                    else
                    {
                        point.Y = zeroHeight;
                    }
                    path.AddLine(lastPoint, point);
                    lastPoint = point;
                    point.X  += (RGFloat)scaleX;
                }

                if (lastPoint.Y != zeroHeight)
                {
                    point.X = lastPoint.X;
                    point.Y = zeroHeight;
                    path.AddLine(lastPoint, point);
                }

                path.CloseFigure();

                g.FillPath(style.FillColor, path);

                path.Reset();
            }

            path.Dispose();
#elif WPF
            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style = axisChart.DataSerialStyles[r];

                var seg = new System.Windows.Media.PathFigure();

                var lastPoint = new System.Windows.Point(0.5 * scaleX, zeroHeight);
                seg.StartPoint = lastPoint;

                var point = seg.StartPoint;
                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    if (ds[r][c] is double value)
                    {
                        point.Y = zeroHeight - value * scaleY;
                    }
                    else
                    {
                        point.Y = zeroHeight;
                    }
                    seg.Segments.Add(new System.Windows.Media.LineSegment(point, true));
                    lastPoint = point;
                    point.X  += scaleX;
                }

                point.X = lastPoint.X;
                point.Y = zeroHeight;
                seg.Segments.Add(new System.Windows.Media.LineSegment(point, true));

                seg.IsClosed = true;

                var path = new System.Windows.Media.PathGeometry();
                path.Figures.Add(seg);
                g.FillPath(style.LineColor, path);
            }
#endif // WPF
        }
Ejemplo n.º 27
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();
        }
Ejemplo n.º 28
0
        //タイマーの時間がたったとき、、、
        private void timer_Tick(object sender, EventArgs e)
        {
            //バックバッファに描画開始
            Graphics g = Graphics.FromImage(backbuffer);

            g.Clear(Color.White);

            //現在のゲームで見分ける
            switch (nowGameType)
            {
            case GameType.Title:    //タイトル
            {
                Font font = new Font(this.Font.FontFamily, 40, FontStyle.Bold);
                g.DrawString(Application.ProductName, font, Brushes.Black,
                             WindowSize.Width / 2 - g.MeasureString(Application.ProductName, font).Width / 2, 20);

                font = new Font(this.Font.FontFamily, 20);
                string text   = "ゲームスタート";
                int    titleY = 200;
                g.DrawRectangle(new Pen(Brushes.Black), WindowSize.Width / 2 - 100, titleY, 200, 30);
                g.DrawString(text, font, Brushes.Black, WindowSize.Width / 2 - g.MeasureString(text, font).Width / 2, titleY);
                text   = "ハイスコア";
                titleY = 250;
                g.DrawRectangle(new Pen(Brushes.Black), WindowSize.Width / 2 - 100, titleY, 200, 30);
                g.DrawString(text, font, Brushes.Black, WindowSize.Width / 2 - g.MeasureString(text, font).Width / 2, titleY);
                text   = "終了";
                titleY = 300;
                g.DrawRectangle(new Pen(Brushes.Black), WindowSize.Width / 2 - 100, titleY, 200, 30);
                g.DrawString(text, font, Brushes.Black, WindowSize.Width / 2 - g.MeasureString(text, font).Width / 2, titleY);
                break;
            }

            case GameType.Game:    //ゲーム中
            {
                //障害物を描画する
                g.FillPolygon(Brushes.Green, syougaiObject);

                //敵の基地を描画する
                g.FillRectangle(Brushes.Black, enemyRectangle);
                //敵の移動
                if (gameStopWatch.IsRunning)
                {
                    if (enemyMoveAdvance)
                    {
                        enemyRectangle.X += enemyMovedt;
                        if (enemyRectangle.X > WindowSize.Width - BaseSize)
                        {
                            enemyMoveAdvance = false;
                        }
                    }
                    else
                    {
                        enemyRectangle.X -= enemyMovedt;
                        if (enemyRectangle.X < enemyStartX)
                        {
                            enemyMoveAdvance = true;
                        }
                    }
                }

                //自分の基地を描画
                g.FillRectangle(Brushes.Black, myRectangle);
                //砲弾シミュレート中ならば、、、
                if (timeStopwatch.IsRunning)
                {
                    //現時点での時間を保存する
                    double time = timeStopwatch.Elapsed.TotalSeconds;
                    //現時点の砲弾位置を計算する
                    x = v0 * Math.Cos(angle) * time + myRectangle.X + (myRectangle.Width / 2);
                    y = v0 * Math.Sin(angle) * time - 0.5 * Gravity * Math.Pow(time, 2) +
                        (WindowSize.Height - myRectangle.Y - myRectangle.Height / 2);
                    //砲弾を描画する
                    g.FillPie(Brushes.Black, (float)x - 5, WindowSize.Height - (float)y - 5, 10, 10, 0, 360);
                    //あたり判定
                    if (enemyRectangle.IntersectsWith(new Rectangle((int)x - 5, WindowSize.Height - (int)y - 5, 10, 10)))
                    {
                        //時間を停止する
                        timeStopwatch.Stop();
                        //ゲーム時間を停止する
                        gameStopWatch.Stop();
                        //自分の位置決定
                        myRectangle = new Rectangle(10, WindowSize.Height - BaseSize, BaseSize, BaseSize);
                        //敵の位置決定
                        Random rnd = new Random();
                        enemyRectangle = new Rectangle(rnd.Next(enemyStartX, WindowSize.Width - BaseSize),
                                                       WindowSize.Height - BaseSize,
                                                       BaseSize, BaseSize);
                        //スコアに追加する。
                        int i = hiScore.Add(new ScoreClass(ShotNumber, gameStopWatch.Elapsed, DateTime.Now));
                        //ゲームタイプを変更
                        nowGameType = GameType.Title;
                        //砲撃完了したメッセージを表示する。
                        if (i == -1)
                        {
                            MessageBox.Show("砲撃完了!\n残念ながらスコア外です。。。\n次はがんばってくださいぃ。。。\n\n" +
                                            "発射回数=" + ShotNumber + "回\n所要時間=" + gameStopWatch.Elapsed.ToString());
                        }
                        else
                        {
                            MessageBox.Show("砲撃完了!\nすごいですぅ。。。\n" + (i + 1) + "位です!!さすがぁ。。。\n\n" +
                                            "発射回数=" + ShotNumber + "回\n所要時間=" + gameStopWatch.Elapsed.ToString());
                        }
                        break;
                    }
                    //砲弾が地面よりも下と右を超えてしまったならば、、、
                    if (y < 0 || x < 0 || x >= WindowSize.Width)
                    {
                        timeStopwatch.Stop();
                    }

                    //砲弾と障害物との当たり判定
                    if (syougaiObject[1].X <= x && x <= syougaiObject[2].X &&
                        syougaiObject[0].Y <= WindowSize.Height - y && WindowSize.Height - y <= syougaiObject[1].Y)
                    {
                        System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
                        gp.AddPolygon(syougaiObject);
                        if (gp.IsVisible((int)x, WindowSize.Height - (int)y))
                        {
                            timeStopwatch.Stop();
                        }
                        gp.Dispose();
                    }
                }
                else if (gameStopWatch.IsRunning)        //ゲームが動いているならば、、、
                {
                    //指示線を描画する
                    Pen pen = new Pen(Brushes.Black, 5);
                    pen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
                    g.DrawLine(pen, myRectangle.X + (myRectangle.Width / 2), myRectangle.Y + (myRectangle.Height / 2),
                               mousePoint.X, mousePoint.Y);
                }

                //情報表示
                int showV0    = (int)v0;
                int showAngle = (int)(angle * 180 / Math.PI);
                g.DrawString("初速度=" + showV0.ToString("d3") + "[m/s]\n角度=" + showAngle.ToString("d3") + "[°]" +
                             "\n発射回数=" + ShotNumber + "回\n自分の基地をクリックするとゲームを終了します。",
                             this.Font, Brushes.Red, 10, 10);
                break;
            }

            case GameType.Hiscore:    //ハイスコア画面
            {
                Font font = new Font(this.Font.FontFamily, 40, FontStyle.Bold);
                g.DrawString("ハイスコア", font, Brushes.Black,
                             WindowSize.Width / 2 - g.MeasureString("ハイスコア", font).Width / 2, 20);
                font = new Font(this.Font.FontFamily, 20);
                g.DrawString("クリックするとタイトル画面に戻れます。", font, Brushes.Black,
                             WindowSize.Width / 2 - g.MeasureString("クリックするとタイトル画面に戻れます。", font).Width / 2, 70);

                //水平線を描画する。
                int yy = -1;
                for (; yy <= 10; yy++)
                {
                    g.DrawLine(new Pen(Brushes.Black), 50, yy * 30 + 200, 750, yy * 30 + 200);
                }
                //垂直線を描画する
                g.DrawLine(new Pen(Brushes.Black), 50, 170, 50, 500);
                g.DrawLine(new Pen(Brushes.Black), 120, 170, 120, 500);
                g.DrawLine(new Pen(Brushes.Black), 240, 170, 240, 500);
                g.DrawLine(new Pen(Brushes.Black), 500, 170, 500, 500);
                g.DrawLine(new Pen(Brushes.Black), 750, 170, 750, 500);
                //ヘッダを描画する
                string text = "順位";
                g.DrawString(text, font, Brushes.Black,
                             (120 - 50) / 2 + 50 - g.MeasureString(text, font).Width / 2, 170);
                text = "発射回数";
                g.DrawString(text, font, Brushes.Black,
                             (240 - 120) / 2 + 120 - g.MeasureString(text, font).Width / 2, 170);
                text = "所要時間";
                g.DrawString(text, font, Brushes.Black,
                             (500 - 240) / 2 + 240 - g.MeasureString(text, font).Width / 2, 170);
                text = "達成日時";
                g.DrawString(text, font, Brushes.Black,
                             (750 - 500) / 2 + 500 - g.MeasureString(text, font).Width / 2, 170);
                yy = 0;
                foreach (ScoreClass sc in hiScore)
                {
                    text = (yy + 1).ToString();
                    g.DrawString(text, font, Brushes.Black,
                                 (120 - 50) / 2 + 50 - g.MeasureString(text, font).Width / 2, yy * 30 + 200);
                    text = sc.ShotNumber.ToString();
                    g.DrawString(text, font, Brushes.Black,
                                 (240 - 120) / 2 + 120 - g.MeasureString(text, font).Width / 2, yy * 30 + 200);
                    text = sc.GameTime.ToString();
                    g.DrawString(text, font, Brushes.Black,
                                 (500 - 240) / 2 + 240 - g.MeasureString(text, font).Width / 2, yy * 30 + 200);
                    text = sc.dateTime.ToString();
                    g.DrawString(text, font, Brushes.Black,
                                 (750 - 500) / 2 + 500 - g.MeasureString(text, font).Width / 2, yy * 30 + 200);
                    yy++;
                }
                for (; yy < 10; yy++)
                {
                    text = (yy + 1).ToString();
                    g.DrawString(text, font, Brushes.Black,
                                 (120 - 50) / 2 + 50 - g.MeasureString(text, font).Width / 2, yy * 30 + 200);
                    text = "----";
                    g.DrawString(text, font, Brushes.Black,
                                 (240 - 120) / 2 + 120 - g.MeasureString(text, font).Width / 2, yy * 30 + 200);
                    text = "--:--:--.-----";
                    g.DrawString(text, font, Brushes.Black,
                                 (500 - 240) / 2 + 240 - g.MeasureString(text, font).Width / 2, yy * 30 + 200);
                    text = "----/--/-- --:--:--";
                    g.DrawString(text, font, Brushes.Black,
                                 (750 - 500) / 2 + 500 - g.MeasureString(text, font).Width / 2, yy * 30 + 200);
                }
                break;
            }
            }

            //デバッグメッセージ描画
#if DEBUG
            g.DrawString("DebugMessage Mouse=(" + mousePoint.X + "," + mousePoint.Y + ") TIME=" + timeStopwatch.Elapsed +
                         " Fire=(" + (int)x + "," + (int)y + ")" + " GameTime=" + gameStopWatch.Elapsed, this.Font, Brushes.Black, 0, 0);
#endif

            //描画終了
            g.Dispose();
            //描画
            g = CreateGraphics();
            g.DrawImage(backbuffer, 0, 0);
            g.Dispose();
        }
Ejemplo n.º 29
0
        /// <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();
        }
Ejemplo n.º 30
0
 void drawQuadTex(Graphics g, Bitmap tex, PointF[] quad) {
     System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
     gp.AddPolygon(new PointF[] { quad[0], quad[1], quad[3] });
     g.SetClip(gp, System.Drawing.Drawing2D.CombineMode.Replace);
     g.DrawImage(tex, new PointF[] { quad[0], quad[1], quad[3] });
     gp.Reset();
     gp.AddPolygon(new PointF[] { quad[2], quad[3], quad[1] });
     g.SetClip(gp, System.Drawing.Drawing2D.CombineMode.Replace);
     tex.RotateFlip(RotateFlipType.Rotate180FlipNone);
     g.DrawImage(tex, new PointF[] { quad[2], quad[3], quad[1] });
     tex.RotateFlip(RotateFlipType.Rotate180FlipNone);
     gp.Dispose();
     g.ResetClip();
 }
Ejemplo n.º 31
0
        private void set_jimaku()
        {
            System.Drawing.Drawing2D.GraphicsPath path =
            new System.Drawing.Drawing2D.GraphicsPath();

            int style = 0;
            style += (text.Font.Bold) ? (int)FontStyle.Bold : (int)FontStyle.Regular;
            style += (text.Font.Italic) ? (int)FontStyle.Italic : (int)FontStyle.Regular;
            style += (text.Font.Underline) ? (int)FontStyle.Underline : (int)FontStyle.Regular;
            style += (text.Font.Strikeout) ? (int)FontStyle.Strikeout : (int)FontStyle.Regular;
            path.AddString(text.Text, text.Font.FontFamily,
                style,
                (float)(text.Font.SizeInPoints / 0.75), new Point(0, 0),
                StringFormat.GenericDefault);
            myForm.Region = new Region(path);
            myForm.BackColor = text.ForeColor;
            path.Dispose();
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Render plot view region of line chart component.
        /// </summary>
        /// <param name="dc">Platform no-associated drawing context.</param>
        protected override void OnPaint(DrawingContext dc)
        {
            var axisChart = base.Chart as AxisChart;

            if (axisChart == null)
            {
                return;
            }

            var ds = Chart.DataSource;

            var g          = dc.Graphics;
            var clientRect = this.ClientBounds;


#if WINFORM
            var path = new System.Drawing.Drawing2D.GraphicsPath();

            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style     = axisChart.DataSerialStyles[r];
                var lastPoint = new System.Drawing.PointF(axisChart.PlotColumnPoints[0], axisChart.ZeroHeight);

                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    var pt = axisChart.PlotDataPoints[r][c];

                    System.Drawing.PointF point;

                    if (pt.hasValue)
                    {
                        point = new System.Drawing.PointF(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight - pt.value);
                    }
                    else
                    {
                        point = new System.Drawing.PointF(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight);
                    }

                    path.AddLine(lastPoint, point);
                    lastPoint = point;
                }

                var endPoint = new System.Drawing.PointF(axisChart.PlotColumnPoints[ds.CategoryCount - 1], axisChart.ZeroHeight);

                if (lastPoint != endPoint)
                {
                    path.AddLine(lastPoint, endPoint);
                }

                path.CloseFigure();

                g.FillPath(style.FillColor, path);

                path.Reset();
            }

            path.Dispose();
#elif WPF
            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style = axisChart.DataSerialStyles[r];

                var seg = new System.Windows.Media.PathFigure();

                seg.StartPoint = new System.Windows.Point(axisChart.PlotColumnPoints[0], axisChart.ZeroHeight);

                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    var pt = axisChart.PlotDataPoints[r][c];

                    System.Windows.Point point;

                    if (pt.hasValue)
                    {
                        point = new System.Windows.Point(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight - pt.value);
                    }
                    else
                    {
                        point = new System.Windows.Point(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight);
                    }

                    seg.Segments.Add(new System.Windows.Media.LineSegment(point, true));
                }

                var endPoint = new System.Windows.Point(axisChart.PlotColumnPoints[ds.CategoryCount - 1], axisChart.ZeroHeight);
                seg.Segments.Add(new System.Windows.Media.LineSegment(endPoint, true));

                seg.IsClosed = true;

                var path = new System.Windows.Media.PathGeometry();
                path.Figures.Add(seg);
                g.FillPath(style.LineColor, path);
            }
#endif // WPF
        }
        public ActionResult UnderLine()
        {
            string sVirtualPath = @"/Content/File/UnderLine/";

            //web请求
            HttpServerUtility httpServerUtility = System.Web.HttpContext.Current.Server;
            if (!Directory.Exists(httpServerUtility.MapPath(sVirtualPath)))
            {
                //按虚拟路径创建所有目录和子目录
                Directory.CreateDirectory(@httpServerUtility.MapPath(sVirtualPath));
            }

            string index = "1";
            string reIndex = Request["index"];
            if (!string.IsNullOrEmpty(reIndex))
            {
                int n;
                index = int.TryParse(reIndex, out n) ? n.ToString() : "1";
            }

            lock (temp)
            {
                string dFilePath = Server.MapPath(sVirtualPath + "UnderLine" + index + ".png");

                //判断图片是否存在
                #region 验证空格图片是否存在
                if (System.IO.File.Exists(dFilePath))
                {
                    Response.ClearContent(); //需要输出图象信息 要修改HTTP头
                    Response.ContentType = "image/Png";
                    Response.BinaryWrite(System.IO.File.ReadAllBytes(dFilePath));
                    Response.End();
                }
                #endregion

                #region 创建新空格图片
                else
                {
                    string filePath = Server.MapPath(sVirtualPath + "UnderLine.gif");
                    Bitmap bgImg = (Bitmap)Bitmap.FromFile(filePath);

                    int width = 36;
                    int height = 18;

                    Bitmap theBitmap = new Bitmap(width, height);
                    Graphics theGraphics = Graphics.FromImage(theBitmap);
                    theGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                    theGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                    theGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    theGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                    //  白色背景
                    //theGraphics.Clear(Color.White);
                    theGraphics.DrawImage(bgImg, new Rectangle(0, 0, width, height), new Rectangle(0, 0, bgImg.Width, bgImg.Height), GraphicsUnit.Pixel);
                    //13pt的字体
                    float fontSize = height * 1.0f / 1.38f;
                    Font theFont = new Font("Arial", fontSize);
                    System.Drawing.Drawing2D.GraphicsPath gp = null;

                    int indLen = index.Length;

                    Point thePos = new Point((int)(fontSize - (indLen > 1 ? indLen * 2.5 : indLen * 2)), 2);
                    gp = new System.Drawing.Drawing2D.GraphicsPath();
                    gp.AddString(index, theFont.FontFamily, 0, fontSize, thePos, new StringFormat());

                    theGraphics.DrawPath(new Pen(Color.White, 2f), gp);
                    theGraphics.FillPath(new SolidBrush(Color.Red), gp);
                    theGraphics.ResetTransform();

                    if (gp != null) gp.Dispose();

                    //  将生成的图片发回客户端
                    MemoryStream ms = new MemoryStream();
                    theBitmap.Save(ms, ImageFormat.Png);

                    //保存文件
                    theBitmap.Save(dFilePath);

                    Response.ClearContent(); //需要输出图象信息 要修改HTTP头
                    Response.ContentType = "image/Png";
                    Response.BinaryWrite(ms.ToArray());
                    theGraphics.Dispose();
                    theBitmap.Dispose();
                    Response.End();
                }
                #endregion
            }

            return View();
        }
Ejemplo n.º 34
0
        private void UpdateBackstageTabMetroRegion()
        {
            int captionHeight = 28;
            RibbonStrip strip = RibbonStrip;
            if (strip != null) captionHeight = strip.GetTotalCaptionHeight();

            _BackstageTab.Controls[SysBackstagePanelName].Height = captionHeight;

            Rectangle tabBounds = _BackstageTab.ClientRectangle;
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddLine(0, 0, _BackstageTab.TabStrip.Width, 0);
            path.AddLine(_BackstageTab.TabStrip.Width, 0, _BackstageTab.TabStrip.Width, captionHeight);
            path.AddLine(_BackstageTab.TabStrip.Width, captionHeight, tabBounds.Width, captionHeight);
            path.AddLine(tabBounds.Width, tabBounds.Height, 0, tabBounds.Height);
            path.CloseAllFigures();
            Region reg = new Region(path);
            _BackstageTab.Region = reg;
            path.Dispose();
        }
Ejemplo n.º 35
0
        // Zeichnet das Rechteck mit abgerundeten Ecken der Termindetails
        public void DrawRoundRect(Graphics g, Pen p, float x, float y, float width, float height, float radius)
        {
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

            gp.AddLine(x + radius, y, x + width - (radius * 2), y); // Line
            gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); // Corner
            gp.AddLine(x + width, y + radius, x + width, y + height - (radius * 2)); // Line
            gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); // Corner
            gp.AddLine(x + width - (radius * 2), y + height, x + radius, y + height); // Line
            gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); // Corner
            gp.AddLine(x, y + height - (radius * 2), x, y + radius); // Line
            gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); // Corner
            gp.CloseFigure();

            g.DrawPath(p, gp);
            gp.Dispose();
        }
Ejemplo n.º 36
0
 public static void DrawRoundedRectangleOutlined(Graphics gfxObj, Pen penObj, float X, float Y, float RectWidth, float RectHeight, float CornerRadius)
 {
     RectWidth--;
     RectHeight--;
     System.Drawing.Drawing2D.GraphicsPath gfxPath = new System.Drawing.Drawing2D.GraphicsPath();
     gfxPath.AddLine(X + CornerRadius, Y, X + RectWidth - (CornerRadius * 2), Y);
     gfxPath.AddArc(X + RectWidth - (CornerRadius * 2), Y, CornerRadius * 2, CornerRadius * 2, 270, 90);
     gfxPath.AddLine(X + RectWidth, Y + CornerRadius, X + RectWidth, Y + RectHeight - (CornerRadius * 2));
     gfxPath.AddArc(X + RectWidth - (CornerRadius * 2), Y + RectHeight - (CornerRadius * 2), CornerRadius * 2, CornerRadius * 2, 0, 90);
     gfxPath.AddLine(X + RectWidth - (CornerRadius * 2), Y + RectHeight, X + CornerRadius, Y + RectHeight);
     gfxPath.AddArc(X, Y + RectHeight - (CornerRadius * 2), CornerRadius * 2, CornerRadius * 2, 90, 90);
     gfxPath.AddLine(X, Y + RectHeight - (CornerRadius * 2), X, Y + CornerRadius);
     gfxPath.AddArc(X, Y, CornerRadius * 2, CornerRadius * 2, 180, 90);
     gfxPath.CloseFigure();
     gfxObj.DrawPath(penObj, gfxPath);
     gfxPath.Dispose();
 }
Ejemplo n.º 37
0
        private void Carte_Paint(object sender, PaintEventArgs e)
        {
            int i;
            double w, h;
            //projet = ((Musliw.MusliW)(this.MdiParent)).projet;
            Graphics page = e.Graphics;

            //page.Clear(this.BackColor);

            w = this.Width;
            h = this.Height;

            Pen stylo = new Pen(fen.stylo_couleur, (int)fen.epaisseur);
            Font fonte = new Font(FontFamily.GenericSansSerif, 7,FontStyle.Bold);
            this.ForeColor = Color.Black;
            Brush brosse =new SolidBrush(fen.brosse_couleur);
            Brush brosse_texte = new SolidBrush(fen.couleur_texte);
            double dx = w / (projet.reseaux[nproj].xu - projet.reseaux[nproj].xl);
            double dy = h / (projet.reseaux[nproj].yu - projet.reseaux[nproj].yl);
            double deltax,deltay,voldeltax,voldeltay;
            double cx = 0.5f * (projet.reseaux[nproj].xu + projet.reseaux[nproj].xl);
            double cy = 0.5f * (projet.reseaux[nproj].yu + projet.reseaux[nproj].yl);

            //MessageBox.Show(xl.ToString() + " " + yu.ToString());
            PointF p1=new PointF();
            PointF p2 = new PointF();
            PointF p3 = new PointF();
            PointF p4 = new PointF();
            PointF p5 = new PointF();

            PointF[] points = new PointF[4] ;
               double angle=0,norme=0;
            double sinx = 0, cosx = 1;
            if (fen.volume_echelle < 1e-6f)
            {
                fen.volume_echelle = 1e-6f;
            }
            for (i = 0; i < projet.reseaux[nproj].links.Count; i++)
            {
                norme = fen.norme(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur);
                if ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_visible == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_visible == true && norme > 0) && (projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_valid == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_valid == true))
                {

                    //page.DrawRectangle(stylo, 0f, 0f, 200, 200);
                    //MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
                deltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
                deltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
                cosx = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);
                sinx = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);

                    voldeltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    voldeltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    page.DrawLine(stylo, (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay), (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax),(float) (((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay),(float) (((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax));

                    p1.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay);
                    p1.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax);
                    p2.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + voldeltay);
                    p2.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + voldeltax);
                    p3.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + voldeltay);
                    p3.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + voldeltax);
                    p4.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay);
                    p4.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax);

                    System.Drawing.Drawing2D.GraphicsPath epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
                    System.Drawing.Drawing2D.GraphicsPath texte_epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
                    epaisseur.StartFigure();
                    points[0] = p1;
                    points[1] = p2;
                    points[2] = p3;
                    points[3] = p4;

                    epaisseur.AddPolygon(points);
                    epaisseur.CloseFigure();
                    //page.FillPath(brosse, epaisseur);
                    //page.FillPolygon(brosse, points);
                    //page.DrawPolygon(stylo,points);
                    epaisseur.Reset();
                    texte_epaisseur.StartFigure();
                    p5.X = 0.5f * (p3.X + p2.X);
                    p5.Y = 0.5f * (p3.Y + p2.Y);
                    texte_epaisseur.AddString(projet.reseaux[projet.reseau_actif].links[i].volau.ToString("0"), FontFamily.GenericSansSerif, 0, (float)fen.taille_texte, new PointF(p5.X, p5.Y), StringFormat.GenericDefault);
                    RectangleF encombrement = texte_epaisseur.GetBounds();
                    // texte_epaisseur.AddRectangle(encombrement);
                    //texte_epaisseur.AddPie(p5.X,p5.Y,2,2,0,360);

                    page.FillPolygon(brosse, points);
                    page.DrawPolygon(stylo, points);

                    if (encombrement.Width < fen.norme(p1.X, p4.X, p1.Y, p4.Y, 1) && projet.reseaux[projet.reseau_actif].links[i].volau > 0)
                    {
                        System.Drawing.Drawing2D.Matrix rotation = new System.Drawing.Drawing2D.Matrix();

                        if (cosx >= 0 && sinx <= 0)
                        {
                            angle = 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(-0.5f * encombrement.Width * cosx),(float)( 0.5f * encombrement.Width * sinx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();
                            page.FillPath(brosse_texte, texte_epaisseur);

                        }
                        else if (cosx <= 0 && sinx >= 0)
                        {
                            angle = 180f - 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(+0.5f * encombrement.Width * cosx + (encombrement.Height) * sinx),(float)( -0.5f * encombrement.Width * sinx + (encombrement.Height) * cosx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);

                        }
                        else if (cosx >= 0 && sinx >= 0)
                        {
                            angle = -180f * (float)Math.Acos(cosx) / (float)Math.PI;
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(-0.5f * encombrement.Width * cosx),(float)( 0.5f * encombrement.Width * sinx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);
                        }
                        else if (cosx <= 0 && sinx <= 0)
                        {
                            angle = 180 + 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(+0.5f * encombrement.Width * cosx + (encombrement.Height) * sinx),(float)( -0.5f * encombrement.Width * sinx + (encombrement.Height) * cosx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);
                        }

                    }
                    epaisseur.Dispose();
                    texte_epaisseur.Dispose();
                }

            }
            /*        for (i = 0; i < projet.reseaux[nproj].nodes.Count; i++)
            {
                if (projet.reseaux[nproj].nodes[i].i != 0)
                {
                    //page.DrawRectangle(stylo, 0f, 0f, 200, 200);
                    //MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
                    page.FillRectangle(brosse, (res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f);
                    page.DrawRectangle(stylo, (res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f);
                    page.DrawString(res.nodes[i].i.ToString(), fonte, Brushes.Black, new RectangleF((res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f));
                }
            }*/
        }
Ejemplo n.º 38
0
        static public byte[] Create(HttpPostedFileBase FileUploader)
        {
            if (FileUploader == null)
            {
                return(null);
            }
            if (!FileUploader.ContentType.StartsWith("image"))
            {
                return(null);
            }

            var _Bytes = new byte[FileUploader.ContentLength];

            FileUploader.InputStream.Read(_Bytes, 0, FileUploader.ContentLength);

            using (var ms = new MemoryStream(_Bytes))
            {
                Bitmap imgIn  = new Bitmap(ms);
                double y      = imgIn.Height;
                double x      = imgIn.Width;
                int    height = 100;
                int    width  = 200;
                int    Radius = 100;

                double factor = 1;
                if (width > 0)
                {
                    factor = width / x;
                }
                else if (height > 0)
                {
                    factor = height / y;
                }
                System.IO.MemoryStream outStream = new System.IO.MemoryStream();
                Bitmap imgOut = new Bitmap((int)(x * factor), (int)(y * factor));
                imgOut.SetResolution(72, 72);
                Graphics g = Graphics.FromImage(imgOut);
                g.DrawImage(imgIn, new Rectangle(0, 0, (int)(factor * x), (int)(factor * y)), new Rectangle(0, 0, (int)x, (int)y), GraphicsUnit.Pixel);
                Brush brush = new System.Drawing.SolidBrush(Color.Transparent);
                for (int i = 0; i < 4; i++)
                {
                    Point[] CornerUpLeft = new Point[3];
                    CornerUpLeft[0].X = 0;
                    CornerUpLeft[0].Y = 0;
                    CornerUpLeft[1].X = Radius;
                    CornerUpLeft[1].Y = 0;
                    CornerUpLeft[2].X = 0;
                    CornerUpLeft[2].Y = Radius;
                    System.Drawing.Drawing2D.GraphicsPath pathCornerUpLeft =
                        new System.Drawing.Drawing2D.GraphicsPath();
                    pathCornerUpLeft.AddArc(CornerUpLeft[0].X, CornerUpLeft[0].Y,
                                            Radius, Radius, 180, 90);
                    pathCornerUpLeft.AddLine(CornerUpLeft[0].X, CornerUpLeft[0].Y,
                                             CornerUpLeft[1].X, CornerUpLeft[1].Y);
                    pathCornerUpLeft.AddLine(CornerUpLeft[0].X, CornerUpLeft[0].Y,
                                             CornerUpLeft[2].X, CornerUpLeft[2].Y);
                    g.FillPath(brush, pathCornerUpLeft);
                    pathCornerUpLeft.Dispose();
                    imgOut.RotateFlip(RotateFlipType.Rotate90FlipNone);
                }
                imgOut.Save(outStream, ImageFormat.Png);
                return(outStream.ToArray());
            }
        }
Ejemplo n.º 39
0
        public List<Point> ToPoints(
    float angle,
    Rectangle rect)
        {
            // Create a GraphicsPath.
            System.Drawing.Drawing2D.GraphicsPath path =
                new System.Drawing.Drawing2D.GraphicsPath();

            path.AddRectangle(rect);

            // Declare a matrix that will be used to rotate the text.
            System.Drawing.Drawing2D.Matrix rotateMatrix =
                new System.Drawing.Drawing2D.Matrix();

            // Set the rotation angle and starting point for the text.
            rotateMatrix.RotateAt(180.0F, new PointF(10.0F, 100.0F));

            // Transform the text with the matrix.
            path.Transform(rotateMatrix);

            List<Point> results = new List<Point>();
            foreach(PointF p in path.PathPoints)
            {
                results.Add(new Point((int)p.X, (int)p.Y));
            }

            path.Dispose();

            return results;
        }
Ejemplo n.º 40
0
        /// <summary>
        /// Paint the tab
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            bool Painting = false;

            if (Painting)
            {
                return;
            }
            Painting = true;
            this.SuspendLayout();
            Color RenderBorderColor = new Color();
            Color RenderBottomColor = new Color();
            Color RenderHighColor   = new Color();
            Color RenderLowColor    = new Color();

            System.Drawing.Drawing2D.GraphicsPath GraphicPath = new System.Drawing.Drawing2D.GraphicsPath();

            int w = this.Width;

            CalculateWidth();
            if (w != this.Width)
            {
                GraphicPath.Dispose();
                return;
            }

            if (m_Selected)
            {
                RenderBorderColor = Helper.RenderColors.BorderColor(m_RenderMode, BorderColor);
                RenderHighColor   = Helper.RenderColors.TabBackHighColor(m_RenderMode, BackHighColor);
                RenderLowColor    = Helper.RenderColors.TabBackLowColor(m_RenderMode, BackLowColor);
                RenderBottomColor = Helper.RenderColors.TabBackLowColor(m_RenderMode, BackLowColor);
            }
            else if (m_Hot)
            {
                RenderBorderColor = Helper.RenderColors.BorderColor(m_RenderMode, BorderColor);
                RenderHighColor   = Helper.RenderColors.TabBackHighColor(m_RenderMode, BackHighColor);
                RenderLowColor    = Helper.RenderColors.TabBackLowColor(m_RenderMode, BackLowColor);
                RenderBottomColor = Helper.RenderColors.BorderColor(m_RenderMode, BorderColor);
            }
            else
            {
                RenderBorderColor = Helper.RenderColors.BorderColorDisabled(m_RenderMode, BorderColorDisabled);
                RenderHighColor   = Helper.RenderColors.TabBackHighColorDisabled(m_RenderMode, BackHighColorDisabled);
                RenderLowColor    = Helper.RenderColors.TabBackLowColorDisabled(m_RenderMode, BackLowColorDisabled);
                RenderBottomColor = Helper.RenderColors.BorderColor(m_RenderMode, BorderColor);
            }

            e.Graphics.SmoothingMode = m_SmoothingMode;

            GraphicPath.AddPolygon(GetRegion(Width - 1, Height - 1, System.Convert.ToInt32(this.IsSelected ? Height : Height - 1)));

            // if is bottom mirror the button vertically
            if (m_Alignment == TabControl.TabAlignment.Bottom)
            {
                MirrorPath(GraphicPath);
                Color x = RenderHighColor;
                RenderHighColor = RenderLowColor;
                RenderLowColor  = x;
            }

            // Get the correct region including all the borders
            Region R  = new Region(GraphicPath);
            Region R1 = new Region(GraphicPath);
            Region R2 = new Region(GraphicPath);
            Region R3 = new Region(GraphicPath);

            System.Drawing.Drawing2D.Matrix M1 = new System.Drawing.Drawing2D.Matrix();
            System.Drawing.Drawing2D.Matrix M2 = new System.Drawing.Drawing2D.Matrix();
            System.Drawing.Drawing2D.Matrix M3 = new System.Drawing.Drawing2D.Matrix();
            M1.Translate(0, -0.5F);
            M2.Translate(0, 0.5F);
            M3.Translate(1, 0);
            R1.Transform(M1);
            R2.Transform(M2);
            R3.Transform(M3);
            R.Union(R1);
            R.Union(R2);
            R.Union(R3);
            this.Region = R;

            RectangleF RF  = R.GetBounds(e.Graphics);
            Rectangle  rec = new Rectangle(0, 0, (int)RF.Width, (int)RF.Height);

            TabControl.TabPaintEventArgs te = default(TabControl.TabPaintEventArgs);

            te = new TabControl.TabPaintEventArgs(e.Graphics, rec, m_Selected, m_Hot, GraphicPath, Width, Height);
            if (TabPaintBackgroundEvent != null) // try to owner draw
            {
                TabPaintBackgroundEvent(this, te);
            }
            System.Drawing.Drawing2D.LinearGradientBrush gb = CreateGradientBrush(new Rectangle(0, 0, this.Width, this.Height), RenderHighColor, RenderLowColor);
            if (!te.Handled)
            {
                e.Graphics.FillPath(gb, GraphicPath);
            }
            gb.Dispose();
            te.Dispose();

            te = new TabControl.TabPaintEventArgs(e.Graphics, rec, m_Selected, m_Hot, GraphicPath, Width, Height);
            if (TabPaintBorderEvent != null) // try to owner draw
            {
                TabPaintBorderEvent(this, te);
            }
            if (!te.Handled)
            {
                if (m_BorderEnhanced)
                {
                    Color c = m_Alignment == TabControl.TabAlignment.Bottom ? RenderLowColor : RenderHighColor;
                    Pen   p = new Pen(c, (float)m_BorderEnhanceWeight);
                    e.Graphics.DrawLines(p, GraphicPath.PathPoints);
                    p.Dispose();
                }
                Pen p1 = new Pen(RenderBorderColor);
                e.Graphics.DrawLines(p1, GraphicPath.PathPoints);
                p1.Dispose();
            }
            te.Dispose();

            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
            e.Graphics.DrawLine(new Pen(RenderBottomColor), GraphicPath.PathPoints[0], GraphicPath.PathPoints[GraphicPath.PointCount - 1]);
            e.Graphics.SmoothingMode = m_SmoothingMode;

            DrawIcon(e.Graphics);
            DrawText(e.Graphics);
            if (m_CloseButtonVisible)
            {
                DrawCloseButton(e.Graphics);
            }
            this.ResumeLayout();

            // do the memory cleanup
            GraphicPath.Dispose();
            M1.Dispose();
            M2.Dispose();
            M3.Dispose();
            R1.Dispose();
            R2.Dispose();
            R3.Dispose();
            R.Dispose();
            te.Dispose();
            Painting = false;
        }
Ejemplo n.º 41
0
        private void DrawCharactorsOutLines(ref Graphics g)
        {
            System.Drawing.Drawing2D.GraphicsPath oOutline = new System.Drawing.Drawing2D.GraphicsPath();
            int iSymbolIndex = 0;
            g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    string sCharactor = new string(Convert.ToChar(iSymbolIndex++), 1);
                    oOutline = new System.Drawing.Drawing2D.GraphicsPath();
                    oOutline.AddString(sCharactor, this._curFont.FontFamily, (int)FontStyle.Regular, this._fontSize - 7, new Point(j * this._fontSize, i * this._fontSize), StringFormat.GenericDefault);
                    g.FillPath(new SolidBrush(Color.Black), oOutline);
                    oOutline.Dispose();
                    //g.DrawString(sCharactor, this._curFont, new SolidBrush(Color.Black), new RectangleF(j * this._fontSize , i * this._fontSize, this._fontSize, this._fontSize), StringFormat.GenericTypographic);
                }
            }
        }
Ejemplo n.º 42
0
        private void frmmain_Load(object sender, EventArgs e)
        {
            this.Width  = this.BackgroundImage.Width;
            this.Height = this.BackgroundImage.Height;

            //Declare A GraphicsPath Object, Which Is Used To Draw The Shape Of The Button
            System.Drawing.Drawing2D.GraphicsPath CirclePath = new System.Drawing.Drawing2D.GraphicsPath();

            //Create A 60 x 60 Circle Path
            CirclePath.AddEllipse(new Rectangle(0, 0, 53, 34));

            //Size Of The Button
            btnExit.Size = new System.Drawing.Size(53, 34);

            //if (blnCircleClicked)
            //  {
            //If The Button Is Selected To Draw, Change The Color
            btnExit.BackColor = Color.Black;
            btnExit.ForeColor = Color.White;
            //}
            //else
            //  {
            //If The Button Is Not Selected To Draw With, Change Back To Original Color
            //btnOptions.BackColor = Color.Aquamarine;
            //}

            //Create The Circular Shaped Button, Based On The Graphics Path
            btnExit.Region = new Region(CirclePath);

            //Release All Resources Owned By The Graphics Path Object
            CirclePath.Dispose();



            ///////////////////

            string cmd1 = "AT#CID=1";
            string cmd2 = "AT+VCID=1";
            string cmd3 = "AT#CID=2";
            string cmd4 = "AT%CCID=1";
            string cmd5 = "AT%CCID=2";
            string cmd6 = "AT#CC1";
            string cmd7 = "AT*ID1";
            string cmd8 = "AT#CLS=8#CID=1";

            //if (comport.GetType == System.Int32)
            //    {
            if (InputBox("Enter COM Port#", "Enter the COM Port number to which modem is connected. (eg:1)", ref comport) == DialogResult.OK)
            {
                serialPort1.PortName = "COM" + comport;
                serialPort1.Open();
                serialPort1.WriteLine(cmd1 + System.Environment.NewLine);
                serialPort1.WriteLine(cmd2 + System.Environment.NewLine);
                serialPort1.WriteLine(cmd3 + System.Environment.NewLine);
                serialPort1.WriteLine(cmd4 + System.Environment.NewLine);
                serialPort1.WriteLine(cmd5 + System.Environment.NewLine);
                serialPort1.WriteLine(cmd6 + System.Environment.NewLine);
                serialPort1.WriteLine(cmd7 + System.Environment.NewLine);
                serialPort1.WriteLine(cmd8 + System.Environment.NewLine);
                serialPort1.WriteLine(cmd1);
                serialPort1.WriteLine(cmd2);
                serialPort1.WriteLine(cmd3);
                serialPort1.WriteLine(cmd4);
                serialPort1.WriteLine(cmd5);
                serialPort1.WriteLine(cmd6);
                serialPort1.WriteLine(cmd7);
                serialPort1.WriteLine(cmd8);
            }
            //    }
            //else
            //    MessageBox.Show("Invalid COM port format. Please input only the COM Port numbe");
        }
Ejemplo n.º 43
0
        private static System.Drawing.Drawing2D.GraphicsPath CreateRinkPath()
        {
            System.Drawing.Drawing2D.GraphicsPath result = null;
            System.Drawing.Drawing2D.GraphicsPath rink   = null;
            try {
                const float cornerDiameter = cornerRadiusOfBoards * 2.0F;

                RectangleF topLeftCorner =
                    new RectangleF(0.0F,
                                   0.0F,
                                   cornerDiameter,
                                   cornerDiameter);
                RectangleF topRightCorner =
                    new RectangleF(rinkLength - cornerDiameter,
                                   0.0F,
                                   cornerDiameter,
                                   cornerDiameter);
                RectangleF bottomLeftCorner =
                    new RectangleF(0.0F,
                                   rinkWidth - cornerDiameter,
                                   cornerDiameter,
                                   cornerDiameter);
                RectangleF bottomRightCorner =
                    new RectangleF(rinkLength - cornerDiameter,
                                   rinkWidth - cornerDiameter,
                                   cornerDiameter,
                                   cornerDiameter);

                rink = new System.Drawing.Drawing2D.GraphicsPath();
                rink.StartFigure();
                rink.AddArc(topLeftCorner, 180.0F, 90.0F);
                rink.AddLine(0.0F + cornerRadiusOfBoards,
                             0.0F,
                             rinkLength - cornerRadiusOfBoards,
                             0.0F);
                rink.AddArc(topRightCorner, 270.0F, 90.0F);
                rink.AddLine(rinkLength,
                             0.0F + cornerRadiusOfBoards,
                             rinkLength,
                             rinkWidth - cornerRadiusOfBoards);
                rink.AddArc(bottomRightCorner, 0.0F, 90.0F);
                rink.AddLine(rinkLength - cornerRadiusOfBoards,
                             rinkWidth,
                             0.0F + cornerRadiusOfBoards,
                             rinkWidth);
                rink.AddArc(bottomLeftCorner, 90.0F, 90.0F);
                rink.AddLine(0.0F,
                             rinkWidth - cornerRadiusOfBoards,
                             0.0F,
                             0.0F + cornerRadiusOfBoards);
                rink.CloseFigure();

                result = rink;
                rink   = null;
                return(result);
            } finally {
                if (null != rink)
                {
                    rink.Dispose();
                }
            }
        }
Ejemplo n.º 44
0
 private void DrawRoundRect(Graphics g, float x, float y, float width, float height, float radius, Color color)
 {
     System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
     gp.AddLine(x + radius, y, x + width - (radius * 2), y); //追加线段
     gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90);  //追加椭圆弧
     gp.AddLine(x + width, y + radius, x + width, y + height - (radius * 2));
     gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
     gp.AddLine(x + width - (radius * 2), y + height, x + radius, y + height);
     gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
     gp.AddLine(x, y + height - (radius * 2), x, y + radius);
     gp.AddArc(x, y, radius * 2, radius * 2, 180, 90);
     gp.CloseFigure();
     Pen pen = new System.Drawing.Pen(ColorTranslator.FromHtml("#CCCCCC"), 1);
     g.DrawPath(pen, gp);
     Rectangle rec = new Rectangle((int)x, (int)y, (int)width, (int)height);
     Brush brush = new System.Drawing.SolidBrush(color);
     g.FillPath(brush, gp);
     gp.Dispose();
 }