示例#1
0
        public void ShowAlert(string message, NotificationType eType)
        {
            Opacity       = 0.0;
            StartPosition = FormStartPosition.Manual;
            string formName;

            for (int i = 1; i < 10; i++)
            {
                formName = "alert" + i.ToString();
                Form_Alert frm = (Form_Alert)Application.OpenForms[formName];

                if (frm == null)
                {
                    Name     = formName;
                    posX     = Screen.PrimaryScreen.WorkingArea.Width - Width + 15;
                    posY     = Screen.PrimaryScreen.WorkingArea.Height - Height * i - 5 * i;
                    Location = new Point(posX, posY);
                    break;
                }
            }

            posX = Screen.PrimaryScreen.WorkingArea.Width - Width - 5;

            switch (eType)
            {
            case NotificationType.Success:
                iconPictureBox1.IconChar  = FontAwesome.Sharp.IconChar.Check;
                iconPictureBox1.IconColor = Color.White;
                iconPictureBox1.BackColor = Color.SeaGreen;
                BackColor = Color.SeaGreen;
                break;

            case NotificationType.Error:
                iconPictureBox1.IconChar  = FontAwesome.Sharp.IconChar.Bug;
                iconPictureBox1.IconColor = Color.White;
                iconPictureBox1.BackColor = Color.DarkRed;
                BackColor = Color.DarkRed;
                break;

            case NotificationType.Info:
                iconPictureBox1.IconChar  = FontAwesome.Sharp.IconChar.Info;
                iconPictureBox1.IconColor = Color.White;
                iconPictureBox1.BackColor = Color.RoyalBlue;
                BackColor = Color.RoyalBlue;
                break;

            case NotificationType.Warning:
                iconPictureBox1.IconChar  = FontAwesome.Sharp.IconChar.SkullCrossbones;
                iconPictureBox1.IconColor = Color.White;
                iconPictureBox1.BackColor = Color.DarkOrange;
                BackColor = Color.DarkOrange;
                break;
            }

            labelMessage.Text = message;
            Show();
            notificationAction = NotificationAction.start;
            timer1.Interval    = 1;
            timer1.Start();
        }
        public void Alert(string message, NotificationType eType)
        {
            Form_Alert frm = new Form_Alert();

            frm.ShowAlert(message, eType);
        }