public void ShowAlert(String msj, TypeMessage type) { this.Message = msj; this.Opacity = 0.0; this.StartPosition = FormStartPosition.Manual; string Frame; for (int i = 0; i < 10; i++) { Frame = "alert" + i.ToString(); Form_Alert frm = (Form_Alert)Application.OpenForms[Frame]; if (frm == null) { this.Name = Frame; this.x = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 15; this.x = Screen.PrimaryScreen.WorkingArea.Height - this.Height * i; y = 0; this.Location = new Point(this.x, this.y); break; } } this.x = Screen.PrimaryScreen.WorkingArea.Width - base.Width - 5; this.lbl_msj.Text = Message; switch (type) { case TypeMessage.ERROR: this.BackColor = Color.DarkRed; break; case TypeMessage.WARNING: this.BackColor = Color.DarkOrange; break; case TypeMessage.INFO: this.BackColor = Color.RoyalBlue; break; case TypeMessage.SUCCESS: this.BackColor = Color.SeaGreen; break; } this.Show(); this.action = enumAction.start; this.timer1.Interval = 1; timer1.Start(); }
private void timerAlert1_Tick(object sender, EventArgs e) { switch (this.action) { case enumAction.wait: timerAlert1.Interval = 20000; action = enumAction.close; break; case Form_Alert.enumAction.start: this.timerAlert1.Interval = 1; this.Opacity += 0.1; if (this.x < this.Location.X) { this.Left--; } else { if (this.Opacity == 1.0) { action = Form_Alert.enumAction.wait; } } break; case enumAction.close: timerAlert1.Interval = 1; this.Opacity -= 0.1; this.Left -= 3; if (base.Opacity == 0.0) { base.Close(); } break; case enumAction.waitALot: timerAlert1.Interval = 20000; action = enumAction.close; break; } }
public void showAlert(string msg, int totalCount, enmType type) { this.Opacity = 0.0; this.StartPosition = FormStartPosition.Manual; string fname; for (int i = 1; i < 10; i++) { fname = "alert" + i.ToString(); Form_Alert frm = (Form_Alert)Application.OpenForms[fname]; if (frm == null) { this.Name = fname; this.x = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 15; this.y = Screen.PrimaryScreen.WorkingArea.Height - this.Height * i - 5 * i; this.Location = new Point(this.x, this.y); break; } } switch (type) { case enmType.Success: this.pictureBox1.Image = Resources.success; break; case enmType.Warning: this.pictureBox1.Image = Resources.warning; break; } this.x = Screen.PrimaryScreen.WorkingArea.Width - base.Width - 5; this.textBox1.Text = msg; this.label3.Text = totalCount.ToString(); this.Show(); this.action = enumAction.start; this.timerAlert1.Interval = 1; this.timerAlert1.Start(); }
private void button1_Click(object sender, EventArgs e) { timerAlert1.Interval = 1; action = enumAction.close; }
private void pictureBox2_Click(object sender, EventArgs e) { timer1.Interval = 1; action = enumAction.close; }