Exemplo n.º 1
0
        public void Alert(string caption, string message = "", AlertKind alertKind = AlertKind.Primary)
        {
            Opacity       = 0.0;
            StartPosition = FormStartPosition.Manual;
            string instance;

            for (int i = 1; i < 10; i++)
            {
                instance = "noty" + i.ToString();
                Noty f = (Noty)Application.OpenForms[instance];

                if (f == null)
                {
                    this.Name = instance;
                    _x        = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 15;
                    _y        = Screen.PrimaryScreen.WorkingArea.Height - this.Height * i - 5 * i;
                    Location  = new Point(_x, _y);
                    break;
                }
            }

            _x = Screen.PrimaryScreen.WorkingArea.Width - base.Width - 5;

            Caption.Text = caption;
            Message.Text = message;

            switch (alertKind)
            {
            case AlertKind.Primary:
                Icon.Image = Resources.info;
                SetBackColor(93, 156, 236);     // blue jeans
                SetBorderColor(74, 137, 220);   // hover
                SetCaptionColor(21, 61, 115);
                break;

            case AlertKind.Secondary:
                Icon.Image = Resources.info;
                SetBackColor(101, 109, 120);    // dark gray
                SetBorderColor(67, 74, 84);     // hover
                SetCaptionColor(27, 30, 36);
                break;

            case AlertKind.Success:
                Icon.Image = Resources.success;
                SetBackColor(160, 212, 104);     // grass
                SetBorderColor(140, 193, 82);    // hover
                SetCaptionColor(49, 89, 5);
                break;

            case AlertKind.Info:
                Icon.Image = Resources.info;
                SetBackColor(79, 193, 233);     // aqua
                SetBorderColor(59, 175, 218);   // hover
                SetCaptionColor(12, 98, 130);
                break;

            case AlertKind.Warning:
                Icon.Image = Resources.warning;
                SetBackColor(255, 206, 84);     // sunflower
                SetBorderColor(252, 187, 66);   // hover
                SetCaptionColor(161, 107, 10);
                break;

            case AlertKind.Error:
                Icon.Image = Resources.error;
                SetBackColor(237, 85, 101);     // grapefruit
                SetBorderColor(218, 68, 83);    // hover
                SetCaptionColor(110, 21, 30);
                break;

            case AlertKind.Reminder:
                Icon.Image = Resources.warning;
                SetBackColor(252, 110, 81);     // grapefruit
                SetBorderColor(233, 87, 63);    // hover
                SetCaptionColor(135, 31, 14);
                break;

            default:
                Icon.Image = Resources.info;
                SetBackColor(93, 156, 236);     // blue jeans
                SetBorderColor(74, 137, 220);   // hover
                SetCaptionColor(32, 77, 138);
                break;
            }

            Show();
            _action        = ActionKind.Start;
            timer.Interval = 1;
            timer.Start();
        }
Exemplo n.º 2
0
        public void Alert(string caption, string message, AlertKind alertKind)
        {
            Noty n = new Noty();

            n.Alert(caption, message, alertKind);
        }