ویژوال 30 شارپ

سورس کدهای جالب سی شارپ فقط با یک نگاه

ویژوال 30 شارپ

سورس کدهای جالب سی شارپ فقط با یک نگاه

In The Name Of God

        int i = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            Bitmap b = new Bitmap(Width, Height);
            Graphics g = Graphics.FromImage(b);
            i+=1;
            g.DrawString("به نام", new Font("Tahoma", 14,FontStyle.Underline), Brushes.Black, new PointF((float)Math.Cos(Math.PI * i / 180) * 100 + Width / 2, (float)(float)Math.Sin(Math.PI * i / 180) * 100 + Height / 2));
            g.DrawString("خداوند", new Font("Tahoma", 14, FontStyle.Underline), Brushes.Black, new PointF((float)Math.Cos(Math.PI * (i + 90) / 180) * 100 + Width / 2, (float)(float)Math.Sin(Math.PI * (i + 90) / 180) * 100 + Height / 2));
            g.DrawString("بخشنده", new Font("Tahoma", 14, FontStyle.Underline), Brushes.Black, new PointF((float)Math.Cos(Math.PI * (i + 180) / 180) * 100 + Width / 2, (float)(float)Math.Sin(Math.PI * (i + 180) / 180) * 100 + Height / 2));
            g.DrawString("بخشایشگر", new Font("Tahoma", 14, FontStyle.Underline), Brushes.Black, new PointF((float)Math.Cos(Math.PI * (i + 270) / 180) * 100 + Width / 2, (float)(float)Math.Sin(Math.PI * (i + 270) / 180) * 100 + Height / 2));
            this.BackgroundImage = b;
        }

3D Text

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            Bitmap b = new Bitmap(Width, Height);
            Graphics g = Graphics.FromImage(b);
            for (int i = 0; i < 255; i++)
            {
                SolidBrush sb = new SolidBrush(Color.FromArgb(i, 0, 0));
                // OR
               // SolidBrush sb = new SolidBrush(Color.FromArgb(0, i, 0));
               // SolidBrush sb = new SolidBrush(Color.FromArgb(0, 0, i));
                g.DrawString(textBox1.Text, new Font("Arial", 24), sb, new PointF(i / 30, i / 30));
            }
            this.BackgroundImage=b;
        }

Sinus


        private void Form1_Load(object sender, EventArgs e)
        {
            Bitmap b = new Bitmap(Width, Height);
            for (int i = 0; i < this.Width; i++)
            {
                Graphics g = Graphics.FromImage(b);
                g.DrawLine(new Pen(Brushes.Black), i - 1, (float)Math.Sin(Math.PI * (i - 1) / 180) * b.Height / 4 + this.Height / 2,
                    i, (float)Math.Sin(Math.PI * i / 180) * b.Height / 4 + this.Height / 2);
               
            }
            this.BackgroundImage = b;
        }

Like sun

        double i = 0;
        SolidBrush s = new SolidBrush(Color.Black);
        private void timer1_Tick(object sender, EventArgs e)
        {
            Bitmap b = new Bitmap(pictureBox1.Image, pictureBox1.Size);
            Graphics g = Graphics.FromImage(b);
            i += 3;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.DrawLine(new Pen(Brushes.Black),
     float.Parse((-Math.Cos(Math.PI * i / 180) * (b.Width / 20 + (i / 11)) + b.Width / 2).ToString()),
     float.Parse((-Math.Sin(Math.PI * i / 180) * (b.Width / 20 + (i / 11)) + b.Width / 2).ToString()),
     float.Parse((Math.Cos(Math.PI * (i - 1) / 180) * (b.Width / 20 + ((i - 1) / 11)) + b.Width / 2).ToString()),
     float.Parse((Math.Sin(Math.PI * (i - 1) / 180) * (b.Width / 20 + ((i - 1) / 11)) + b.Width / 2).ToString())
     );
            pictureBox1.Image = b;
            this.Text = i.ToString();
            if (i >= 2660)
            {
                timer1.Enabled = false;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Bitmap b = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            pictureBox1.Image = b;
        }

Iran

    using System.Drawing.Drawing2D;


    private void Form1_Load(object sender, EventArgs e)
        {
            LinearGradientBrush lb = new LinearGradientBrush(this.ClientRectangle, Color.Red, Color.Black, 150);
            ColorBlend cb = new ColorBlend();
            Color[] c = new Color[] { Color.Green, Color.White, Color.Red };
            cb.Colors = c;
            cb.Positions = new float[] { 0.0f, 0.5f, 1f };
            lb.InterpolationColors = cb;
            Bitmap b = new Bitmap(Width, Height);
            Graphics g = Graphics.FromImage(b);
            g.FillRectangle(lb, this.ClientRectangle);
            this.BackgroundImage = b;
        }