SoFunction
Updated on 2025-03-07

Imitation of the left telescopic menu effect of imitating windows based on C#

This article describes a folding menu based on C#. The style is modeled after Windows opens the telescopic menu effect on the left side of my computer. It is also blue. It looks as beautiful as the effect of Windows, and can realize functions such as folding and expanding. This can be used when learning C# interface programming, and its main implementation code is as follows:

using System;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
namespace LikesXP
{
  public partial class Frm_Main : Form
  {
    public Frm_Main()
    {
      InitializeComponent();
    }
    private static Panel Var_Panel = new Panel();//Create static fields    private static PictureBox Var_Pict = //Create static fields      new PictureBox();
    private static int Var_i = 0;//Create static fields    private Font Var_Font = new Font("Songyi", 9); //Create font fields    private void pictureBox_1_Click(object sender, EventArgs e)
    {
      Var_i = Convert.ToInt16((//Get the data in the control        (PictureBox)sender).());
      switch (Var_i)
      {
        case 1:
          {
            Var_Panel = panel_Gut_1;//Get the panel object reference            //Var_Pict = pictureBox_1;//Get the reference of the PictureBox object            break;
          }
        case 2:
          {
            Var_Panel = panel_Gut_2;//Get the panel object reference            Var_Pict = pictureBox_2;//Get the PictureBox object reference            break;
          }
        case 3:
          {
            Var_Panel = panel_Gut_3;//Get the panel object reference            Var_Pict = pictureBox_3;//Get the PictureBox object reference            break;
          }
      }
      if (Convert.ToInt16(Var_Panel.()) == 0 || Convert.ToInt16(Var_Panel.()) == 2)
      {
        Var_Panel.Tag = 1;//Set to hide the logo        Var_Pict.Image = .Down button;//Set image properties        Var_Panel.Visible = false;//Hide panel      }
      else
      {
        if (Convert.ToInt16(Var_Panel.()) == 1)
        {
          Var_Panel.Tag = 2;//Set to display the logo          Var_Pict.Image = .Upward button;//Set image properties          Var_Panel.Visible = true;//Display panel        }
      }
    }
    private void Form1_Load(object sender, EventArgs e)
    {
      //pictureBox_1.Image = .upward button;//Set image information      pictureBox_2.Image = .Upward button;//Set image information      pictureBox_3.Image = .Upward button;//Set image information      Var_Font = label_1.Font;//Get font object    }
    private void label_1_MouseEnter(object sender, EventArgs e)
    {
      ((Label)sender).ForeColor = ;//Set the control text color      ((Label)sender).Font = //Set the control font        new Font(Var_Font, Var_Font.Style | );
    }
    private void label_1_MouseLeave(object sender, EventArgs e)
    {
      ((Label)sender).ForeColor = ;//Set the control text color      ((Label)sender).Font = //Set the control font        new Font(Var_Font, Var_Font.Style);
    }
    private void pictureBox1_Click(object sender, EventArgs e)
    {
      if (Convert.ToInt16(()) == 1)
      {
        ();
        ("").ToShortDateString();
        //  = .Down button;//Set image properties        // = false;//Hide panel      }
      else
      {
        if (Convert.ToInt16(()) == 0)
        {
          ();
          // = 1;//Set to display the logo          // = .Upward button;//Set image properties          // = true;//Display panel        }
      }
    }
    private void timer1_Tick(object sender, EventArgs e)
    {
      long longWidth = ;
      //If the panel is currently hidden      if (Convert.ToInt16(()) == 0)
      {
        if (longWidth == 200)
        {
           = false;
           = 1;//Set to display the logo        }
        else
        {
           += 10;
        }
      }
      //If the panel is currently displayed      if (Convert.ToInt16(()) == 1)
      {
        if (longWidth == 0)
        {
           = false;
           = 0;//Set to hide the logo        }
        else
        {
           -= 10;
        }
      }
    }
  }
}

Only the main functional code is displayed here, and readers can further improve other implementation details.