Hiệu ứng hiển thị menu slide trong winform
Xin chào các bạn, bài viết hôm nay mình sẽ tiếp tục chia sẻ đến các bạn hiệu ứng hiển thị menu trên C#, Winform
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace animation_menu
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool isShow = false;
#region "animation"
private void timer1_Tick(object sender, EventArgs e)
{
panel1.Left -= 7;
label1.Left -= 7;
if (panel1.Left <= 300)
{
timer2.Start();
}
if (panel2.Left <= 300)
{
timer3.Start();
}
if (panel3.Left <= 300)
{
timer4.Start();
}
if (panel1.Left <= 22)
{
timer1.Stop();
}
}
private void timer2_Tick(object sender, EventArgs e)
{
panel2.Left -= 7;
label2.Left -= 7;
if (panel2.Left <= 22)
{
timer2.Stop();
}
}
private void timer3_Tick(object sender, EventArgs e)
{
panel3.Left -= 7;
label3.Left -= 7;
if (panel3.Left <= 22)
{
timer3.Stop();
}
}
private void timer4_Tick(object sender, EventArgs e)
{
panel4.Left -= 7;
label4.Left -= 7;
if (panel4.Left <= 22)
{
timer4.Stop();
isShow = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void timer5_Tick(object sender, EventArgs e)
{
panel1.Left += 7;
label1.Left += 7;
if (panel1.Left >= 62)
{
timer6.Start();
}
if (panel2.Left >= 62)
{
timer7.Start();
}
if (panel3.Left >= 62)
{
timer8.Start();
}
if (panel1.Left >= 344)
{
timer5.Stop();
}
}
private void timer6_Tick(object sender, EventArgs e)
{
panel2.Left += 7;
label2.Left += 7;
if (panel2.Left >= 344)
{
timer6.Stop();
isShow = false;
}
}
private void timer7_Tick(object sender, EventArgs e)
{
panel3.Left += 7;
label3.Left += 7;
if (panel3.Left >= 344)
{
timer7.Stop();
}
}
private void timer8_Tick(object sender, EventArgs e)
{
panel4.Left += 7;
label4.Left += 7;
if (panel4.Left >= 344)
{
timer8.Stop();
}
}
#endregion
private void label6_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void panel6_Click(object sender, EventArgs e)
{
if (!isShow)
{
timer1.Start();
}
else
{
timer5.Start();
}
}
}
}
Ồ, bạn chưa phải thành viên của forum
Đăng nhập hoặc đăng ký ngay.
Chúc các bạn thành công!