ИЗМЕНИТЬ:
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 TestMinimize
{
public partial class Form1 : Form
{
System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer();
bool Minimized;
public Form1()
{
InitializeComponent();
t.Interval = 2; // specify interval time as you want
t.Tick += new EventHandler(timer_Tick);
this.SizeChanged += new EventHandler(this_SizeChanged);
t1.Interval = 1;
t1.Tick += new EventHandler(timer1_Tick);
t1.Start();
}
private void this_SizeChanged(object source, EventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
Minimized = false;
}
}
private void timer_Tick(object source, EventArgs e)
{
this.Height = this.Height-8;
if (this.Height == 39)
{
t.Stop();
t.Enabled = false;
this.WindowState = FormWindowState.Minimized;
Minimized = true;
}
}
private void timer1_Tick(object source, EventArgs e)
{
if(Minimized==false && t.Enabled == false)
{
this.Height = 221;
}
}
private void button1_Click(object sender, EventArgs e)
{
t.Start();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}