Example #1
0
        private Boolean Ask(String function, String yes)
        {
            if (!Config.Current.Ask)
            {
                return(true);
            }

            using (TaskDialog dialog = new TaskDialog()
            {
                Icon = TaskDialogStandardIcon.Information
            }) {
                TaskDialogCommandLink yesButton = new TaskDialogCommandLink("yes", "Yes, " + function, yes);
                yesButton.Click += delegate(object s, EventArgs ea) {
                    dialog.Close(TaskDialogResult.Yes);
                };

                TaskDialogCommandLink noButton = new TaskDialogCommandLink("no", "No", "Get me out of here...");
                noButton.Click += delegate(object s, EventArgs ea) {
                    dialog.Close(TaskDialogResult.No);
                };

                dialog.InstructionText = "Are you sure you want to " + function + "?";
                dialog.Caption         = "Simple Power Plus - " + function;
                dialog.Controls.Add(yesButton);
                dialog.Controls.Add(noButton);

                var result = dialog.Show();

                return(result == TaskDialogResult.Yes);
            }
        }
Example #2
0
        private static void ShowException(string text, string instructionText, Exception?exception, bool isTerminating)
        {
            using var dialog = new TaskDialog
                  {
                      OwnerWindowHandle = OwnerFormHandle,
                      Text            = text,
                      InstructionText = instructionText,
                      Caption         = GitUI.Strings.Error,
                      Icon            = TaskDialogStandardIcon.Error,
                      Cancelable      = true,
                  };

            if (exception is not null)
            {
                var btnReport = new TaskDialogCommandLink("Report", GitUI.Strings.ButtonReportBug);
                btnReport.Click += (s, e) =>
                {
                    dialog.Close();
                    ShowNBug(OwnerForm, exception, isTerminating);
                };

                dialog.Controls.Add(btnReport);
            }

            var btnIgnoreOrClose = new TaskDialogCommandLink("IgnoreOrClose", isTerminating ? GitUI.Strings.ButtonCloseApp : GitUI.Strings.ButtonIgnore);

            btnIgnoreOrClose.Click += (s, e) =>
            {
                dialog.Close();
            };
            dialog.Controls.Add(btnIgnoreOrClose);

            dialog.Show();
        }
Example #3
0
        private async void loginSubmitButton(object sender, EventArgs e)
        {
            if (keyData == null)
            {
                // Make sure the user has loaded a keyData file. If they haven't, we should ask if they
                // would like us to generate one.
                using (var confirmGenerate = new TaskDialog()
                {
                    Caption = "Generate Key File",
                    InstructionText = "Would you like us to generate a key file for you?",
                    Text = "A key file is needed in order to encrypt your passwords. You'll be " +
                           "asked to save this file somewhere on your PC.\n\n" +
                           "If you already generated a key file, press Browse in the Login window " +
                           "to locate your key file.",
                    OwnerWindowHandle = this.Handle
                })
                {
                    var buttonGenerate = new TaskDialogButton("GenerateButton", "Generate key file")
                    {
                        Default = true
                    };
                    buttonGenerate.Click += async(object theSender, EventArgs theArgs) =>
                    {
                        confirmGenerate.Close();

                        var saveDialog = new SaveFileDialog()
                        {
                            Title  = "Save Key File",
                            Filter = "Key File (*.key)|*.key",
                        };
                        if (saveDialog.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        keyData = Shared.CryptManager.generateKey();
                        using (var stream = saveDialog.OpenFile())
                        {
                            await stream.WriteAsync(keyData, 0, keyData.Length);
                        }

                        await SendLoginRequest();
                    };

                    var buttonCancel = new TaskDialogButton("CancelButton", "Cancel");
                    buttonCancel.Click += (object theSender, EventArgs theArgs) =>
                    {
                        confirmGenerate.Close();
                    };

                    confirmGenerate.Controls.Add(buttonGenerate);
                    confirmGenerate.Controls.Add(buttonCancel);
                    confirmGenerate.Show();
                }
            }
            else
            {
                await SendLoginRequest();
            }
        }
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            using (var dialog = new TaskDialog()
            {
                Caption = "Delete Account",
                InstructionText = "Are you sure you want to delete your account?",
                Icon = TaskDialogStandardIcon.Warning
            })
            {
                var deleteButton = new TaskDialogButton("DeleteButton", "Delete account");
                deleteButton.Click += (object s, EventArgs ea) =>
                {
                    // TODO: Delete account request.
                    dialog.Close();
                };

                var cancelButton = new TaskDialogButton("CancelButton", "Don't delete");
                cancelButton.Default = true;
                cancelButton.Click  += (object s, EventArgs ea) =>
                {
                    dialog.Close();
                };

                dialog.Controls.Add(deleteButton);
                dialog.Controls.Add(cancelButton);
                dialog.Show();
            }
        }
Example #5
0
 static void dontSendButton_Click(object sender, EventArgs e)
 {
     if (tdError != null)
     {
         tdError.Close(TaskDialogResult.Ok);
     }
 }
Example #6
0
 async Task <TaskDialogResult> QuerySaveAsync(Action <TaskDialogResult> beforeSave = null)
 {
     if (!comic.IsDirty)
     {
         return(TaskDialogResult.No);
     }
     using (TaskDialog dialog = new TaskDialog())
     {
         dialog.Caption           = Application.ProductName;
         dialog.InstructionText   = string.Format(CultureInfo.CurrentCulture, Properties.Resources.DoYouSaveChanges, HumanReadableSavedFileName);
         dialog.OwnerWindowHandle = Handle;
         TaskDialogButton SaveButton = new TaskDialogButton(nameof(SaveButton), Properties.Resources.Save);
         SaveButton.Click += (s, ev) => dialog.Close(TaskDialogResult.Yes);
         TaskDialogButton DoNotSaveButton = new TaskDialogButton(nameof(DoNotSaveButton), Properties.Resources.DoNotSave);
         DoNotSaveButton.Click += (s, ev) => dialog.Close(TaskDialogResult.No);
         TaskDialogButton CancelButton = new TaskDialogButton(nameof(CancelButton), Properties.Resources.Cancel);
         CancelButton.Click += (s, ev) => dialog.Close(TaskDialogResult.Cancel);
         dialog.Controls.Add(SaveButton);
         dialog.Controls.Add(DoNotSaveButton);
         dialog.Controls.Add(CancelButton);
         dialog.Cancelable      = true;
         dialog.StartupLocation = TaskDialogStartupLocation.CenterOwner;
         var result = dialog.Show();
         if (beforeSave != null)
         {
             beforeSave(result);
         }
         if (result == TaskDialogResult.Yes && !await SaveAsync())
         {
             result = TaskDialogResult.Cancel;
         }
         return(result);
     }
 }
        public void File_New()
        {
            var cl = 0;

            var td        = new TaskDialog();
            var tdb1200   = new TaskDialogButton("btnCL1200", "CL 1200");
            var tdb1400   = new TaskDialogButton("btnCL1400", "CL 1400");
            var tdbCancel = new TaskDialogButton("btnCancel", "Cancel");

            tdb1200.Click   += (s, e) => { cl = 1200;  td.Close(TaskDialogResult.CustomButtonClicked); };
            tdb1400.Click   += (s, e) => { cl = 1400;  td.Close(TaskDialogResult.CustomButtonClicked); };
            tdbCancel.Click += (s, e) => { td.Close(TaskDialogResult.Cancel); };

            td.Controls.Add(tdb1200);
            td.Controls.Add(tdb1400);
            td.Controls.Add(tdbCancel);

            td.Caption = "Choose Compatibility Level";
            td.Text    = "Which Compatibility Level (1200 or 1400) do you want to use for the new model?";

            var tdr = td.Show();

            if (cl == 0)
            {
                return;
            }

            Handler       = new TabularModelHandler(cl, Preferences.Current.GetSettings());
            File_Current  = null;
            File_SaveMode = Handler.SourceType;

            LoadTabularModelToUI();
        }
Example #8
0
        public static void Report(Exception exception, bool isTerminating)
        {
            bool isUserExternalOperation = exception is UserExternalOperationException;
            bool isExternalOperation     = exception is ExternalOperationException;

            StringBuilder text      = new();
            string        rootError = Append(text, exception);

            using var taskDialog = new TaskDialog
                  {
                      OwnerWindowHandle = OwnerFormHandle,
                      Icon            = TaskDialogStandardIcon.Error,
                      Caption         = TranslatedStrings.Error,
                      InstructionText = rootError,
                      Cancelable      = true,
                  };

            // prefer to ignore failed external operations
            if (isExternalOperation)
            {
                AddIgnoreOrCloseButton();
            }

            // no bug reports for user configured operations
            if (!isUserExternalOperation)
            {
                // directions and button to raise a bug
                text.AppendLine().AppendLine(TranslatedStrings.ReportBug);
            }

            string buttonText = isUserExternalOperation ? TranslatedStrings.ButtonViewDetails : TranslatedStrings.ButtonReportBug;
            TaskDialogCommandLink taskDialogCommandLink = new(buttonText, buttonText);

            taskDialogCommandLink.Click += (s, e) =>
            {
                taskDialog.Close();
                ShowNBug(OwnerForm, exception, isTerminating);
            };
            taskDialog.Controls.Add(taskDialogCommandLink);

            // let the user decide whether to report the bug
            if (!isExternalOperation)
            {
                AddIgnoreOrCloseButton();
            }

            taskDialog.Text = text.ToString().Trim();
            taskDialog.Show();
            return;

            void AddIgnoreOrCloseButton()
            {
                string buttonText = isTerminating ? TranslatedStrings.ButtonCloseApp : TranslatedStrings.ButtonIgnore;
                TaskDialogCommandLink taskDialogCommandLink = new(buttonText, buttonText);

                taskDialogCommandLink.Click += (s, e) => taskDialog.Close();
                taskDialog.Controls.Add(taskDialogCommandLink);
            }
        }
Example #9
0
        public DialogResult ShowDialog(IWin32Window owner)
        {
            var isLogicError = !IsID10TError(_exception);

            var editReportLinkHref = "edit_report";

            var dialog = new TaskDialog
            {
                Cancelable        = true,
                DetailsExpanded   = false,
                HyperlinksEnabled = true,
                ExpansionMode     = TaskDialogExpandedDetailsLocation.ExpandFooter,
                StartupLocation   = TaskDialogStartupLocation.CenterOwner,

                Icon                = TaskDialogStandardIcon.Error,
                Caption             = _title,
                InstructionText     = "An unexpected error occured.",
                Text                = _exception.Message,
                DetailsExpandedText = _exception.ToString(),

                DetailsCollapsedLabel = "Show &details",
                DetailsExpandedLabel  = "Hide &details",

                FooterText = string.Format("<a href=\"{0}\">Edit report contents</a>", editReportLinkHref),

                OwnerWindowHandle = owner.Handle
            };

            var sendButton = new TaskDialogCommandLink("sendButton", "&Report This Error\nFast and painless - I promise!");

            sendButton.Click += delegate
            {
                new TaskBuilder()
                .OnCurrentThread()
                .DoWork((invoker, token) => ErrorReporter.Report(_exception))
                .Fail(args => ReportExceptionFail(owner, args))
                .Succeed(() => ReportExceptionSucceed(owner))
                .Build()
                .Start();
                dialog.Close(TaskDialogResult.Yes);
            };

            var dontSendButton = new TaskDialogCommandLink("dontSendButton", "&No Thanks\nI don't feel like being helpful");

            dontSendButton.Click += delegate
            {
                dialog.Close(TaskDialogResult.No);
            };

            dialog.HyperlinkClick += (sender, args) => MessageBox.Show(owner, args.LinkText);

            if (true || isLogicError)
            {
                dialog.Controls.Add(sendButton);
                dialog.Controls.Add(dontSendButton);
            }

            return(dialog.Show().ToDialogResult());
        }
        public static string DisplayInformationalText()
        {
            var result      = "";
            var detailsText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum";

            var closeButton = new TaskDialogButton("CloseTaskDialogButton", "Not now")
            {
                Default = true
            };
            var proceedButton = new TaskDialogButton("ProceedTaskDialogButton", "Get going");

            var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TextFile1.txt");

            var dialog = new TaskDialog
            {
                Caption = "Read file",
                DetailsCollapsedLabel = "More >>",
                DetailsExpanded       = false,
                DetailsExpandedLabel  = "<< Less",
                DetailsExpandedText   = detailsText,
                ExpansionMode         = TaskDialogExpandedDetailsLocation.Hide,
                InstructionText       = $"Reading the file '{Path.GetFileName(fileName)}'",
                Icon            = TaskDialogStandardIcon.Information,
                Cancelable      = true,
                StartupLocation = TaskDialogStartupLocation.CenterOwner
            };

            dialog.Controls.Add(closeButton);
            dialog.Controls.Add(proceedButton);

            dialog.OwnerWindowHandle = Form.ActiveForm.Handle;

            dialog.Opened += (senderObject, ea) =>
            {
                TaskDialog taskDialog = senderObject as TaskDialog;
                taskDialog.Icon = taskDialog.Icon;
            };

            closeButton.Click += (e, a) =>
            {
                dialog.Close(TaskDialogResult.Cancel);
            };

            proceedButton.Click += (e, a) =>
            {
                dialog.Close(TaskDialogResult.Ok);
            };

            if (dialog.Show() == TaskDialogResult.Cancel)
            {
                result = "Canceled";
            }
            else
            {
                result = "Continue";
            }

            return(result);
        }
Example #11
0
        /// <inheritdoc/>
        public bool ShowDeleteInvalidRepositoryDialog(string repositoryPath)
        {
            int invalidPathCount = ThreadHelper.JoinableTaskFactory.Run(() => RepositoryHistoryManager.Locals.LoadRecentHistoryAsync())
                                   .Count(repo => !GitModule.IsValidGitWorkingDir(repo.Path));
            int dialogResult = -1;

            using var dialog = new TaskDialog
                  {
                      InstructionText = Strings.DirectoryInvalidRepository,
                      Caption         = Strings.Open,
                      Icon            = TaskDialogStandardIcon.Error,
                      StandardButtons = TaskDialogStandardButtons.Cancel,
                      Cancelable      = true,
                  };
            var btnRemoveSelectedInvalidRepository = new TaskDialogCommandLink("RemoveSelectedInvalidRepository", null, Strings.RemoveSelectedInvalidRepository);

            btnRemoveSelectedInvalidRepository.Click += (s, e) =>
            {
                dialogResult = 0;
                dialog.Close();
            };
            dialog.Controls.Add(btnRemoveSelectedInvalidRepository);
            if (invalidPathCount > 1)
            {
                var btnRemoveAllInvalidRepositories = new TaskDialogCommandLink("RemoveAllInvalidRepositories", null, string.Format(Strings.RemoveAllInvalidRepositories, invalidPathCount));
                btnRemoveAllInvalidRepositories.Click += (s, e) =>
                {
                    dialogResult = 1;
                    dialog.Close();
                };
                dialog.Controls.Add(btnRemoveAllInvalidRepositories);
            }

            dialog.Show();

            switch (dialogResult)
            {
            case 0:
            {
                /* Remove selected invalid repo */
                ThreadHelper.JoinableTaskFactory.Run(() => RepositoryHistoryManager.Locals.RemoveRecentAsync(repositoryPath));
                return(true);
            }

            case 1:
            {
                /* Remove all invalid repos */
                ThreadHelper.JoinableTaskFactory.Run(() => RepositoryHistoryManager.Locals.RemoveInvalidRepositoriesAsync(repoPath => GitModule.IsValidGitWorkingDir(repoPath)));
                return(true);
            }

            default:
            {
                /* Cancel */
                return(false);
            }
            }
        }
        public static void StupidThreeButtonsDemo()
        {
            var yesButton = new TaskDialogButton("YesTaskDialogButton", "YeeHaa!")
            {
                Default = true
            };
            var neverButton = new TaskDialogButton("NeverTaskDialogButton", "No way!!!");
            var dunnoButton = new TaskDialogButton("dunnoTaskDialogButton", "I donno?");

            var dialog = new TaskDialog
            {
                Caption             = "Stupid",
                InstructionText     = "You are about to do something stupid",
                Icon                = TaskDialogStandardIcon.Shield,
                DetailsExpandedText = "Are you sure you want to continue with this really bad idea?",
                DetailsExpanded     = true,
                Cancelable          = false,
                StartupLocation     = TaskDialogStartupLocation.CenterOwner
            };

            dialog.FooterText = "I double dog dare you";
            dialog.FooterIcon = TaskDialogStandardIcon.Information;
            dialog.Controls.Add(yesButton);
            dialog.Controls.Add(neverButton);
            dialog.Controls.Add(dunnoButton);

            dialog.OwnerWindowHandle = Form.ActiveForm.Handle;

            dialog.Opened += (senderObject, ea) =>
            {
                var taskDialog = senderObject as TaskDialog;
                if (taskDialog != null)
                {
                    taskDialog.Icon       = taskDialog.Icon;
                    taskDialog.FooterIcon = taskDialog.FooterIcon;
                }
            };

            yesButton.Click += (e, a) =>
            {
                dialog.Close(TaskDialogResult.Close);
            };

            neverButton.Click += (e, a) =>
            {
                dialog.Close(TaskDialogResult.Close);
            };

            dunnoButton.Click += (e, a) =>
            {
                dialog.Close(TaskDialogResult.Close);
            };

            dialog.Show();
        }
        /// <summary>
        /// Ask to close application with user defined buttons
        /// </summary>
        /// <param name="stayText">Text to show for not leaving</param>
        /// <param name="leaveText">Text to show for leaving</param>
        /// <returns></returns>
        public static TaskDialogResult ExitApplication(string stayText, string leaveText)
        {
            //
            // Defines the default button
            //
            var stayButton = new TaskDialogButton("StayButton", stayText)
            {
                Default = true
            };
            var closeButton = new TaskDialogButton("CancelButton", leaveText);

            var dialog = new TaskDialog
            {
                Caption           = "Question",
                InstructionText   = $"Close '{Application.ProductName}'",
                Icon              = TaskDialogStandardIcon.Warning,
                Cancelable        = true,
                OwnerWindowHandle = Form.ActiveForm.Handle,
                StartupLocation   = TaskDialogStartupLocation.CenterOwner
            };

            //
            // Place buttons in the order they should appear
            //
            dialog.Controls.Add(closeButton);
            dialog.Controls.Add(stayButton);

            //
            // Issue that requires icon to be set here else
            // it will not show.
            //
            dialog.Opened += (sender, ea) =>
            {
                var taskDialog = sender as TaskDialog;
                taskDialog.Icon = taskDialog.Icon;
            };

            //
            // Set result for when dialog closes
            //
            stayButton.Click += (e, a) =>
            {
                dialog.Close(TaskDialogResult.Cancel);
            };

            closeButton.Click += (e, a) =>
            {
                dialog.Close(TaskDialogResult.Close);
            };

            //
            // Display dialog
            //
            return(dialog.Show());
        }
Example #14
0
        private void buttonDeleteUser_Click(object sender, EventArgs e)
        {
            using (var confirmDialog = new TaskDialog()
            {
                Caption = "Delete Account",
                InstructionText = "Are you sure you want to delete this account?",
                Icon = TaskDialogStandardIcon.Warning
            })
            {
                var deleteButton = new TaskDialogButton("DeleteButton", "Delete user");
                deleteButton.Click += async(object s, EventArgs a) =>
                {
                    confirmDialog.Close();

                    if (this.listviewAccounts.SelectedItems.Count != 1)
                    {
                        return;
                    }

                    var selectedItem = this.listviewAccounts.SelectedItems[0];

                    try
                    {
                        var response = await SocketManager.Instance.SendRequest <DeleteUserResponse>(new DeleteUserRequest(selectedItem.SubItems[0].Text));

                        selectedItem.Remove();
                    }
                    catch (ResponseException ex)
                    {
                        using (var dialog = new TaskDialog()
                        {
                            Caption = "Password Manager",
                            InstructionText = "Unable to remove this user",
                            Text = ex.Message,
                            Icon = TaskDialogStandardIcon.Error,
                            StandardButtons = TaskDialogStandardButtons.Close
                        })
                        {
                            dialog.Show();
                        }
                    }
                };

                var cancelButton = new TaskDialogButton("CancelButton", "Don't delete");
                cancelButton.Click += (object s, EventArgs a) =>
                {
                    confirmDialog.Close();
                };

                confirmDialog.Controls.Add(deleteButton);
                confirmDialog.Controls.Add(cancelButton);
                confirmDialog.Show();
            }
        }
Example #15
0
        void Open(string fileName)
        {
            TaskDialogResult result;

            do
            {
                Activate();
                prevMain.ViewPane.Select();
                using (TaskDialog dialog = new TaskDialog())
                {
                    dialog.Cancelable = false;
                    dialog.Controls.Add(new TaskDialogButton("btnCancel", Properties.Resources.Cancel));
                    dialog.Caption           = Application.ProductName;
                    dialog.Icon              = TaskDialogStandardIcon.None;
                    dialog.InstructionText   = Properties.Resources.OpeningFile;
                    dialog.OwnerWindowHandle = Handle;
                    dialog.ProgressBar       = new TaskDialogProgressBar(0, 100, 0);
                    dialog.Opened           += async(s, ev) =>
                    {
                        ((TaskDialogButtonBase)dialog.Controls["btnCancel"]).Enabled = false;
                        try
                        {
                            await icd.OpenAsync(fileName, new Progress <int>(value => dialog.ProgressBar.Value = value));

                            dialog.Close(TaskDialogResult.Ok);
                        }
                        catch (OperationCanceledException)
                        {
                            dialog.Close(TaskDialogResult.Close);
                        }
                    };
                    dialog.StartupLocation = TaskDialogStartupLocation.CenterOwner;
                    result = dialog.Show();
                }
            } while (result == TaskDialogResult.Retry);
            if (result == TaskDialogResult.Close)
            {
                Close();
                return;
            }
            conBookmarks.Items.AddRange(icd.Bookmarks.Select(b => new ToolStripMenuItem(b.Name, null, (sen, eve) =>
            {
                current = spreads.FindIndex(sp => sp.Left == b.Target || sp.Right == b.Target);
                ViewCurrentPage();
            })).ToArray());
            spreads         = new List <Spread>(icd.ConstructSpreads(false));
            openingFileName = "";
            ViewCurrentPage();
        }
Example #16
0
        public static TaskDialogResult Show(IWin32Window owner, Exception exception)
        {
            _exception = exception;

            _taskDialog = new TaskDialog
            {
                InstructionText     = "Critical error occured!",
                Text                = exception.Message,
                Icon                = TaskDialogStandardIcon.Error,
                Cancelable          = true,
                DetailsExpandedText = exception.ToString(),
                StartupLocation     = TaskDialogStartupLocation.CenterScreen,
                OwnerWindowHandle   = owner.Handle
            };

            var commandLinkSend = new TaskDialogCommandLink("SendFeedbackButton", "Report", "Create an issue on Github (Stacktrace will be copied to clipboard).");

            commandLinkSend.Click += CommandLinkSend_Click;

            var commandLinkIgnore = new TaskDialogCommandLink("IgnoreButton", "Ignore", "Proceed and ignore this error.");

            commandLinkIgnore.Click += (s, e) => _taskDialog.Close();

            _taskDialog.Controls.Add(commandLinkSend);
            _taskDialog.Controls.Add(commandLinkIgnore);

            return(_taskDialog.Show());
        }
Example #17
0
 private void command4_Executed(object sender, EventArgs e)
 {
     Opcion = 5;
     TaskDialog.Close(eTaskDialogResult.Custom1);
     accion();
     backgroundWorker1.RunWorkerAsync();
 }
Example #18
0
        public static TaskDialog Exception(Exception exception, string errorTitle, string errorRemedy = null, IWin32Window owner = null)
        {
            var td = new TaskDialog
            {
                DetailsExpanded       = false,
                Cancelable            = true,
                Icon                  = TaskDialogStandardIcon.Error,
                Caption               = MainCaption,
                InstructionText       = errorTitle ?? "An unknown error occurred",
                Text                  = errorRemedy,
                DetailsExpandedLabel  = "Hide details",
                DetailsCollapsedLabel = "Show details",
                DetailsExpandedText   = exception.GetType().Name + ": " + exception.Message + "\n--- Begin stack trace ---\n" + exception.StackTrace,
                ExpansionMode         = TaskDialogExpandedDetailsLocation.ExpandFooter,
                OwnerWindowHandle     = owner?.Handle ?? IntPtr.Zero
            };

            if (Debugger.IsAttached)
            {
                var button = new TaskDialogButton("Break", "Break into debugger");
                button.Click += (sender, args) => Debugger.Break();
                td.Controls.Add(button);
            }
            var okButton = new TaskDialogButton("OK", "OK");

            okButton.Click += (sender, args) => td.Close(TaskDialogResult.Ok);
            td.Controls.Add(okButton);

            td.Opened += (sender, args) =>
            {
                td.Icon = TaskDialogStandardIcon.Error;
                SystemSounds.Hand.Play();
            };
            return(td);
        }
Example #19
0
        private static void CommandLinkSend_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(_exception.ToString());
            Process.Start("https://github.com/midare160/SpotifyAdRemover/issues/new");

            _taskDialog.Close();
        }
Example #20
0
        // OMG, http://www.roblox.com/Game/PlaceLauncher.ashx?request=RequestGame&placeId=1818

        private void button1_Click(object sender, EventArgs e)
        {
            Console.WriteLine("f");
            TaskDialog dialog = new TaskDialog();

            dialog.Opened += dialog_Opened;
            TaskDialogProgressBar bar = new TaskDialogProgressBar(0, 100, 2);

            bar.State = TaskDialogProgressBarState.Marquee;
            dialog.Controls.Add(bar);

            dialog.StandardButtons = TaskDialogStandardButtons.None;

            backgroundWorker1.RunWorkerCompleted += (s, ev) =>
            {
                if (ev.Result == (object)true)
                {
                    try
                    {
                        dialog.Close(TaskDialogResult.Ok);
                    }
                    catch { }
                }
            };

            dialog.InstructionText = "Launching Roblox...";
            dialog.Text            = "Getting Authentication Url, Ticket, and Join Script.";
            dialog.Closing        += dialog_Closing;
            dialog.Show();
        }
Example #21
0
 private void Tick(int ticks)
 {
     if (ExecuteCompleted)
     {
         TaskDialog.Close(ID);
     }
 }
Example #22
0
        /// <summary>
        /// Handles the Click event of the buttonReset control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void buttonReset_Click(object sender, RoutedEventArgs e)
        {
            TaskDialog dialog = new TaskDialog();

            dialog.OwnerWindowHandle = new WindowInteropHelper(Window.GetWindow(this)).Handle;
            dialog.Cancelable        = true;
            dialog.Caption           = Properties.Resources.ResetDatabaseCaption;
            dialog.ExpansionMode     = TaskDialogExpandedDetailsLocation.Hide;
            dialog.Icon            = TaskDialogStandardIcon.Warning;
            dialog.StartupLocation = TaskDialogStartupLocation.CenterOwner;
            dialog.Text            = Properties.Resources.ResetDatabaseText;

            TaskDialogCommandLink buttonYes = new TaskDialogCommandLink("buttonYes", Properties.Resources.ResetDatabaseYes);

            buttonYes.Click += new EventHandler(delegate(object snd, EventArgs eventArgs)
            {
                Service.TicketSource.Reset();
                listBoxStatus.ItemsSource              = new ObservableCollection <TicketEventArgs>();
                lineSeriesStatisticTotal.ItemsSource   = BuildStatistic(StatisticMode.Total);
                areaSeriesStatisticPerUnit.ItemsSource = BuildStatistic(StatisticMode.PerUnit);
                UpdateStatus();

                dialog.Close();
            });
            TaskDialogCommandLink buttonNo = new TaskDialogCommandLink("buttonNo", Properties.Resources.ResetDatabaseNo);

            buttonNo.Click += new EventHandler(delegate(object snd, EventArgs eventArgs) { dialog.Close(); });

            dialog.Controls.Add(buttonYes);
            dialog.Controls.Add(buttonNo);

            dialog.Show();
        }
Example #23
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);
                });
            }
        }
Example #24
0
        private static TaskDialogCommandLink CreateDeclineButton(TaskDialog dialog)
        {
            var dontSendButton = new TaskDialogCommandLink("declineButton", "&No Thanks\nI don't feel like being helpful");

            dontSendButton.Click += delegate { dialog.Close(TaskDialogResult.No); };
            return(dontSendButton);
        }
Example #25
0
        /// <summary>
        /// Handles the Closing event of the Window control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param>
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            TaskDialog dialog = new TaskDialog();

            dialog.OwnerWindowHandle = new WindowInteropHelper(this).Handle;
            dialog.Cancelable        = true;
            dialog.Caption           = Properties.Resources.CloseWarningCaption;
            dialog.ExpansionMode     = TaskDialogExpandedDetailsLocation.Hide;
            dialog.Icon            = TaskDialogStandardIcon.None;
            dialog.StartupLocation = TaskDialogStartupLocation.CenterOwner;
            dialog.Text            = Properties.Resources.CloseWarningText;

            TaskDialogCommandLink buttonYes = new TaskDialogCommandLink("buttonYes", Properties.Resources.CloseWarningYes);

            buttonYes.Click += new EventHandler(delegate(object snd, EventArgs eventArgs)
            {
                host.Close();
                dialog.Close();
            });
            TaskDialogCommandLink buttonNo = new TaskDialogCommandLink("buttonNo", Properties.Resources.CloseWarningNo);

            buttonNo.Click += new EventHandler(delegate(object snd, EventArgs eventArgs) { dialog.Close(); e.Cancel = true; });

            dialog.Controls.Add(buttonYes);
            dialog.Controls.Add(buttonNo);

            dialog.Show();
        }
Example #26
0
 static void adminTaskButton_Click(object sender, EventArgs e)
 {
     if (tdElevation != null)
     {
         tdElevation.Close(TaskDialogResult.Ok);
     }
 }
        /// <summary>
        /// Handles the Click event of the buttonDelete control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void buttonDelete_Click(object sender, RoutedEventArgs e)
        {
            TaskDialog dialog = new TaskDialog();

            dialog.OwnerWindowHandle = new WindowInteropHelper(Window.GetWindow(this)).Handle;
            dialog.Cancelable        = true;
            dialog.Caption           = Properties.Resources.DeleteTicketCaption;
            dialog.ExpansionMode     = TaskDialogExpandedDetailsLocation.Hide;
            dialog.Icon            = TaskDialogStandardIcon.None;
            dialog.StartupLocation = TaskDialogStartupLocation.CenterOwner;
            dialog.Text            = Properties.Resources.DeleteTicketText;

            TaskDialogCommandLink buttonYes = new TaskDialogCommandLink("buttonYes", Properties.Resources.DeleteTicketYes);

            buttonYes.Click += new EventHandler(delegate(object snd, EventArgs eventArgs)
            {
                Ticket.Delete();
                Ticket = null;
                dialog.Close();
            });
            TaskDialogCommandLink buttonNo = new TaskDialogCommandLink("buttonNo", Properties.Resources.DeleteTicketNo);

            buttonNo.Click += new EventHandler(delegate(object snd, EventArgs eventArgs) { dialog.Close(); });

            dialog.Controls.Add(buttonYes);
            dialog.Controls.Add(buttonNo);

            dialog.Show();
        }
Example #28
0
        private void taskDialogTest_Click(object sender, EventArgs e)
        {
            TaskDialog taskDialog = new TaskDialog();

            taskDialog.Caption         = "인생에 대해서..";
            taskDialog.InstructionText = "야겜안하는 애들이 사랑이 뭔지나 알겠냐";

            taskDialog.HyperlinksEnabled = true;
            taskDialog.Text = "기껏해야 밖에서도 힘싸움하고 애들 밟고 까이고 떠들고 웃고 즐기기나 하겠지. " +
                              "남자가 여자를 사랑한다는 그 참된 의미를 이해나 하겠냐? " +
                              "슬퍼서 눈물 흘린다는 말의 참의미를 깨달을수나 있겠냐? " +
                              "야겜 안하는새끼는 나중에 커서 지 부모도 잡아먹을새끼가 틀림없어. " +
                              "내가 보증한다. " +
                              "<a href=\"test\">개새끼들...</a>";

            taskDialog.FooterCheckBoxText    = "이런거 이제 그만 보여줘요";
            taskDialog.FooterCheckBoxChecked = false;

            TaskDialogButton okButton = new TaskDialogButton("okButton", "그르네");

            okButton.Click += (s, ev) => MessageBox.Show("맞어!");

            TaskDialogButton closeButton = new TaskDialogButton("closeButton", "먼 개소리를");

            closeButton.Click += (s, ev) => taskDialog.Close();

            taskDialog.Controls.Add(okButton);
            taskDialog.Controls.Add(closeButton);

            TaskDialogResult result = taskDialog.Show();
        }
Example #29
0
        static void button3_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Custom close button was clicked. Closing the dialog...", "Custom Buttons Sample");

            if (tdCustomButtons != null)
            {
                tdCustomButtons.Close(TaskDialogResult.CustomButtonClicked);
            }
        }
 public void Close(TaskDialogResult taskDlgResult = TaskDialogResult.Close)
 {
     if (IsOpened == false)
     {
         return;
     }
     IsOpened = false;
     TaskDlg.Close(taskDlgResult);
 }