Мне нужна помощь. Я сейчас программирую уведомления, и я хотел бы создать одну и ту же форму несколько раз, но всегда немного ниже, это мой код.У меня есть все, что я когда-либо узнал, но я ничего не принес. Надеюсь, я найду здесь помощь.
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 UniqueOS_
{
public partial class alert : Form
{
public alert(string _message, AlertType type)
{
InitializeComponent();
Nachricht.Text = _message;
switch (type)
{
case AlertType.success:
this.BackColor = Color.SeaGreen;
this.pictureBox1.Image = Properties.Resources.icons8_ok_70;
break;
case AlertType.info:
this.BackColor = Color.Gray;
this.pictureBox1.Image = Properties.Resources.icons8_info_70;
break;
case AlertType.warning:
this.BackColor = Color.FromArgb(255, 128, 0);
this.pictureBox1.Image = Properties.Resources.icons8_error_70__1_;
break;
case AlertType.error:
this.BackColor = Color.Crimson;
this.pictureBox1.Image = Properties.Resources.icons8_error_70__1_;
break;
}
}
/// <summary>
///
/// </summary>
/// <param name="message"></param>
/// <param name="type"></param>
public static void Show(string message, AlertType type)
{
new UniqueOS_.alert(message, type).Show();
}
private void alert_Load(object sender, EventArgs e)
{
this.TopMost = true;
this.Top = -1 * (this.Height);
this.Left = Screen.PrimaryScreen.Bounds.Width - this.Width - 40;
show.Start();
button1.FlatAppearance.BorderColor = this.BackColor;
}
public enum AlertType
{
success, info, warning, error
}
private void button1_Click(object sender, EventArgs e)
{
close.Start();
}
int interval = 0;
public void show_Tick(object sender, EventArgs e)
{
if (this.Top < 60)
{
this.Top += interval;
interval += 2;
}
else
{
show.Stop();
interval += 4;
Verschwindertimer.Start();
}
}
private void close_Tick(object sender, EventArgs e)
{
if (this.Opacity > 0)
{
this.Opacity -= 0.1;
}
else
{
this.Close();
}
}
private void timeout_Tick(object sender, EventArgs e)
{
}
private void Verschwindertimer_Tick(object sender, EventArgs e)
{
close.Start();
}
private void Nachricht_Click(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}