ویژوال 30 شارپ

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

ویژوال 30 شارپ

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

Text Coder

        private void button1_Click(object sender, EventArgs e)
        {
            string otext = textBox1.Text;
            string ntext = string.Empty;
            for (int i = 0; i < textBox1.Text.Length; i++)
            {
                int j = char.ConvertToUtf32(otext, i);
                ntext += char.ConvertFromUtf32(255-j );

            }
            textBox1.Text = ntext;
        }

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;
        }