Exemple #1
0
        public NotifyBoxInterface(string title, string message, NotifyBoxType type, NotifyBoxIcon icon)
        {
            InitializeComponent( );

            TITLE_LABEL.Text   = title;
            MESSAGE_LABEL.Text = message;

            this.SetStyle(ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
            this.UpdateStyles( );
            this.Opacity = 0;

            switch (icon)
            {
            case NotifyBoxIcon.Error:
                TYPE_ICON.Image = Properties.Resources.ERROR_ICON;
                System.Media.SystemSounds.Hand.Play( );
                break;

            case NotifyBoxIcon.Information:
                TYPE_ICON.Image = Properties.Resources.INFORMATION_ICON;
                System.Media.SystemSounds.Beep.Play( );
                break;

            case NotifyBoxIcon.Warning:
                TYPE_ICON.Image = Properties.Resources.WARNING_ICON;
                System.Media.SystemSounds.Exclamation.Play( );
                break;

            case NotifyBoxIcon.Question:
                TYPE_ICON.Image = Properties.Resources.QUESTION_ICON;
                System.Media.SystemSounds.Beep.Play( );
                break;

            case NotifyBoxIcon.Danger:
                TYPE_ICON.Image = Properties.Resources.DANGER_ICON;
                System.Media.SystemSounds.Hand.Play( );
                break;
            }

            switch (type)
            {
            case NotifyBoxType.OK:
                OK_Button.Visible  = true;
                Yes_Button.Visible = false;
                NO_Button.Visible  = false;

                OK_Button.Focus( );

                this.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (Result != NotifyBoxResult.OK)
                    {
                        Result = NotifyBoxResult.OK;
                    }
                };
                break;

            case NotifyBoxType.YesNo:
                OK_Button.Visible  = false;
                Yes_Button.Visible = true;
                NO_Button.Visible  = true;

                this.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (Result != NotifyBoxResult.Yes && Result != NotifyBoxResult.No)
                    {
                        Result = NotifyBoxResult.No;
                    }
                };
                break;
            }
        }
Exemple #2
0
        public NotifyBoxInterface(string title, string message, NotifyBoxType type, NotifyBoxIcon icon)
        {
            InitializeComponent( );

            TITLE_LABEL.Text   = title;
            MESSAGE_LABEL.Text = message;

            switch (icon)
            {
            case NotifyBoxIcon.Error:
                TYPE_ICON.Image = Properties.Resources.ERROR_ICON;
                System.Media.SystemSounds.Exclamation.Play( );
                break;

            case NotifyBoxIcon.Information:
                TYPE_ICON.Image = Properties.Resources.INFORMATION_ICON;
                System.Media.SystemSounds.Asterisk.Play( );
                break;

            case NotifyBoxIcon.Warning:
                TYPE_ICON.Image = Properties.Resources.WARNING_ICON;
                System.Media.SystemSounds.Exclamation.Play( );
                break;

            case NotifyBoxIcon.Question:
                TYPE_ICON.Image = Properties.Resources.QUESTION_ICON;
                System.Media.SystemSounds.Question.Play( );
                break;
            }

            switch (type)
            {
            case NotifyBoxType.OK:
                OK_Button.Visible  = true;
                Yes_Button.Visible = false;
                NO_Button.Visible  = false;

                this.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (Result != NotifyBoxResult.OK)
                    {
                        Result = NotifyBoxResult.OK;
                    }
                };
                break;

            case NotifyBoxType.YesNo:
                OK_Button.Visible  = false;
                Yes_Button.Visible = true;
                NO_Button.Visible  = true;

                this.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (Result != NotifyBoxResult.Yes && Result != NotifyBoxResult.No)
                    {
                        Result = NotifyBoxResult.No;
                    }
                };
                break;
            }
        }
Exemple #3
0
        public static NotifyBoxResult Show(System.Windows.Forms.Form parent, string title = "메세지 박스", string message = "메세지", NotifyBoxType type = NotifyBoxType.OK, NotifyBoxIcon icon = NotifyBoxIcon.Information)
        {
            NotifyBoxResult returnType = NotifyBoxResult.Null;

            NotifyBoxInterface notify = new NotifyBoxInterface(title, message, type, icon);

            if (parent == null)
            {
                Main mainForm = Utility.GetMainForm( );

                if (mainForm != null)
                {
                    mainForm.Invoke(new Action(() =>
                    {
                        notify.Owner         = mainForm;
                        notify.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                        notify.ShowDialog( );

                        returnType = notify.Result;
                    }));
                }
                else
                {
                    notify.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                    notify.ShowDialog( );

                    returnType = notify.Result;
                }
            }
            else
            {
                parent.Invoke(new Action(() =>
                {
                    notify.Owner         = parent;
                    notify.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
                    notify.ShowDialog(parent);

                    returnType = notify.Result;
                }));
            }

            return(returnType);
        }
Exemple #4
0
        public static NotifyBoxResult Show(Form parent, string title, string titleEng, string message, NotifyBoxType type, NotifyBoxIcon icon, int timeout = 0)
        {
            NotifyBoxResult returnType = NotifyBoxResult.Null;

            NotifyBoxForm form = new NotifyBoxForm(title, titleEng, message, type, icon, timeout);

            if (parent == null)
            {
                form.StartPosition = FormStartPosition.CenterScreen;
                form.ShowDialog( );

                returnType = form.Result;
            }
            else
            {
                parent.Invoke(new Action(() =>
                {
                    form.Owner         = parent;
                    form.StartPosition = FormStartPosition.CenterParent;
                    form.ShowDialog(parent);

                    returnType = form.Result;
                }));
            }

            return(returnType);
        }