ویژوال 30 شارپ

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

ویژوال 30 شارپ

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

Transparent Control

control.BackColor = Color.Transparent;

Star Form

int l = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            l-=1;
            System.Drawing.Drawing2D.GraphicsPath g = new System.Drawing.Drawing2D.GraphicsPath();
            for (int i = 0; i <= 360; i+=20)
            {
                g.AddLine((float)Math.Cos(Math.PI * (i+l) / 180) * this.Width / 2 + this.Width / 2
                    , (float)Math.Sin(Math.PI * (i+l) / 180) * this.Height / 2 + this.Height / 2,
                    (float)Math.Cos(Math.PI * (i +l) / 180) * this.Width / 4 + this.Width / 2,
                    (float)Math.Sin(Math.PI * (i+l) / 180) * this.Height / 4 + this.Height / 2);
            }
            this.Region = new Region(g);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Width = 300;
            this.Height = 300;
        }

Picture In TextBox

private void Form1_Load(object sender, EventArgs e)
{
    PictureBox pic = new PictureBox();
    //pic.Image = Image.FromFile("FilePath");
    pic.Image = SystemIcons.Information.ToBitmap();;
    textBox1.Controls.Add(pic);
}

ListView View Change

private void button2_Click(object sender, EventArgs e)
{
    int n = (int) listView1.View;
    if (n == 4)
        n = -1;
    listView1.View = (View)Enum.ToObject(typeof(View), ++n);
}

Form Opacity

private void button1_Click(object sender, EventArgs e)
{
    this.Opacity = 1;
    for (int i = 0; i < 100; i++)
    {
        this.Opacity -= 0.01;
        Application.DoEvents();
    }
}