public static void PluginExc(Exception z, jZmPlugin plug) { TaskDialog diag = new TaskDialog(); diag.InstructionText = "'" + plug.Name + "' by '" + plug.Author + "' has thrown a exception."; diag.Text = "One of your plugins has thrown an unhandled exception.\nThis means that one of your plugin may be unstable."; diag.Caption = "WTF?"; diag.Icon = TaskDialogStandardIcon.Error; diag.DetailsExpandedText = z.ToString(); TaskDialogCommandLink linkz = new TaskDialogCommandLink("r", "Restart jZm"); linkz.ShowElevationIcon = true; linkz.Click += delegate(object sender, EventArgs argz) { diag.Close(); Application.Restart(); }; diag.Controls.Add(linkz); linkz = new TaskDialogCommandLink("r", "Exit jZm"); linkz.Click += delegate(object sender, EventArgs argz) { diag.Close(); Environment.Exit(-1); }; diag.Controls.Add(linkz); linkz = new TaskDialogCommandLink("r", "Ignore error", "Warning: Plugin might throw more errors, You'll probably be better off contacting the owner and/or removing the plugin."); linkz.Click += delegate(object sender, EventArgs argz) { diag.Close(); }; diag.Controls.Add(linkz); diag.Show(); }
/// <summary> /// Shows the dialog. /// </summary> public static TaskDialogResult Show(IntPtr owner) { TaskDialog td = new TaskDialog(); TaskDialogCommandLink cusButton = new TaskDialogCommandLink("cusButton", U.T("AssociationsChoose"), U.T("AssociationsChooseText")); TaskDialogCommandLink skipButton = new TaskDialogCommandLink("skipButton", U.T("AssociationsSkip"), U.T("AssociationsSkipText")); TaskDialogCommandLink defButton = new TaskDialogCommandLink("defButton", U.T("AssociationsYes"), U.T("AssociationsYesText")); defButton.Click += new EventHandler(defButton_Click); skipButton.Click += new EventHandler(skipButton_Click); td.Controls.Add(defButton); td.Controls.Add(cusButton); td.Controls.Add(skipButton); td.Caption = U.T("AssociationsCaption"); td.InstructionText = U.T("AssociationsInstruction"); td.Text = U.T("AssociationsText"); td.StartupLocation = TaskDialogStartupLocation.CenterOwner; td.OwnerWindowHandle = owner; return td.Show(); }
/* * Continue button click event handler. */ private void continueButton_Click(object sender, EventArgs e) { // Save team domain if valid otherwise show team not found information dialog if(IsTeamDomainValid()) { SlackTeamDomain = teamDomainTextBox.Text.ToLowerInvariant(); DialogResult = DialogResult.OK; Close(); } else { TaskDialog noTeamDialog = new TaskDialog() { Caption = Application.ProductName, HyperlinksEnabled = true, Icon = TaskDialogStandardIcon.Information, InstructionText = "We couldn't find your team.", OwnerWindowHandle = Handle, StandardButtons = TaskDialogStandardButtons.Ok, Text = "If you can't remember your team's address, Slack can <a href=\"#\">send you a reminder</a>." }; noTeamDialog.HyperlinkClick += delegate { Process.Start(FindYourTeamUrl); }; // Workaround for a bug in the Windows TaskDialog API noTeamDialog.Opened += (td, ev) => { TaskDialog taskDialog = td as TaskDialog; taskDialog.Icon = noTeamDialog.Icon; taskDialog.InstructionText = noTeamDialog.InstructionText; }; noTeamDialog.Show(); } }
private void ButtonTaskDialogIconFix_Click(object sender, RoutedEventArgs e) { using (var dialog = new TaskDialog { Caption = "Caption", DetailsCollapsedLabel = "DetailsCollapsedLabel", DetailsExpanded = true, DetailsExpandedLabel = "DetailsExpandedLabel", DetailsExpandedText = "DetailsExpandedText", ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandContent, FooterCheckBoxChecked = true, FooterCheckBoxText = "FooterCheckBoxText", FooterIcon = TaskDialogStandardIcon.Information, FooterText = "FooterText", HyperlinksEnabled = true, Icon = TaskDialogStandardIcon.Shield, InstructionText = "InstructionText", ProgressBar = new TaskDialogProgressBar {Value = 100}, StandardButtons = TaskDialogStandardButtons.Ok | TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No | TaskDialogStandardButtons.Cancel | TaskDialogStandardButtons.Close | TaskDialogStandardButtons.Retry, StartupLocation = TaskDialogStartupLocation.CenterScreen, Text = "Text" }) { dialog.Show(); } }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.SelectedItem != null) { ParentalControlsCredential cred = new ParentalControlsCredential(textBox1.Text, textBox2.Text, false); if(!file.Remove((ParentalControlsCredential)comboBox1.SelectedItem)) { TaskDialog dialog = new TaskDialog(); dialog.Caption = this.Text; dialog.InstructionText = "Failed to Change Credential"; dialog.Text = "An unknown error occured while changing \""+((ParentalControlsCredential)comboBox1.SelectedItem).Username+"\""; dialog.Opened += (a, b) => { dialog.Icon = TaskDialogStandardIcon.Error; }; dialog.Show(); } else { file.Add(cred); RefreshItems(false); comboBox1.SelectedItem = cred; } } }
private void ExecuteStart(object sender, RoutedEventArgs e) { if (!_viewModel.DoNotShowWarning) { using (TaskDialog dlg = new TaskDialog()) { dlg.Caption = "Подтвердите операцию"; dlg.Text = "Во время своей работы приложение создаст временные базы данных на указанном вами сервере. Они будут удалены сразу после окончания тестирования.\r\n\r\nНе используйте данное приложение с рабочим SQL Server!"; dlg.Cancelable = true; var okLink = new TaskDialogCommandLink("ok", "Согласен. Продолжаем!"); okLink.Click += (sender2, e2) => ((TaskDialog)((TaskDialogCommandLink)sender2).HostingDialog).Close(TaskDialogResult.Ok); var cancelLink = new TaskDialogCommandLink("cancel", "Я передумал") {Default = true}; cancelLink.Click += (sender2, e2) => ((TaskDialog)((TaskDialogCommandLink)sender2).HostingDialog).Close(TaskDialogResult.Cancel); dlg.Controls.Add(okLink); dlg.Controls.Add(cancelLink); dlg.FooterCheckBoxText = "Больше не спрашивать"; var result = dlg.Show(); _viewModel.DoNotShowWarning = dlg.FooterCheckBoxChecked.Value; if (result != TaskDialogResult.Ok) return; } } _viewModel.PoolTestRunning = true; _viewModel.Server = tbServer.Text.Trim(); _viewModel.UseSqlAuthentication = cbUseSqlAuth.IsChecked.Value; _viewModel.UserName = tbUserName.Text.Trim(); _viewModel.Password = tbPassword.Password; _viewModel.LogLines.Clear(); Thread t = new Thread(_presenter.RunPoolTest); t.Start(); }
public static void Crash(Exception z) { TaskDialog diag = new TaskDialog(); diag.InstructionText = "An unhandled exception was caught"; diag.Text = "jZm has crashed because of a unhandled exception, this means something happend that shouldn't happen."; diag.Caption = "WTF?"; diag.Icon = TaskDialogStandardIcon.Error; diag.DetailsExpandedText = z.ToString(); TaskDialogCommandLink linkz = new TaskDialogCommandLink("r", "Restart jZm"); linkz.ShowElevationIcon = true; linkz.Click += delegate(object sender, EventArgs argz) { diag.Close(); Application.Restart(); }; diag.Controls.Add(linkz); linkz = new TaskDialogCommandLink("r", "Exit jZm"); linkz.Click += delegate(object sender, EventArgs argz) { diag.Close(); Environment.Exit(-1); }; diag.Controls.Add(linkz); diag.Show(); Environment.Exit(-1); }
public static void Show(Window owner = null, string text = "", string instructionText = "", string caption = "Information") { IntPtr windowHandle = IntPtr.Zero; if (owner == null) windowHandle = new WindowInteropHelper(Application.Current.MainWindow).Handle; else windowHandle = new WindowInteropHelper(owner).Handle; try { using (TaskDialog taskDialog = new TaskDialog()) { taskDialog.OwnerWindowHandle = windowHandle; taskDialog.StandardButtons = TaskDialogStandardButtons.Ok; taskDialog.StartupLocation = TaskDialogStartupLocation.CenterOwner; taskDialog.Icon = TaskDialogStandardIcon.Information; taskDialog.Text = text; taskDialog.InstructionText = instructionText; taskDialog.Caption = caption; taskDialog.Show(); } } catch (Exception) { if (owner != null) MessageBox.Show(owner, text, caption, MessageBoxButton.OK, MessageBoxImage.Information); else MessageBox.Show(text, caption, MessageBoxButton.OK, MessageBoxImage.Information); } }
public static void HandleException(Window window, FileNotFoundException ex) { try { string fileName = Path.GetFileName(ex.FileName); string message = string.Format(Properties.Resources.MessageFileNotFoundException, fileName); TaskDialog dialog = new TaskDialog(); dialog.InstructionText = message; //dialog.Text dialog.Icon = TaskDialogStandardIcon.Error; dialog.StandardButtons = TaskDialogStandardButtons.Ok; dialog.DetailsExpandedText = ex.Message; dialog.Caption = App.Current.ApplicationTitle; if (window != null) { dialog.OwnerWindowHandle = new WindowInteropHelper(window).Handle; } dialog.Show(); } catch (PlatformNotSupportedException) { MessageBox.Show(ex.Message); } }
private void ButtonTaskDialogCustomButtonClose_Click(object sender, RoutedEventArgs e) { var helper = new WindowInteropHelper(this); var td = new TaskDialog {OwnerWindowHandle = helper.Handle}; var closeLink = new TaskDialogCommandLink("close", "Close", "Closes the task dialog"); closeLink.Click += (o, ev) => td.Close(TaskDialogResult.CustomButtonClicked); var closeButton = new TaskDialogButton("closeButton", "Close"); closeButton.Click += (o, ev) => td.Close(TaskDialogResult.CustomButtonClicked); // Enable one or the other; can't have both at the same time td.Controls.Add(closeLink); //td.Controls.Add(closeButton); // needed since none of the buttons currently closes the TaskDialog td.Cancelable = true; switch (td.Show()) { case TaskDialogResult.CustomButtonClicked: MessageBox.Show("The task dialog was closed by a custom button"); break; case TaskDialogResult.Cancel: MessageBox.Show("The task dialog was canceled"); break; default: MessageBox.Show("The task dialog was closed by other means"); break; } }
// 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(); }
private void cmdShow_Click(object sender, EventArgs e) { TaskDialog td = new TaskDialog(); #region Button(s) TaskDialogStandardButtons button = TaskDialogStandardButtons.None; if (chkOK.Checked) button |= TaskDialogStandardButtons.Ok; if (chkCancel.Checked) button |= TaskDialogStandardButtons.Cancel; if (chkYes.Checked) button |= TaskDialogStandardButtons.Yes; if (chkNo.Checked) button |= TaskDialogStandardButtons.No; if (chkClose.Checked) button |= TaskDialogStandardButtons.Close; if (chkRetry.Checked) button |= TaskDialogStandardButtons.Retry; #endregion #region Icon if (rdoError.Checked) { td.Icon = TaskDialogStandardIcon.Error; } else if (rdoInformation.Checked) { td.Icon = TaskDialogStandardIcon.Information; } else if (rdoShield.Checked) { td.Icon = TaskDialogStandardIcon.Shield; } else if (rdoWarning.Checked) { td.Icon = TaskDialogStandardIcon.Warning; } #endregion #region Prompts string title = txtTitle.Text; string instruction = txtInstruction.Text; string content = txtContent.Text; #endregion td.StandardButtons = button; td.InstructionText = instruction; td.Caption = title; td.Text = content; td.OwnerWindowHandle = this.Handle; TaskDialogResult res = td.Show(); this.resultLbl.Text = "Result = " + res.ToString(); }
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(); }
private static DialogResult Show(Guid id, string title, string instruction, string message, TaskDialogStandardButtons buttons, TaskDialogStandardIcon icon, string details, int progressBarMaxValue, Action <int> tickEventHandler) { TaskDialogProgressBar progressBar = progressBarMaxValue < 0 ? null : new TaskDialogProgressBar(0, progressBarMaxValue, 0) { State = progressBarMaxValue == 0 ? TaskDialogProgressBarState.Marquee : TaskDialogProgressBarState.Normal }; APITaskDialog taskDialog = new APITaskDialog() { Caption = title, InstructionText = instruction, Text = message, Icon = icon, StandardButtons = buttons, Cancelable = true, ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter, DetailsExpanded = false, DetailsCollapsedLabel = "Show Details", DetailsExpandedLabel = "Hide Details", DetailsExpandedText = details, ProgressBar = progressBar, StartupLocation = TaskDialogStartupLocation.CenterOwner, OwnerWindowHandle = NativeMethods.GetActiveWindow() }; Action <object, TaskDialogTickEventArgs> internalTickEventHandler = null; if (tickEventHandler != null) { internalTickEventHandler = (sender, e) => tickEventHandler(e.Ticks); taskDialog.Tick += new EventHandler <TaskDialogTickEventArgs>(internalTickEventHandler); } if (id != Guid.Empty) { lock (_taskDialogs) _taskDialogs[id] = taskDialog; } DialogResult result = ConvertFromTaskDialogResult(taskDialog.Show()); if (tickEventHandler != null) { taskDialog.Tick -= new EventHandler <TaskDialogTickEventArgs>(internalTickEventHandler); } if (id != Guid.Empty) { lock (_taskDialogs) _taskDialogs.Remove(id); } return(result); }
/// <summary> /// Ask a new replays folder to the user and return it. /// </summary> /// <param name="oldPath">The old Path to show in the message box</param> /// <returns>return a string for the new path with the replay</returns> public static bool GetNewReplayFolder( string oldPath, out string newPath ) { // Select a new folder command link var anotherReplayFolderCMDLink = new TaskDialogCommandLink("anotherFolder", "Select another replay folder\nThe folder must have .wargamerpl2 files"); anotherReplayFolderCMDLink.Click += AnotherReplayFolderCMDLink_Click; // Exit Application command link var exitApplicationCMDLink = new TaskDialogCommandLink("exitApplication", "Exit the application"); exitApplicationCMDLink.Click += ( s, d ) => { _buttonPressed = "exitApplication"; var s2 = (TaskDialogCommandLink)s; var taskDialog = (TaskDialog)(s2.HostingDialog); //taskDialog.Close(TaskDialogResult.CustomButtonClicked); }; // Task Dialog settings var td = new TaskDialog(); td.Caption = "Empty Replay Folder"; td.Controls.Add(anotherReplayFolderCMDLink); td.Controls.Add(exitApplicationCMDLink); td.Icon = TaskDialogStandardIcon.Error; td.InstructionText = String.Format("The Replay folder is empty."); td.Text = String.Format("The folder {0} doesn't contains any .wargamerpl2 files.", oldPath); td.Closing += Td_Closing; TaskDialogResult tdResult = td.Show(); if ( tdResult == TaskDialogResult.CustomButtonClicked ) { if( _buttonPressed == "anotherFolder" && !String.IsNullOrEmpty(_newPath)) { newPath = _newPath; return true; } else { newPath = null; return false; } } else { newPath = null; return false; } }
/// <summary> /// Pops up a simple TaskDialog box /// with just a Close button and /// the default standard dialog icon /// </summary> /// <param name="captionText">Text that goes in the window's caption</param> /// <param name="instructionText">Instructional text (Appears next to the error icon)</param> /// <param name="messageText">Smaller message detail text at bottom</param> public virtual void ShowSimple(String captionText, String instructionText, String messageText) { using (APICodePack.TaskDialog simpleTaskDialog = new APICodePack.TaskDialog()) { simpleTaskDialog.Caption = captionText; simpleTaskDialog.InstructionText = instructionText; simpleTaskDialog.Text = messageText; simpleTaskDialog.Icon = this.DefaultTaskIcon; simpleTaskDialog.StandardButtons = APICodePack.TaskDialogStandardButtons.Close; simpleTaskDialog.Opened += new EventHandler(simpleTaskDialog_Opened); simpleTaskDialog.StartupLocation = APICodePack.TaskDialogStartupLocation.CenterScreen; simpleTaskDialog.Show(); } }
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(); }
private void Form1_Shown( object sender, EventArgs e ) { try { SensorList<Sensor> sl = SensorManager.GetAllSensors(); SensorManager.RequestPermission( this.Handle, true, sl ); } catch( SensorPlatformException spe ) { TaskDialog dialog = new TaskDialog( ); dialog.InstructionText = spe.Message; dialog.Text = "This application will now exit."; dialog.StandardButtons = TaskDialogStandardButtons.Close; dialog.Show(); Application.Exit( ); } }
public void Error(Exception e, string TaskName) { // Error dialog TaskDialog tdError = new TaskDialog(); TaskDialogStandardButtons button = TaskDialogStandardButtons.Ok; tdError.StandardButtons = button; tdError.DetailsExpanded = false; tdError.Cancelable = true; tdError.Icon = TaskDialogStandardIcon.Error; tdError.Caption = TaskName; tdError.InstructionText = Properties.Resources.ErrorMsg; tdError.DetailsExpandedText = e.ToString(); tdError.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter; TaskDialogResult res = tdError.Show(); }
private static void Main(string[] commands) { bool pobjIOwnMutex; using (new Mutex(true, "PathDefence", out pobjIOwnMutex)) { if (pobjIOwnMutex || (commands.Length > 0 && commands[0] == "-r")) { //LogFramework.Initialize("PathDefence",Settings.Default.LogServer, Settings.Default.LogAccount,Settings.Default.LogPw,"1.0.0.0",1,"abc"); //LogFramework.AddLog("Starting PathDefence...",false,LogType.StartLog); using (var game = new PathDefenceGame()) { game.Run(); } //LogFramework.FinalizeLogger(); } else { if (TaskDialog.IsPlatformSupported) { var dlg = new TaskDialog { Cancelable = true, Caption = "Fehler", DetailsCollapsedLabel = "Hilfe anzeigen", DetailsExpandedText = "Sollten Sie das Programm soeben beendet haben, so warten Sie ein paar Sekunden und versuchen Sie es erneut.", DetailsExpandedLabel = "Hilfe ausblenden", ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandContent, InstructionText = "Es wird bereits eine Instanz dieses Programms ausgeführt!", Text = "Bitte schließen Sie diese Instanz bevor Sie das Programm erneut öffnen!", StandardButtons = TaskDialogStandardButtons.Close, Icon = TaskDialogStandardIcon.Error }; var killProcess = new TaskDialogCommandLink("killprocess", "Andere Instanz beenden", "Die andere laufende Instanz wird beendet.\nDaten des Spiels könnten möglicherweise verloren gehen."); killProcess.Click += killProcess_Click; dlg.Controls.Add(killProcess); dlg.Show(); } else { MessageBox.Show( "Es wird bereits eine Instanz dieses Programms ausgeführt!\n" + "Bitte schließen Sie diese Instanz bevor Sie das Programm erneut öffnen!\n" + "Sollten Sie das Programm soeben beendet haben, so warten Sie ein paar Sekunden und versuchen Sie es erneut.", "Fehler beim Starten des Programms", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void button1_Click(object sender, EventArgs e) { DirtyMem(); try { var tdError = new TaskDialog { DetailsExpanded = false, Cancelable = false, Icon = TaskDialogStandardIcon.Error, Caption = "This dialog works", InstructionText = "A good news for you - this dialog works!", Text = "It might be possible to continue by pressing Ignore button. This error has been reported to Credit Master Support.", DetailsExpandedLabel = "Hide details", DetailsCollapsedLabel = "Show details", ExpansionMode = TaskDialogExpandedDetailsLocation.Hide }; tdError.DetailsExpandedText = "Exception Text"; tdError.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter; var ignoreButton = new TaskDialogCommandLink("ignore", "Ignore\nDo not close the application."); ignoreButton.Click += (s, e1) => tdError.Close(TaskDialogResult.Retry); tdError.Controls.Add(ignoreButton); var closeButton = new TaskDialogCommandLink("close", "Close\nClose the application and exit."); closeButton.Click += (s, e1) => tdError.Close(TaskDialogResult.Cancel); tdError.Controls.Add(closeButton); var copyButton = new TaskDialogCommandLink("copy", "Copy Details to Clipboard\nCopy error details to clipboard for further investigation."); copyButton.Click += (s, e1) => MessageBox.Show(""); tdError.Controls.Add(copyButton); tdError.OwnerWindowHandle = Handle; Text = tdError.Show().ToString(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void CheckUpdate() { System.Net.WebClient client = new System.Net.WebClient(); string xml = client.DownloadString(new Uri(Define.NewVersionUrl)); string v = ""; var a = from b in XElement.Parse(xml).Elements() select new { Version = b.Element("McMDK").Value }; foreach(var item in a) { v = item.Version; } int r = int.Parse(v.Substring(v.LastIndexOf(".") + 1)); if(Define.Release < r) { //New version var taskDialog = new TaskDialog(); taskDialog.Caption = "更新"; taskDialog.InstructionText = "McMDKの最新版がリリースされています!"; taskDialog.Text = "McMDKの最新版\"" + v + "\"がリリースされています。\n更新しますか?"; taskDialog.Icon = TaskDialogStandardIcon.Information; taskDialog.StandardButtons = TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No; taskDialog.Opened += (sender, e) => { var dialog = (TaskDialog)sender; dialog.Icon = dialog.Icon; }; if(taskDialog.Show() == TaskDialogResult.Yes) { //Update } } this.DownloadResources(); }
public static void HandleException(Window window, DirectoryNotFoundException ex) { try { var message = string.Format(Properties.Resources.MessageDirectoryNotFoundException); var dialog = new TaskDialog { InstructionText = message, Icon = TaskDialogStandardIcon.Error, StandardButtons = TaskDialogStandardButtons.Ok, DetailsExpandedText = ex.Message, Caption = App.Current.ApplicationTitle }; if (window != null) { dialog.OwnerWindowHandle = new WindowInteropHelper(window).Handle; } dialog.Show(); } catch (PlatformNotSupportedException) { MessageBox.Show(ex.Message); } }
void Form1_FormClosing(object sender, FormClosingEventArgs e) { // If the user is closing the app, ask them if they wish to close the current tab // or all the tabs if (tabControl1 != null && tabControl1.TabPages.Count > 0) { if (tabControl1.TabPages.Count <= 1) { // close the tab and the application cancelFormClosing = false; } else { // More than 1 tab.... show the user the TaskDialog TaskDialog tdClose = new TaskDialog(); tdClose.Caption = "Tabbed Thumbnail demo (Winforms)"; tdClose.InstructionText = "Do you want to close all the tabs or the current tab?"; tdClose.Cancelable = true; tdClose.OwnerWindowHandle = this.Handle; TaskDialogButton closeAllTabsButton = new TaskDialogButton("closeAllTabsButton", "Close all tabs"); closeAllTabsButton.Default = true; closeAllTabsButton.Click += new EventHandler(closeAllTabsButton_Click); tdClose.Controls.Add(closeAllTabsButton); TaskDialogButton closeCurrentTabButton = new TaskDialogButton("closeCurrentTabButton", "Close current tab"); closeCurrentTabButton.Click += new EventHandler(closeCurrentTabButton_Click); tdClose.Controls.Add(closeCurrentTabButton); tdClose.Show(); } } e.Cancel = cancelFormClosing; }
private void _ButtonRemove_Click(object sender, EventArgs e) { TaskDialog dialog = new TaskDialog(); dialog.Caption = Resources.WindowTitle; dialog.InstructionText = Locale.Current.Labels.RemoveConfirmation; dialog.Cancelable = true; dialog.OwnerWindowHandle = base.Handle; TaskDialogButton buttonYes = new TaskDialogButton("yesButton", Locale.Current.Labels.Yes); buttonYes.Default = true; buttonYes.Click += _TaskButtonYes_Click; TaskDialogButton buttonNo = new TaskDialogButton("noButton", Locale.Current.Labels.No); buttonNo.Click += _TaskButtonNo_Click; dialog.Controls.Add(buttonYes); dialog.Controls.Add(buttonNo); dialog.Show(); }
/// <summary> /// Updates the thumbnail preview for currently selected item and current view /// </summary> private void UpdatePreview() { if (currentItem != null) { // Set the appropiate FormatOption if (currentMode == Mode.ThumbnailOrIcon) currentItem.Thumbnail.FormatOption = ShellThumbnailFormatOptions.Default; else if (currentMode == Mode.ThumbnailOnly) currentItem.Thumbnail.FormatOption = ShellThumbnailFormatOptions.ThumbnailOnly; else currentItem.Thumbnail.FormatOption = ShellThumbnailFormatOptions.IconOnly; // Get the correct bitmap try { if (currentView == Views.Small) pictureBox1.Image = currentItem.Thumbnail.SmallBitmap; else if (currentView == Views.Medium) pictureBox1.Image = currentItem.Thumbnail.MediumBitmap; else if (currentView == Views.Large) pictureBox1.Image = currentItem.Thumbnail.LargeBitmap; else if (currentView == Views.ExtraLarge) pictureBox1.Image = currentItem.Thumbnail.ExtraLargeBitmap; } catch (NotSupportedException) { TaskDialog tdThumbnailHandlerError = new TaskDialog(); tdThumbnailHandlerError.Caption = "Error getting the thumbnail"; tdThumbnailHandlerError.InstructionText = "The selected file does not have a valid thumbnail or thumbnail handler."; tdThumbnailHandlerError.Icon = TaskDialogStandardIcon.Error; tdThumbnailHandlerError.StandardButtons = TaskDialogStandardButtons.Ok; tdThumbnailHandlerError.Show(); } catch (InvalidOperationException) { if (currentMode == Mode.ThumbnailOnly) { // If we get an InvalidOperationException and our mode is Mode.ThumbnailOnly, // then we have a ShellItem that doesn't have a thumbnail (icon only). // Let the user know this and if they want, change the mode. if (showErrorTaskDialog) { TaskDialogResult tdr = td.Show(); showErrorTaskDialog = !td.FooterCheckBoxChecked.Value; } // If the user picked the first option, change the mode... if (onErrorChangeMode) { // Change the mode to ThumbnailOrIcon comboBox1.SelectedIndex = 0; UpdatePreview(); } else // else, ignore and display nothing. pictureBox1.Image = null; } else pictureBox1.Image = null; } } else pictureBox1.Image = null; }
private static bool LocateMissingGit() { int dialogResult = -1; using var dialog1 = new Microsoft.WindowsAPICodePack.Dialogs.TaskDialog { InstructionText = ResourceManager.TranslatedStrings.GitExecutableNotFound, Icon = TaskDialogStandardIcon.Error, StandardButtons = TaskDialogStandardButtons.Cancel, Cancelable = true, }; var btnFindGitExecutable = new TaskDialogCommandLink("FindGitExecutable", null, ResourceManager.TranslatedStrings.FindGitExecutable); btnFindGitExecutable.Click += (s, e) => { dialogResult = 0; dialog1.Close(); }; var btnInstallGitInstructions = new TaskDialogCommandLink("InstallGitInstructions", null, ResourceManager.TranslatedStrings.InstallGitInstructions); btnInstallGitInstructions.Click += (s, e) => { dialogResult = 1; dialog1.Close(); }; dialog1.Controls.Add(btnFindGitExecutable); dialog1.Controls.Add(btnInstallGitInstructions); dialog1.Show(); switch (dialogResult) { case 0: { using var dialog = new System.Windows.Forms.OpenFileDialog { Filter = @"git.exe|git.exe|git.cmd|git.cmd", }; if (dialog.ShowDialog(null) == DialogResult.OK) { AppSettings.GitCommandValue = dialog.FileName; } if (CheckSettingsLogic.SolveGitCommand()) { return(true); } return(false); } case 1: { OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/wiki/Application-Dependencies#git"); return(false); } default: { return(false); } } }
public static void Report(Exception exception, bool isTerminating) { if (isTerminating) { // TODO: this is not very efficient SerializableException serializableException = new(exception); string xml = serializableException.ToXmlString(); string encoded = Base64Encode(xml); Process.Start("BugReporter.exe", encoded); return; } bool isUserExternalOperation = exception is UserExternalOperationException; bool isExternalOperation = exception is ExternalOperationException; StringBuilder text = new(); string rootError = Append(text, exception); using var taskDialog = new Microsoft.WindowsAPICodePack.Dialogs.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); } }
private void CheckFileRegistration() { bool registered = false; try { RegistryKey openWithKey = Registry.ClassesRoot.OpenSubKey(Path.Combine(".txt", "OpenWithProgIds")); string value = openWithKey.GetValue(progId, null) as string; if (value == null) registered = false; else registered = true; } finally { // Let the user know if (!registered) { td = new TaskDialog(); td.Text = "File type is not registered"; td.InstructionText = "This demo application needs to register .txt files as associated files to properly execute the Taskbar related features."; td.Icon = TaskDialogStandardIcon.Information; td.Cancelable = true; TaskDialogCommandLink button1 = new TaskDialogCommandLink("registerButton", "Register file type for this application", "Register .txt files with this application to run this demo application correctly."); button1.Click += new EventHandler(button1_Click); // Show UAC shield as this task requires elevation button1.UseElevationIcon = true; td.Controls.Add(button1); TaskDialogResult tdr = td.Show(); } } }
void DoStartup() { if (Properties.Settings.Default.checkForUpdates) { #region Update Shit Party_Buffalo.Update u = new Update(); #if TRACE Party_Buffalo.Update.UpdateInfo ud = u.CheckForUpdates(new Uri("http://clkxu5.com/drivexplore/coolapplicationstuff.xml")); #endif #if DEBUG Party_Buffalo.Update.UpdateInfo ud = new Update.UpdateInfo(); if (UpdateDebug) { if (!UpdateDebugForce) { ud = u.CheckForUpdates(new Uri("http://clkxu5.com/drivexplore/dev/coolapplicationstuff.xml")); } else { ud.Update = true; ud.UpdateText = "This`Is`A`Test"; ud.UpdateVersion = "9000"; } } #endif if (ud.Update) { if (!Aero) { Forms.UpdateForm uf = new Party_Buffalo.Forms.UpdateForm(ud); uf.ShowDialog(); } else { TaskDialog td = new TaskDialog(); td.Caption = "Update Available"; td.InstructionText = "Version " + ud.UpdateVersion + " is Available"; td.Text = "An update is available for Party Buffalo"; td.DetailsCollapsedLabel = "Change Log"; td.DetailsExpandedLabel = "Change Log"; td.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter; string[] Split = ud.UpdateText.Split('`'); string UpdateText = ""; for (int i = 0; i < Split.Length; i++) { if (i != 0) { UpdateText += "\r\n"; } if (Split[i] == "") { continue; } UpdateText += "-" + Split[i]; } td.DetailsExpandedText = UpdateText; TaskDialogCommandLink Download = new TaskDialogCommandLink("Download", "Download Party Buffalo version " + ud.UpdateVersion, ""); Download.Click += (o, f) => { Forms.UpdateDownloadForm udf = new Party_Buffalo.Forms.UpdateDownloadForm(ud); udf.ShowDialog(); }; TaskDialogCommandLink DontDownload = new TaskDialogCommandLink("DontDownload", "Let me go about my business and I'll download this stuff later...", ""); DontDownload.Click += (o, f) => { td.Close(); }; td.Controls.Add(Download); td.Controls.Add(DontDownload); td.Show(); } } if (ud.QuickMessage != null && ud.QuickMessage != "") { quickMessage.Text = ud.QuickMessage; } else { quickMessage.Text = "Could not load quick message"; } #endregion } else { m_DisableUpdates.Checked = true; } if (!Properties.Settings.Default.Upgraded) { Properties.Settings.Default.Upgrade(); Properties.Settings.Default.Upgraded = true; Properties.Settings.Default.Save(); } if (Properties.Settings.Default.width > 50 && Properties.Settings.Default.height > 50) { this.Height = Properties.Settings.Default.height; this.Width = Properties.Settings.Default.width; } quickAddMode.Checked = Properties.Settings.Default.quickAddMode; SaveIcons.Checked = Properties.Settings.Default.SaveIcons; m_loadEntireDrive.Checked = Properties.Settings.Default.loadEntireDrive; m_LoadSTFS.Checked = Properties.Settings.Default.loadSTFS; m_retrieveGameNames.Checked = Properties.Settings.Default.loadTIDNames; cacheContentIcons.Checked = Properties.Settings.Default.cacheContentIcons; if (Properties.Settings.Default.hideToolBar) { m_hideToolBar.PerformClick(); } if (Properties.Settings.Default.hideAddressBar) { m_hideAddressBar.PerformClick(); } if (Properties.Settings.Default.hideStatusBar) { m_hideStatusBar.PerformClick(); } switch (Properties.Settings.Default.view) { case View.Details: c_Details.Checked = true; listView1.View = View.Details; break; case View.LargeIcon: c_largeIcon.Checked = true; listView1.View = View.LargeIcon; break; case View.List: c_List.Checked = true; listView1.View = View.List; break; case View.SmallIcon: c_SmallIcon.Checked = true; listView1.View = View.SmallIcon; break; case View.Tile: c_Tile.Checked = true; listView1.View = View.Tile; break; } if (Properties.Settings.Default.recentFiles != null) { List<string> Remove = new List<string>(); foreach (string s in Properties.Settings.Default.recentFiles) { if (System.IO.File.Exists(s)) { MenuItem i = new MenuItem(s); i.Click += new EventHandler(RecentFileHandler); m_Open.MenuItems.Add(i); } else { Remove.Add(s); } } for (int i = 0; i < Remove.Count; ) { Properties.Settings.Default.recentFiles.Remove(Remove[i]); Remove.RemoveAt(i); } } List<MenuItem> mil = new List<MenuItem>(); List<MenuItem> mit = new List<MenuItem>(); // Add the "new known folder" (cached) items for (int i = 0; i < CLKsFATXLib.VariousFunctions.Known.Length; i++) { string ss = CLKsFATXLib.VariousFunctions.Known[i]; string s = CLKsFATXLib.VariousFunctions.KnownEquivilent[i]; // Create our listview menu item... MenuItem mu = new MenuItem(s + " (" + ss + ")"); // Set its tag mu.Tag = ss; // Set its event handler mu.Click += new EventHandler(mu_Click); // Create our treeview menu item... MenuItem mut = new MenuItem(s + " (" + ss + ")"); // Set its tag mut.Tag = ss; // Create its event handler mut.Click += new EventHandler(mut_Click); // Add it to the cached menu items mil.Add(mu); mit.Add(mut); //lCached.MenuItems.Add(mu); //tCached.MenuItems.Add(mut); } // Cast those as arrays MenuItem[] ArrayL = mil.ToArray(); Array.Sort(ArrayL, new Extensions.MenuItemComparer()); MenuItem[] ArrayT = mit.ToArray(); Array.Sort(ArrayT, new Extensions.MenuItemComparer()); // Add ranges lStatic.MenuItems.AddRange(ArrayL); tStatic.MenuItems.AddRange(ArrayT); // For treeview icon size switch (Properties.Settings.Default.treeViewIconWidthHeight) { case 16: size16.Checked = true; break; case 24: size24.Checked = true; break; case 32: size32.Checked = true; break; case 64: size64.Checked = true; break; } treeView1.ImageList.ImageSize = new Size(Properties.Settings.Default.treeViewIconWidthHeight, Properties.Settings.Default.treeViewIconWidthHeight); }
private void m_CheckForUpdates_Click(object sender, EventArgs e) { #region Update Shit Party_Buffalo.Update u = new Update(); #if TRACE Party_Buffalo.Update.UpdateInfo ud = u.CheckForUpdates(new Uri("http://clkxu5.com/drivexplore/coolapplicationstuff.xml")); #endif #if DEBUG Party_Buffalo.Update.UpdateInfo ud = new Update.UpdateInfo(); if (UpdateDebug) { if (!UpdateDebugForce) { ud = u.CheckForUpdates(new Uri("http://clkxu5.com/drivexplore/dev/coolapplicationstuff.xml")); } else { ud.Update = true; ud.UpdateText = "This`Is`A`Test"; ud.UpdateVersion = "9000"; } } #endif if (ud.Update) { if (!Aero) { Forms.UpdateForm uf = new Party_Buffalo.Forms.UpdateForm(ud); uf.ShowDialog(); } else { TaskDialog td = new TaskDialog(); td.Caption = "Update Available"; td.InstructionText = "Version " + ud.UpdateVersion + " is Available"; td.Text = "An update is available for Party Buffalo"; td.DetailsCollapsedLabel = "Change Log"; td.DetailsExpandedLabel = "Change Log"; td.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter; string[] Split = ud.UpdateText.Split('`'); string UpdateText = ""; for (int i = 0; i < Split.Length; i++) { if (i != 0) { UpdateText += "\r\n"; } if (Split[i] == "") { continue; } UpdateText += "-" + Split[i]; } td.DetailsExpandedText = UpdateText; TaskDialogCommandLink Download = new TaskDialogCommandLink("Download", "Download Party Buffalo version " + ud.UpdateVersion, ""); Download.Click += (o, f) => { Forms.UpdateDownloadForm udf = new Party_Buffalo.Forms.UpdateDownloadForm(ud); udf.ShowDialog(); }; TaskDialogCommandLink DontDownload = new TaskDialogCommandLink("DontDownload", "Let me go about my business and I'll download this stuff later...", ""); DontDownload.Click += (o, f) => { td.Close(); }; td.Controls.Add(Download); td.Controls.Add(DontDownload); td.Show(); } } else { MessageBox.Show("Party Buffalo is up to date!"); } if (ud.QuickMessage != null && ud.QuickMessage != "") { quickMessage.Text = ud.QuickMessage; } else { quickMessage.Text = "Could not load quick message"; } #endregion }
public TaskDialogResult Show() { return(Dialog.Show()); }
//private void CreateArchive_Show(OutArchiveFormat format) //{ // var selectedItems = new List<string>(); // foreach(ShellObject item in Explorer.SelectedItems) // { // if (Directory.Exists(item.ParsingName)) // { // DirectoryInfo di = new DirectoryInfo(item.ParsingName); // FileInfo[] Files = di.GetFiles("*", SearchOption.AllDirectories); // foreach (FileInfo fi in Files) // { // selectedItems.Add(fi.FullName); // } // } // else // { // selectedItems.Add(item.ParsingName); // } // } // if (selectedItems.Count > 0) // { // try // { // var CAI = new CreateArchive(selectedItems, // true, // Path.GetDirectoryName(selectedItems[0]), // format); // CAI.Show(this.GetWin32Window()); // } // catch (Exception exception) // { // var dialog = new TaskDialog(); // dialog.StandardButtons = TaskDialogStandardButtons.Ok; // dialog.Text = exception.Message; // dialog.Show(); // } // } // } private void ExtractFiles() { var selectedItems = new List<string>(); foreach (ShellObject item in Explorer.SelectedItems) { selectedItems.Add(item.ParsingName); } try { var CAI = new CreateArchive(selectedItems, false, Explorer.SelectedItems[0].ParsingName); CAI.Show(this.GetWin32Window()); } catch (Exception exception) { var dialog = new TaskDialog(); dialog.StandardButtons = TaskDialogStandardButtons.Ok; dialog.Text = exception.Message; dialog.Show(); } }
private void Button_Click_3(object sender, RoutedEventArgs e) { TaskDialog td = new TaskDialog(); td.Caption = "Reset Library"; td.Icon = TaskDialogStandardIcon.Warning; td.Text = "Click \"OK\" to reset currently selected library properties"; td.InstructionText = "Reset Library Properties?"; td.FooterIcon = TaskDialogStandardIcon.Information; //td.FooterText = "This will reset all the properties to default properties for library type"; td.DetailsCollapsedLabel = "More info"; td.DetailsExpandedLabel = "More Info"; td.DetailsExpandedText = "This will reset all the properties to default properties for library type"; td.DetailsExpanded = false; td.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter; td.StandardButtons = TaskDialogStandardButtons.Ok | TaskDialogStandardButtons.Cancel; td.OwnerWindowHandle = this.Handle; if (td.Show() == TaskDialogResult.Ok) { if (Explorer.SelectedItems[0].GetDisplayName(DisplayNameType.Default).ToLowerInvariant() != "documents" && Explorer.SelectedItems[0].GetDisplayName(DisplayNameType.Default).ToLowerInvariant() != "music" && Explorer.SelectedItems[0].GetDisplayName(DisplayNameType.Default).ToLowerInvariant() != "videos" && Explorer.SelectedItems[0].GetDisplayName(DisplayNameType.Default).ToLowerInvariant() != "pictures") { ShellLibrary lib = ShellLibrary.Load(Explorer.SelectedItems[0].GetDisplayName(DisplayNameType.Default), false); lib.IsPinnedToNavigationPane = true; lib.LibraryType = LibraryFolderType.Generic; lib.IconResourceId = new IconReference(@"C:\Windows\System32\imageres.dll", 187); lib.Close(); } } }
/// <summary> /// Check for file registration if running Windows 7 for Taskbar support /// </summary> public static void CheckFileRegistration() { bool registered = false; try { RegistryKey appCommand = Registry.ClassesRoot.OpenSubKey(Path.Combine(Application.ProductName, @"shell\Open\Command")); if (appCommand != null) { string value = appCommand.GetValue("", null) as string; if (string.IsNullOrEmpty(value)) // !value.Contains(Application.ExecutablePath) is quite annoying registered = false; else registered = true; } } catch (Exception ex) { DebugHelper.WriteException(ex); } finally { // Let the user know if (!registered) { td = new TaskDialog(); td.Caption = GetProductName(); td.Text = "File types are not registered"; td.InstructionText = "ZScreen needs to register image files as associated files to properly execute the Taskbar related features."; td.Icon = TaskDialogStandardIcon.Information; td.Cancelable = true; TaskDialogCommandLink tdclRegister = new TaskDialogCommandLink("registerButton", "Register file type for this application", "Register image/text files with this application to run ZScreen correctly."); tdclRegister.Click += new EventHandler(btnRegisterWin7_Click); // Show UAC shield as this task requires elevation tdclRegister.UseElevationIcon = true; td.Controls.Add(tdclRegister); TaskDialogResult tdr = td.Show(); } } }