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(); }
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); }
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; } }
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(); }
/// <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; } }
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 static void ShowResponseDialog(IWin32Window owner, string error) { TaskDialog td = new TaskDialog() { OwnerWindowHandle = owner == null ? IntPtr.Zero : owner.Handle, Caption = "Exception Explorer", Cancelable = true }; td.Opened += (sender, args) => td.Icon = td.Icon; VersionCheckResponse response = Options.Current.Update.LastResponse.Value; if (AppVersion.UpgradeRequired) { response = VersionCheckResponse.NewVersion; } switch (response) { case VersionCheckResponse.Failed: td.Icon = TaskDialogStandardIcon.Warning; td.InstructionText = "Could not find the latest version."; td.DetailsExpandedText = error; break; case VersionCheckResponse.OK: td.Icon = TaskDialogStandardIcon.Information; td.InstructionText = "You are already running the latest version."; break; case VersionCheckResponse.NewVersion: td.Icon = TaskDialogStandardIcon.Information; td.InstructionText = "A new version is available."; td.DetailsExpandedText = string.Format("Version {0} is available.\nYou are running {1}.", AppVersion.Latest, AppVersion.Current); TaskDialogCommandLink download = new TaskDialogCommandLink("name", "Download now"); download.Click += (sender, args) => { Web.OpenSite(SiteLink.NewVersion); td.Close(); }; TaskDialogCommandLink later = new TaskDialogCommandLink("name", "Remind me later"); later.Click += (sender, args) => { td.Close(); }; //td.FooterCheckBoxText = "Don't remind me of this version"; td.Controls.Add(download); td.Controls.Add(later); break; } td.Show(); }
static void SettingsThread(object zz) { if (!SettingsShowing) { SettingsShowing = true; SettingsV3 v3 = null; try { v3 = new SettingsV3(); } catch (Exception z) { TaskDialog d = new TaskDialog(); d.InstructionText = "Unable to load settings"; d.Text = "The configuration file might be corrupt, do you want to reset it?"; TaskDialogCommandLink l1 = new TaskDialogCommandLink("l1", "Reset the configuration file", "This will delete your current settings, but then you'll be able to open the settings again"); TaskDialogCommandLink l2 = new TaskDialogCommandLink("l2", "Don't reset the configuration file", "Settings screen won't load anymore, but you'll keep your settings"); l1.Click += delegate(object a, EventArgs b) { File.Delete(Core.Settings.path); File.Copy(Path.GetDirectoryName(Application.ExecutablePath) + "\\example.ini", Core.Settings.path); Core_Click(null, null); }; l2.Click += delegate(object a, EventArgs b) { d.Close(); }; d.Controls.Add(l1); d.Controls.Add(l2); d.Icon = TaskDialogStandardIcon.Error; d.Caption = d.InstructionText; d.DetailsCollapsedLabel = "Show error"; d.DetailsExpandedLabel = "Hide error"; d.DetailsExpandedText = z.ToString(); d.Show(); } finally { try { if (v3 != null) { v3.ShowDialog(); v3.Dispose(); GC.Collect(); } } catch (Exception z) { FatalError(z); } } SettingsShowing = false; } }
static void Main(string[] args) { string gameName; if (args.Length > 0) gameName = args[0]; else gameName = "t6zm"; Process[] games = Process.GetProcessesByName(gameName); Process gameProcess = null; if (games.Length > 1) { TaskDialog diag = new TaskDialog(); diag.Caption = "Woops!"; diag.InstructionText = "I found more than 2 running games!"; diag.Icon = TaskDialogStandardIcon.Warning; diag.Text = "jZm has found more than just one game.\r\nWhat would you like to do?"; foreach (Process game in games) { TaskDialogCommandLink link = new TaskDialogCommandLink(game.ProcessName, game.ProcessName, "PID " + game.Id); link.Click += delegate(object sender, EventArgs argz) { gameProcess = game; diag.Close(); }; diag.Controls.Add(link); } TaskDialogCommandLink linkz = new TaskDialogCommandLink("r", "Restart", "Restart jZm"); linkz.ShowElevationIcon = true; linkz.Click += delegate(object sender, EventArgs argz) { diag.Close(); Application.Restart(); //mare sure we're dead Environment.Exit(-1); }; diag.Controls.Add(linkz); linkz = new TaskDialogCommandLink("r", "Exit", "Exit jZm"); linkz.ShowElevationIcon = true; linkz.Click += delegate(object sender, EventArgs argz) { diag.Close(); Environment.Exit(-1); }; diag.Controls.Add(linkz); diag.Show(); } else if (games.Length == 0) { TaskDialog diag = new TaskDialog(); diag.Caption = "Woops!"; diag.InstructionText = "I was unable to find any games"; diag.Icon = TaskDialogStandardIcon.Error; diag.Text = "jZm was unable to find any processes matching the name '" + gameName + "'.\r\nWhat would you like to do?"; TaskDialogCommandLink linkz = new TaskDialogCommandLink("r", "Restart jZm", "Restart and look for the game again"); linkz.ShowElevationIcon = true; linkz.Click += delegate(object sender, EventArgs argz) { diag.Close(); Application.Restart(); //mare sure we're dead Environment.Exit(-1); }; 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(); } else gameProcess = games[0]; API = new ZombieAPI.ZombieAPI(); MainForm = new Main(); MainForm.Show(); try { API.Bootstrap(gameProcess); } catch (Exception z) { Crash(z); } Application.Run(); }
public static void Init() { Console.WindowWidth = Console.LargestWindowWidth - 25; Console.WindowHeight = Console.LargestWindowHeight - 25; Console.Title = "SkypeStats - Debug Console"; Out.WritePlain("SkypeStats by JariZ"); Out.WriteBlank(); AddStats(); Out.WriteLine("Searching for skype databases..."); string[] Accounts = GetAccounts(); TaskDialog chooser = new TaskDialog(); chooser.InstructionText = "The following accounts were found on this computer"; chooser.Text = "SkypeStats has found several accounts, which one do you want to analyse?"; chooser.FooterCheckBoxText = "Load entire DB into memory and max out cache"; string Account = ""; foreach (string account in Accounts) { TaskDialogCommandLink link = new TaskDialogCommandLink(Path.GetFileName(account), Path.GetFileName(account)); link.Click += delegate(object send, EventArgs args) { Account = ((TaskDialogCommandLink)send).Name; chooser.Close(); }; chooser.Controls.Add(link); } chooser.FooterText = "Loading everything into memory might be faster but requires a lot of RAM, only choose this if you know what you're doing"; chooser.FooterIcon = TaskDialogStandardIcon.Information; chooser.Show(); MaxedOutMode = chooser.FooterCheckBoxChecked; Core.Account = Account; DatabasePath = SkypeAppData + "\\" + Account + "\\main.db"; if (!File.Exists(DatabasePath)) Failure("Database file not found, restart SkypeStats"); Out.WriteDebug("DB path is " + DatabasePath + " and exists"); Out.WriteDebug("Connecting to DB..."); try { Database = new DB(DatabasePath); } catch(Exception z) { Out.WriteDebug("UNABLE TO CONNECT TO DB:"); Out.WriteError(z.ToString(), z); Failure("Unable to connect to database file: " + z.Message); } Out.WriteLine("Successfully connected to DB!"); ProgressDialog progress = null; if (ProgDiag) { Out.WriteDebug("Init progressdialog..."); progress = new ProgressDialog(IntPtr.Zero); progress.Title = "SkypeStats"; progress.Line1 = "Initializing..."; progress.Line2 = " "; progress.Line3 = " "; progress.ShowDialog(); //wait for progdiag to show up Thread.Sleep(1000); } else { Thread splash = new Thread(SplashThread); splash.SetApartmentState(ApartmentState.STA); splash.Start(); while (Splash == null) { } } Out.WriteDebug("Counting messages...."); if (ProgDiag) { progress.Line1 = "Counting messages..."; progress.Value = 1337; } else { Splash.Status = "Counting messages..."; Splash.Value = 1337; } MessageCount = Convert.ToInt32(Database.ExecuteScalar("SELECT COUNT(*) FROM Messages")); Out.WriteLine(MessageCount + " messages found!"); Out.WriteDebug("Counting conversations...."); if (ProgDiag) { progress.Line1 = "Counting conversations..."; progress.Value = 1337; } else { Splash.Status = "Counting conversations..."; Splash.Value = 1337; } ConvoCount = Convert.ToInt32(Database.ExecuteScalar("SELECT COUNT(*) FROM Conversations")); Out.WriteLine(ConvoCount + " conversations found!"); Out.WriteDebug("Counting contacts...."); if (ProgDiag) { progress.Line1 = "Counting contacts..."; progress.Value = 1337; } else { Splash.Status = "Counting contacts..."; Splash.Value = 1337; } ContactCount = Convert.ToInt32(Database.ExecuteScalar("SELECT COUNT(*) FROM Contacts")); Out.WriteLine(ContactCount + " contacts found!"); AnalysisStart = DateTime.Now; Out.WriteLine("Analysis started @ " + AnalysisStart.ToLongTimeString()); Out.WriteLine("Analysing contacts..."); if (ProgDiag) { progress.Line1 = "Analysing contacts..."; progress.Maximum = Convert.ToUInt32(ContactCount); progress.Value = 0; } else { Splash.Status = "Analysing contacts..."; Splash.Maximum = ContactCount; Splash.Value = 0; } int limit = 0; int step = 1000; if (MaxedOutMode == true) step = int.MaxValue; string columns = Columns(ColumnType.Contact); Out.WriteDebug("Using " + columns + " columns."); while (limit < ContactCount) { string query = string.Format("SELECT {0} FROM Contacts LIMIT {1},{2}", columns, limit, limit + step); DataTable dt = Database.GetDataTable(query); foreach (DataRow row in dt.Rows) { foreach (Stat stat in Stats) { stat.RunContactStep(row); } } limit += step; if (ProgDiag) progress.Value += Convert.ToUInt32(step); else Splash.AddValue(step); } Out.WriteLine("Analysing conversations..."); if (ProgDiag) { progress.Line1 = "Analysing conversations..."; progress.Maximum = Convert.ToUInt32(ConvoCount); progress.Value = 0; } else { Splash.Status = "Analysing conversations..."; Splash.Maximum = ConvoCount; Splash.Value = 0; } limit = 0; step = 1000; if (MaxedOutMode == true) step = int.MaxValue; columns = Columns(ColumnType.Convo); Out.WriteDebug("Using " + columns + " columns."); while (limit < ConvoCount) { string query = string.Format("SELECT {0} FROM Conversations WHERE type = 1 LIMIT {1},{2}", columns, limit, limit + step); DataTable dt = Database.GetDataTable(query); foreach (DataRow row in dt.Rows) { foreach (Stat stat in Stats) { stat.RunConversationStep(row); } } limit += step; if (ProgDiag) progress.Value += Convert.ToUInt32(step); else Splash.AddValue(step); } Out.WriteLine("Analysing messages..."); if (ProgDiag) { progress.Line1 = "Analysing messages..."; progress.Maximum = Convert.ToUInt32(MessageCount); progress.Value = 0; } else { Splash.Status = "Analysing messages..."; Splash.Maximum = MessageCount; Splash.Value = 0; } limit = 0; step = 10000; if (MaxedOutMode == true) step = int.MaxValue; columns = Columns(ColumnType.Message); Out.WriteDebug("Using " + columns + " columns."); while (limit < MessageCount) { string query = string.Format("SELECT {0} FROM Messages LIMIT {1},{2}", columns, limit, limit + step); DataTable dt = Database.GetDataTable(query); foreach (DataRow row in dt.Rows) { foreach (Stat stat in Stats) { stat.RunMessageStep(row); } } limit += step; if (ProgDiag) progress.Value += Convert.ToUInt32(step); else Splash.AddValue(step); } AnalysisFinish = DateTime.Now; DateTime difference = new DateTime(AnalysisFinish.Ticks - AnalysisStart.Ticks); Out.WriteLine(string.Format("Analysis finished in {0}s {1}ms", difference.Second, difference.Millisecond)); if (ProgDiag) progress.CloseDialog(); else Splash.Kill(); System.Windows.Forms.Application.Run(new SkypeStats()); }
private static void CreateTaskDialogDemo() { TaskDialog taskDialogMain = new TaskDialog(); taskDialogMain.Caption = "TaskDialog Samples"; taskDialogMain.InstructionText = "Pick a sample to try:"; taskDialogMain.FooterText = "Demo application as part of <a href=\"http://code.msdn.microsoft.com/WindowsAPICodePack\">Windows API Code Pack for .NET Framework</a>"; taskDialogMain.Cancelable = true; // Enable the hyperlinks taskDialogMain.HyperlinksEnabled = true; taskDialogMain.HyperlinkClick += new EventHandler<TaskDialogHyperlinkClickedEventArgs>(taskDialogMain_HyperlinkClick); // Add a close button so user can close our dialog taskDialogMain.StandardButtons = TaskDialogStandardButtons.Close; #region Creating and adding command link buttons TaskDialogCommandLink buttonTestHarness = new TaskDialogCommandLink("test_harness", "TaskDialog Test Harness"); buttonTestHarness.Click += new EventHandler(buttonTestHarness_Click); TaskDialogCommandLink buttonCommon = new TaskDialogCommandLink("common_buttons", "Common Buttons Sample"); buttonCommon.Click += new EventHandler(buttonCommon_Click); TaskDialogCommandLink buttonElevation = new TaskDialogCommandLink("elevation", "Elevation Required Sample"); buttonElevation.Click += new EventHandler(buttonElevation_Click); buttonElevation.UseElevationIcon = true; TaskDialogCommandLink buttonError = new TaskDialogCommandLink("error", "Error Sample"); buttonError.Click += new EventHandler(buttonError_Click); TaskDialogCommandLink buttonIcons = new TaskDialogCommandLink("icons", "Icons Sample"); buttonIcons.Click += new EventHandler(buttonIcons_Click); TaskDialogCommandLink buttonProgress = new TaskDialogCommandLink("progress", "Progress Sample"); buttonProgress.Click += new EventHandler(buttonProgress_Click); TaskDialogCommandLink buttonProgressEffects = new TaskDialogCommandLink("progress_effects", "Progress Effects Sample"); buttonProgressEffects.Click += new EventHandler(buttonProgressEffects_Click); TaskDialogCommandLink buttonTimer = new TaskDialogCommandLink("timer", "Timer Sample"); buttonTimer.Click += new EventHandler(buttonTimer_Click); TaskDialogCommandLink buttonCustomButtons = new TaskDialogCommandLink("customButtons", "Custom Buttons Sample"); buttonCustomButtons.Click += new EventHandler(buttonCustomButtons_Click); TaskDialogCommandLink buttonEnableDisable = new TaskDialogCommandLink("enableDisable", "Enable/Disable sample"); buttonEnableDisable.Click += new EventHandler(buttonEnableDisable_Click); taskDialogMain.Controls.Add(buttonTestHarness); taskDialogMain.Controls.Add(buttonCommon); taskDialogMain.Controls.Add(buttonCustomButtons); taskDialogMain.Controls.Add(buttonEnableDisable); taskDialogMain.Controls.Add(buttonElevation); taskDialogMain.Controls.Add(buttonError); taskDialogMain.Controls.Add(buttonIcons); taskDialogMain.Controls.Add(buttonProgress); taskDialogMain.Controls.Add(buttonProgressEffects); taskDialogMain.Controls.Add(buttonTimer); #endregion // Show the taskdialog taskDialogMain.Show(); }
private static void buttonError_Click(object sender, EventArgs e) { // Error dialog tdError = new TaskDialog(); tdError.DetailsExpanded = false; tdError.Cancelable = true; tdError.Icon = TaskDialogStandardIcon.Error; tdError.Caption = "Error Sample 1"; tdError.InstructionText = "An unexpected error occured. Please send feedback now!"; tdError.Text = "Error message goes here..."; tdError.DetailsExpandedLabel = "Hide details"; tdError.DetailsCollapsedLabel = "Show details"; tdError.DetailsExpandedText = "Stack trace goes here..."; tdError.FooterCheckBoxChecked = true; tdError.FooterCheckBoxText = "Don't ask me again"; tdError.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter; TaskDialogCommandLink sendButton = new TaskDialogCommandLink("sendButton", "Send Feedback\nI'm in a giving mood"); sendButton.Click += new EventHandler(sendButton_Click); TaskDialogCommandLink dontSendButton = new TaskDialogCommandLink("dontSendButton", "No Thanks\nI don't feel like being helpful"); dontSendButton.Click += new EventHandler(dontSendButton_Click); tdError.Controls.Add(sendButton); tdError.Controls.Add(dontSendButton); tdError.Show(); tdError = null; }
private static void buttonElevation_Click(object sender, EventArgs e) { // Show a dialog with elevation button tdElevation = new TaskDialog(); tdElevation.Cancelable = true; tdElevation.InstructionText = "Elevated task example"; TaskDialogCommandLink adminTaskButton = new TaskDialogCommandLink("adminTaskButton", "Admin stuff", "Run some admin tasks"); adminTaskButton.UseElevationIcon = true; adminTaskButton.Click += new EventHandler(adminTaskButton_Click); adminTaskButton.Default = true; tdElevation.Controls.Add(adminTaskButton); tdElevation.Show(); tdElevation = null; }
static TaskDialog Step2(TaskDialog d) { d.Text = "Do you want to follow a quick tutorial to get started with EasyCapture?"; d.FooterText = "Question 2/2"; TaskDialogCommandLink cmd1 = new TaskDialogCommandLink("cmd1", "Yes, I'll follow the - really short - tutorial", "Recommended for people who have never used EasyCapture before"); TaskDialogCommandLink cmd2 = new TaskDialogCommandLink("cmd2", "No, I already know how the program works"); cmd1.Click += delegate(object sender, EventArgs argz) { d.Close(); ThreadPool.QueueUserWorkItem(new WaitCallback(DemoThread)); }; cmd2.Click += delegate(object sender, EventArgs argz) { d.Close(); }; d.Controls.Add(cmd1); d.Controls.Add(cmd2); return d; }
public static void FatalError(Exception z) { Out.WritePlain("A unhandled exception was acquired. Below is the information (possibly repeated) of the exception which made EZCap crash."); Out.WriteError("\r\n----------- EZCAP FATALERROR -----------\r\n" + z.ToString() + "\r\n----------------------------------------"); TaskDialog diag = new TaskDialog(); diag.InstructionText = "EasyCapture has failed you, master."; diag.Text = "EasyCapture has encountered an fatal error."; diag.Icon = TaskDialogStandardIcon.Error; diag.DetailsExpandedText = z.ToString(); TaskDialogCommandLink cmd1 = new TaskDialogCommandLink("exit", "Exit the application"); TaskDialogCommandLink cmd2 = new TaskDialogCommandLink("continue", "Continue and ignore error"); TaskDialogCommandLink cmd3 = new TaskDialogCommandLink("debug", "Debug the program", "Show the console and try to find out what happend"); cmd1.Click += delegate(object a, EventArgs b) { Environment.Exit(1); }; cmd2.Click += delegate(object a, EventArgs b) { diag.Close(); }; cmd3.Click += delegate(object a, EventArgs b) { diag.Close(); startConsole(); Out.WritePlain("EZCap debug mode entered"); Out.WritePlain("EZCap was forced to stop executing. Press enter to resume."); Console.Title = "EasyCapture Debug Session"; Console.ReadLine(); WINAPI.FreeConsole(); }; diag.Controls.Add(cmd1); diag.Controls.Add(cmd2); diag.Controls.Add(cmd3); diag.Caption = "Oops!"; diag.DetailsExpandedLabel = "Hide error"; diag.DetailsCollapsedLabel = "Show error"; diag.Show(); }
/// <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(); } } }
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 }
static void Main(string[] args) { if (args.Length > 0) foreach (string arg in args) { switch (arg) { case "/s": Silent = true; break; case "/i": Ignore = true; break; } } //Out.WriteBlank("^0C^1o^2l^3o^4r^5T^6e^7s^8t^9d^10A^11b^12c"); //AllocConsole(); //WINAPI.ShowWindow(WINAPI.GetConsoleWindow(), WINAPI.ShowWindowCommands.Hide); //WINAPI.ShowWindow(ConPtr, WINAPI.ShowWindowCommands.Hide); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Out.WritePlain(Core.Version); foreach (Process p in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Application.ExecutablePath))) { if (p.MainModule.FileName == Application.ExecutablePath && !Ignore && p.Id != Process.GetCurrentProcess().Id) { TaskDialog.Show("You cannot run multiple EasyCaptures, Please exit the currently running EasyCapture first.", "EasyCapture is already running"); Environment.Exit(1); } } if (Silent) Out.WriteLine("Running in silent mode. Not showing splash screen."); ServicePointManager.Expect100Continue = false; Core.Status = "Initializing user directory..."; Out.WriteLine("Initializing user directory..."); UserDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\EasyCapture"; if (!Directory.Exists(UserDir)) Directory.CreateDirectory(UserDir); if (!File.Exists(UserDir + "\\EasyCapture.ini")) if (File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "\\example.ini")) File.Copy(Path.GetDirectoryName(Application.ExecutablePath) + "\\example.ini", UserDir + "\\EasyCapture.ini"); else { MessageBox.Show("EasyCapture could not find one if it's required files.\r\nPlease reinstall the program.", "EasyCapture installation corrupt", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(10); } Core.Status = "Cleaning up user directory..."; Out.WriteLine("Cleaning up user directory..."); CleanUp(); Core.Status = "Reading settings..."; Out.WriteLine("Reading settings..."); Core.Settings = new IniFile(UserDir + "\\EasyCapture.ini"); if(!Silent) Silent = !Convert.ToBoolean(Convert.ToInt32(Settings.IniReadValue("MISC", "ShowSplash"))); if (!Silent) { new Thread(splash).Start(); while (statusChanged == null) { Thread.Sleep(250); } } if (Settings.IniReadValue("MISC", "Console") == "1") { startConsole(); Console.Clear(); Out.Write(Out.Buffer, true, new object[] { }); Console.Title = "EasyCapture.Console"; } if (Settings.IniReadValue("Update", "Disable") != "1") { Core.Status = "Checking for updates..."; Out.WriteLine("Checking for updates..."); try { using (WebClient wc = new WebClient()) { JObject o = (JObject)JsonConvert.DeserializeObject(wc.DownloadString("http://update.easycaptu.re/version")); dynamic json = new JsonObject(o); if (isNewer(Application.ProductVersion, json.version)) { Out.WriteLine("Downloading installer..."); Status = "Downloading installer..."; string installer = UserDir + "\\EZCapInstaller-" + Path.GetRandomFileName().Replace(".", "") + ".exe"; new WebClient().DownloadFile("http://update.easycaptu.re/download/" + json.version + "/EasyCaptureInstaller.exe", installer); System.Diagnostics.Process.Start(installer, "/f"); System.Diagnostics.Process.GetCurrentProcess().Kill(); } } } catch (Exception z) { Out.WriteError("Checking for updates failed: " + z); Status = "Checking for updates failed :("; Thread.Sleep(2000); } } Out.WriteLine("Setting up hotkey hook"); new Thread(HotKeys.Init).Start(); Core.Status = "Setting up audio driver..."; Out.WriteLine("Setting up audio driver..."); SoundCapture.Init(); new Thread(icon).Start(); if (Settings.IniReadValue("CHANGELOG", "ReadV" + Application.ProductVersion) != "1") { Settings.IniWriteValue("CHANGELOG", "ReadV" + Application.ProductVersion, "1"); TaskDialog changelog = new TaskDialog(); changelog.InstructionText = "EasyCapture has just been updated!"; changelog.Text = "EasyCapture has just been updated, Please read through this changelog if you want to see what changes there are in this version"; changelog.DetailsCollapsedLabel = "Show changelog"; changelog.Caption = changelog.InstructionText; changelog.DetailsExpandedLabel = "Hide changelog"; changelog.HyperlinksEnabled = true; changelog.HyperlinkClick += delegate(object sender, TaskDialogHyperlinkClickedEventArgs e) { openLink(e.LinkText); }; string chfile = Path.GetDirectoryName(Application.ExecutablePath) + "\\" + Application.ProductVersion + ".txt"; try { changelog.DetailsExpandedText = File.ReadAllText(chfile); } catch { changelog.DetailsExpandedText = string.Format("Unable to read changelog file '{0}'", chfile); } //changelog.DetailsExpanded = true; changelog.Icon = TaskDialogStandardIcon.Shield; changelog.Show(); } //ThreadPool.QueueUserWorkItem(new WaitCallback(DemoThread)); //Reminder("EC ALPHA RELEASE "+Application.ProductVersion, "Not for distribution, Testing build only.\r\nStill has - known - bugs.", 3000); //if (Settings.IniReadValue("MISC", "ShowLoginReminder") != "0") //Reminder("Create an account and get more!", "If you create a account you can see all your texts and images and modify them as well from any computer. Click this message to sign up!", 5000); if (Settings.IniReadValue("MISC", "NotFirstTime") != "1") { Settings.IniWriteValue("MISC", "NotFirstTime", "1"); TaskDialog d = WelcomeDialog(); TaskDialogCommandLink link1 = new TaskDialogCommandLink("link1", "Let EasyCapture start with windows"); link1.ShowElevationIcon = true; TaskDialogCommandLink link2 = new TaskDialogCommandLink("link2", "Don't let EasyCapture start with windows", "If you change your mind, you can still change it in the settings"); link1.Click += delegate(object sender, EventArgs arg) { RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); key.SetValue("EasyCapture", "\"" + Application.ExecutablePath + "\" /s"); d.Close(); /*d = WelcomeDialog(); d = Step2(d); d.Show();*/ }; link2.Click += delegate(object sender, EventArgs arg) { d.Close(); /*d = WelcomeDialog(); d = Step2(d); d.Show();*/ }; d.Controls.Add(link1); d.Controls.Add(link2); d.Show(); CustomBalloon("Oh, Hai there!", "You can click this icon to customize EasyCapture to your likings!", 5000, ECIcon.BigIcon); ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object o) { Thread.Sleep(6000); Keys textkeys = (Keys)Convert.ToInt32(Core.Settings.IniReadValue("HotKeys", "text")); Keys screenkeys = (Keys)Convert.ToInt32(Core.Settings.IniReadValue("HotKeys", "screen")); Keys soundkeys = (Keys)Convert.ToInt32(Core.Settings.IniReadValue("HotKeys", "sound")); CustomBalloon("Wondering how to take a capture?", "Press " + SettingsV3.getModifier(screenkeys).ToString() + "+" + SettingsV3.removeModifiers(screenkeys).ToString() + " to take a Screen Capture\r\n" + "Press " + SettingsV3.getModifier(textkeys).ToString() + "+" + SettingsV3.removeModifiers(textkeys).ToString() + " to take a Text Capture\r\n" + "Press " + SettingsV3.getModifier(soundkeys).ToString() + "+" + SettingsV3.removeModifiers(soundkeys).ToString() + " to take a Sound Capture\r\n" , 10000, ECIcon.BigIcon); }), null); } int garbagecollects = 0; int pointer = 0; Out.WriteDebug("Hotkey loop started"); while (Online) { try { Thread.Sleep(100); // RAM garbage collecting pointer++; if (pointer == 100) { GC.Collect(); garbagecollects++; pointer = 0; } if (soundCapture) { if (SoundCaptureUp != null) SoundCaptureUp(); //if (!SoundCapture.Recording) Reminder("Recording sound...", "EasyCapture is now recording all sound output from the sound device '" + SoundCapture.RecordDevice + "'. Press the SoundCapture button again to cancel. There is a 30 seconds limit.", 5000); ThreadPool.QueueUserWorkItem(GoSS); soundCapture = false; SoundCapture.Record(); int i = 0; while (SoundCapture.Recording && soundCapture == false && i != 300) { Thread.Sleep(100); i++; } soundCapture = false; var file = SoundCapture.Stop(); StopSS(); //upload ThreadPool.QueueUserWorkItem(new WaitCallback(doDiag)); WebClient wc = new WebClient(); NameValueCollection nvc = new NameValueCollection(); nvc.Add("type", "sound"); nvc.Add("content", Convert.ToBase64String(File.ReadAllBytes(file))); File.Delete(file); bool w8 = true; bool canceled = false; string resp = ""; wc.UploadProgressChanged += delegate(object sender, UploadProgressChangedEventArgs e) { diag.Line3 = e.BytesSent + "/" + e.TotalBytesToSend; diag.Value = Convert.ToUInt32(e.ProgressPercentage); if (diag.HasUserCancelled) { wc.CancelAsync(); canceled = true; } }; wc.UploadValuesCompleted += delegate(object sender, UploadValuesCompletedEventArgs e) { if (e.Error != null && !canceled) Refused(); else { if (!canceled) { Out.WriteLine("Sound uploaded"); resp = Encoding.Default.GetString(e.Result); } diag.CloseDialog(); w8 = false; } }; string key = Core.Settings.IniReadValue("MISC", "userkey"); string ukey = ""; if (key != string.Empty) ukey = "?userkey=" + Crypto.DecryptStringAES(key, Core.Secret); wc.UploadValuesAsync(new Uri("http://upload.easycaptu.re/" + Application.ProductVersion+ukey), nvc); /*try { resp = Encoding.Default.GetString(wc.UploadValues(new Uri("http://upload.easycaptu.re/" + Application.ProductVersion), nvc)); } catch { }*/ while (w8) { Thread.Sleep(100); } if (!canceled) { Out.WriteLine("Server responded:\r\n" + resp); List<EasyCaptureResponse> keys = (List<EasyCaptureResponse>)JsonConvert.DeserializeObject(resp, typeof(List<EasyCaptureResponse>)); if (keys != null || resp != string.Empty) { var inn = String.Format("http://in.easycaptu.re/{0}/{1}", keys[0].hash, keys[0].authcode); int action = Convert.ToInt32(Core.Settings.IniReadValue("ACTIONS", "sound")); Out.WriteDebug("action=" + action); if (action == 0) { Out.WriteLine("Opening '" + inn + "'"); openLink(inn); } else if (action == 1) { string raw = "http://easycaptu.re/" + keys[0].hash + ".mp3"; Out.WriteLine("Opening '" + raw + "'"); openLink(raw); } else if (action == 2) { string copy = "http://easycaptu.re/" + keys[0].hash; Clipboard.SetText(copy); Out.WriteLine("Copied '" + copy + "' to clipboard"); Reminder("Link copied", "Link was copied to your clipboard", 2000); } } else Refused(); } if (SoundCaptureTrigger != null) SoundCaptureTrigger(); soundCapture = false; } if (textCapture) { if (TextCaptureUp != null) TextCaptureUp(); string ccopy = HotKeys.Copy(); if (ccopy == string.Empty) { TaskDialog err = new TaskDialog(); err.Icon = TaskDialogStandardIcon.Error; err.Text = "Are you sure you selected something?"; err.InstructionText = "Unable to get selected text"; err.Show(); } else { if (Settings.IniReadValue("TextCapture", "pastebin") != "1") { WebClient wc = new WebClient(); NameValueCollection nvc = new NameValueCollection(); nvc.Add("type", "text"); nvc.Add("content", Convert.ToBase64String(Encoding.Default.GetBytes(ccopy))); //Out.WriteDebug("[DEBUG] [SUPERDEBUG] [EXPIREMENTAL] " + nvc["content"]); string resp = ""; string key = Core.Settings.IniReadValue("MISC", "userkey"); string ukey = ""; if (key != string.Empty) ukey = "?userkey=" + Crypto.DecryptStringAES(key, Core.Secret); resp = Encoding.Default.GetString(wc.UploadValues("http://upload.easycaptu.re/" + Application.ProductVersion + ukey, "POST", nvc)); Out.WriteLine("Server responded:\r\n" + resp); List<EasyCaptureResponse> keys = (List<EasyCaptureResponse>)JsonConvert.DeserializeObject(resp, typeof(List<EasyCaptureResponse>)); if (keys != null || resp != string.Empty) { var inn = String.Format("http://in.easycaptu.re/{0}/{1}", keys[0].hash, keys[0].authcode); int action = Convert.ToInt32(Core.Settings.IniReadValue("ACTIONS", "text")); Out.WriteDebug("action=" + action); if (action == 0) { Out.WriteLine("Opening '" + inn + "'"); openLink(inn); } else if (action == 1) { string raw = "http://easycaptu.re/" + keys[0].hash + ".txt"; Out.WriteLine("Opening '" + raw + "'"); openLink(raw); } else if (action == 2) { string copy = "http://easycaptu.re/" + keys[0].hash; Clipboard.SetText(copy); Out.WriteLine("Copied '" + copy + "' to clipboard"); Reminder("Link copied", "Link was copied to your clipboard", 2000); } else Refused(); } } else { using (WebClient wc = new WebClient()) { string user = Crypto.DecryptStringAES(Settings.IniReadValue("TextCapture", "user_key"), Core.Secret); NameValueCollection nvc = new NameValueCollection(); nvc.Add("api_dev_key", ApiKeys.Pastebin); nvc.Add("api_option", "paste"); nvc.Add("api_paste_code", ccopy); nvc.Add("api_paste_private", Settings.IniReadValue("TextCapture", "exposure")); nvc.Add("api_paste_name", "Uploaded with easycaptu.re - Share media instantly!"); if (user != string.Empty) nvc.Add("api_user_key", user); string resp = Encoding.Default.GetString(wc.UploadValues("http://pastebin.com/api/api_post.php", nvc)); Out.WriteDebug("Server responded:\r\n" + resp); //if(!resp.StartsWith("http:// Out.WriteLine("Checking for captcha's...."); wc.Headers.Add("User-Agent", "EC RequestCaptcha " + Application.ProductVersion); string spam = wc.DownloadString(resp); CookieContainer cc = new CookieContainer(); cc.SetCookies(new Uri("http://pastebin.com"), wc.ResponseHeaders["Set-Cookie"]); string url = ""; string code = ""; foreach (string a in spam.Split(new string[] { "\n" }, StringSplitOptions.None)) { if (a.Contains("<img id=\"siimage\"")) { string re1 = ".*?"; // Non-greedy match on filler string re2 = "\".*?\""; // Uninteresting: string string re3 = ".*?"; // Non-greedy match on filler string re4 = "\".*?\""; // Uninteresting: string string re5 = ".*?"; // Non-greedy match on filler string re6 = "(\"/etc.*?\")"; // Double Quote String 1 Regex r = new Regex(re1 + re2 + re3 + re4 + re5 + re6, RegexOptions.IgnoreCase | RegexOptions.Singleline); Match m = r.Match(a); if (m.Success) { url = m.Groups[1].ToString(); } } if (a.Contains("captcha_item_key")) { string re1 = ".*?"; // Non-greedy match on filler string re2 = "(?:[a-z][a-z0-9_]*)"; // Uninteresting: var string re3 = ".*?"; // Non-greedy match on filler string re4 = "(?:[a-z][a-z0-9_]*)"; // Uninteresting: var string re5 = ".*?"; // Non-greedy match on filler string re6 = "(?:[a-z][a-z0-9_]*)"; // Uninteresting: var string re7 = ".*?"; // Non-greedy match on filler string re8 = "(?:[a-z][a-z0-9_]*)"; // Uninteresting: var string re9 = ".*?"; // Non-greedy match on filler string re10 = "((?:[a-z][a-z0-9_]*))"; // Variable Name 1 Regex r = new Regex(re1 + re2 + re3 + re4 + re5 + re6 + re7 + re8 + re9 + re10, RegexOptions.IgnoreCase | RegexOptions.Singleline); Match m = r.Match(a); if (m.Success) { code = m.Groups[1].ToString(); } } } Out.WriteDebug("---- headerdump ----"); foreach (string d in wc.Headers) { Out.WriteDebug(d); } Out.WriteDebug("Image = " + url + " Captcha key = " + code); if (url != string.Empty) { RequestCaptcha(url, code, resp, cc); } switch (Convert.ToInt32(Core.Settings.IniReadValue("ACTIONS", "text"))) { case 0: Out.WriteLine("Opening " + resp); openLink(resp); break; case 1: string dd = "http://pastebin.com/raw.php?i=" + resp.Replace("http://pastebin.com/", ""); Out.WriteLine("Opening " + dd); openLink(resp); break; case 2: Out.WriteLine("Copying " + resp); Clipboard.SetText(resp); Out.WriteLine("Copied '" + resp + "' to clipboard"); Reminder("Link copied", "Link was copied to your clipboard", 2000); break; } } } } if (TextCaptureTrigger != null) TextCaptureTrigger(); textCapture = false; } if (screenCapture) { if (ScreenCaptureUp != null) ScreenCaptureUp(); Form1 screencap = new Form1(false); screencap.ShowDialog(); if (!screencap.abort) { string resp = Encoding.Default.GetString(screencap.DATAZ); Out.WriteLine("Server responded:\r\n" + resp); if (!screencap.imgur) { List<EasyCaptureImageResponse> keys = (List<EasyCaptureImageResponse>)JsonConvert.DeserializeObject(resp, typeof(List<EasyCaptureImageResponse>)); if (keys != null || resp != string.Empty) { int action = Convert.ToInt32(Core.Settings.IniReadValue("ACTIONS", "screen")); Out.WriteDebug("action=" + action); var inn = String.Format("http://in.easycaptu.re/{0}/{1}", keys[0].hash, keys[0].authcode); if (action == 0) { Out.WriteLine("Opening " + inn); openLink(inn); } else if (action == 1) { Out.WriteLine("Opening absolute pic"); openLink(string.Format("http://easycaptu.re/{0}.png", keys[0].hash)); } else if (action == 2) { Out.WriteLine("Copying link"); //Invoke(new cliphandler(Clipboard.SetText), (object)(string.Format("http://easycapture.re/{0}", keys[0].hash))); Clipboard.SetText(string.Format("http://easycaptu.re/{0}", keys[0].hash)); Reminder("Link copied", "Link was copied to your clipboard", 2000); } } else Refused(); } else { try { XmlDocument doc = new XmlDocument(); doc.LoadXml(resp); int action = Convert.ToInt32(Core.Settings.IniReadValue("ACTIONS", "screen")); string url = doc.GetElementsByTagName("imgur_page")[0].InnerText; string direct = doc.GetElementsByTagName("original")[0].InnerText; switch (action) { case 0: Out.WriteLine("Opening " + url); openLink(url); break; case 1: Out.WriteLine("Opening absolute pic"); openLink(direct); break; case 2: Out.WriteLine("Copying link"); Clipboard.SetText(url); Reminder("Link copied", "Link was copied to your clipboard", 2000); break; default: TaskDialog.Show("Invalid action (see %AppData%\\EasyCapture.ini)"); break; } } catch(Exception z) { Out.WriteError("Error while parsing response: " + z.ToString()); Refused(); } } } if (ScreenCaptureTrigger != null) ScreenCaptureTrigger(); screenCapture = false; } } catch (Exception z) { //if (!DebugMode) FatalError(z); //else throw (z); } } Out.WriteLine("Main thread stopped, all other threads are offline as well."); Out.WriteDebug("BYE!"); //Thread.Sleep(2000); //Application.Run(new Form1()); }
public static void LicenceMessage(IWin32Window owner) { Licence lic = Options.Current.Licence; if (lic.IsValid) { return; } string caption = null; string message = null; bool die = false; if (lic.TrialInfo.LevelChanged) { switch (lic.TrialLevel) { case TrialLevel.Remind: caption = "Reminder"; message = "Don't forget, this is the trial version of Exception Explorer - but it wont last forever.\n\nConsider purchasing a licence if you would like to continue using Exception Explorer."; break; case TrialLevel.Warn: caption = "Your trial will end soon!"; message = "Your time to use Exception Explorer will soon run out, so purchase a licence this week to avoid disappointment!"; break; case TrialLevel.Stop: caption = "Final chance..."; message = "This is your final chance to try out Exception Explorer.\n\nAfter this session, you will no longer be able to use this software without purchasing a licence."; break; } } else if (lic.TrialLevel == TrialLevel.Stop) { caption = "Purchase a licence today."; message = "Unfortunately, your time to try Exception Explorer has now come to an end.\n\nFor this to happen, you must have been using this software enough to find it useful...\n\nFeel free to purchace a licence if you would like to continue using Exception Explorer."; die = true; } if (message != null) { TaskDialog td = new TaskDialog() { InstructionText = caption.Fix(), Text = message.Fix(), StandardButtons = TaskDialogStandardButtons.Close, Cancelable = true, DetailsExpandedText = string.Format("Installed for {0} days.\nRan {1} times, over {2} distinct days.\n", lic.TrialInfo.DaysInstalled, lic.TrialInfo.RunCount, lic.TrialInfo.DayCount).Fix(), }; TaskDialogCommandLink purchase = new TaskDialogCommandLink("purchase", "Purchase Licence".Fix()); purchase.Click += (sender, e) => { Web.OpenSite(SiteLink.Buy); td.Close(); }; td.Controls.Add(purchase); if (!die) { TaskDialogCommandLink later = new TaskDialogCommandLink("later", "Maybe later"); later.Click += (sender, e) => { td.Close(); }; } td.Show(owner); if (die) { Application.Exit(); } } }
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 Show(bool canResume) { this.errorDialog = new TaskDialog() { Caption = "Exception Explorer", InstructionText = "An error has occurred.", Text = this.exception.Message + "\n\n" + this.exception.GetType().FullName, Icon = TaskDialogStandardIcon.Error, StandardButtons = TaskDialogStandardButtons.Close, FooterCheckBoxText = "Send an error report", FooterCheckBoxChecked = this.reportDefault, Cancelable = true, }; this.errorDialog.Opened += (sender, e) => { this.errorDialog.Icon = this.errorDialog.Icon; }; if (canResume) { TaskDialogCommandLink continueLink = new TaskDialogCommandLink("continue", "Continue"); continueLink.Click += (sender, e) => { this.errorDialog.Close(); }; TaskDialogCommandLink restartLink = new TaskDialogCommandLink("restart", "Restart"); restartLink.Click += (sender, e) => { this.restart = true; this.errorDialog.Close(); }; this.errorDialog.Controls.Add(continueLink); this.errorDialog.Controls.Add(restartLink); } this.errorDialog.Show(Program.ExceptionExplorerForm); using (RegistryKey key = Registry.CurrentUser.CreateSubKey(Options.RegistryRootKeyName)) { key.SetValue("ReportErrors", this.errorDialog.FooterCheckBoxChecked.Value ? 1 : 0); } if (this.errorDialog.FooterCheckBoxChecked.Value == true) { this.SendErrorReport(); } if (this.restart) { Program.Restart("/restart"); } }
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(); } } }
public void FirstInstall() { Enable(false); RegistryKey reg = ParentalControlsRegistry.GetRegistryKey(); reg.SetValue("Path", Application.StartupPath, RegistryValueKind.String); reg.SetValue("AlarmFile", Application.StartupPath + @"\" + ALARMS_FILE); TaskDialog dialog = new TaskDialog(); dialog.Caption = Application.ProductName+" Setup"; dialog.InstructionText = Application.ProductName+" is mostly setup!"; dialog.Text = "What you need to do is setup a password for any cases that you need to force close an alarm."; TaskDialogButton button = new TaskDialogButton("btnOne", "Continue"); button.Click += (aa, ab) => { TaskDialogButton tdb = (TaskDialogButton)aa; ((TaskDialog)tdb.HostingDialog).Close(TaskDialogResult.Ok); if (file2.ParentalControlsCredentials.Count > 0) { TaskDialog dadialog = new TaskDialog(); dadialog.InstructionText = "Setup Complete!"; dadialog.Text = "You are now done setting up Parental Controls!"; dadialog.StandardButtons = TaskDialogStandardButtons.Ok; dadialog.Show(); return; } NetworkCredential cred = null; WindowsSecurity.GetCredentialsVistaAndUp("Please enter new credentials for Parental Controls", "Set username and password for stopping an alarm.", out cred); while (cred == null || (string.IsNullOrWhiteSpace(cred.UserName) || string.IsNullOrWhiteSpace(cred.Password))) { WindowsSecurity.GetCredentialsVistaAndUp("Please enter new credentials for Parental Controls", "Set username and password for stopping an alarm. (Credentials must not be empty)", out cred); } ParentalControlsCredential c; try { c = (ParentalControlsCredential)cred; c.HashedPassword = SHA256Hash.Hash(c.HashedPassword); file2.Add(c); file2.Save(); } catch { } TaskDialog ndialog = new TaskDialog(); ndialog.Caption = Application.ProductName + " Setup"; ndialog.InstructionText = "Want to test your credentials?"; ndialog.FooterText = "Fun Fact: You can create as many accounts as you want!"; ndialog.FooterIcon = TaskDialogStandardIcon.Information; TaskDialogCommandLink linka = new TaskDialogCommandLink("linkA", "Test Credentials"); linka.Click += (ba, bb) => { TaskDialogButton tb = (TaskDialogButton)ba; ((TaskDialog)tb.HostingDialog).Close(TaskDialogResult.Yes); WindowsSecurity.GetCredentialsVistaAndUp("Please enter credentials for \"Parental Controls\"", "Force disabling \"TestAlarm\"", out cred); c = new ParentalControlsCredential(); try { c = (ParentalControlsCredential)cred; c.HashedPassword = SHA256Hash.Hash(c.HashedPassword); } catch { } bool wevalidated = true; while (cred == null || !file2.Validate(c) || (string.IsNullOrWhiteSpace(cred.UserName) || string.IsNullOrWhiteSpace(cred.Password))) { TaskDialog ddialog = new TaskDialog(); ddialog.InstructionText = "Credentials Invalid"; ddialog.Text = "You want to stop testing credentials?"; ddialog.StandardButtons = TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No; if (ddialog.Show() == TaskDialogResult.Yes) { wevalidated = false; break; } else WindowsSecurity.GetCredentialsVistaAndUp("Please enter credentials for \"Parental Controls\"", "Force disabling \"TestAlarm\"", out cred); } TaskDialog dadialog = new TaskDialog(); if (wevalidated) { dadialog.InstructionText = "Credentials Valid!"; } else { dadialog.InstructionText = "Setup Complete!"; } dadialog.Text = "You are now done setting up Parental Controls!"; dadialog.StandardButtons = TaskDialogStandardButtons.Ok; dadialog.Show(); }; TaskDialogCommandLink linkb = new TaskDialogCommandLink("linkB", "Skip Test"); linkb.Click += (ba, bb) => { TaskDialogButton tb = (TaskDialogButton)ba; ((TaskDialog)tb.HostingDialog).Close(TaskDialogResult.No); TaskDialog dadialog = new TaskDialog(); dadialog.InstructionText = "Setup Complete!"; dadialog.Text = "You are now done setting up Parental Controls!"; dadialog.StandardButtons = TaskDialogStandardButtons.Ok; dadialog.Show(); }; ndialog.Controls.Add(linka); ndialog.Controls.Add(linkb); ndialog.Show(); file2.Save(); }; dialog.Controls.Add(button); dialog.Show(); Enable(true); // Kind of an hacky way of making this window get focused after showing dialogs. SwitchToSelf(); }
public ThumbnailBrowser() { InitializeComponent(); // Set some ExplorerBrowser properties explorerBrowser1.ContentOptions.SingleSelection = true; explorerBrowser1.ContentOptions.ViewMode = ExplorerBrowserViewMode.List; explorerBrowser1.NavigationOptions.PaneVisibility.Navigation = PaneVisibilityState.Hide; explorerBrowser1.NavigationOptions.PaneVisibility.CommandsView = PaneVisibilityState.Hide; explorerBrowser1.NavigationOptions.PaneVisibility.CommandsOrganize = PaneVisibilityState.Hide; explorerBrowser1.NavigationOptions.PaneVisibility.Commands = PaneVisibilityState.Hide; // set our initial state CurrentView == large toolStripSplitButton1.Image = Microsoft.WindowsAPICodePack.Samples.ThumbnailBrowserDemo.Properties.Resources.large; smallToolStripMenuItem.Checked = false; mediumToolStripMenuItem.Checked = false; largeToolStripMenuItem.Checked = true; extraLargeToolStripMenuItem.Checked = false; // comboBox1.SelectedIndex = 0; // explorerBrowser1.SelectionChanged += new ExplorerBrowserSelectionChangedEventHandler(explorerBrowser1_SelectionChanged); // Create our Task Dialog for displaying the error to the user // when they are asking for Thumbnail Only and the selected item doesn't have a thumbnail. td = new TaskDialog(); td.OwnerWindowHandle = this.Handle; td.InstructionText = "Error displaying thumbnail"; td.Text = "The selected item does not have a thumbnail and you have selected the viewing mode to be thumbnail only. Please select one of the following options:"; td.StartupLocation = TaskDialogStartupLocation.CenterOwner; td.Icon = TaskDialogStandardIcon.Error; td.Cancelable = true; td.FooterCheckBoxText = "Do not show this dialog again"; td.FooterCheckBoxChecked = false; TaskDialogCommandLink button1 = new TaskDialogCommandLink("changeModeButton", "Change mode to Thumbnail Or Icon", "Change the viewing mode to Thumbnail or Icon. If the selected item does not have a thumbnail, it's associated icon will be displayed."); button1.Click += new EventHandler(button1_Click); TaskDialogCommandLink button2 = new TaskDialogCommandLink("noChangeButton", "Keep the current mode", "Keep the currently selected mode (Thumbnail Only). If the current mode is Thumbnail Only and the selected item does not have a thumbnail, nothing will be shown in the preview panel."); button2.Click += new EventHandler(button2_Click); td.Controls.Add(button1); td.Controls.Add(button2); }
/// <summary> /// Handles the unexpected exception. /// </summary> /// <param name="ex">The exception.</param> /// <param name="isTerminating">if set to <c>true</c> the exception will terminate the execution.</param> public void HandleUnexpectedException(Exception ex, bool isTerminating = false) { if (ex is ThreadAbortException) { return; } var show = Settings.Get<bool>("Show Unhandled Errors"); var sb = new StringBuilder(); parseException: sb.AppendLine(ex.GetType() + ": " + ex.Message); sb.AppendLine(ex.StackTrace); if (ex.InnerException != null) { ex = ex.InnerException; goto parseException; } if (show) { var mc = Regex.Matches(sb.ToString(), @"\\(?<file>[^\\]+\.cs)(?::lig?ne|, sor:) (?<ln>[0-9]+)"); var loc = "at a location where it was not expected"; if (mc.Count != 0) { loc = "in file {0} at line {1}".FormatWith(mc[0].Groups["file"].Value, mc[0].Groups["ln"].Value); } var td = new TaskDialog { Icon = TaskDialogStandardIcon.Error, Caption = "An unexpected error occurred", InstructionText = "An unexpected error occurred", Text = "An exception of type {0} was thrown {1}.".FormatWith(ex.GetType().ToString().Replace("System.", string.Empty), loc) + (isTerminating ? "\r\n\r\nUnfortunately this exception occured at a crucial part of the code and the execution of the software will be terminated." : string.Empty), DetailsExpandedText = sb.ToString(), DetailsExpandedLabel = "Hide stacktrace", DetailsCollapsedLabel = "Show stacktrace", Cancelable = true, StandardButtons = TaskDialogStandardButtons.None }; if ((bool)Dispatcher.Invoke((Func<bool>)(() => IsVisible))) { td.Opened += (s, r) => Utils.Win7Taskbar(100, TaskbarProgressBarState.Error); td.Closing += (s, r) => Utils.Win7Taskbar(state: TaskbarProgressBarState.NoProgress); } var fd = new TaskDialogCommandLink { Text = "Submit bug report" }; fd.Click += (s, r) => { td.Close(); ReportException(sb.ToString()); }; var ig = new TaskDialogCommandLink { Text = "Ignore exception" }; ig.Click += (s, r) => td.Close(); td.Controls.Add(fd); td.Controls.Add(ig); td.Show(); } else { ReportException(sb.ToString()); } }