コード例 #1
0
        protected void OnPaint(object sender, System.WinForms.PaintEventArgs e)
        {
            Graphics g       = e.Graphics;
            Pen      thePen  = new Pen(Color.Black, 10);
            int      yOffSet = 10;

            // Get all members of the LineCap enum.
            Object[] obj = Enum.GetValues(typeof(LineCap));

            // Draw a line with a LineCap member.
            for (int x = 0; x < obj.Length; x++)
            {
                // Get next cap and configure pen.
                LineCap temp = (LineCap)obj[x];
                thePen.StartCap = temp;
                thePen.EndCap   = temp;

                // Print name of LineCap enum.
                g.DrawString(temp.Format(), new Font("Times New Roman", 10),
                             new SolidBrush(Color.Black), 0, yOffSet);

                // Draw a line with the correct cap.
                g.DrawLine(thePen, 100, yOffSet, Width - 50, yOffSet);

                yOffSet += 40;
            }
        }
コード例 #2
0
        protected void OnPaint(object sender, System.WinForms.PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            // Make a blue SolidBrush.
            SolidBrush blueBrush = new SolidBrush(Color.Blue);

            // Get a stock brush from the Brushes type.
            SolidBrush pen2 = (SolidBrush)Brushes.Firebrick;

            // Render some shapes with the brushes.
            g.FillEllipse(blueBrush, 10, 10, 100, 100);
            g.FillPie(Brushes.Black, 150, 10, 120, 150, 90, 80);

            // Draw a purple dashed polygon as well...
            SolidBrush brush3 = new SolidBrush(Color.Purple);

            g.FillPolygon(brush3, new Point[] { new Point(30, 140),
                                                new Point(265, 200),
                                                new Point(100, 225),
                                                new Point(190, 190),
                                                new Point(50, 330),
                                                new Point(20, 180) });

            // And a rect with some text...
            Rectangle r = new Rectangle(150, 10, 130, 60);

            g.FillRectangle(Brushes.Blue, r);
            g.DrawString("Hello out there...How are ya?",
                         new Font("Arial", 12), Brushes.White, r);
        }
コード例 #3
0
        protected void OnPaint(object sender, System.WinForms.PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.FillRectangle(Brushes.AntiqueWhite, dropRect);

            // Display instructions.
            g.DrawString("Drag the happy guy in here...", new Font("Times New Roman", 25),
                         Brushes.Red, dropRect);
        }
コード例 #4
0
        protected void OnPaint(object sender, System.WinForms.PaintEventArgs e)
        {
            Graphics  g = e.Graphics;
            Rectangle r = ClientRectangle;

            // Paint the clouds on the client araa.
            g.FillRectangle(texturedBGroundBrush, r);

            // Some big bold text with a textured brush.
            g.DrawString("Bitmaps as brushes!  Way cool...",
                         new Font("Arial", 60,
                                  FontStyle.BoldItalic),
                         texturedTextBrush,
                         r);
        }