Exemplo n.º 1
0
        private void restoreButtonX_Click(object sender, EventArgs e)
        {
            if (backupListBox.SelectedIndex != -1)
            {
                if (restoreDBBackgroundWorker.IsBusy)
                {
                    TaskDialog.Show(new TaskDialogInfo("Try again later", eTaskDialogIcon.Stop, "Restore Currently in Progress", "Try again after it has been completed", eTaskDialogButton.Ok));
                }
                else
                {
                    eTaskDialogButton button = eTaskDialogButton.Yes;
                    button |= eTaskDialogButton.No;

                    eTaskDialogResult result = TaskDialog.Show(new TaskDialogInfo("Confirm", eTaskDialogIcon.Hand, "Are you sure?", String.Format("This will overwrite the databases: {0}, {1}, {2}. Once the restore has been started, it cannot be stopped.", Settings.Default.AuthDB, Settings.Default.CharactersDB, Settings.Default.WorldDB), button));

                    if (result == eTaskDialogResult.Yes)
                    {
                        restoreCircularProgress.IsRunning = true;

                        restoreDBBackgroundWorker.RunWorkerAsync(backupListBox.Items[backupListBox.SelectedIndex].ToString());
                    }
                }
            }
            else
            {
                TaskDialog.Show(new TaskDialogInfo("Error", eTaskDialogIcon.Stop, "No Backup Selected", "Please select a backup, then try again.", eTaskDialogButton.Ok));
            }
        }
Exemplo n.º 2
0
        private void downloadGitRepoButtonX_Click(object sender, EventArgs e)
        {
            eTaskDialogButton button = eTaskDialogButton.Yes;

            button |= eTaskDialogButton.No;

            eTaskDialogResult result = TaskDialog.Show(new TaskDialogInfo("Are you sure?", eTaskDialogIcon.Hand, "Are you sure?", String.Format("By doing this, you will replace the databases: \"{0}\", \"{1}\", and \"{2}\". Are you sure you want to continue?", authDB, charDB, worldDB), button));

            if (result == eTaskDialogResult.Yes)
            {
                if (DBFolderBrowserDialog.ShowDialog() == DialogResult.OK)
                {
                    aDB = authDB;
                    cDB = charDB;
                    wDB = worldDB;

                    location = DBFolderBrowserDialog.SelectedPath;

                    MySQLPercentLabelX.Visible  = true;
                    DBProgressBarX.Visible      = true;
                    DBProgressBarX.ProgressType = eProgressItemType.Standard;


                    downloadGitRepoButtonX.Enabled = false;

                    gitBackgroundWorker.RunWorkerAsync(location);
                }
            }
        }
Exemplo n.º 3
0
        private eTaskDialogButton GetTaskDialogButtons()
        {
            eTaskDialogButton button = eTaskDialogButton.Ok;

            if (checkBoxCancel.Checked)
            {
                button |= eTaskDialogButton.Cancel;
            }
            if (checkBoxYes.Checked)
            {
                button |= eTaskDialogButton.Yes;
            }
            if (checkBoxNo.Checked)
            {
                button |= eTaskDialogButton.No;
            }
            if (checkBoxRetry.Checked)
            {
                button |= eTaskDialogButton.Retry;
            }
            if (checkBoxClose.Checked)
            {
                button |= eTaskDialogButton.Close;
            }

            if (!checkBoxOk.Checked && button != eTaskDialogButton.Ok)
            {
                button = button & ~(button & eTaskDialogButton.Ok);
            }

            return(button);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 跳出Yes、No的對話框
        /// </summary>
        /// <param name="dialogText"></param>
        /// <param name="dialogIcon"></param>
        /// <param name="dialogTitle"></param>
        /// <param name="dialogHeader"></param>
        /// <returns></returns>
        public static eTaskDialogResult ShowMsgYesNo(string dialogText, eTaskDialogIcon dialogIcon = eTaskDialogIcon.Help, string dialogTitle = "Message", string dialogHeader = "")
        {
            eTaskDialogButton          dialogButtons = eTaskDialogButton.Yes | eTaskDialogButton.No;
            eTaskDialogBackgroundColor dialogColor   = eTaskDialogBackgroundColor.Silver;
            eTaskDialogResult          result        = TaskDialog.Show(dialogTitle, dialogIcon, dialogHeader, dialogText, dialogButtons, dialogColor);

            return(result);
        }
Exemplo n.º 5
0
        private eTaskDialogButton GetTaskDialogButtons()
        {
            eTaskDialogButton button = eTaskDialogButton.Yes;

            button |= eTaskDialogButton.Close;

            if (button != eTaskDialogButton.Yes)
            {
                button = button & ~(button & eTaskDialogButton.Yes);
            }
            return(button);
        }
Exemplo n.º 6
0
        private eTaskDialogButton GetTaskDialogButtons()
        {
            eTaskDialogButton button = eTaskDialogButton.Ok;

            button |= eTaskDialogButton.Yes;
            button |= eTaskDialogButton.No;

            if (button != eTaskDialogButton.Ok)
            {
                button = button & ~(button & eTaskDialogButton.Ok);
            }
            return(button);
        }
Exemplo n.º 7
0
        private void UserSettings_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!finished)
            {
                eTaskDialogButton button = eTaskDialogButton.Yes;

                button |= eTaskDialogButton.No;

                eTaskDialogResult result = TaskDialog.Show(new TaskDialogInfo("Are you sure?", eTaskDialogIcon.Exclamation, "Confirm", "Are you sure you want to exit the setup wizard?", button));

                if (result == eTaskDialogResult.Yes)
                {
                    finished = true;

                    if (Settings.Default.raEnabled)
                    {
                        if (Settings.Default.raHost != String.Empty && Settings.Default.raPort != 0 && Settings.Default.raUsername != String.Empty && Settings.Default.raPassword != String.Empty)
                        {
                            e.Cancel = false;

                            return;
                        }
                    }
                    else
                    {
                        if (Settings.Default.trinityFolder != String.Empty)
                        {
                            e.Cancel = false;

                            return;
                        }
                    }


                    TaskDialog.Show(new TaskDialogInfo("Wizard Failed", eTaskDialogIcon.Stop, "You failed to complete the setup wizard...", "TrinityCore Manager is now closing", eTaskDialogButton.Ok));

                    Application.Exit();
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
Exemplo n.º 8
0
        private void LootCreator_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!finished)
            {
                eTaskDialogButton button = eTaskDialogButton.Yes;

                button |= eTaskDialogButton.No;

                eTaskDialogResult result = TaskDialog.Show(new TaskDialogInfo("Are you sure?", eTaskDialogIcon.Exclamation, "Confirm", "Are you sure you want to exit?", button));

                if (result == eTaskDialogResult.Yes)
                {
                    finished = true;
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the TaskDialogInfo structure.
 /// </summary>
 /// <param name="title">Title of dialog.</param>
 /// <param name="taskDialogIcon">Task-dialog icon</param>
 /// <param name="header">Header text.</param>
 /// <param name="text">Dialog main/content text.</param>
 /// <param name="dialogButtons">Dialog buttons displayed.</param>
 public TaskDialogInfo(string title, eTaskDialogIcon taskDialogIcon, string header, string text, eTaskDialogButton dialogButtons, eTaskDialogButton defaultButton)
 {
     _Title = title;
     _Header = header;
     _Text = text;
     _DialogButtons = dialogButtons;
     _DialogColor = eTaskDialogBackgroundColor.Default;
     _RadioButtons = null;
     _Buttons = null;
     _FooterText = null;
     _CheckBoxCommand = null;
     _TaskDialogIcon = taskDialogIcon;
     _FooterImage = null;
     _TopMost = false;
     _DefaultButton = defaultButton;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the TaskDialogInfo structure.
 /// </summary>
 /// <param name="title">Title of dialog.</param>
 /// <param name="taskDialogIcon">Task-dialog icon</param>
 /// <param name="header">Header text.</param>
 /// <param name="text">Dialog main/content text.</param>
 /// <param name="dialogButtons">Dialog buttons displayed.</param>
 /// <param name="dialogColor">Dialog background color.</param>
 /// <param name="radioButtons">Radio Button Commands</param>
 /// <param name="buttons">Button commands.</param>
 /// <param name="checkBoxCommand">Check-box command.</param>
 /// <param name="footerText">Footer text</param>
 /// <param name="footerImage">Footer image.</param>
 /// <param name="topMost">Indicates whether TaskDialog is top most.</param>
 public TaskDialogInfo(string title, eTaskDialogIcon taskDialogIcon, string header, string text, eTaskDialogButton dialogButtons, eTaskDialogBackgroundColor dialogColor, Command[] radioButtons, Command[] buttons, Command checkBoxCommand, string footerText, Image footerImage, bool topMost)
 {
     _Title = title;
     _Header = header;
     _Text = text;
     _DialogButtons = dialogButtons;
     _DialogColor = dialogColor;
     _RadioButtons = radioButtons;
     _Buttons = buttons;
     _FooterText = footerText;
     _CheckBoxCommand = checkBoxCommand;
     _TaskDialogIcon = taskDialogIcon;
     _FooterImage = footerImage;
     _TopMost = topMost;
     _DefaultButton = eTaskDialogButton.Ok;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Displays TaskDialog message.
 /// </summary>
 /// <param name="dialogTitle">Title of the window.</param>
 /// <param name="dialogHeader">Task dialog header.</param>
 /// <param name="dialogText">Task dialog text.</param>
 /// <param name="dialogButtons">Displayed buttons.</param>
 /// <returns>Result from task-dialog.</returns>
 public static eTaskDialogResult Show(string dialogTitle, string dialogHeader, string dialogText, eTaskDialogButton dialogButtons)
 {
     TaskDialogInfo info = new TaskDialogInfo(dialogTitle, eTaskDialogIcon.Information, dialogHeader, dialogText, dialogButtons);
     return Show(info);
 }
Exemplo n.º 12
0
        public eTaskDialogResult ShowTaskDialog(IWin32Window owner, TaskDialogInfo dialogInfo)
        {
            if (owner != null)
                this.StartPosition = FormStartPosition.CenterParent;
            else
                this.StartPosition = FormStartPosition.CenterScreen;

            UpdateDialogColor(dialogInfo);

            int dialogButtonsWidth = 20;
            int footerWidth = 0;
            int contentHeight = 32;

            this.Text = dialogInfo.Title;
            headerLabel.Text = dialogInfo.Header;
            contentLabel.Text = dialogInfo.Text;
            _DefaultButton = dialogInfo.DefaultButton;

            if (dialogInfo.TaskDialogIcon == eTaskDialogIcon.None)
            {
                int diff = this.Width - headerLabel.Right;
                headerLabel.Left = headerImage.Left;
                headerLabel.Width = this.Width - diff - headerLabel.Left;

                diff = this.Width - contentLabel.Right;
                contentLabel.Left = headerImage.Left;
                contentLabel.Width = this.Width - diff - contentLabel.Left;

                diff = this.Width - buttonsPanel.Right;
                buttonsPanel.Left = headerImage.Left;
                buttonsPanel.Width = this.Width - diff - buttonsPanel.Left;
                headerImage.Visible = false;
            }
            else
                headerImage.Image = TaskDialog.GetImage(dialogInfo.TaskDialogIcon);

            if (dialogInfo.CheckBoxCommand != null)
            {
                taskCheckBox.Command = dialogInfo.CheckBoxCommand;
                //taskCheckBox.Checked = dialogInfo.CheckBoxCommand.Checked;
                dialogButtonsWidth += taskCheckBox.Width + 12;
            }
            else
                taskCheckBox.Visible = false;
            
            if (!string.IsNullOrEmpty(dialogInfo.FooterText))
            {
                footerLabel.Text = dialogInfo.FooterText;
                footerWidth += footerLabel.Width + 12;
            }
            else
                footerLabel.Visible = false;

            if (dialogInfo.FooterImage != null)
            {
                footerImage.Image = dialogInfo.FooterImage;
                footerWidth += footerImage.Width;
            }
            else
            {
                footerImage.Visible = false;
                footerLabel.Left = footerImage.Left;
            }

            if (dialogInfo.RadioButtons != null && dialogInfo.RadioButtons.Length > 0)
            {
                foreach (Command command in dialogInfo.RadioButtons)
                {
                    CheckBoxItem item = new CheckBoxItem();
                    item.CheckBoxStyle = eCheckBoxStyle.RadioButton;
                    //item.Checked = command.Checked;
                    item.Command = command;
                    buttonsPanel.Items.Add(item);
                } 
            }

            if (dialogInfo.Buttons != null && dialogInfo.Buttons.Length > 0)
            {
                foreach (Command command in dialogInfo.Buttons)
                {
                    ButtonItem item = new ButtonItem();
                    if (command.Image != null)
                    {
                        item.ButtonStyle = eButtonStyle.ImageAndText;
                        item.ImagePosition = eImagePosition.Left;
                    }
                    
                    item.Command = command;

                    buttonsPanel.Items.Add(item);

                    ButtonItemLayout.LayoutButton(item);
                    footerWidth = Math.Max(footerWidth, item.WidthInternal + buttonsPanel.Left * 2);

                }
            }

            if ((dialogInfo.DialogButtons & eTaskDialogButton.Ok) == 0)
            {
                buttonOk.Visible = false;
            }
            else
            {
                dialogButtonsWidth += buttonOk.Width + 3;
                if (dialogInfo.DefaultButton == eTaskDialogButton.Ok)
                    this.AcceptButton = buttonOk;
            }
            if ((dialogInfo.DialogButtons & eTaskDialogButton.Cancel) == 0)
            {
                buttonCancel.Visible = false;
            }
            else
            {
                dialogButtonsWidth += buttonCancel.Width + 3;
                this.CancelButton = buttonCancel;
                if (dialogInfo.DefaultButton == eTaskDialogButton.Cancel)
                    this.AcceptButton = buttonCancel;
            }
            if ((dialogInfo.DialogButtons & eTaskDialogButton.Yes) == 0)
            {
                buttonYes.Visible = false;
            }
            else
            {
                dialogButtonsWidth += buttonYes.Width + 3;
                if (dialogInfo.DefaultButton == eTaskDialogButton.Yes)
                    this.AcceptButton = buttonYes;
            }

            if ((dialogInfo.DialogButtons & eTaskDialogButton.No) == 0)
            {
                buttonNo.Visible = false;
            }
            else
            {
                dialogButtonsWidth += buttonNo.Width + 3;
                if (this.CancelButton == null)
                    this.CancelButton = buttonNo;
                if (dialogInfo.DefaultButton == eTaskDialogButton.No)
                    this.AcceptButton = buttonNo;
            }
            if ((dialogInfo.DialogButtons & eTaskDialogButton.Close) == 0)
            {
                buttonClose.Visible = false;
            }
            else
            {
                dialogButtonsWidth += buttonClose.Width + 3;
                if (this.CancelButton == null)
                    this.CancelButton = buttonClose;
                else if (dialogInfo.DefaultButton == eTaskDialogButton.Close)
                    this.AcceptButton = buttonClose;
            }
            if ((dialogInfo.DialogButtons & eTaskDialogButton.Retry) == 0)
            {
                buttonRetry.Visible = false;
            }
            else
            {
                dialogButtonsWidth += buttonRetry.Width + 3;
                if (dialogInfo.DefaultButton == eTaskDialogButton.Retry)
                    this.AcceptButton = buttonRetry;
            }

            // If only OK button is visible it is cancel button as well
            if (dialogInfo.DialogButtons == eTaskDialogButton.Ok)
                this.CancelButton = buttonOk;

            if (string.IsNullOrEmpty(dialogInfo.FooterText) && dialogInfo.FooterImage == null)
            {
                footerPanel.Visible = false;
                bottomPanel.Height = flowLayoutPanel1.Height + 4;
            }
            else
                contentHeight += footerImage.Height;

            this.Width = Math.Max(MinimumWidth, Math.Max(footerWidth, dialogButtonsWidth));

            using (Graphics g = headerLabel.CreateGraphics()) { }
            headerLabel.MaximumSize=new Size(headerLabel.Width, 1000);
            headerLabel.Height=headerLabel.GetPreferredSize(Size.Empty).Height;
            contentHeight += headerLabel.Height + 3;

            using (Graphics g = contentLabel.CreateGraphics()) { }
            contentLabel.Top = headerLabel.Bounds.Bottom + 3;
            contentLabel.MaximumSize = new Size(contentLabel.Width, 1000);
            contentLabel.Height=contentLabel.GetPreferredSize(Size.Empty).Height;
            contentHeight += contentLabel.Height + 3;
            if (contentLabel.IsUsingTextMarkup)
                contentHeight += 8;

            buttonsPanel.Top = contentLabel.Bottom + 3;
            if (buttonsPanel.Items.Count == 0)
            {
                buttonsPanel.Visible = false;
            }
            else
            {
                using (Graphics g = buttonsPanel.CreateGraphics()) { }
                buttonsPanel.Height = buttonsPanel.GetAutoSizeHeight() + 2;
                contentHeight += buttonsPanel.Height + 6;
                if (string.IsNullOrEmpty(dialogInfo.FooterText) && dialogInfo.FooterImage == null)
                    contentHeight += 8;
            }

            contentHeight += bottomPanel.Height;

            this.Height = Math.Max(MinimumHeight, contentHeight);

            if (dialogInfo.TaskDialogIcon == eTaskDialogIcon.Help)
                System.Media.SystemSounds.Question.Play();
            else if (dialogInfo.TaskDialogIcon == eTaskDialogIcon.Information)
                System.Media.SystemSounds.Asterisk.Play();
            else
                System.Media.SystemSounds.Exclamation.Play();

            LocalizeText();

            ShowDialog(owner);

            return _Result;
        }
Exemplo n.º 13
-1
 /// <summary>
 /// Displays TaskDialog message.
 /// </summary>
 /// <param name="dialogTitle">Title of the window.</param>
 /// <param name="dialogIcon">Icon displayed on dialog.</param>
 /// <param name="dialogHeader">Task dialog header.</param>
 /// <param name="dialogText">Task dialog text.</param>
 /// <param name="dialogButtons">Displayed buttons.</param>
 /// <param name="dialogColor">Specifies the predefined color for the dialog.</param>
 /// <returns>Result from task-dialog.</returns>
 public static eTaskDialogResult Show(string dialogTitle, eTaskDialogIcon dialogIcon, string dialogHeader, string dialogText, eTaskDialogButton dialogButtons, eTaskDialogBackgroundColor dialogColor)
 {
     TaskDialogInfo info = new TaskDialogInfo(dialogTitle, dialogIcon, dialogHeader, dialogText, dialogButtons, dialogColor);
     return Show(info);
 }