예제 #1
0
        //-------------------------------------------------------------------------------------------------------------------------------
        //                                  Event for "Notify Dialog" button
        //-------------------------------------------------------------------------------------------------------------------------------
        private void oNotifyDialogButtonClick(object sender, EventArgs e)
        {
            Notifier.Type   noteType = Notifier.Type.INFO;
            BackDialogStyle back     = BackDialogStyle.FadedApplication;

            // Note type
            if (radioButtonInfo.Checked)
            {
                noteType = Notifier.Type.INFO;                  // Note type INFO
            }
            if (radioButtonOk.Checked)
            {
                noteType = Notifier.Type.OK;                    // Note type OK
            }
            if (radioButtonWarning.Checked)
            {
                noteType = Notifier.Type.WARNING;               // Note type WARNING
            }
            if (radioButtonError.Checked)
            {
                noteType = Notifier.Type.ERROR;                 // Note type ERROR
            }
            if (backNone.Checked)
            {
                back = BackDialogStyle.None;                    // Faded Background type: None
            }
            if (backApp.Checked)
            {
                back = BackDialogStyle.FadedApplication;        // Faded Background type: Application
            }
            if (backFull.Checked)
            {
                back = BackDialogStyle.FadedScreen;             // Faded Background type: Fullscreen
            }
            Notifier.ShowDialog(textNote.Text,                  // It is not possible to get the ID of the note on the Creation for dialogs// It is not possible to get the ID of the note on the Creation for dialogs
                                noteType,
                                textTitle.Text,
                                back,
                                this);
        }
예제 #2
0
        //-------------------------------------------------------------------------------------------------------------------------------
        //                                  Show a Dialog note: with faded background if specified
        //-------------------------------------------------------------------------------------------------------------------------------
        public static DialogResult ShowDialog(string content,
                                              Type type    = Type.INFO,
                                              string title = "Notifier",
                                              BackDialogStyle backDialogStyle = BackDialogStyle.FadedScreen,
                                              Form application = null)
        {
            Form back               = null;
            int  backBorder         = 200;
            bool orgTopMostSettings = false;

            if (backDialogStyle == BackDialogStyle.FadedApplication &&
                application == null)
            {
                backDialogStyle = BackDialogStyle.FadedScreen;
            }

            if (backDialogStyle != BackDialogStyle.None)
            {
                back = new Form();                                              // Create the fade background
                back.FormBorderStyle = FormBorderStyle.None;
                back.BackColor       = Color.FromArgb(0, 0, 0);
                back.Opacity         = 0.6;
                back.ShowInTaskbar   = false;
            }

            Notifier note = new Notifier(content, type, title, true);                // Instantiate the Notifier form

            note.backDialogStyle = backDialogStyle;

            switch (note.backDialogStyle)
            {
            case BackDialogStyle.None:
                if (application != null)                                        // Set the startup position
                {
                    note.Owner         = application;
                    note.StartPosition = FormStartPosition.CenterParent;
                }
                else
                {
                    note.StartPosition = FormStartPosition.CenterScreen;
                }
                break;

            case BackDialogStyle.FadedScreen:
                back.Location = new System.Drawing.Point(-backBorder, -backBorder);
                back.Size     = new Size(Screen.PrimaryScreen.WorkingArea.Width + backBorder,
                                         Screen.PrimaryScreen.WorkingArea.Height + backBorder);

                if (application != null)
                {
                    back.Show(application);
                }
                back.TopMost       = true;
                note.StartPosition = FormStartPosition.CenterScreen;            // Set the startup position
                break;

            case BackDialogStyle.FadedApplication:
                note.myCallerApp    = application;
                orgTopMostSettings  = application.TopMost;
                application.TopMost = true;
                back.StartPosition  = FormStartPosition.Manual;
                back.Size           = application.Size;
                back.Location       = application.Location;
                if (application != null)
                {
                    back.Show(application);
                }
                back.TopMost       = true;
                note.StartPosition = FormStartPosition.CenterParent;            // Set the startup position
                break;
            }

            notes.Add(note);                                                    // Add to our collection of Notifiers
            note.ShowInTaskbar = false;
            note.ShowDialog();

            if (back != null)                                                   // Close the back
            {
                back.Close();
            }

            if (application != null)                                            // restore app window top most property
            {
                application.TopMost = orgTopMostSettings;
            }

            return(DialogResult.OK);
        }
예제 #3
0
        // DIALOG NOTE - With faded background!!!
        #region DIALOG NOTE CREATION
        public static DialogResult ShowDialog(string desc, Type type          = Type.INFO, string tit = "Notifier",
                                              BackDialogStyle backDialogStyle = BackDialogStyle.FadedScreen,
                                              Form obscureMe = null)
        {
            if (backDialogStyle == BackDialogStyle.FadedApplication && obscureMe == null)
            {
                backDialogStyle = BackDialogStyle.FadedScreen;
            }

            Form back = new Form();

            back.FormBorderStyle = FormBorderStyle.None;
            back.BackColor       = Color.FromArgb(0, 0, 0);
            back.Opacity         = 0.6;
            int border = 200;

            // Instantiate the Notifier form
            Notifier not = new Notifier(desc, type, tit, true);

            not.backDialogStyle = backDialogStyle;
            bool orgTopMostSettings = false;

            // To draw it on primary screen
            switch (not.backDialogStyle)
            {
            case BackDialogStyle.FadedScreen:
                back.Location = new System.Drawing.Point(-border, -border);
                back.Size     = new Size(Screen.PrimaryScreen.WorkingArea.Width + border,
                                         Screen.PrimaryScreen.WorkingArea.Height + border);
                back.Show();
                back.TopMost = true;
                break;

            case BackDialogStyle.FadedApplication:
                not.myCallerApp    = obscureMe;
                orgTopMostSettings = obscureMe.TopMost;
                obscureMe.TopMost  = true;
                Point locationOnForm = obscureMe.PointToScreen(Point.Empty);
                back.Size          = obscureMe.Size;
                back.Location      = obscureMe.Location;
                back.StartPosition = FormStartPosition.Manual;
                back.Show();
                back.TopMost = true;
                break;

            default:
                /*back.Location = new System.Drawing.Point(-2, -2);
                 * back.Size = new Size(1,1);
                 * back.Show();*/
                break;
            }
            // Add to our collection of Notifiers, cause "OpenForms"
            // is currently buggy
            Notifiers.Add(not);

            not.ShowDialog();

            back.Close();
            if (obscureMe != null)
            {
                obscureMe.TopMost = orgTopMostSettings;
            }

            return(DialogResult.OK);
        }