Dispose() public method

public Dispose ( ) : void
return void
コード例 #1
6
        public override void Draw(System.Drawing.RectangleF dirtyRect)
        {
            var g = new Graphics();

            // NSView does not have a background color so we just use Clear to white here
            g.Clear(Color.White);

            //RectangleF ClientRectangle = this.Bounds;
            RectangleF ClientRectangle = dirtyRect;

            // Calculate the location and size of the drawing area
            // within which we want to draw the graphics:
            Rectangle rect = new Rectangle((int)ClientRectangle.X, (int)ClientRectangle.Y,
                                           (int)ClientRectangle.Width, (int)ClientRectangle.Height);
            drawingRectangle = new Rectangle(rect.Location, rect.Size);
            drawingRectangle.Inflate(-offset, -offset);
            //Draw ClientRectangle and drawingRectangle using Pen:
            g.DrawRectangle(Pens.Red, rect);
            g.DrawRectangle(Pens.Black, drawingRectangle);
            // Draw a line from point (3,2) to Point (6, 7)
            // using the Pen with a width of 3 pixels:
            Pen aPen = new Pen(Color.Green, 3);
            g.DrawLine(aPen, Point2D(new PointF(3, 2)),
                       Point2D(new PointF(6, 7)));

            g.PageUnit = GraphicsUnit.Inch;
            ClientRectangle = new RectangleF(0.5f,0.5f, 1.5f, 1.5f);
            aPen.Width = 1 / g.DpiX;
            g.DrawRectangle(aPen, ClientRectangle);

            aPen.Dispose();

            g.Dispose();
        }
コード例 #2
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int Line1 = 40;
            int Line2 = 230;

            System.Drawing.Pen   DarkPen    = new System.Drawing.Pen(System.Drawing.Color.DarkGray);
            System.Drawing.Pen   WhitePen   = new System.Drawing.Pen(System.Drawing.Color.White);
            System.Drawing.Brush WhiteBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            System.Drawing.Brush BlackBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            System.Drawing.Font  Font       = new Font("Arial", 16);

            System.Drawing.Graphics formGraphics = this.CreateGraphics();

            formGraphics.FillRectangle(WhiteBrush, 0, 0, 500, Line1);

            formGraphics.DrawLine(DarkPen, 0, Line1, 500, Line1);
            formGraphics.DrawLine(WhitePen, 0, Line1 + 1, 500, Line1 + 1);
            formGraphics.DrawLine(DarkPen, 0, Line2, 500, Line2);
            formGraphics.DrawLine(WhitePen, 0, Line2 + 1, 500, Line2 + 1);

            formGraphics.DrawString("Welcome to OML Database Setup ", Font, BlackBrush, 10, 10);

            DarkPen.Dispose();
            WhitePen.Dispose();
            WhiteBrush.Dispose();
            BlackBrush.Dispose();
            WhitePen.Dispose();

            formGraphics.Dispose();
        }
コード例 #3
0
 /// <summary>
 /// Dispose scene
 /// </summary>
 public void Dispose()
 {
     _pen.Dispose();
     _brush.Dispose();
     foreach (var layer in Layers)
     {
         layer.Dispose();
     }
 }
コード例 #4
0
 public override System.Drawing.Bitmap GetNext()
 {
     if (this.nowState == MarqueeDisplayState.First)
     {
         this.nowPosition = (int)this.nowPositionF;
         int num = (this.newBitmap.Width - this.nowPosition) / 2;
         System.Drawing.Bitmap   bitmap   = new System.Drawing.Bitmap(this.newBitmap);
         System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
         System.Drawing.Brush    brush    = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
         graphics.FillRectangle(brush, new System.Drawing.Rectangle(0, 0, num, this.newBitmap.Height));
         graphics.FillRectangle(brush, new System.Drawing.Rectangle(num + this.nowPosition, 0, num, this.newBitmap.Height));
         brush.Dispose();
         System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Red);
         graphics.DrawLine(pen, new System.Drawing.Point(num, 0), new System.Drawing.Point(num, this.newBitmap.Height));
         graphics.DrawLine(pen, new System.Drawing.Point(num - 1, 0), new System.Drawing.Point(num - 1, this.newBitmap.Height));
         graphics.DrawLine(pen, new System.Drawing.Point(num - 2, 0), new System.Drawing.Point(num - 2, this.newBitmap.Height));
         graphics.DrawLine(pen, new System.Drawing.Point(num + this.nowPosition, 0), new System.Drawing.Point(num + this.nowPosition, this.newBitmap.Height));
         graphics.DrawLine(pen, new System.Drawing.Point(num + this.nowPosition + 1, 0), new System.Drawing.Point(num + this.nowPosition + 1, this.newBitmap.Height));
         graphics.DrawLine(pen, new System.Drawing.Point(num + this.nowPosition + 2, 0), new System.Drawing.Point(num + this.nowPosition + 2, this.newBitmap.Height));
         pen.Dispose();
         graphics.Dispose();
         this.nowPositionF -= this.step;
         if (this.nowPosition <= 0)
         {
             this.nowState = MarqueeDisplayState.Stay;
         }
         return(bitmap);
     }
     return(null);
 }
コード例 #5
0
            protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
            {
                ToolStripMenuItem t = e.Item as ToolStripMenuItem;

                if (t != null)
                {
                    System.Drawing.SolidBrush b;
                    if (t.Pressed)
                    {
                        if (t.HasDropDownItems && t.OwnerItem == null)
                        {
                            b = new System.Drawing.SolidBrush(Color.FromArgb(31, 31, 31));
                            e.Graphics.FillRectangle(b, 0, 0, t.Width, t.Height);
                            b.Dispose();

                            System.Drawing.Pen p;
                            p = new System.Drawing.Pen(Color.FromArgb(127, 127, 127));
                            e.Graphics.DrawRectangle(p, 0, 0, t.Width - 1, t.Height);
                            p.Dispose();
                        }
                        else
                        {
                            b = new System.Drawing.SolidBrush(Color.FromArgb(127, 127, 127));
                            e.Graphics.FillRectangle(b, 3, 1, t.Width - 5, t.Height - 2);
                            b.Dispose();
                        }
                    }
                    else if (t.Selected)
                    {
                        b = new System.Drawing.SolidBrush(Color.FromArgb(127, 127, 127));
                        e.Graphics.FillRectangle(b, 3, 1, t.Width - 5, t.Height - 2);
                        b.Dispose();
                    }
                }
            }
コード例 #6
0
ファイル: Line.cs プロジェクト: Diullei/Storm
 protected override void OnPaint(PaintEventArgs e)
 {
     //base.OnPaint(e);
     Rectangle r = ClientRectangle;
     r.Inflate(-2,-2);
     Pen p = new Pen(ForeColor, 1);
     if ((int)(LinePositions & AnchorStyles.Left) > 0)
     {
         e.Graphics.DrawLine(p, r.Left-1, r.Top, r.Left-1, r.Bottom-1);
         e.Graphics.DrawLine(Pens.WhiteSmoke, r.Left, r.Top, r.Left, r.Bottom-1);
     }
     if ((int)(LinePositions & AnchorStyles.Right) > 0)
     {
         e.Graphics.DrawLine(p, r.Right, r.Top, r.Right, r.Bottom-1);
         e.Graphics.DrawLine(Pens.WhiteSmoke, r.Right+1, r.Top, r.Right+1, r.Bottom-1);
     }
     if ((int)(LinePositions & AnchorStyles.Top) > 0)
     {
         e.Graphics.DrawLine(p, r.Left, r.Top-1, r.Right-1, r.Top-1);
         e.Graphics.DrawLine(Pens.WhiteSmoke, r.Left, r.Top, r.Right-1, r.Top);
     }
     if ((int)(LinePositions & AnchorStyles.Bottom) > 0)
     {
         e.Graphics.DrawLine(p, r.Left, r.Bottom, r.Right-1, r.Bottom);
         e.Graphics.DrawLine(Pens.WhiteSmoke, r.Left, r.Bottom+1, r.Right-1, r.Bottom+1);
     }
     p.Dispose();
 }
コード例 #7
0
ファイル: MediaPanel.cs プロジェクト: WesleyYep/ispyconnect
        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);

            var g = pe.Graphics;
            if (Loading)
            {
                var txt = LocRm.GetString("Loading");
                var s = g.MeasureString(txt, MainForm.Drawfont);
                g.DrawString(txt, MainForm.Drawfont, MainForm.OverlayBrush, Convert.ToInt32(Width / 2) - s.Width / 2, Convert.ToInt32(Height / 2) - s.Height / 2);
            }

            if (SelectStart != Point.Empty && SelectEnd != Point.Empty)
            {
                var b = new SolidBrush(Color.White);
                var p = new Pen(b, 1) { DashStyle = DashStyle.Dash };
                g.DrawLine(p, SelectStart.X, SelectStart.Y, SelectStart.X, SelectEnd.Y);
                g.DrawLine(p, SelectStart.X, SelectEnd.Y, SelectEnd.X, SelectEnd.Y);
                g.DrawLine(p, SelectEnd.X, SelectEnd.Y, SelectEnd.X, SelectStart.Y);
                g.DrawLine(p, SelectEnd.X, SelectStart.Y, SelectStart.X, SelectStart.Y);

                b.Dispose();
                p.Dispose();
            }
        }
コード例 #8
0
ファイル: Rect.cs プロジェクト: svutborg/Programming-II
 public void DrawRectangle(Pen pen, Panel canvas)
 {
     Graphics g = canvas.CreateGraphics();
     g.DrawRectangle(pen, new Rectangle(X, Y, Width, Height));
     g.Dispose();
     pen.Dispose();
 }
コード例 #9
0
        public override void Draw(Graphics g, int dx, int dy, float zoom)
        {
            //TEST
            //Matrix precMx = g.Transform.Clone();//store previos trasformation
            //Matrix mx = g.Transform; // get previous trasformation
            //PointF p = new PointF(zoom * (this.X + dx + (this.X1 - this.X) / 2), zoom * (this.Y + dy + (this.Y1 - this.Y) / 2));
            //mx.RotateAt(this.getRotation(), p, MatrixOrder.Append); //add a trasformation
            //g.Transform = mx;

            base.Draw(g, dx, dy, zoom);
            System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Blue, 1.5f);
            myPen.DashStyle = DashStyle.Dash;
            if (this.sonoUnaLinea)
            {
                g.DrawLine(myPen, (this.X + dx) * zoom, (this.Y + dy) * zoom, (this.X1 + dx) * zoom, (this.Y1 + dy) * zoom);
            }
            else
            {
                g.DrawRectangle(myPen, (this.X + dx) * zoom, (this.Y + dy) * zoom, (this.X1 - this.X) * zoom, (this.Y1 - this.Y) * zoom);
            }
            myPen.Dispose();

            //TEST
            //g.Transform = precMx;
            //precMx.Dispose();
            //mx.Dispose();
        }
コード例 #10
0
ファイル: TextBoxEx.cs プロジェクト: sumito0507/PlusUltra
 protected override void WndProc(ref Message m)
 {
     base.WndProc(ref m);
     if (m.Msg == WM_PAINT)
     {
         Graphics  graphics = CreateGraphics();
         Rectangle rect     = this.ClientRectangle;
         if (_CustomBorderColor != Color.FromArgb(171, 173, 179))
         {
             var pen = new System.Drawing.Pen(_CustomBorderColor);
             try
             {
                 graphics.DrawRectangle(pen, 0, 0, this.Width - 1, this.Height - 1);
             }
             finally
             {
                 pen.Dispose();
             }
         }
         else
         {
             ControlPaint.DrawVisualStyleBorder(graphics, new Rectangle(0, 0, this.Width - 1, this.Height - 1));
         }
     }
 }
コード例 #11
0
        public static Cursor CreateCrossCursor(Brush brush, int radius)
        {
            int w = 20 + radius * 2;
            int p = w / 2;
            int h = 6;

            var bmp = new Bitmap(w, w);

            Graphics g = Graphics.FromImage(bmp);

            g.SmoothingMode     = SmoothingMode.Default;
            g.InterpolationMode = InterpolationMode.High;

            var pen = new System.Drawing.Pen(Brushes.Black, 2);

            g.DrawLine(pen, new Point(p, 0), new Point(p, h));                    // vertical line
            g.DrawLine(pen, new Point(p, w - h), new Point(p, w));                // vertical line
            g.DrawLine(pen, new Point(0, p), new Point(h, p));                    // horizontal line
            g.DrawLine(pen, new Point(w - h, p), new Point(w, p));                // horizontal line

            g.FillEllipse(brush, p - radius, p - radius, radius * 2, radius * 2); // Middle dot
            g.Flush();
            g.Dispose();
            pen.Dispose();

            var c = CreateBmpCursor(bmp);

            bmp.Dispose();

            return(c);
        }
コード例 #12
0
        private void DrawItem(Point po, int w, int h, String l)
        {
            Graphics     g    = panel1.CreateGraphics();;
            GraphicsPath path = new GraphicsPath();
            Pen          p    = new System.Drawing.Pen(Color.Black, 2);
            Size         s    = new Size(w, h);

            SolidBrush sb = new SolidBrush(Color.Gainsboro);

            g.FillRectangle(sb, new Rectangle(new Point((po.X - 1), (po.Y + 1)), new Size(9999, h)));
            sb.Dispose();

            Point t  = new Point(po.X + 75, po.Y);
            Point ll = new Point(po.X, po.Y + 25);
            Point r  = new Point(po.X + 150, po.Y + 25);
            Point b  = new Point(po.X + 75, po.Y + 50);

            PointF[] points = { r, t, ll, b };
            g.DrawPolygon(p, points);
            path.AddPolygon(points);
            PathGradientBrush pgb = new PathGradientBrush(path);

            pgb.CenterColor = Color.LightSkyBlue;
            Color[] sc = new Color[1];
            sc[0] = Color.PowderBlue;
            pgb.SurroundColors = sc;
            g.FillPolygon(pgb, points);
            po.Y += 10;
            po.X += 15;
            g.DrawString(l, new Font("Arial", 16), new SolidBrush(Color.Black), new Point(po.X + 25, po.Y));
            p.Dispose();
            g.Dispose();
            path.Dispose();
            pgb.Dispose();
        }
コード例 #13
0
        private void DrawAction(Point po, int w, int h, String l)
        {
            Graphics     g    = panel1.CreateGraphics();;
            GraphicsPath path = new GraphicsPath();
            Pen          p    = new System.Drawing.Pen(Color.Black, 2);
            Size         s    = new Size(w, h);

            SolidBrush sb = new SolidBrush(Color.Gainsboro);

            g.FillRectangle(sb, new Rectangle(new Point((po.X - 1), (po.Y + 1)), new Size(9999, h)));
            sb.Dispose();

            g.DrawEllipse(p, new RectangleF(po, s));
            path.AddEllipse(new RectangleF(po, s));
            PathGradientBrush pgb = new PathGradientBrush(path);

            pgb.CenterColor = Color.LightSkyBlue;
            Color[] sc = new Color[1];
            sc[0] = Color.PowderBlue;
            pgb.SurroundColors = sc;
            g.FillEllipse(pgb, new RectangleF(po, s));
            po.Y += 10;
            po.X += 10;
            g.DrawString(l, new Font("Arial", 16), new SolidBrush(Color.Black), po);
            path.Dispose();
            pgb.Dispose();
            p.Dispose();
            g.Dispose();
        }
コード例 #14
0
        private void updateMap()
        {
            System.Drawing.Pen myPen;
            myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
            //formGraphics = this.CreateGraphics();

            Actor[] _monsters;
            _monsters = Data.GetMapItems();


            //formGraphics.DrawLine(myPen, 0, 0, 2000, 2000);
            int centrum_x = this.Size.Width / 2;
            int centrum_y = this.Size.Height / 2;

            this.formGraphics.Clear(Color.Gray);
            drawDot(centrum_x, centrum_y, "black");

            foreach (Actor actor in _monsters)
            {
                int x = (int)((actor.Pos1.x - Data.GetMe().Pos1.x));
                int y = (int)((actor.Pos1.y - Data.GetMe().Pos1.y));
                if (actor.Alive == -1)
                {
                    drawDot(centrum_x - x, centrum_y + y, "blue");
                }
                else if (actor.Alive == 0)
                {
                    drawDot(centrum_x - x, centrum_y + y, "red");
                }
            }
            myPen.Dispose();
        }
コード例 #15
0
        private static void drawChartTempGrid(Graphics g)
        {
            System.Drawing.Pen myPen;
            myPen = new System.Drawing.Pen(System.Drawing.Color.Gray);
            for (double i = MIN_RATE; i < MAX_RATE; i = i + (MAX_RATE / 10.0))
            {
                g.DrawLine(myPen, 0, (float)rateToYLoc(i), uiForm.pbTempGraph.Size.Width, (float)rateToYLoc(i));
            }
            // Target
            myPen.Width = 2;
            myPen.Color = Color.Black;
            g.DrawLine(myPen, 0, (float)rateToYLoc(TRG_RATE), uiForm.pbTempGraph.Size.Width, (float)rateToYLoc(TRG_RATE));

            // Free gyro mode markers
            if (freeGyroMode == true)
            {
                // Roll Marker
                myPen.Width = 3;
                myPen.Color = Color.Red;
                g.DrawLine(myPen, uiForm.pbTempGraph.Size.Width - 25, (float)rateToYLoc(rollMarker), uiForm.pbTempGraph.Size.Width, (float)rateToYLoc(rollMarker));

                // Pitch Marker
                myPen.Width = 3;
                myPen.Color = Color.Green;
                g.DrawLine(myPen, uiForm.pbTempGraph.Size.Width - 25, (float)rateToYLoc(pitchMarker), uiForm.pbTempGraph.Size.Width, (float)rateToYLoc(pitchMarker));
            }

            myPen.Dispose();
        }
コード例 #16
0
        private void button1_Click(object sender, EventArgs e)
        {
            Point pt = Cursor.Position;

            startpoint = pt;
            endpoint   = pt;
            string[] arr = textBox1.Text.Split(';');
            Array.Sort(arr);
            bt = new Button[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                bt[i] = new Button();
                this.Controls.Add(bt[i]);
                bt[i].Location = new Point(50 + i * 50, 200);
                bt[i].Name     = "button" + i;
                bt[i].Size     = new Size(50, 30);
                bt[i].TabIndex = i;
                bt[i].Text     = arr[i];
                bt[i].UseVisualStyleBackColor = true;
                //bt[i].Click += new System.EventHandler(this.button1_Click);
                System.Drawing.Pen myPen;
                myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
                System.Drawing.Graphics formGraphics = this.CreateGraphics();
                formGraphics.DrawLine(myPen, 0, 0, 200, 200);
                myPen.Dispose();
                formGraphics.Dispose();
            }
        }
コード例 #17
0
        public static Cursor CreateCrossCursor()
        {
            const int w = 25;
            const int h = 25;

            var bmp = new Bitmap(w, h);

            Graphics g = Graphics.FromImage(bmp);
            g.SmoothingMode = SmoothingMode.Default;
            g.InterpolationMode = InterpolationMode.High;

            var pen= new Pen(Brushes.Black, 2);
            g.DrawLine(pen, new Point(12, 0), new Point(12, 8)); // vertical line 
            g.DrawLine(pen, new Point(12, 17), new Point(12, 25)); // vertical line
            g.DrawLine(pen, new Point(0, 12), new Point(8, 12)); // horizontal line 
            g.DrawLine(pen, new Point(16, 12), new Point(24, 12)); // horizontal line
            g.DrawLine(pen, new Point(12, 12), new Point(12, 13)); // Middle dot 

            g.Flush();
            g.Dispose();
            pen.Dispose();

            var c = CreateBmpCursor(bmp);

            bmp.Dispose();

            return c;
        }
コード例 #18
0
ファイル: ThingEditorCtrl.cs プロジェクト: 15831944/Test3-1
        private void drawGrid(Graphics gr)
        {
            switch (GridStyle)
            {
            case EGridStyle.GrdLine:
                System.Drawing.Pen drawPen = new System.Drawing.Pen(GridColor, 1);
                for (int i = this.ClientRectangle.Left; i < this.ClientRectangle.Right + scrollX; i += gridSize)
                {
                    gr.DrawLine(drawPen, i - scrollX, this.ClientRectangle.Top, i - scrollX, this.ClientRectangle.Bottom);
                }
                for (int i = this.ClientRectangle.Top; i < this.ClientRectangle.Bottom + scrollY; i += gridSize)
                {
                    gr.DrawLine(drawPen, this.ClientRectangle.Left, i - scrollY, this.ClientRectangle.Right, i - scrollY);
                }
                drawPen.Dispose();
                break;

            case EGridStyle.GrdDot:
                System.Drawing.SolidBrush solidBrush = new System.Drawing.SolidBrush(GridColor);
                for (int i = this.ClientRectangle.Left; i < this.ClientRectangle.Right + scrollX; i += gridSize)
                {
                    for (int j = this.ClientRectangle.Top; j < this.ClientRectangle.Bottom + scrollY; j += gridSize)
                    {
                        gr.FillEllipse(solidBrush, i - scrollX - 1, j - scrollY - 1, 2, 2);
                    }
                }
                solidBrush.Dispose();
                break;
            }
        }
コード例 #19
0
        public Subtitle(string content,
			Font font, Color fillColor, Color borderColor, float borderWidth,
			long startTime, long endTime)
        {
            StartTime = startTime;
            EndTime = endTime;

            IntPtr screenDc = ApiHelper.GetDC(IntPtr.Zero);
            Graphics g = Graphics.FromHdc(screenDc);
            SizeF gsize = g.MeasureString(content, font);
            g.Dispose();
            this.Size = Size.Ceiling(new SizeF(gsize.Width + borderWidth, gsize.Height + borderWidth));

            hMemDc = ApiHelper.CreateCompatibleDC(screenDc);
            hMemBitmap = ApiHelper.CreateCompatibleBitmap(screenDc, Size.Width, Size.Height);
            ApiHelper.ReleaseDC(IntPtr.Zero, screenDc);
            ApiHelper.SelectObject(hMemDc, hMemBitmap);
            g = Graphics.FromHdc(hMemDc);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            GraphicsPath path = new GraphicsPath();
            path.AddString(content, font.FontFamily, (int)font.Style, font.Size,
                new Rectangle(Point.Empty, Size), defaultFormat);

            Pen pen = new Pen(borderColor, borderWidth);
            pen.LineJoin = LineJoin.Round;
            pen.Alignment = PenAlignment.Outset;
            g.DrawPath(pen, path);
            pen.Dispose();
            Brush brush = new SolidBrush(fillColor);
            g.FillPath(brush, path);
            brush.Dispose();
            g.Dispose();
        }
コード例 #20
0
 public void DrawChart(int i,int x1,int y1,int x2, int y2,int x3,int y3)
 {
     System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Blue);
     System.Drawing.Graphics formGraphics;
     formGraphics = this.CreateGraphics();
     if (i==1)
     {
         formGraphics.DrawLine(myPen, 77+x1,103-y1, 77+x2,103- y2);
         formGraphics.DrawLine(myPen, 77 + x2, 103-y2, 77 + x3, 103-y3);
     }
     else if (i == 3)
     {
         formGraphics.DrawLine(myPen,77+ x1, 200-y1, 77+x2, 200-y2);
         formGraphics.DrawLine(myPen, 77 + x2, 200 - y2, 77 + x3, 200 - y3);
     }
     else if (i == 0)
     {
         formGraphics.DrawLine(myPen, 77+x1, 296 - y1, 77+x2, 296 - y2);
         formGraphics.DrawLine(myPen, 77 + x2, 296 - y2, 77 + x3, 296 - y3);
     }
     else if (i == 2)
     {
         formGraphics.DrawLine(myPen, 77+x1, 392 - y1, 77+x2, 392 - y2);
         formGraphics.DrawLine(myPen, 77 + x2, 392 - y2, 77 + x3, 392 - y3);
     }
     myPen.Dispose();
     formGraphics.Dispose();
 }
コード例 #21
0
        public override void Draw(CGRect rect)
        {
            var g = Graphics.FromCurrentContext ();

            // NSView does not have a background color so we just use Clear to white here
            g.Clear (Color.White);
            CGRect ClientRectangle = rect;
            var rectangle = new Rectangle ((int)ClientRectangle.X, (int)ClientRectangle.Y, (int)ClientRectangle.Width, (int)ClientRectangle.Height);

            drawingRectangle = new Rectangle (rectangle.Location, rectangle.Size);
            drawingRectangle.Inflate (-offset, -offset);
            //Draw ClientRectangle and drawingRectangle using Pen:
            g.DrawRectangle (Pens.Red, rectangle);
            g.DrawRectangle (Pens.Black, drawingRectangle);
            // Draw a line from point (3,2) to Point (6, 7)
            // using the Pen with a width of 3 pixels:
            var aPen = new Pen (Color.Green, 3);
            g.DrawLine (aPen, Point2D (new CGPoint (3, 2)), Point2D (new CGPoint (6, 7)));

            g.PageUnit = GraphicsUnit.Inch;
            ClientRectangle = new CGRect(0.5f,0.5f, 1.5f, 1.5f);
            aPen.Width = 1 / g.DpiX;
            g.DrawRectangle (aPen, (float)ClientRectangle.X, (float)ClientRectangle.Y, (float)ClientRectangle.Width, (float)ClientRectangle.Height);

            aPen.Dispose();
            g.Dispose();
        }
コード例 #22
0
ファイル: Drawing.cs プロジェクト: cyotek/translateclient
        public static void Frame3D(Graphics graphics, Rectangle rc, Color topColor, Color bottomColor, int width)
        {
            if(graphics == null)
                throw new ArgumentNullException("graphics");

            Pen pen = new Pen(topColor, 1);
            pen.Width = 1;

            while(width > 0)
            {
                width--;
                pen.Color = topColor;
                Point[] top_pnts =
                {
                    new Point(rc.Left, rc.Bottom),
                    new Point(rc.Left, rc.Top),
                    new Point(rc.Right, rc.Top)
                };
                graphics.DrawLines(pen, top_pnts);
                pen.Color = bottomColor;
                Point[] bottom_pnts =
                {
                    new Point(rc.Right, rc.Top),
                    new Point(rc.Right, rc.Bottom),
                    new Point(rc.Left, rc.Bottom)
                };
                graphics.DrawLines(pen, bottom_pnts);
                rc.Inflate(-1, -1);
            }
            pen.Dispose();
        }
コード例 #23
0
ファイル: FrmObGrInfo.cs プロジェクト: movsar/daymohk-gis
        private void drawSampleLine()
        {
            Color     c  = _Dh.colorFromHex(lineColor);
            DashStyle ds = DashStyle.Solid;

            if (lineDashStyle.Equals("solid"))
            {
                ds = DashStyle.Solid;
            }
            if (lineDashStyle.Equals("dashed"))
            {
                ds = DashStyle.Dash;
            }
            if (lineDashStyle.Equals("dotted"))
            {
                ds = DashStyle.Dot;
            }

            System.Drawing.Pen myPen;
            myPen           = new System.Drawing.Pen(c, 10);
            myPen.DashStyle = ds;

            System.Drawing.Graphics formGraphics = pnlColor.CreateGraphics();
            formGraphics.Clear(System.Drawing.SystemColors.Control);
            formGraphics.DrawLine(myPen, 0, 15, 99, 15);

            myPen.Dispose();
            formGraphics.Dispose();
        }
コード例 #24
0
            public void Line(int x1, int y1, int x2, int y2, Color color, bool b = false, bool f = false)
#endif
            {
                Graphics g = GetGraphics();

                AdjustXAndY(ref x1, ref y1);
                AdjustXAndY(ref x2, ref y2);
                Pen pen = new System.Drawing.Pen(color);

                try
                {
                    if (b)
                    {
                        g.DrawRectangle(pen, x1, y1, x2 - x1, y2 - y1);
                    }
                    else if (f)
                    {
                        System.Diagnostics.Debug.Assert(b != false, "You cannot use F without B");
                        g.FillRectangle(new SolidBrush(color), x1, y1, x2 - x1, y2 - y1);
                    }
                    else
                    {
                        g.DrawLine(pen, x1, y1, x2, y2);
                    }
                }
                finally
                {
                    Free(g);
                    pen.Dispose();
                }
            }
コード例 #25
0
        //------ End Constructors -----//
        public override void Paint(Graphics g, System.Drawing.Drawing2D.GraphicsPath gp, bool isSelected)
        {
            if (isSelected)
            {
                SolidBrush br = new SolidBrush(selectedBack);
                Pen pen = new Pen(selectedLine);
                g.FillPath(br, gp);
                g.DrawPath(pen, gp);
                br.Dispose();
                pen.Dispose();
            }
            else  //is not selected
            {
                if (_PaintBack)
                {
                    SolidBrush br = new SolidBrush(_BackColor);
                    g.FillPath(br,gp);
                    br.Dispose();
                }

                if (_PaintLine)
                {
                    Pen pen = new Pen(_LineColor);
                    g.DrawPath(pen, gp);
                    pen.Dispose();
                }
            }
        }
コード例 #26
0
 public void Draw(Graphics g)
 {
     Pen pen = new Pen(Color.Yellow, Width);
     Point p = new Point(X, Y);
     g.DrawLine(pen, p, End);
     pen.Dispose();
 }
コード例 #27
0
        protected override void OnPaint(PaintEventArgs e)
        {
            System.Drawing.Pen TLPen;
            System.Drawing.Pen TRPen;
            System.Drawing.Pen BLPen;
            System.Drawing.Pen BRPen;
            TLPen = new System.Drawing.Pen(System.Drawing.Color.Black);
            TRPen = new System.Drawing.Pen(System.Drawing.Color.Red);
            BLPen = new System.Drawing.Pen(System.Drawing.Color.Green);
            BRPen = new System.Drawing.Pen(System.Drawing.Color.Blue);

            System.Drawing.Graphics formGraphics = CreateGraphics();
            //formGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            Rectangle rect  = this.ClientRectangle;
            int       cx    = rect.Width;
            int       cy    = rect.Height;
            float     scale = (float)cy / (float)cx;

            for (int x = 0; x < cx; x += 7)
            {
                formGraphics.DrawLine(TLPen, 0, x * scale, cx - x, 0);
                formGraphics.DrawLine(TRPen, cx - x, 0 * scale, cx, (cx - x) * scale);
                formGraphics.DrawLine(BLPen, 0, (cx - x) * scale, cx - x, cx * scale);
                formGraphics.DrawLine(BRPen, cx - x, cx * scale, cx, x * scale);
            }
            formGraphics.Dispose();
            TLPen.Dispose();
            TRPen.Dispose();
            BLPen.Dispose();
            BRPen.Dispose();
        }
コード例 #28
0
        public void draw(int numb)
        {
            Graphics g = this.picback.CreateGraphics();
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //g.Clear(this.picback.BackColor);
            System.Drawing.Pen pn = new System.Drawing.Pen(System.Drawing.Color.Green, 2);
            int maxY = (int)this.picback.Height;//获取窗体的高
            int maxX = (int)this.picback.Width - 1;//获取窗体的宽

            double f = numb * 2.0 * Math.PI / maxX;
            int lmin = 0;
            int rmax = maxX; //this.picback.Width;//把具体的宽度分成200等份
            int count = rmax - lmin;
            PointF[] mypoint = new PointF[count + 1];
            int x = 0;
            for (int i = lmin; i <= rmax; i++)
            {
                //0.5为半个波形占容器高度的50%
                //根据具体的容器高度设置PointF点的Y坐标,(具体情况而定)

                double temp = 0.5 * (maxY - maxY * Math.Sin(f * i));
                mypoint[x] = new PointF((float)i, (float)temp);
                x++;
            }
            g.DrawCurve(pn, mypoint);
            pn.Dispose();
            g.Dispose();
        }
コード例 #29
0
 public void Dispose()
 {
     if (_pen != null)
     {
         _pen.Dispose();
     }
 }
コード例 #30
0
 public static void RepertoryImage(Graphics drawDestination)
 {
     StringFormat itemStringFormat = new StringFormat();
     RectangleF itemBox = new RectangleF(10, 30, 60, 20);
     float[] pattern = {4f,4f};
     Pen rPen = new Pen(Color.Black);
     rPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
     rPen.DashPattern = pattern;
     itemStringFormat.Alignment = StringAlignment.Center;
     itemStringFormat.LineAlignment = StringAlignment.Center;
     drawDestination.DrawLine(Pens.LightGray,10,10,10,70);
     drawDestination.DrawLine(rPen,10,20,70,20);
     drawDestination.DrawLine(rPen,10,60,70,60);
     PointF[] capPolygon = new PointF[3];
     capPolygon[0] = new PointF(65, 19);
     capPolygon[1] = new PointF(69, 11);
     capPolygon[2] = new PointF(61, 11);
     drawDestination.DrawPolygon(Pens.Black,capPolygon);
     capPolygon[0] = new PointF(65, 61);
     capPolygon[1] = new PointF(69, 69);
     capPolygon[2] = new PointF(61, 69);
     drawDestination.DrawPolygon(Pens.Black,capPolygon);
     drawDestination.DrawLine(rPen,65,20,65,60);
     drawDestination.DrawString("Measure",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
     rPen.Dispose();
     itemStringFormat.Dispose();
 }
コード例 #31
0
            protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
            {
                ToolStripDropDown t = e.ToolStrip as ToolStripDropDown;

                if (t != null)
                {
                    System.Drawing.Pen p;
                    p = new System.Drawing.Pen(Color.FromArgb(127, 127, 127));
                    e.Graphics.DrawRectangle(p, 0, 0, t.Width - 1, t.Height - 1);
                    p.Dispose();

                    if (t.OwnerItem != null)
                    {
                        if (t.OwnerItem.OwnerItem == null)
                        {
                            p = new System.Drawing.Pen(Color.FromArgb(31, 31, 31));
                            e.Graphics.DrawLine(p, 1, 0, t.OwnerItem.Width - 2, 0);
                            p.Dispose();
                        }
                        else
                        {
                            t.Show(new Point(4, 5));
                        }
                    }
                }
            }
コード例 #32
0
        /// <summary>
        /// Occurs during the drawing of an item
        /// </summary>
        /// <param name="e"></param>
        protected override void OnDrawItem(DrawItemEventArgs e)
        {

            Rectangle outer = e.Bounds;
            outer.Inflate(1, 1);
            e.Graphics.FillRectangle(Brushes.White, outer);
            Brush fontBrush = Brushes.Black;
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                Rectangle r = e.Bounds;
                r.Inflate(-1, -1);
                e.Graphics.FillRectangle(Global.HighlightBrush(r, Color.FromArgb(215, 238, 252)), r);
                Pen p = new Pen(Color.FromArgb(215, 238, 252));
                Global.DrawRoundedRectangle(e.Graphics, p, e.Bounds);
                p.Dispose();
            }
           
          
            string name = Items[e.Index].ToString();
            FontFamily ff = new FontFamily(name);
            Font fnt = new Font("Arial", 10, FontStyle.Regular);
            if (ff.IsStyleAvailable(FontStyle.Regular))
            {
                fnt = new Font(name, 10, FontStyle.Regular);
            }
            else if (ff.IsStyleAvailable(FontStyle.Italic))
            {
                fnt = new Font(name, 10, FontStyle.Italic);
            }
            SizeF box = e.Graphics.MeasureString(name, Font);
            e.Graphics.DrawString(name, Font, fontBrush, e.Bounds.X, e.Bounds.Y);
            e.Graphics.DrawString("ABC", fnt, fontBrush, e.Bounds.X + box.Width, e.Bounds.Y);

        }
コード例 #33
0
        private void RectARP_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

            GraphicsPath graphicPath = new GraphicsPath();

            graphicPath.AddArc(0, 0, _ARPWidth * 2, _ARPWidth * 2, 180f, 90f);

            graphicPath.AddLine(_ARPWidth, 0, this.Width - _ARPWidth, 0);

            graphicPath.AddArc(this.Width - _ARPWidth * 2, 0, _ARPWidth * 2, _ARPWidth * 2, 270f, 90f);

            graphicPath.AddLine(this.Width, _ARPWidth, this.Width, this.Height - _ARPWidth);

            graphicPath.AddArc(this.Width - _ARPWidth * 2, this.Height - _ARPWidth * 2, _ARPWidth * 2, _ARPWidth * 2, 0f, 90f);

            graphicPath.AddLine(this.Width - _ARPWidth, this.Height, _ARPWidth, this.Height);

            graphicPath.AddArc(0, this.Height - _ARPWidth * 2, _ARPWidth * 2, _ARPWidth * 2, 90f, 90f);

            graphicPath.AddLine(0, this.Height - _ARPWidth, 0, _ARPWidth);

            if (_BorderWidth > 0)
            {
                System.Drawing.Pen drawPen = new System.Drawing.Pen(Color.Black, _BorderWidth);

                drawPen.Alignment = PenAlignment.Inset;

                e.Graphics.DrawPath(drawPen, graphicPath);

                drawPen.Dispose();
            }

            this.Region = new Region(graphicPath);
        }
コード例 #34
0
ファイル: Form5.cs プロジェクト: piglaker/SHcrack
        private void pictureBox3_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.Pen pen = new System.Drawing.Pen(Color.Orange, 3);

            pictureBox3.BackgroundImageLayout = ImageLayout.Stretch;

            //pen.Width = 2;

            if (m_bMouseDown)

            {
                //实时的画矩形

                Graphics g = e.Graphics;

                g.DrawRectangle(pen, m_ptStart.X, m_ptStart.Y, m_ptEnd.X - m_ptStart.X, m_ptEnd.Y - m_ptStart.Y);
            }



            //实时的画之前已经画好的矩形
            if (dicPoints != null)
            {
                foreach (var item in dicPoints)
                {
                    Point p1 = item.Key;
                    Point p2 = item.Value;
                    e.Graphics.DrawRectangle(pen, p1.X, p1.Y, p2.X - p1.X, p2.Y - p1.Y);
                }
                pen.Dispose();
            }
        }
コード例 #35
0
		// This procedure performs the actual drawing, and is called by
		// DrawSquare_MouseDown and DrawSquare_Paint.
		private void DrawRectangle(Rectangle rect, Graphics g)
		{
			Pen pen = new Pen(Color.Red, 10);
			g.DrawRectangle(pen, rect);
			pen.Dispose();
			lblCount.Text = " " + squares.Count.ToString() + " squares";
		}
コード例 #36
0
ファイル: Edge.cs プロジェクト: Raixur/BeGraph
		public override void Draw(Graphics gr) {
			// Calculation of begin and end points of edge. 
			double c = Math.Sqrt(Math.Pow(second.Position.X - first.Position.X, 2) + Math.Pow(second.Position.Y - first.Position.Y, 2));
			double sin = (second.Position.Y - first.Position.Y) / c;
			double cos = (second.Position.X - first.Position.X) / c;
			Point firstPoint = new Point(first.Position.X + (int)(cos * Vertex.r), first.Position.Y + (int)(sin * Vertex.r));
			Point secondPoint = new Point(second.Position.X - (int)(cos * Vertex.r), second.Position.Y - (int)(sin * Vertex.r));
			Pen edgePen = new Pen(Color.DarkBlue, 2);
			

			gr.DrawLine(edgePen, firstPoint, secondPoint);

			if (weight != 0) {
				string text = weight.ToString();
				Font textFont = new Font("Arial", 11);
				Brush textBrush = new SolidBrush(Color.Black);
				Brush textBackground = new SolidBrush(Color.White);
				Point textLocation = new Point((firstPoint.X + secondPoint.X) / 2, (firstPoint.Y + secondPoint.Y) / 2 - 6);

				SizeF textSize = new Size();
				textSize = gr.MeasureString(text, textFont);

				// Рисование линии между вершинам графа
				gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
				gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
				gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
				gr.DrawLine(edgePen, firstPoint, secondPoint);

				textBackground.Dispose();
				textBrush.Dispose();
				textFont.Dispose();
			}
			edgePen.Dispose();
		}
コード例 #37
0
        public static Cursor CreateCrossCursor()
        {
            const int w = 25;
            const int h = 25;

            var bmp = new Bitmap(w, h);

            Graphics g = Graphics.FromImage(bmp);

            g.SmoothingMode     = SmoothingMode.Default;
            g.InterpolationMode = InterpolationMode.High;
            var pen = new System.Drawing.Pen(Brushes.Black, 2);

            g.DrawLine(pen, new Point(12, 0), new Point(12, 8));   // vertical line
            g.DrawLine(pen, new Point(12, 17), new Point(12, 25)); // vertical line
            g.DrawLine(pen, new Point(0, 12), new Point(8, 12));   // horizontal line
            g.DrawLine(pen, new Point(16, 12), new Point(24, 12)); // horizontal line
            g.DrawLine(pen, new Point(12, 12), new Point(12, 13)); // Middle dot
            g.Flush();
            g.Dispose();
            pen.Dispose();
            var c = CreateBmpCursor(bmp);

            bmp.Dispose();
            return(c);
        }
コード例 #38
0
        private void VisualElement_GenerateClicked(object sender, RoutedEventArgs e)
        {
            Bitmap src = new Bitmap((int)VisualElement.ResultImage.Width, (int)VisualElement.ResultImage.Height);

            GridWorldGenerator grid = new GridWorldGenerator((uint)items.Find(r => r.Name == "Seed").Value, NoiseType.SIMPLEX, (int)VisualElement.ResultImage.Width, (int)VisualElement.ResultImage.Height);

            grid.Generate();

            GridData[,] data = grid.Data.Data;

            for (int y = 0; y < data.GetLength(0); y++)
            {
                for (int x = 0; x < data.GetLength(1); x++)
                {
                    int val = (int)(data[y, x].height * 255);
                    src.SetPixel(x, y, System.Drawing.Color.FromArgb(val, val, val));
                }
            }

            System.Drawing.Pen black = new System.Drawing.Pen(System.Drawing.Color.Black, 2);
            using (var graphics = Graphics.FromImage(src))
            {
            }

            black.Dispose();
            VisualElement.ResultImage.Source = Utilities.BitmapToImageSource(src);
        }
コード例 #39
0
        internal override void Draw(Graphics g)
        {
            IsInvalidated = false;

            Rectangle r = GetUnsignedRectangle();

            //Shadow
            GraphicsPath gp = CreatePath(r.X + 5, r.Y + 5, r.Width, r.Height, Radius);
            //g.FillPath(new SolidBrush(Color.FromArgb((int)(255.0f * (50 / 100.0f)), Color.LightGray)), gp);

            g.FillPath(new SolidBrush(Color.LightGray), gp);

            gp.Dispose();

            //Border
            gp = CreatePath(r.X, r.Y, r.Width, r.Height, Radius);

            Pen p = new Pen(borderColor, borderWidth);
            g.DrawPath(p, gp);            
            p.Dispose();

            //Color
            Brush b = this.GetBrush(r);
            g.FillPath(b, gp);
            gp.Dispose();

            b.Dispose();
        }
コード例 #40
0
ファイル: AxisLine.cs プロジェクト: bbriggs/wesay
		public void Draw(Graphics graphics)
		{
			graphics.SetClip(parentGraph.ClientRectangle);

			Pen axisPen = new Pen(new SolidBrush(parentGraph.YAxisColor), 2F);
			axisPen.EndCap = LineCap.ArrowAnchor;

			RectangleF graphArea = parentGraph.GraphArea;

			graphics.DrawLine(axisPen,
							  graphArea.Left,
							  graphArea.Bottom,
							  graphArea.Left,
							  graphArea.Top);

			axisPen.Color = parentGraph.XAxisColor;
			axisPen.EndCap = LineCap.ArrowAnchor;

			graphics.DrawLine(axisPen,
							  graphArea.Left,
							  graphArea.Bottom,
							  graphArea.Right,
							  graphArea.Bottom);

			axisPen.Dispose();
		}
コード例 #41
0
ファイル: Form1.cs プロジェクト: Guille1257/pergelisol
        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            Pen contour = new Pen(Brushes.Black);
            Font writing = new Font(FontFamily.GenericSansSerif, 10);
            StringFormat formatWriting = new StringFormat();
            formatWriting.Alignment = StringAlignment.Far;
            SolidBrush writingBrush = new SolidBrush(Color.Black);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(new Bitmap(1, 1));
            int largeurTemp = (int)graphics.MeasureString(m_sTemp, writing).Width;

            if(m_temp < 0)
                pe.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 4,130,255)), new Rectangle(0, 0, this.Size.Width, this.Size.Height));
            else
                pe.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 224, 205, 14)), new Rectangle(0, 0, this.Size.Width, this.Size.Height));

            pe.Graphics.DrawLine(contour, 0, 0, this.Size.Width, 0);
            pe.Graphics.DrawLine(contour, 0, 0, 0, this.Size.Height);
            pe.Graphics.DrawLine(contour, this.Size.Width - 1, 0, this.Size.Width - 1, this.Size.Height);
            pe.Graphics.DrawLine(contour, 0, this.Size.Height - 1, this.Size.Width, this.Size.Height - 1);

            pe.Graphics.DrawString(m_sTemp, writing, writingBrush, new Rectangle(0, 1, largeurTemp + 2, 20), formatWriting);
            pe.Graphics.DrawString(m_sProfondeur, writing, writingBrush, new Rectangle(0, 20, largeurTemp, 20), formatWriting);

            pe.Graphics.DrawString(string.Format("{0: 0.00} °C", m_temp), writing, writingBrush, new Point(largeurTemp, 0));
            pe.Graphics.DrawString(string.Format("{0: 0.00} m", m_profondeur), writing, writingBrush, new Point(largeurTemp, 20));

            contour.Dispose();
            writing.Dispose();
            writingBrush.Dispose();
        }
コード例 #42
0
 public void DrawChart(int i, int x1, int y1, int x2, int y2, int x3, int y3)
 {
     System.Drawing.Pen      myPen = new System.Drawing.Pen(System.Drawing.Color.Blue);
     System.Drawing.Graphics formGraphics;
     formGraphics = this.CreateGraphics();
     if (i == 1)
     {
         formGraphics.DrawLine(myPen, 77 + x1, 103 - y1, 77 + x2, 103 - y2);
         formGraphics.DrawLine(myPen, 77 + x2, 103 - y2, 77 + x3, 103 - y3);
     }
     else if (i == 3)
     {
         formGraphics.DrawLine(myPen, 77 + x1, 200 - y1, 77 + x2, 200 - y2);
         formGraphics.DrawLine(myPen, 77 + x2, 200 - y2, 77 + x3, 200 - y3);
     }
     else if (i == 0)
     {
         formGraphics.DrawLine(myPen, 77 + x1, 296 - y1, 77 + x2, 296 - y2);
         formGraphics.DrawLine(myPen, 77 + x2, 296 - y2, 77 + x3, 296 - y3);
     }
     else if (i == 2)
     {
         formGraphics.DrawLine(myPen, 77 + x1, 392 - y1, 77 + x2, 392 - y2);
         formGraphics.DrawLine(myPen, 77 + x2, 392 - y2, 77 + x3, 392 - y3);
     }
     myPen.Dispose();
     formGraphics.Dispose();
 }
コード例 #43
0
ファイル: PanelRender.cs プロジェクト: pokk/CSharpVAST
        public void Show(Point aoi_center, UInt16 AOI_RADIUS, List<Node> neighborList, String SelfName, int SelfDirect, ulong listener)  // 顯示在營幕上
        {
            Pen myPen = new Pen(Color.Black, 1);
            Size center_size = new Size(15, 15);  // 節點大小
            Rectangle center_rect = new Rectangle(aoi_center.X - (center_size.Height / 2), aoi_center.Y - (center_size.Width / 2), center_size.Height, center_size.Width);
            Size aoi_size = new Size(AOI_RADIUS * 2, AOI_RADIUS * 2);  // AOI 範圍大小
            Rectangle aoi_rect = new Rectangle(aoi_center.X - AOI_RADIUS, aoi_center.Y - AOI_RADIUS, aoi_size.Height, aoi_size.Width);

            myPanel.CreateGraphics().FillEllipse(Brushes.Gray, center_rect);  // 本身塗灰
            myPanel.CreateGraphics().DrawEllipse(myPen, center_rect);  // 本身節點之位置
            myPanel.CreateGraphics().DrawEllipse(myPen, aoi_rect);  // 本身節點之aoi範圍
            OrienRender(aoi_center.X, aoi_center.Y, SelfDirect, true);  // 畫移動方向

            myPanel.CreateGraphics().DrawString(SelfName, new Font("新細明體", 10), new SolidBrush(Color.Black), aoi_center);  // 本身節點的名字

            // 把鄰居的節點畫在 Panel 上面
            for (int i = 0; i < neighborList.Count; i++)
            {
                RectangleF center_neighbor = new RectangleF(neighborList[i].x - (center_size.Height / 2), neighborList[i].y - (center_size.Width / 2), center_size.Height, center_size.Width);
                PointF pos = new PointF(neighborList[i].x, neighborList[i].y);  // 鄰居的位置座標
                myPanel.CreateGraphics().DrawEllipse(myPen, center_neighbor);
                myPanel.CreateGraphics().DrawString(neighborList[i].name, new Font("新細明體", 10), new SolidBrush(Color.Black), pos);  // 鄰居節點的名字
                OrienRender(neighborList[i].x, neighborList[i].y, neighborList[i].direct, false);
            }

            ListenerRender(neighborList, aoi_center, listener);  // listener 是誰的虛線

            myPen.Dispose();
        }
コード例 #44
0
ファイル: PenEditor.cs プロジェクト: 15831944/Test3-1
        public override void PaintValue(PaintValueEventArgs e)
        {
            MindFusion.FlowChartX.Pen pen =
                e.Value as MindFusion.FlowChartX.Pen;

            if (pen == null)
            {
                return;
            }

            try
            {
                // Be careful with pens...
                System.Drawing.Pen gdiPen = pen.CreateGDIPen();
                e.Graphics.DrawLine(gdiPen,
                                    e.Bounds.Left, e.Bounds.Top + e.Bounds.Height / 2,
                                    e.Bounds.Right - 1, e.Bounds.Top + e.Bounds.Height / 2);
                gdiPen.Dispose();
            }
            catch
            {
#if DEBUG
                System.Diagnostics.Debug.WriteLine("Shift!");
#endif
            }
        }
コード例 #45
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics myGraphics = e.Graphics;
            Pen myPen = new Pen(Color.Black, 1.0f);
            GraphicsPath gp = new GraphicsPath();
            Matrix RotationTransform;

            float centerX = this.Size.Width / 2f;
            float centerY = this.Size.Height / 2f;

            gp.AddPolygon(new PointF[] {
                new PointF(centerX, centerY - 5),
                new PointF(centerX-5, centerY + 5),
                new PointF(centerX+5, centerY + 5)
            });

            RotationTransform = new Matrix(1, 0, 0, 1, 0, 0); // rotation matrix
            PointF RotationPoint = new PointF(centerX, centerY); // rotation point
            RotationTransform.RotateAt(heading, RotationPoint);
            gp.Transform(RotationTransform);

            myGraphics.FillPath(myPen.Brush, gp);
            myGraphics.DrawPath(myPen, gp);
            myPen.Dispose();
            gp.Dispose();
        }
コード例 #46
0
        public override void Draw(Graphics g, int dx, int dy, float zoom)
        {
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            myBrush.Color = this.Trasparency(Color.Black, 80);
            System.Drawing.Pen whitePen = new System.Drawing.Pen(System.Drawing.Color.White);
            System.Drawing.Pen myPen    = new System.Drawing.Pen(System.Drawing.Color.Blue, 1.5f);
            myPen.DashStyle = DashStyle.Dash;

            g.FillRectangle(myBrush, new RectangleF((this.X + dx) * zoom, (this.Y + dy) * zoom, (this.X1 - this.X) * zoom, (this.Y1 - this.Y) * zoom));
            g.DrawRectangle(whitePen, (this.X + dx) * zoom, (this.Y + dy) * zoom, (this.X1 - this.X) * zoom, (this.Y1 - this.Y) * zoom);

            //CENTER POINT
            float midX, midY = 0;

            midX = (this.X1 - this.X) / 2;
            midY = (this.Y1 - this.Y) / 2;

            PointF Hp = new PointF(0, 25);

            PointF RotHP = this.rotatePoint(Hp, this._rotation);

            RotHP.X += this.X;
            RotHP.Y += this.Y;
            g.FillEllipse(myBrush, (RotHP.X + midX + dx - 3) * zoom, (RotHP.Y + dy - 3 + midY) * zoom, 6 * zoom, 6 * zoom);
            g.DrawEllipse(whitePen, (RotHP.X + midX + dx - 3) * zoom, (RotHP.Y + dy - 3 + midY) * zoom, 6 * zoom, 6 * zoom);
            g.DrawLine(myPen, (this.X + midX + dx) * zoom, (this.Y + midY + dy) * zoom, (RotHP.X + midX + dx) * zoom, (RotHP.Y + midY + dy) * zoom);

            myPen.Dispose();
            myBrush.Dispose();
            whitePen.Dispose();
        }
コード例 #47
0
        /// <summary>
        /// Draw rectangle
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            Pen pen = new Pen(Color, PenWidth);

            Rectangle _rect = new Rectangle();
            _rect = DrawRectangle.GetNormalizedRectangle(Rectangle);

            int x = _rect.X;
            int y = _rect.Y;
            int w = _rect.Width;
            int h = _rect.Height;
            int wArc = (w/6);
            int wArc2 = wArc * 2;
            int wReta = w - wArc;

            // g.DrawArc(pen, DrawRectangle.GetNormalizedRectangle(Rectangle), -270, 180);
            g.DrawArc(pen, x - wArc, y, wArc2, h, 270, 180);
            g.DrawArc(pen, x - wArc + wReta, y, wArc2, h, 270, 180);

            Point SE = new Point(x, y);          //SuperiorEsquerdo
            Point SD = new Point(x + wReta, y);             //SuperiorDireito

            Point IE = new Point(x, y + h);      //InferioriEsquerdo
            Point ID = new Point(x + wReta, y + h);         //InferiorDireito

            g.DrawLine(pen, SE, SD);
            g.DrawLine(pen, IE, ID);

            //g.DrawRectangle(pen, x, y, w, h);

            pen.Dispose();
        }
コード例 #48
0
ファイル: DrawPolygon.cs プロジェクト: dalinhuang/tdcodes
        public override void Draw(Graphics g)
        {
            var property = Property as PolygonProperty;
            var borderColor = PropertyUtility.ParseToColor(property.BorderColor);
            var borderThick = PropertyUtility.ParseToNumber(property.BorderThickness);
            var pen = new Pen(borderColor, borderThick);

            g.SmoothingMode = SmoothingMode.AntiAlias;
            int x1 = 0, y1 = 0;     // previous point
            int x2, y2;             // current point
            var enumerator = property.PointArray.GetEnumerator();
            if (enumerator.MoveNext())
            {
                x1 = ((Point)enumerator.Current).X;
                y1 = ((Point)enumerator.Current).Y;
            }
            while (enumerator.MoveNext())
            {
                x2 = ((Point)enumerator.Current).X;
                y2 = ((Point)enumerator.Current).Y;
                g.DrawLine(pen, x1, y1, x2, y2);
                x1 = x2;
                y1 = y2;
            }
            pen.Dispose();
        }
コード例 #49
0
        public override Bitmap render(BBox bbox, int width, int height, int elevation)
        {
            Bitmap mapImg = new Bitmap(width, height);
            Graphics gfx = Graphics.FromImage(mapImg);

            gfx.Clear(Color.FromArgb(0, 0, 0, 0));

            Pen pen = new Pen(Color.Red);
            Brush brush = Brushes.Red;

            // draw agent position on the map
            try
            {
                m_scene.ForEachScenePresence(delegate(ScenePresence agent)
                {
                    if (!agent.IsChildAgent)
                    {
                        PointF agentPos = new PointF(agent.OffsetPosition.X, agent.OffsetPosition.Y);
                        PointF agentImgPos = Conversion.Projection(ref agentPos, ref bbox, width, height);
                        RectangleF rect = new RectangleF(agentImgPos.X, agentImgPos.Y, 20, 20); //point width and height hard coded as 20, should be changed
                        gfx.FillEllipse(brush, rect);
                    }
                }
                );
            }
            catch (Exception)
            {
                throw new Exception("agent layer rendering failed");
            }
            gfx.Dispose();
            pen.Dispose();
            return mapImg;
        }
コード例 #50
0
ファイル: Form1.cs プロジェクト: Gost2013/Tetris0
        private void DrawField(int height, int width, Graphics graphics)
        {
            int blockSize = 25;

            System.Drawing.Pen pen_fieldGrid;
            pen_fieldGrid = new System.Drawing.Pen(System.Drawing.Color.DarkGray);
            System.Drawing.Graphics formGraphics = graphics;

            int rowCount = height / blockSize;
            int colCount = width / blockSize;

            int row_StartPoint = height % blockSize;//лишнее оставляем сверху (та часть поля, которая не кратна blockSize)
            for (int i = 0; i < rowCount; i++)
            {
                formGraphics.DrawLine(pen_fieldGrid, 0, row_StartPoint + blockSize * i, width, row_StartPoint + blockSize * i);
            }
            //тут лишнее останется справа (в идеале - найти способ убрать лишнее)
            for (int i = 0; i < colCount; i++)
            {
                formGraphics.DrawLine(pen_fieldGrid, blockSize * (i + 1), 0, blockSize * (i + 1), height);
            }

            pen_fieldGrid.Dispose();
            formGraphics.Dispose();
        }
コード例 #51
0
        public override void OnDraw(Graphics graphics, Rectangle valueRect, Color textColor, PropertyEnumerator propEnum, string drawAnotherString)
        {
            valueRect.Height++;

            Rectangle colorRect = GetColorRect(valueRect);

            // Draw the color box
            Color color;
            try
            {
                color = (Color)Value.GetActualValue(drawAnotherString);
            }
            catch (Exception)
            {
                color = (Color)Value.GetValue();
            }
            Brush brush = new SolidBrush(color);
            graphics.FillRectangle(brush, colorRect);

            if (propEnum.Property.Value.HasMultipleValues)
                graphics.DrawLine(SystemPens.GrayText, colorRect.Left, colorRect.Bottom, colorRect.Right, colorRect.Top);

            // Draw a black frame around
            Pen pen = new Pen(Color.Black);
            graphics.DrawRectangle(pen, colorRect);
            pen.Dispose();

            Rectangle strRect = GetDisplayStringRect(graphics, valueRect, Point.Empty /* not used */);
            strRect.Width = valueRect.Right - strRect.Left;

            Win32Calls.DrawText(graphics, (drawAnotherString == null ? DisplayString : drawAnotherString),
                ref strRect, Value.Font, textColor,
                Win32Calls.DT_VCENTER | Win32Calls.DT_SINGLELINE | Win32Calls.DT_END_ELLIPSIS | Win32Calls.DT_NOPREFIX);
        }
コード例 #52
0
ファイル: Win10Tsr.cs プロジェクト: Stoom/KeePass
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem tsi = ((e != null) ? e.Item : null);

            if((tsi != null) && ((tsi.Owner is ContextMenuStrip) ||
                (tsi.OwnerItem != null)) && tsi.Selected && !tsi.Enabled)
            {
                Rectangle rect = tsi.ContentRectangle;
                rect.Offset(0, -1);
                rect.Height += 1;

                // In image area (228, 228, 228), in text area (230, 230, 230)
                Color clrBack = Color.FromArgb(229, 229, 229);
                Color clrBorder = Color.FromArgb(229, 229, 229);

                SolidBrush br = new SolidBrush(clrBack);
                Pen p = new Pen(clrBorder);

                Graphics g = e.Graphics;
                if(g != null)
                {
                    g.FillRectangle(br, rect);
                    g.DrawRectangle(p, rect);
                }
                else { Debug.Assert(false); }

                p.Dispose();
                br.Dispose();
            }
            else base.OnRenderMenuItemBackground(e);
        }
コード例 #53
0
        protected override void OnPaint(PaintEventArgs e)
        {
            double x, y;
            double radius;
            double half;
            int i;

            x = Width / 2;
            y = Height / 2;
            radius = Math.Min(Width / 2, Height / 2) - 5;
            half = lines / 2;

            for (i = 0; i < lines; i++)
            {
                double inset = 0.7 * radius;
                double t = (double)((i + lines - current) % lines) / lines;

                Color c = Color.FromArgb((int)(t * 255), 0, 0, 0);
                Pen pen = new Pen(c);
                pen.Width = 2;

                PointF start = new PointF((float)(x + (radius - inset) * Math.Cos(i * Math.PI / half)),
                           (float)(y + (radius - inset) * Math.Sin(i * Math.PI / half)));

                PointF end = new PointF((float)(x + radius * Math.Cos(i * Math.PI / half)),
                           (float)(y + radius * Math.Sin(i * Math.PI / half)));

                e.Graphics.DrawLine(pen, start, end);
                pen.Dispose();
            }

            base.OnPaint(e);
        }
コード例 #54
0
ファイル: TitleDivision.cs プロジェクト: Orvid/Cosmos
		void TitleDivision_Paint(object sender, PaintEventArgs e)
		{
			Pen linePen;
			Single halfHeight;
			Single start;
			Single end;

			halfHeight = (this.Size.Height * 0.5f) + 1.0f;
			start = (Single)this.labelTitle.Right;

			if (String.IsNullOrEmpty(this.labelTitle.Text) == false)
			{
				start += (Single)this.labelTitle.Margin.Right;
			}else{
				start += (Single)this.Padding.Left;
			}

			end = this.Size.Width - (Single)this.Padding.Right;

			linePen = new Pen(this.LineColor);

			e.Graphics.DrawLine(linePen, start, halfHeight, end, halfHeight);

			linePen.Dispose();
			linePen = null;
		}
コード例 #55
0
ファイル: ImageHelper.cs プロジェクト: jaccopa/WpfApp3
        public byte[] AddRulerMark(int width, int height, byte[] datas)
        {
            Bitmap bp       = ArrayToIamge(width, height, datas);
            int    startDot = (int)CLanmage.StartLevelBaseDots;

            if (bp == null)
            {
                return(null);
            }

            Graphics g = Graphics.FromImage(bp);

            System.Drawing.Pen curPen = new System.Drawing.Pen(System.Drawing.Brushes.White, 1);

            for (int i = 0; i < CLanmage.CurrentDepth; i++)
            {
                int y = startDot + i * (int)(10 / CLanmage.LengthPerDotY);

                int x2 = 10 + 600;

                if ((i + 1) % 5 == 0)
                {
                    x2 = 20 + 600;
                }

                g.DrawLine(curPen, new System.Drawing.Point(600, y), new System.Drawing.Point(x2, y));
            }

            byte[] outData = ImageToArrayFast(bp);
            curPen.Dispose();
            g.Dispose();
            bp.Dispose();
            return(outData);
        }
コード例 #56
0
        private void Drawing(MouseEventArgs e) // 내가 그릴때
        {
            countInfoset++;

            Pen myPen;

            myPen = new System.Drawing.Pen(PenColor, PenWidth); // 펜 설정

            myPen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
            myPen.EndCap   = System.Drawing.Drawing2D.LineCap.Round;
            //myPen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(10,0,0,255));


            Graphics formGraphics = vForm.CreateGraphics(); // viewForm 에 대신 그림

            //Console.WriteLine(e.X + " " + e.Y);
            formGraphics.DrawLine(myPen, x, y, e.X, e.Y);
            DrawInfoSet += ((x + "," + y + "," + e.X + "," + e.Y + "," + PenColor.Name + "," + PenWidth.ToString()).ToString() + ",<EOF>\n");

            x = e.X;
            y = e.Y;

            if (countInfoset >= 15)
            {
                // 서버 전송
                SendPenInfo();
                countInfoset = 0;
            }

            myPen.Dispose();
            formGraphics.Dispose();
        }
コード例 #57
0
ファイル: Ruler.cs プロジェクト: bangush/SharpDevelopLite
        void PaintHorizontal(Graphics g)
        {
            Pen   pen   = new System.Drawing.Pen(System.Drawing.Color.Black, 0.25f);
            Brush brush = new SolidBrush(System.Drawing.Color.Black);

            switch (scaleUnit)
            {
            case GraphicsUnit.Millimeter:
                g.PageUnit  = GraphicsUnit.Millimeter;
                g.PageScale = 1;
                SetSize(scaleUnit);
                break;

            case GraphicsUnit.Inch:
                break;
            }

            SizeF size = CalcReciprocals(g);
            int   bLine, sLine;

            sLine = (int)(this.Height / 3 * size.Height);
            bLine = sLine * 2;

            int start = 0;

            if (startValue > 0)
            {
                start = (int)(startValue / 10);
            }

            endValue = paperSize.Width;

            if (drawFrame == true)
            {
                g.DrawRectangle(pen, 0, 0, (this.Width - 1) * size.Width, (this.Height - 1) * size.Width);
            }


            int i       = 0;
            int drawPos = 0;

            while (i < (int)((endValue / 10) + 1))
            {
                drawPos = i * bigStep;
                g.DrawString((i + start).ToString(System.Globalization.CultureInfo.CurrentCulture),
                             this.Font, brush, drawPos, sLine);
                Line(g, pen, drawPos, 0, i * bigStep, bLine);
                Line(g, pen, drawPos - smallStep, 0, drawPos - smallStep, sLine);
                i++;
            }
            // MarginMarker
            if (leftMargin > 0)
            {
                Line(g,
                     (int)(leftMargin), 0,
                     (int)(leftMargin), bLine);
            }
            pen.Dispose();
            brush.Dispose();
        }
コード例 #58
0
ファイル: Shared.cs プロジェクト: developeramarish/cnaswns
        internal static void ResetBorderColor(Message m, Control control)
        {
            System.Drawing.Pen pen = pen = new Pen(Shared.ControlBorderBackColor, 1);
            IntPtr             hDC = Win32.GetWindowDC(m.HWnd);

            if (hDC.ToInt32() == 0)
            {
                return;
            }

            if (pen != null)
            {
                //绘制边框
                System.Drawing.Graphics g = Graphics.FromHdc(hDC);
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                g.DrawRectangle(pen, 0, 0, control.Width - 1, control.Height - 1);
                pen.Dispose();
            }

            //返回结果
            //m.Result = IntPtr.Zero;

            //释放
            Win32.ReleaseDC(m.HWnd, hDC);
        }
コード例 #59
0
ファイル: Circle.cs プロジェクト: tsiganoff/PFSOFT_Test
        /// <summary>
        /// Проверяет попадание точки в фигуру
        /// </summary>
        /// <param name="p"></param>
        /// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
        public override int ContainsPoint(Point p)
        {
            if (this.IsSelected)
            {
                for (int i = 1; i <= KeyPoints.Length; i++)
                {
                    if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
                        return i;
                }
            }

            var path = new GraphicsPath();
            Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);

            Rectangle rect = NormalRectToSquare(PaintHelper.NormalizeRect(StartPoint, EndPoint));
            path.AddEllipse(rect);
            path.Widen(pen);

            Region region = new Region(path);
            pen.Dispose();
            if(region.IsVisible(p))
                return 0;

            Point center = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
            double radius = rect.Width / 2;
            float dx = p.X - center.X;
            float dy = p.Y - center.Y;
            if (Math.Sqrt(dx * dx + dy * dy) <= radius)
                return 0;
            return -1;
        }
コード例 #60
0
ファイル: HatchCombo.cs プロジェクト: 15831944/Test3-1
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);

            e.DrawBackground();

            HatchStyle style = FromString((string)this.Items[e.Index]);

            System.Drawing.Drawing2D.HatchBrush brush =
                new System.Drawing.Drawing2D.HatchBrush(style, Color.Black, e.BackColor);
            System.Drawing.Pen pen =
                new System.Drawing.Pen(Color.Black, 0);

            Rectangle rect = e.Bounds;

            rect.Inflate(-1, -1);
            rect.Width  -= 1;
            rect.Height -= 1;

            e.Graphics.RenderingOrigin = new Point(0, 0);
            e.Graphics.FillRectangle(brush, rect);
            e.Graphics.DrawRectangle(pen, rect);

            pen.Dispose();
            brush.Dispose();
        }