Smoothing Paint : Smooth Paint « 2D Graphics « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » 2D Graphics » Smooth PaintScreenshots 
Smoothing Paint
Smoothing Paint

/*
User Interfaces in C#: Windows Forms and Custom Controls
by Matthew MacDonald

Publisher: Apress
ISBN: 1590590457
*/

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace GDI_Basics
{
    /// <summary>
    /// Summary description for Smoothing.
    /// </summary>
    public class Smoothing : System.Windows.Forms.Form
    {
        internal System.Windows.Forms.GroupBox grpHighQuality;
        internal System.Windows.Forms.PictureBox picHighQuality;
        internal System.Windows.Forms.GroupBox grpAntiAlias;
        internal System.Windows.Forms.PictureBox picAntialias;
        internal System.Windows.Forms.GroupBox grpHighSpeed;
        internal System.Windows.Forms.PictureBox picHighSpeed;
        internal System.Windows.Forms.GroupBox grpNone;
        internal System.Windows.Forms.PictureBox picNone;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public Smoothing()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Disposebool disposing )
        {
            ifdisposing )
            {
                if(components != null)
                {
                    components.Dispose();
                }
            }
            base.Disposedisposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.grpHighQuality = new System.Windows.Forms.GroupBox();
            this.picHighQuality = new System.Windows.Forms.PictureBox();
            this.grpAntiAlias = new System.Windows.Forms.GroupBox();
            this.picAntialias = new System.Windows.Forms.PictureBox();
            this.grpHighSpeed = new System.Windows.Forms.GroupBox();
            this.picHighSpeed = new System.Windows.Forms.PictureBox();
            this.grpNone = new System.Windows.Forms.GroupBox();
            this.picNone = new System.Windows.Forms.PictureBox();
            this.grpHighQuality.SuspendLayout();
            this.grpAntiAlias.SuspendLayout();
            this.grpHighSpeed.SuspendLayout();
            this.grpNone.SuspendLayout();
            this.SuspendLayout();
            // 
            // grpHighQuality
            // 
            this.grpHighQuality.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                         this.picHighQuality});
            this.grpHighQuality.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.grpHighQuality.Location = new System.Drawing.Point(12276);
            this.grpHighQuality.Name = "grpHighQuality";
            this.grpHighQuality.Size = new System.Drawing.Size(34485);
            this.grpHighQuality.TabIndex = 8;
            this.grpHighQuality.TabStop = false;
            this.grpHighQuality.Text = "HighQuality";
            // 
            // picHighQuality
            // 
            this.picHighQuality.Location = new System.Drawing.Point(816);
            this.picHighQuality.Name = "picHighQuality";
            this.picHighQuality.Size = new System.Drawing.Size(32864);
            this.picHighQuality.TabIndex = 0;
            this.picHighQuality.TabStop = false;
            this.picHighQuality.Paint += new System.Windows.Forms.PaintEventHandler(this.picHighQuality_Paint);
            // 
            // grpAntiAlias
            // 
            this.grpAntiAlias.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                       this.picAntialias});
            this.grpAntiAlias.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.grpAntiAlias.Location = new System.Drawing.Point(12188);
            this.grpAntiAlias.Name = "grpAntiAlias";
            this.grpAntiAlias.Size = new System.Drawing.Size(34485);
            this.grpAntiAlias.TabIndex = 7;
            this.grpAntiAlias.TabStop = false;
            this.grpAntiAlias.Text = "AntiAlias";
            // 
            // picAntialias
            // 
            this.picAntialias.Location = new System.Drawing.Point(816);
            this.picAntialias.Name = "picAntialias";
            this.picAntialias.Size = new System.Drawing.Size(32864);
            this.picAntialias.TabIndex = 0;
            this.picAntialias.TabStop = false;
            this.picAntialias.Paint += new System.Windows.Forms.PaintEventHandler(this.picAntialias_Paint);
            // 
            // grpHighSpeed
            // 
            this.grpHighSpeed.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                       this.picHighSpeed});
            this.grpHighSpeed.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.grpHighSpeed.Location = new System.Drawing.Point(12100);
            this.grpHighSpeed.Name = "grpHighSpeed";
            this.grpHighSpeed.Size = new System.Drawing.Size(34485);
            this.grpHighSpeed.TabIndex = 6;
            this.grpHighSpeed.TabStop = false;
            this.grpHighSpeed.Text = "HighSpeed";
            // 
            // picHighSpeed
            // 
            this.picHighSpeed.Location = new System.Drawing.Point(816);
            this.picHighSpeed.Name = "picHighSpeed";
            this.picHighSpeed.Size = new System.Drawing.Size(32864);
            this.picHighSpeed.TabIndex = 0;
            this.picHighSpeed.TabStop = false;
            this.picHighSpeed.Paint += new System.Windows.Forms.PaintEventHandler(this.picHighSpeed_Paint);
            // 
            // grpNone
            // 
            this.grpNone.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                  this.picNone});
            this.grpNone.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.grpNone.Location = new System.Drawing.Point(1212);
            this.grpNone.Name = "grpNone";
            this.grpNone.Size = new System.Drawing.Size(34485);
            this.grpNone.TabIndex = 5;
            this.grpNone.TabStop = false;
            this.grpNone.Text = "None";
            // 
            // picNone
            // 
            this.picNone.Location = new System.Drawing.Point(816);
            this.picNone.Name = "picNone";
            this.picNone.Size = new System.Drawing.Size(32864);
            this.picNone.TabIndex = 0;
            this.picNone.TabStop = false;
            this.picNone.Paint += new System.Windows.Forms.PaintEventHandler(this.picNone_Paint);
            // 
            // Smoothing
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(514);
            this.ClientSize = new System.Drawing.Size(372374);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.grpHighQuality,
                                                                          this.grpAntiAlias,
                                                                          this.grpHighSpeed,
                                                                          this.grpNone});
            this.Font = new System.Drawing.Font("Tahoma"8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.Name = "Smoothing";
            this.Text = "Smoothing";
            this.grpHighQuality.ResumeLayout(false);
            this.grpAntiAlias.ResumeLayout(false);
            this.grpHighSpeed.ResumeLayout(false);
            this.grpNone.ResumeLayout(false);
            this.ResumeLayout(false);

        }
        #endregion

        private void picNone_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            DrawEllipse(e.Graphics);
        }

        private void picHighSpeed_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.HighSpeed;
            DrawEllipse(e.Graphics);

        }

        private void picAntialias_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            DrawEllipse(e.Graphics);
        }

        private void picHighQuality_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            DrawEllipse(e.Graphics);
        }

        private void DrawEllipse(Graphics g)
        {
            Pen drawingPen = new Pen(Color.Red, 5);
            g.DrawEllipse(drawingPen, 101030040);
        }

        [STAThread]
        static void Main() 
        {
            Application.Run(new Smoothing());
        }
    }
}


           
       
Related examples in the same category
1.HatchBrush Demo HatchBrush Demo
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.