Exemplo n.º 1
0
 private void Tile_Click_1(object sender, RoutedEventArgs e)
 {
     if (TaskDialog.OSSupportsTaskDialogs)
     {
         using (TaskDialog dialog = new TaskDialog())
         {
             dialog.WindowTitle     = "Install from .zip file";
             dialog.MainInstruction = "What type of mod are you going to install?";
             dialog.ButtonStyle     = TaskDialogButtonStyle.CommandLinks;
             TaskDialogButton assetModButton = new TaskDialogButton("Asset Mod");
             assetModButton.CommandLinkNote = "An asset mod is a modification to the game's art, sounds, music and charts. It is not a modification to the game itself.";
             TaskDialogButton otherButton = new TaskDialogButton("Full Mod");
             otherButton.CommandLinkNote = "A full mod is a modification of the game's executable. For example, full week mods do this. You don't need a defulat folder set because it will copy the whole mod to an empty folder.";
             TaskDialogButton cancelButton = new TaskDialogButton(ButtonType.Cancel);
             dialog.Buttons.Add(assetModButton);
             dialog.Buttons.Add(otherButton);
             dialog.Buttons.Add(cancelButton);
             dialog.ShowDialog(this);
         }
     }
     else
     {
         MessageBox.Show("This operating system does not support task dialogs.", "FNF Mod Manager", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 2
0
        private void ok_Click(object sender, RoutedEventArgs e)
        {
            double w;
            double h;

            if (!double.TryParse(width.Text, out w) || w <= 0)
            {
                TaskDialog td = new TaskDialog(this, "Invalid Input", "The width you entered could not be parsed.", MessageType.Error);
                td.ShowDialog();

                width.Focus();
                return;
            }

            if (!double.TryParse(height.Text, out h) || h <= 0)
            {
                TaskDialog td = new TaskDialog(this, "Invalid Input", "The height you entered could not be parsed.", MessageType.Error);
                td.ShowDialog();

                height.Focus();
                return;
            }

            SelectedSize = new Size(w, h);

            DialogResult = true;
        }
Exemplo n.º 3
0
        private void DelPageButton_Click(object sender, RoutedEventArgs e)
        {
            int index = PagesListBox.SelectedIndex;

            if (_chapterManager.LoadedChapter.Pages[index].TextEntries.Count > 0)
            {
                TaskDialog dialog = new TaskDialog();
                dialog.WindowTitle     = "Warning";
                dialog.MainIcon        = TaskDialogIcon.Warning;
                dialog.MainInstruction = "The page you are about to delete contains translations.";
                dialog.Content         = "Would you still like to delete the page?";

                TaskDialogButton deleteButton = new TaskDialogButton("Delete");
                dialog.Buttons.Add(deleteButton);

                TaskDialogButton cancelButton = new TaskDialogButton(ButtonType.Cancel);
                cancelButton.Text = "Cancel";
                dialog.Buttons.Add(cancelButton);

                TaskDialogButton button = dialog.ShowDialog(this);
                if (button.ButtonType == ButtonType.Cancel)
                {
                    return;
                }
            }
            _chapterManager.RemovePage(index);
            PagesListBox.Items.Refresh();
            PagesListBox.SelectedIndex = (index >= _chapterManager.LoadedChapter.TotalPages) ? _chapterManager.LoadedChapter.TotalPages - 1 : index;
            UpdateButtons();
        }
        public void RemoveIndexLocation(object o)
        {
            if (CanRemoveIndexLocation())
            {
                using (var dialog = new TaskDialog())
                {
                    dialog.WindowTitle     = "Remove Index Location";
                    dialog.MainInstruction = "Are you sure you want to remove the selected index location?";
                    dialog.Content         = "This location will not be indexed anymore.";
                    dialog.ButtonStyle     = TaskDialogButtonStyle.CommandLinks;

                    var removeButton = new TaskDialogButton("Remove")
                    {
                        CommandLinkNote = "Yes, remove it"
                    };
                    dialog.Buttons.Add(removeButton);
                    dialog.Buttons.Add(new TaskDialogButton(ButtonType.Cancel));
                    var result = dialog.ShowDialog();

                    if (result == removeButton)
                    {
                        IndexLocations.Remove(SelectedIndexLocation);
                    }
                }
            }
        }
Exemplo n.º 5
0
        public static void ShowAlert(this Dispatcher dispatcher, string title, string message, string action, bool actionIsCommand = false, Action callback = null)
        {
            var dialog = new TaskDialog {
                MainIcon        = TaskDialogIcon.Information,
                WindowTitle     = UISettings.Configurator,
                MainInstruction = title,
                Content         = message
            };

            var ok = new TaskDialogButton {
                Text = action
            };

            if (actionIsCommand)
            {
                dialog.ButtonStyle = TaskDialogButtonStyle.CommandLinks;
            }
            dialog.Buttons.Add(ok);

            dispatcher?.Invoke(() => {
                dialog.ShowDialog();
                dialog.Dispose();

                callback?.Invoke();
            });
        }
Exemplo n.º 6
0
        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            if (!_isHomeLocation)
            {
                string[] favs = Settings.WeatherFavorites;

                if (favs != null)
                {
                    string loc = comboBox.Text.ToLower().Trim();

                    foreach (string each in favs)
                    {
                        if (each.ToLower() == loc)
                        {
                            TaskDialog td = new TaskDialog(this, "Location is in use", "You already have " + textBox.Text + " in your favorites.", MessageType.Error);
                            td.ShowDialog();
                            textBox.SelectAll();
                            return;
                        }
                    }
                }
            }

            if (comboBox.SelectedIndex == -1)
            {
                TaskDialog td = new TaskDialog(this, "Location unavailable", textBox.Text + " is not a recognized city.", MessageType.Error);
                td.ShowDialog();
                textBox.SelectAll();
                return;
            }

            DialogResult = true;
        }
        public Task <T?> ShowDialog <T>(IMessageBox <T> messageBox)
        {
            using (TaskDialog dialog = new TaskDialog())
            {
                dialog.WindowTitle         = messageBox.Title;
                dialog.MainInstruction     = messageBox.MainInstruction;
                dialog.Content             = messageBox.Content;
                dialog.ExpandedInformation = messageBox.ExpandedInformation;
                dialog.Footer     = messageBox.Footer;
                dialog.FooterIcon = ToDialogIcon(messageBox.FooterIcon);
                dialog.MainIcon   = ToDialogIcon(messageBox.Icon);

                Dictionary <TaskDialogButton, T?> buttonToValue = new();
                foreach (var buttonDefinition in messageBox.Buttons)
                {
                    TaskDialogButton button = GenerateButton(buttonDefinition.Name);
                    buttonToValue[button] = buttonDefinition.ReturnValue;
                    dialog.Buttons.Add(button);
                }

                TaskDialogButton returned = dialog.ShowDialog();

                return(Task.FromResult(buttonToValue[returned]));
            }
        }
Exemplo n.º 8
0
 private void CopyLogExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         Clipboard.SetText(stringList.SelectedItem.ToString());
     }
     catch (Exception ex)
     {
         if (TaskDialog.OSSupportsTaskDialogs)
         {
             using (TaskDialog dialog = new TaskDialog())
             {
                 dialog.WindowTitle         = "Application Error";
                 dialog.MainInstruction     = "An error has occurred.";
                 dialog.Content             = "An error occurred when trying to set clipboard data. This could be caused due to another application using the clipboard.\n\nYou can find detailed information below.";
                 dialog.ExpandedInformation = ex.ToString();
                 TaskDialogButton okButton = new TaskDialogButton(ButtonType.Ok);
                 dialog.Buttons.Add(okButton);
                 TaskDialogButton button = dialog.ShowDialog(this);
             }
         }
         else
         {
             MessageBox.Show(this, "An error occurred when trying to set clipboard data.\nThis could be caused due to another application using the clipboard.", "Application Error");
         }
     }
 }
Exemplo n.º 9
0
        private void customPathBtn_Click(object sender, RoutedEventArgs e)
        {
            var continueDialog = new TaskDialog()
            {
                WindowTitle     = "Are you sure?",
                MainInstruction = "Changing this setting has many consequences.",
                Content         = "If you modify this setting, all currently running pingers will be stopped. Once you change the folder path, the existing files will NOT be moved and you will start with fresh logs. By clicking Yes, you acknowledge this, and will be prompted for the new path."
            };
            TaskDialogButton yesButton = new TaskDialogButton(ButtonType.Yes);
            TaskDialogButton noButton  = new TaskDialogButton(ButtonType.No);

            continueDialog.Buttons.Add(yesButton);
            continueDialog.Buttons.Add(noButton);
            var resultBtn = continueDialog.ShowDialog();

            if (resultBtn.ButtonType == ButtonType.No)
            {
                return;
            }
            var folderDialog = new VistaFolderBrowserDialog();

            folderDialog.SelectedPath = Path.GetFullPath(Config.LogSavePath);
            if (folderDialog.ShowDialog() == true)
            {
                Config.LogSavePath = folderDialog.SelectedPath;
                customPathBox.Text = Config.LogSavePath;
                (this.Owner as MainWindow).StopAllLoggers();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Задать вопрос пользователю, варианты "Да\Нет".
        /// </summary>
        /// <param name="title">Заголовок окна.</param>
        /// <param name="text">Текст.</param>
        /// <param name="note">Примечание к тексту.</param>
        /// <param name="checkbox">Текст для галочки.</param>
        /// <returns>True, если выбрано Да.</returns>
        public static Tuple <bool, bool> ShowYesNoDialog(string title, string text, string note, string checkbox)
        {
            var owner         = WindowHelper.Owner;
            var result        = false;
            var checkboxValue = false;

            using (var dialog = new TaskDialog())
            {
                dialog.CenterParent    = true;
                dialog.WindowTitle     = title;
                dialog.MainInstruction = text;
                dialog.Content         = note;
                dialog.MainIcon        = TaskDialogIcon.Information;
                if (!string.IsNullOrWhiteSpace(checkbox))
                {
                    dialog.VerificationText = checkbox;
                }
                dialog.Buttons.Add(new TaskDialogButton(ButtonType.Yes));
                dialog.Buttons.Add(new TaskDialogButton(ButtonType.No));
                if (dialog.ShowDialog(owner).ButtonType == ButtonType.Yes)
                {
                    result        = true;
                    checkboxValue = dialog.IsVerificationChecked;
                }
            }
            return(new Tuple <bool, bool>(result, checkboxValue));
        }
Exemplo n.º 11
0
        private static void Report(Exception exception, bool isTerminating)
        {
            TaskDialogPage page = new()
            {
                AllowCancel   = false,
                AllowMinimize = false,
                Caption       = "Error",
                Icon          = TaskDialogIcon.Error,
                SizeToContent = true,
                Text          = exception.Message,
                Expander      = new TaskDialogExpander
                {
                    Text = exception.Demystify().StackTrace,
                    CollapsedButtonText = "Show stack trace",
                    ExpandedButtonText  = "Hide stack trace"
                }
            };

            if (isTerminating)
            {
                page.Buttons.Add("Terminate");
            }
            else
            {
                page.Buttons.Add(TaskDialogButton.OK);
            }

            Form owner = Application.OpenForms[0];

            if (TaskDialog.ShowDialog(owner, page) != TaskDialogButton.OK)
            {
                Environment.Exit(-1);
            }
        }
    }
Exemplo n.º 12
0
        private void ShowExceptionErrorDialog(Exception exception)
        {
            var reportErrorButton = new TaskDialogButton("Report error");
            var taskDialog        = new TaskDialog
            {
                WindowTitle          = "",
                CollapsedControlText = "See error details",
                ExpandedControlText  = "Close error details",
                Content = "Building cloth resource failed. Please report this error at https://github.com/DurtyFree/altv-cloth-tool",
                Buttons =
                {
                    reportErrorButton,
                    new TaskDialogButton("Close")
                    {
                        ButtonType = ButtonType.Close
                    },
                },
                ExpandedInformation = exception.ToString(),
                MainIcon            = TaskDialogIcon.Error,
                MainInstruction     = "Unknown error occured"
            };
            var pressedButton = taskDialog.ShowDialog(this);

            if (pressedButton == reportErrorButton)
            {
                var issueBody = "I have the following error:\n" + exception +
                                "\n\nCloth files: [Please provide cloth files (ydd, ytd) and cloth project file here]";
                var issueTitle = "Exception error";
                Process.Start($"https://github.com/DurtyFree/altv-cloth-tool/issues/new?body={Uri.EscapeDataString(issueBody)}&title={Uri.EscapeDataString(issueTitle)}");
            }
        }
Exemplo n.º 13
0
    private async void Help_Executed(object sender, ExecutedRoutedEventArgs e)
    {
        TaskDialogButton button = TaskDialog.ShowDialog(this.Handle, new()
        {
            Caption = "KoAR Save Editor",
            Heading = "Help",
            Icon    = TaskDialogIcon.Information,
            Buttons =
            {
                new TaskDialogCommandLinkButton("OK", "Close this window")
                {
                    Tag = 0
                },
                new TaskDialogCommandLinkButton("Found a bug? Open a new GitHub bug report.", "(Requires a free account)")
                {
                    Tag = 1
                },
                new TaskDialogCommandLinkButton("Downgrade to v2...", "I am running Reckoning")
                {
                    Tag = 2
                },
            },
            SizeToContent = true,
            AllowCancel   = true,
            Text          = @"This version of the editor has only been tested against the remaster. If you're on the original and are running into errors, consider downgrading.

1. Your saves are usually not in the same folder as the game. The editor attemps to make educated guesses as to the save file directory.
2. When modifying item names, do NOT use special characters.
3. Editing equipped items is restricted, and even still may cause game crashes.",
            Footnote      = new($"v{App.Version}")
        });
Exemplo n.º 14
0
 private void ShowTaskDialogWithCommandLinks()
 {
     if (TaskDialog.OSSupportsTaskDialogs)
     {
         using (TaskDialog dialog = new TaskDialog())
         {
             dialog.WindowTitle     = "Task dialog sample";
             dialog.MainInstruction = "This is a sample task dialog with command links.";
             dialog.Content         = "Besides regular buttons, task dialogs also support command links. Only custom buttons are shown as command links; standard buttons remain regular buttons.";
             dialog.ButtonStyle     = TaskDialogButtonStyle.CommandLinks;
             TaskDialogButton elevatedButton = new TaskDialogButton("An action requiring elevation");
             elevatedButton.CommandLinkNote   = "Both regular buttons and command links can show the shield icon to indicate that the action they perform requires elevation. It is up to the application to actually perform the elevation.";
             elevatedButton.ElevationRequired = true;
             TaskDialogButton otherButton  = new TaskDialogButton("Some other action");
             TaskDialogButton cancelButton = new TaskDialogButton(ButtonType.Cancel);
             dialog.Buttons.Add(elevatedButton);
             dialog.Buttons.Add(otherButton);
             dialog.Buttons.Add(cancelButton);
             dialog.ShowDialog(this);
         }
     }
     else
     {
         MessageBox.Show(this, "This operating system does not support task dialogs.", "Task Dialog Sample");
     }
 }
Exemplo n.º 15
0
        private void ShowCloseDocumentTaskDialog()
        {
            // Create the page which we want to show in the dialog.
            TaskDialogButton btnCancel   = TaskDialogButton.Cancel;
            TaskDialogButton btnSave     = new TaskDialogButton("&Save");
            TaskDialogButton btnDontSave = new TaskDialogButton("Do&n't save");

            var page = new TaskDialogPage()
            {
                Caption = "My Application",
                Heading = "Do you want to save changes to Untitled?",
                Buttons =
                {
                    btnCancel,
                    btnSave,
                    btnDontSave
                }
            };

            // Show a modal dialog, then check the result.
            TaskDialogButton result = TaskDialog.ShowDialog(this, page);

            if (result == btnSave)
            {
                Console.WriteLine("Saving");
            }
            else if (result == btnDontSave)
            {
                Console.WriteLine("Not saving");
            }
            else
            {
                Console.WriteLine("Canceling");
            }
        }
Exemplo n.º 16
0
        private void ExportAsScriptMenuItem_Click(object sender, RoutedEventArgs e)
        {
            VistaSaveFileDialog fileDialog = new VistaSaveFileDialog();

            fileDialog.AddExtension    = true;
            fileDialog.DefaultExt      = ".txt";
            fileDialog.Filter          = "Script files (*.txt)|*.txt";
            fileDialog.OverwritePrompt = true;
            fileDialog.Title           = "Export Script";
            bool?res = fileDialog.ShowDialog(this);

            if (res ?? false)
            {
                try {
                    Mouse.SetCursor(Cursors.Wait);
                    _chapterManager.ExportScript(fileDialog.FileName);
                    Mouse.SetCursor(Cursors.Arrow);
                }
                catch (Exception ex) {
                    Mouse.SetCursor(Cursors.Arrow);
                    using (TaskDialog dialog = new TaskDialog()) {
                        dialog.WindowTitle     = "Error";
                        dialog.MainIcon        = TaskDialogIcon.Error;
                        dialog.MainInstruction = "There was an error exporting the script.";
                        dialog.Content         = ex.Message;
                        TaskDialogButton okButton = new TaskDialogButton(ButtonType.Ok);
                        dialog.Buttons.Add(okButton);
                        TaskDialogButton button = dialog.ShowDialog(this);
                    }
                }
            }
        }
Exemplo n.º 17
0
        private static bool ConfirmCloseEditorUsingTaskDialog(string title, string message)
        {
            using var dialog = new TaskDialog
                  {
                      WindowTitle             = Resources.Dialog_Title,
                      MainInstruction         = title,
                      Content                 = message,
                      AllowDialogCancellation = false,
                      CenterParent            = true,
                      ButtonStyle             = TaskDialogButtonStyle.CommandLinks
                  };

            var yesButton = new TaskDialogButton
            {
                Text            = "Yes",
                CommandLinkNote = "Return to package view and lose all your changes."
            };

            var noButton = new TaskDialogButton
            {
                Text            = "No",
                CommandLinkNote = "Stay at the metadata editor and fix the error."
            };

            dialog.Buttons.Add(yesButton);
            dialog.Buttons.Add(noButton);

            var result = dialog.ShowDialog();

            return(result == yesButton);
        }
Exemplo n.º 18
0
        private static void ExecutedNewItemCommand(object sender, ExecutedRoutedEventArgs e)
        {
            MainWindow _sender = FindWindow(sender);

            if (_sender.activeDisplayPane == DisplayPane.Calendar)
            {
                _sender.NewAppointment();
            }
            else if (_sender.activeDisplayPane == DisplayPane.People)
            {
                _sender.NewContact();
            }
            else if (_sender.activeDisplayPane == DisplayPane.Tasks)
            {
                _sender.NewTask();
            }
            else if (_sender.activeDisplayPane == DisplayPane.Notes)
            {
                _sender.NewNote();
            }
            else
            {
                TaskDialog td = new TaskDialog(_sender, "Not Applicable", "The requested action is not applicable in the current context.", MessageType.Error);
                td.ShowDialog();
            }
        }
Exemplo n.º 19
0
        private static bool ConfirmUsingTaskDialog(string message, string title, bool isWarning)
        {
            using var dialog = new TaskDialog
                  {
                      WindowTitle             = Resources.Dialog_Title,
                      MainInstruction         = title,
                      Content                 = message,
                      AllowDialogCancellation = true,
                      CenterParent            = true
                  };
            //dialog.ButtonStyle = TaskDialogButtonStyle.CommandLinks;
            if (isWarning)
            {
                dialog.MainIcon = TaskDialogIcon.Warning;
            }

            var yesButton = new TaskDialogButton("Yes");
            var noButton  = new TaskDialogButton("No");

            dialog.Buttons.Add(yesButton);
            dialog.Buttons.Add(noButton);

            var result = dialog.ShowDialog();

            return(result == yesButton);
        }
Exemplo n.º 20
0
        private static bool?ConfirmWithCancelUsingTaskDialog(string message, string title)
        {
            using var dialog = new TaskDialog
                  {
                      WindowTitle             = Resources.Dialog_Title,
                      MainInstruction         = title,
                      AllowDialogCancellation = true,
                      Content      = message,
                      CenterParent = true,
                      MainIcon     = TaskDialogIcon.Warning
                  };
            //dialog.ButtonStyle = TaskDialogButtonStyle.CommandLinks;

            var yesButton    = new TaskDialogButton("Yes");
            var noButton     = new TaskDialogButton("No");
            var cancelButton = new TaskDialogButton("Cancel");

            dialog.Buttons.Add(yesButton);
            dialog.Buttons.Add(noButton);
            dialog.Buttons.Add(cancelButton);

            var result = dialog.ShowDialog();

            if (result == yesButton)
            {
                return(true);
            }
            else if (result == noButton)
            {
                return(false);
            }

            return(null);
        }
 private bool ShowVistaDialog(string title, string mainInstruction, string content, string yesNote, string noNote)
 {
     using (var dialog = new TaskDialog())
     {
         dialog.WindowTitle     = title;
         dialog.MainInstruction = mainInstruction;
         dialog.Content         = content;
         dialog.ButtonStyle     = TaskDialogButtonStyle.CommandLinks;
         var yesButton = new TaskDialogButton("Yes");
         yesButton.CommandLinkNote = yesNote;
         var noButton = new TaskDialogButton("No");
         noButton.CommandLinkNote = noNote;
         dialog.Buttons.Add(yesButton);
         dialog.Buttons.Add(noButton);
         TaskDialogButton result = dialog.ShowDialog(this);
         if (result == yesButton)
         {
             FolderPathViewModel.FolderPath = null;
             return(false);
         }
         if (result == noButton)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 22
0
        void ExceptionHandler(Exception x)
        {
            if (!Aero)
            {
                MessageBox.Show("An exception was thrown: " + x.Message + "\r\n\r\nPress CTRL + C to copy the stack trace:\r\n" + x.StackTrace);
            }
            else
            {
                tm.SetProgressState(TaskbarProgressBarState.Error);
                this.Invoke((MethodInvoker) delegate
                {
                    TaskDialog td            = new TaskDialog();
                    td.Caption               = "Unhandled Exception";
                    td.InstructionText       = "An Unhandled Exception was Thrown";
                    td.Text                  = string.Format("An exception was thrown: {0}\r\n\r\nIf this appears to be a bug, please email me at [email protected] with the details below", x.Message);
                    td.DetailsCollapsedLabel = "Details";
                    td.DetailsExpandedLabel  = "Details";
                    td.DetailsExpandedText   = x.StackTrace;

                    TaskDialogButton Copy = new TaskDialogButton("Copy", "Copy Details to Clipboard");
                    Copy.Click           += (o, f) => { this.Invoke((MethodInvoker) delegate { Clipboard.SetDataObject(x.Message + "\r\n\r\n" + x.StackTrace, true, 10, 200); }); };

                    TaskDialogButton Close = new TaskDialogButton("Close", "Close");
                    Close.Click           += (o, f) => { td.Close(); };

                    td.Controls.Add(Copy);
                    td.Controls.Add(Close);
                    td.ShowDialog(this.Handle);
                });
            }
        }
Exemplo n.º 23
0
        private void Window_Closing(object sender, CancelEventArgs e)
        {
            var unfinishedJobCount = ViewModel.JobStore.UnfinishedJobCount;
            var hasIncompleteSots  = ViewModel.JobStore.HasIncompleteSots;

            //Check to see if we're the last DatasetListWindow
            var windows = Application.Current.Windows.OfType <DatasetListWindow>();

            if ((unfinishedJobCount > 0 || hasIncompleteSots) && windows.Count() == 1)
            {
                var taskDialog = new TaskDialog
                {
                    WindowTitle     = "Results Browser",
                    MainInstruction = "Are you sure you want to close the Results Browser?",
                    Content         = String.Format("There are {0} unfinished jobs remaining in the queue.", unfinishedJobCount),
                    MainIcon        = TaskDialogIcon.Warning
                };
                taskDialog.Buttons.Add(new TaskDialogButton(ButtonType.Yes));
                taskDialog.Buttons.Add(new TaskDialogButton(ButtonType.No)
                {
                    Default = true
                });
                taskDialog.CenterParent = true;
                var selectedButton = taskDialog.ShowDialog(this);

                if (selectedButton.ButtonType != ButtonType.Yes)
                {
                    e.Cancel = true;
                }
            }
        }
Exemplo n.º 24
0
        private static string CheckCrash()
        {
            string res = null;

            if (CrashHandler.LastSessionCrashed)
            {
                TaskDialog dialog = new TaskDialog();
                dialog.WindowTitle     = "Warning";
                dialog.MainIcon        = TaskDialogIcon.Warning;
                dialog.MainInstruction = "It seems like a file can be recovered from last session.";
                dialog.Content         = "Would you like to attempt to recover the file?";
                TaskDialogButton saveButton = new TaskDialogButton(ButtonType.Yes);
                saveButton.Text = "Yes";
                dialog.Buttons.Add(saveButton);
                TaskDialogButton noSaveButton = new TaskDialogButton(ButtonType.No);
                noSaveButton.Text = "No";
                dialog.Buttons.Add(noSaveButton);
                TaskDialogButton button = dialog.ShowDialog();
                string           temp   = CrashHandler.RecoverLastSessionFile();
                if (button.ButtonType == ButtonType.Yes)
                {
                    res = temp;
                }
            }
            return(res);
        }
Exemplo n.º 25
0
        protected override void OnClick()
        {
            base.OnClick();

            switch (DisplayMode)
            {
            case DisplayType.Waiting:
            case DisplayType.Progress:
                updateProcess.StandardInput.WriteLine("show");
                break;

            case DisplayType.Error:
                ((ItemsControl)Parent).Items.Remove(this);
                TaskDialog td = new TaskDialog(Application.Current.MainWindow, "Update Error", _error, MessageType.Error);
                td.ShowDialog();
                break;

            case DisplayType.Complete:
                ((ItemsControl)Parent).Items.Remove(this);
                break;

            default:
                break;
            }
        }
Exemplo n.º 26
0
        private void CleanupButton_OnClick(object sender, RoutedEventArgs e)
        {
            var taskDialog = new TaskDialog
            {
                WindowTitle     = "Clean results folder",
                MainInstruction = "Are you sure you want to clean up the results folder?"
            };

            var cleanButton = new TaskDialogButton()
            {
                ButtonType      = ButtonType.Custom,
                Text            = "Clean results folder",
                CommandLinkNote =
                    "All folders in the results folder which are not included in the library will be moved to the deleted folder."
            };

            taskDialog.Buttons.Add(cleanButton);

            taskDialog.Buttons.Add(new TaskDialogButton(ButtonType.Cancel)
            {
                Default = true
            });
            taskDialog.CenterParent = true;
            taskDialog.ButtonStyle  = TaskDialogButtonStyle.CommandLinks;
            var selectedButton = taskDialog.ShowDialog(this);



            if (selectedButton == cleanButton)
            {
                SetNativeEnabled(false);
                var progressDialog = new ProgressDialog
                {
                    Text = "Cleaning results folder...",
                    ProgressCurrentCount = 0,
                    ProgressTotalCount   = 1,
                    Owner = this
                };
                progressDialog.Show();

                var store     = ViewModel.Store;
                var uiContext = TaskScheduler.FromCurrentSynchronizationContext();

                var cleanupTask = Task.Factory.StartNew(() =>
                {
                    store.Cleanup((completed, total) =>
                    {
                        Task.Factory.StartNew(() =>
                        {
                            progressDialog.ProgressCurrentCount = completed;
                            progressDialog.ProgressTotalCount   = total;
                        }, new CancellationToken(), TaskCreationOptions.None, uiContext);
                    });
                }).ContinueWith(task =>
                {
                    SetNativeEnabled(true); //this must appear first, or we lose focus when the progress dialog closes
                    progressDialog.Close();
                }, uiContext);
            }
        }
Exemplo n.º 27
0
 private void ShowTaskDialogAbout()
 {
     if (TaskDialog.OSSupportsTaskDialogs)
     {
         using (TaskDialog dialog = new TaskDialog())
         {
             dialog.Width               = 200;
             dialog.CenterParent        = true;
             dialog.WindowTitle         = "About this program";
             dialog.MainInstruction     = "Inhouse Camguard 1.0";
             dialog.Content             = "A simple .NET application based on AForge libraries to analyze motion, capture image and data logging from a live webcam feed.";
             dialog.ExpandedInformation = "Open source libraries used in this application: AForge.Core, AForge.Imaging, AForge.Math, AForge.Video, AForge.Vision, OxyPlot.Core, OxyPlot.Wpf, Ookii.Dialogs.Wpf.";
             dialog.Footer              = "Developed by Heiswayi Nrird - <a href=\"https://heiswayi.nrird.com\">https://heiswayi.nrird.com</a>";
             dialog.FooterIcon          = TaskDialogIcon.Information;
             dialog.EnableHyperlinks    = true;
             TaskDialogButton okButton = new TaskDialogButton(ButtonType.Close);
             //TaskDialogButton cancelButton = new TaskDialogButton(ButtonType.Cancel);
             dialog.Buttons.Add(okButton);
             //dialog.Buttons.Add(cancelButton);
             dialog.HyperlinkClicked += new EventHandler <HyperlinkClickedEventArgs>(TaskDialogAbout_HyperLinkClicked);
             TaskDialogButton button = dialog.ShowDialog(this);
         }
     }
     else
     {
         MessageBox.Show(this, "This operating system does not support task dialogs.", "About this program");
     }
 }
Exemplo n.º 28
0
        private void addFavorite_Click(object sender, RoutedEventArgs e)
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                ShowNetworkDialog();
                return;
            }

            ChangeLocationDialog dlg = new ChangeLocationDialog(false);

            dlg.Owner = Window.GetWindow(this);

            if (dlg.ShowDialog() == true)
            {
                try
                {
                    Place    p        = new Place();
                    Location location = new Location(dlg.LocationReference);
                    p.City = location.Locality + ", " + location.AdministrativeAreaLevel1 + ", " + location.Country;

                    string[] favorites = Settings.WeatherFavorites;

                    if (favorites != null)
                    {
                        string loc = p.City.ToLower();

                        foreach (string each in favorites)
                        {
                            if (each.ToLower() == loc)
                            {
                                TaskDialog td = new TaskDialog(Window.GetWindow(this), "Location is in use",
                                                               "You already have " + p.City + " in your favorites.", MessageType.Error);
                                td.ShowDialog();
                                return;
                            }
                        }
                    }

                    p.Click += Place_Click;
                    favoritesPanel.Children.Insert(favoritesPanel.Children.Count - 1, p);

                    if (favorites != null)
                    {
                        Array.Resize(ref favorites, favorites.Length + 1);
                        favorites[favorites.Length - 1] = p.City;
                    }
                    else
                    {
                        favorites = new string[] { p.City }
                    };

                    Settings.WeatherFavorites = favorites;
                }
                catch
                {
                    ShowNetworkDialog();
                }
            }
        }
Exemplo n.º 29
0
        public static AfterSetupAction StartGuidedSetupDialog()
        {
            var quit = new TaskDialogButton("Quit HolzShots");

            var downloadButton = new TaskDialogCommandLinkButton()
            {
                Text             = "Download automatically",
                AllowCloseDialog = false,
            };

            var manualDownload = new TaskDialogCommandLinkButton()
            {
                Text             = "Set up manually",
                AllowCloseDialog = false,
            };

            var doNothing = new TaskDialogCommandLinkButton()
            {
                Text             = "Cancel",
                AllowCloseDialog = false,
            };

            var initialPage = CreateInitialPage(downloadButton, manualDownload);

            var manualSetupPage = CreateManualSetupPage(quit);

            manualDownload.Click += (s, e) => initialPage.Navigate(manualSetupPage);

            var noActionPage = CreateNoActionPage();

            doNothing.Click += (s, e) => initialPage.Navigate(noActionPage);

            var downloadPage = CreatetDownloadPage();

            downloadButton.Click += (s, e) => initialPage.Navigate(downloadPage);

            var answer = TaskDialog.ShowDialog(initialPage, TaskDialogStartupLocation.CenterScreen);

            if (answer == TaskDialogButton.OK)
            {
                // The user clicked "Cancel" and then OK (or an error ocurred)
                return(AfterSetupAction.AbortCurrentAction);
            }

            if (answer == TaskDialogButton.Cancel)
            {
                // The user closed the dialog via "X"
                return(AfterSetupAction.AbortCurrentAction);
            }


            if (answer == quit)
            {
                return(AfterSetupAction.QuitApplication);
            }

            return(AfterSetupAction.Coninue);
        }
 /// <summary>
 /// ダイアログ表示
 /// </summary>
 /// <param name="message"></param>
 private void InformationMessage(InformationMessage message)
 {
     _ = TaskDialog.ShowDialog(this._hwnd, new()
     {
         Caption = message.Caption,
         Text    = message.Text,
         Icon    = GetDialogIcon(message.Image),
     });
 }
Exemplo n.º 31
0
 public override IDisposable Alert(AlertConfig config)
 {
     var dlg = new TaskDialog
     {
         WindowTitle = config.Title,
         Content = config.Message,
         Buttons =
         {
             new TaskDialogButton(config.OkText)
         }
     };
     dlg.ShowDialog();
     return new DisposableAction(dlg.Dispose);
 }
Exemplo n.º 32
0
        public override IDisposable ActionSheet(ActionSheetConfig config)
        {
            var dlg = new TaskDialog
            {
                AllowDialogCancellation = config.Cancel != null,
                WindowTitle = config.Title
            };
            config
                .Options
                .ToList()
                .ForEach(x =>
                    dlg.Buttons.Add(new TaskDialogButton(x.Text)
                ));

            dlg.ButtonClicked += (sender, args) =>
            {
                var action = config.Options.First(x => x.Text.Equals(args.Item.Text));
                action.Action();
            };
            dlg.ShowDialog();
            return new DisposableAction(dlg.Dispose);
        }
Exemplo n.º 33
0
 private void ShowTaskDialogWithCommandLinks()
 {
     if( TaskDialog.OSSupportsTaskDialogs )
     {
         using( TaskDialog dialog = new TaskDialog() )
         {
             dialog.WindowTitle = "Task dialog sample";
             dialog.MainInstruction = "This is a sample task dialog with command links.";
             dialog.Content = "Besides regular buttons, task dialogs also support command links. Only custom buttons are shown as command links; standard buttons remain regular buttons.";
             dialog.ButtonStyle = TaskDialogButtonStyle.CommandLinks;
             TaskDialogButton elevatedButton = new TaskDialogButton("An action requiring elevation");
             elevatedButton.CommandLinkNote = "Both regular buttons and command links can show the shield icon to indicate that the action they perform requires elevation. It is up to the application to actually perform the elevation.";
             elevatedButton.ElevationRequired = true;
             TaskDialogButton otherButton = new TaskDialogButton("Some other action");
             TaskDialogButton cancelButton = new TaskDialogButton(ButtonType.Cancel);
             dialog.Buttons.Add(elevatedButton);
             dialog.Buttons.Add(otherButton);
             dialog.Buttons.Add(cancelButton);
             dialog.ShowDialog(this);
         }
     }
     else
     {
         MessageBox.Show(this, "This operating system does not support task dialogs.", "Task Dialog Sample");
     }
 }
Exemplo n.º 34
0
        /// <summary>Shows either a <c>TaskDialog</c> or a <c>System.Windows.MessageBox</c> if running legacy windows.</summary>
        /// <param name="instructionText">The main text to display (Blue 14pt for <c>TaskDialog</c>).</param>
        /// <param name="icon">The icon to use.</param>
        /// <param name="standardButtons">The standard buttons to use (with or without the custom default button text).</param>
        /// <param name="description">A description of the message, supplements the instruction text.</param>
        /// <param name="footerText">Text to display as a footer message.</param>
        /// <param name="defaultButtonText">Text to display on the button.</param>
        /// <param name="displayShieldOnButton">Indicates if a UAC shield is to be displayed on the defaultButton.</param>
        static void ShowMessage(
            string instructionText, 
            TaskDialogStandardIcon icon, 
            TaskDialogStandardButtons standardButtons, 
            string description = null, 
            string footerText = null, 
            string defaultButtonText = null, 
            bool displayShieldOnButton = false)
        {
            if (TaskDialog.IsPlatformSupported)
            {
                using (var td = new TaskDialog())
                {
                    td.Caption = Resources.SevenUpdateSDK;
                    td.InstructionText = instructionText;
                    td.Text = description;
                    td.Icon = icon;
                    td.FooterText = footerText;
                    td.FooterIcon = TaskDialogStandardIcon.Information;
                    td.CanCancel = true;
                    td.StandardButtons = standardButtons;

                    if (defaultButtonText != null)
                    {
                        var button = new TaskDialogButton(@"btnCustom", defaultButtonText)
                            {
                               Default = true, ShowElevationIcon = displayShieldOnButton
                            };
                        td.Controls.Add(button);
                    }

                    td.ShowDialog(Application.Current.MainWindow);
                    return;
                }
            }

            string message = instructionText;
            var msgIcon = MessageBoxImage.None;

            if (description != null)
            {
                message += Environment.NewLine + description;
            }

            if (footerText != null)
            {
                message += Environment.NewLine + footerText;
            }

            switch (icon)
            {
                case TaskDialogStandardIcon.Error:
                    msgIcon = MessageBoxImage.Error;
                    break;
                case TaskDialogStandardIcon.Information:
                    msgIcon = MessageBoxImage.Information;
                    break;
                case TaskDialogStandardIcon.Warning:
                    msgIcon = MessageBoxImage.Warning;
                    break;
            }

            MessageBoxResult result;

            if (standardButtons == TaskDialogStandardButtons.Cancel || defaultButtonText != null)
            {
                result = MessageBox.Show(message, Resources.SevenUpdateSDK, MessageBoxButton.OKCancel, msgIcon);
            }
            else
            {
                result = MessageBox.Show(message, Resources.SevenUpdateSDK, MessageBoxButton.OK, msgIcon);
            }

            switch (result)
            {
                case MessageBoxResult.No:
                    return;
                case MessageBoxResult.OK:
                    return;
                case MessageBoxResult.Yes:
                    return;
                default:
                    return;
            }
        }
Exemplo n.º 35
0
 private void ShowTaskDialog()
 {
     if( TaskDialog.OSSupportsTaskDialogs )
     {
         using( TaskDialog dialog = new TaskDialog() )
         {
             dialog.WindowTitle = "Task dialog sample";
             dialog.MainInstruction = "This is an example task dialog.";
             dialog.Content = "Task dialogs are a more flexible type of message box. Among other things, task dialogs support custom buttons, command links, scroll bars, expandable sections, radio buttons, a check box (useful for e.g. \"don't show this again\"), custom icons, and a footer. Some of those things are demonstrated here.";
             dialog.ExpandedInformation = "Ookii.org's Task Dialog doesn't just provide a wrapper for the native Task Dialog API; it is designed to provide a programming interface that is natural to .Net developers.";
             dialog.Footer = "Task Dialogs support footers and can even include <a href=\"http://www.ookii.org\">hyperlinks</a>.";
             dialog.FooterIcon = TaskDialogIcon.Information;
             dialog.EnableHyperlinks = true;
             TaskDialogButton customButton = new TaskDialogButton("A custom button");
             TaskDialogButton okButton = new TaskDialogButton(ButtonType.Ok);
             TaskDialogButton cancelButton = new TaskDialogButton(ButtonType.Cancel);
             dialog.Buttons.Add(customButton);
             dialog.Buttons.Add(okButton);
             dialog.Buttons.Add(cancelButton);
             dialog.HyperlinkClicked += new EventHandler<HyperlinkClickedEventArgs>(TaskDialog_HyperLinkClicked);
             TaskDialogButton button = dialog.ShowDialog(this);
             if( button == customButton )
                 MessageBox.Show(this, "You clicked the custom button", "Task Dialog Sample");
             else if( button == okButton )
                 MessageBox.Show(this, "You clicked the OK button.", "Task Dialog Sample");
         }
     }
     else
     {
         MessageBox.Show(this, "This operating system does not support task dialogs.", "Task Dialog Sample");
     }
 }