public void HighlightLine(int linenum, Brush foreground, Brush background) { //Console.WriteLine(String.Format("HighlightLine : {0}", linenum)); if (Watching) { Dispatcher.Invoke((Action)(() => { if (linenum > avalonEdit.Document.LineCount) { return; } try { avalonEdit.ScrollToLine(linenum); DocumentLine line = avalonEdit.Document.GetLineByNumber(linenum); avalonEdit.Select(line.Offset, line.TotalLength - 1); line = null; }catch (Exception ex) { Console.WriteLine(ex.ToString()); ExceptionViewer ev = new ExceptionViewer("TracebackEvent", ex); ev.ShowDialog(); } })); } if (Task != null) { Task.Resume(); } }
public static void RunFormWarm(Form form) { try { for (int i = Application.OpenForms.Count - 1; i >= 0; i--) { Form openForm = Application.OpenForms[i]; openForm.Close(); } form.ShowDialog(); //Show as dialog to have a blocking call so we do not leave the try catch block } catch (Exception e) { if (e is SoftException) { ExceptionViewer ev = new ExceptionViewer(e); if (ev.ShowDialog() == DialogResult.Retry) { RunFormWarm(GetRequestedForm()); } } else { throw; } } }
public void TracebackEvent(object sender, IPYTracebackEventArgs e) { FunctionCode code = e.frame.f_code; string filename = code.co_filename; try { switch (e.result) { case "call": TracebackCall(e); break; case "line": TracebackLine(e); break; case "return": TracebackReturn(e); break; default: break; } } catch (Exception ex) { Invoke((Action)(() => { ExceptionViewer ev = new ExceptionViewer("TracebackEvent", ex); ev.ShowDialog(); })); } }
private void InnerButton_Click(object sender, RoutedEventArgs e) { var errorViewer = new ExceptionViewer(_exception.InnerException); errorViewer.ShowDialog(); GC.Collect(1); }
private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { LogWriter.Log(e.Exception, "On Dispacher Unhandled Exception - Unknow"); var errorViewer = new ExceptionViewer(e.Exception); errorViewer.ShowDialog(); e.Handled = true; }
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { LogWriter.Log(e.Exception, "Thread Exception"); var errorViewer = new ExceptionViewer(e.Exception); errorViewer.ShowDialog(); Environment.Exit(1); }
private void DetailsButton_Click(object sender, RoutedEventArgs e) { if (Exception == null) { return; } var viewer = new ExceptionViewer(Exception); viewer.ShowDialog(); }
public void ShowErrorMessage(string error, bool isException = false, Exception exception = null) { if (isException) { var ev = new ExceptionViewer("Произошло исключение.", exception); ev.ShowDialog(); } else { MessageBox.Show(error, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); } }
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { var ex = (Exception)e.ExceptionObject; LogWriter.Log(ex, "Unhandled Exception"); var errorViewer = new ExceptionViewer(ex); errorViewer.ShowDialog(); Environment.Exit(2); }
private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { ExceptionViewer ev = new ExceptionViewer("Unhandled Exception (Error)", e.Exception, this.MainWindow); ev.ShowDialog(); //if (ev.ShowDialog() == true) // e.Handled = true; //else // e.Handled = true; e.Handled = true; this.MainWindow.Cursor = Cursors.Arrow; }
private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { #if DEBUG if (e.Exception.GetType() == typeof(ResourceReferenceKeyNotFoundException)) // This happens when editing a StaticResource in the XAML designer while the program is running { return; } #endif ExceptionViewer ev = new ExceptionViewer($"Unhandled Exception: {e.Exception.Message}", e.Exception); ev.ShowDialog(); //MessageBox.Show(e.Exception.StackTrace, $"Unhandled Exception: {e.Exception.Message}", MessageBoxButton.OK, MessageBoxImage.Error); e.Handled = true; }
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { var exception = e.ExceptionObject as Exception; if (exception == null) { return; } LogWriter.Log(exception, "Current Domain Unhandled Exception - Unknow"); var errorViewer = new ExceptionViewer(exception); errorViewer.ShowDialog(); }
private static void WriteTagReal(this ITagOp tagOp, string tag, object value) { try { string[] tagNames = new string[1] { tag }; object[] values = new object[1] { value }; ITag itag = tagOp.TAG; itag.WriteTag(tagOp.RegisterCookie, tagNames, values); } catch (Exception ex) { ExceptionViewer ev = new ExceptionViewer("WriteTagReal", ex); ev.ShowDialog(); } }
private void Window_Initialized(object sender, EventArgs e) { try { CreateAndBind(); // Tries to attach to the open Sap2000 Instance otherwise close this.sModel = new S2KModel(null, true); this.bStatusBarBindings.ModelName = this.sModel.FileName; } catch (Exception ex) { this.ResidualMessage = $"Could not find running Sap2000 Instance.{Environment.NewLine}Please open one, and only one, Sap2000 instance and open the model you want to manipulate."; ExceptionViewer ev = new ExceptionViewer(ResidualMessage, ex); ev.ShowDialog(); // Closes the current form to give back control to 3DSMax this.Close(); } }
public static void RunForm(Form form) { try { Application.Run(form); } catch (Exception e) { if (e is SoftException) { ExceptionViewer ev = new ExceptionViewer(e); if (ev.ShowDialog() == DialogResult.Retry) { WarmStartup(); } } else { throw; } } }
private void checkFinishTimer_Tick(object sender, EventArgs e) { if (WaitTask.IsCompleted) { checkFinishTimer.Stop(); if (WaitTask.IsFaulted) { if (WaitTask.Exception.InnerException is SoftException) { ExceptionViewer ev = new ExceptionViewer(WaitTask.Exception, false); ev.ShowDialog(); FLScriptEditor.Settings.Abort = true; Application.Exit(); return; } throw WaitTask.Exception; } DialogResult = DialogResult.OK; Close(); } }
private void HandleException(MakeAction makeAction, string headerMessage) { try { makeAction(); } catch (Exception e) { if (_drawingMode != DrawingMode.Canceled) { _drawingMode = DrawingMode.NotChanged; } if (e is GraphRenderException || e is ValidationException) { MessageBox.Show(e.Message, headerMessage, MessageBoxButton.OK, MessageBoxImage.Error); } else { var exceptionViewer = new ExceptionViewer(headerMessage, e); exceptionViewer.ShowDialog(); } } }
private void Application_Startup(object sender, StartupEventArgs e) { #region Unhandled Exceptions AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; #endregion #region Arguments try { if (e.Args.Length > 0) { //TODO: Watch for Args... } } catch (Exception ex) { var errorViewer = new ExceptionViewer(ex); errorViewer.ShowDialog(); LogWriter.Log(ex, "Generic Exception - Arguments"); } #endregion #region Language try { if (!Settings.Default.Language.Equals("auto")) { Thread.CurrentThread.CurrentCulture = new CultureInfo(Settings.Default.Language); Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Default.Language); } } catch (Exception ex) { var errorViewer = new ExceptionViewer(ex); errorViewer.ShowDialog(); LogWriter.Log(ex, "Language Settings Exception"); } #endregion try { #region Startup if (Settings.Default.StartUp == 0) { var startup = new Startup(); Current.MainWindow = startup; startup.ShowDialog(); } else if (Settings.Default.StartUp == 3) { var edit = new Editor(); Current.MainWindow = edit; edit.ShowDialog(); } else { var editor = new Editor(); List <FrameInfo> frames = null; ExitAction exitArg = ExitAction.Exit; bool? result = null; #region Recorder or Webcam if (Settings.Default.StartUp == 1) { var rec = new Recorder(true); result = rec.ShowDialog(); exitArg = rec.ExitArg; frames = rec.ListFrames; } else if (Settings.Default.StartUp == 2) { var web = new Windows.Webcam(); result = web.ShowDialog(); exitArg = web.ExitArg; frames = web.ListFrames; } #endregion if (result.HasValue && result.Value) { #region If Close Environment.Exit(0); #endregion } else if (result.HasValue) { #region If Backbutton or Stop Clicked if (exitArg == ExitAction.Recorded) { editor.ListFrames = frames; Current.MainWindow = editor; editor.ShowDialog(); } #endregion } } #endregion } catch (Exception ex) { var errorViewer = new ExceptionViewer(ex); errorViewer.ShowDialog(); LogWriter.Log(ex, "Generic Exception - Root"); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); var cancelButton = Template.FindName("CancelButton", this) as ImageButton; var fileButton = Template.FindName("FileButton", this) as ImageButton; var folderButton = Template.FindName("FolderButton", this) as ImageButton; var detailsButton = Template.FindName("DetailsButton", this) as ImageButton; var copyMenu = Template.FindName("CopyMenuItem", this) as ImageMenuItem; var copyImageMenu = Template.FindName("CopyImageMenuItem", this) as ImageMenuItem; var copyFilenameMenu = Template.FindName("CopyFilenameMenuItem", this) as ImageMenuItem; var copyFolderMenu = Template.FindName("CopyFolderMenuItem", this) as ImageMenuItem; if (cancelButton != null) { cancelButton.Click += (s, a) => RaiseCancelClickedEvent(); } if (fileButton != null) { fileButton.Click += (s, a) => { RaiseOpenFileClickedEvent(); try { if (!string.IsNullOrWhiteSpace(OutputFilename) && File.Exists(OutputFilename)) { Process.Start(OutputFilename); } } catch (Exception ex) { Dialog.Ok("Open File", "Error while openning the file", ex.Message); } } } ; if (folderButton != null) { folderButton.Click += (s, a) => { RaiseExploreFolderClickedEvent(); try { if (!string.IsNullOrWhiteSpace(OutputFilename) && Directory.Exists(OutputPath)) { Process.Start("explorer.exe", $"/select,\"{OutputFilename}\""); } } catch (Exception ex) { Dialog.Ok("Explore Folder", "Error while openning the folder", ex.Message); } } } ; if (detailsButton != null) { detailsButton.Click += (s, a) => { if (Exception != null) { var viewer = new ExceptionViewer(Exception); viewer.ShowDialog(); } } } ; if (copyMenu != null) { copyMenu.Click += (s, a) => { if (!string.IsNullOrWhiteSpace(OutputFilename)) { Clipboard.SetFileDropList(new StringCollection { OutputFilename }); } } } ; if (copyImageMenu != null) { copyImageMenu.Click += (s, a) => { if (!string.IsNullOrWhiteSpace(OutputFilename)) { Clipboard.SetImage(OutputFilename.SourceFrom()); } } } ; if (copyFilenameMenu != null) { copyFilenameMenu.Click += (s, a) => { if (!string.IsNullOrWhiteSpace(OutputFilename)) { Clipboard.SetText(OutputFilename); } } } ; if (copyFolderMenu != null) { copyFolderMenu.Click += (s, a) => { if (!string.IsNullOrWhiteSpace(OutputPath)) { Clipboard.SetText(OutputPath); } } } ; }
private static ProcessFlow UnhandledExceptionLogger(Exception exp, StackFrame[] callStackFrames, String errorTitle) { // // If number of errors exist in cache more than MaxQueuedError then skip new errors if (CacheController.SdfManager.ErrorIds.Count > ErrorHandlingOption.MaxQueuedError) { if (!ErrorHandlingOption.AtSentState && ErrorHandlingOption.EnableNetworkSending) { Task.Run(async() => await CacheController.CheckStateAsync()); } return(ErrorHandlingOption.ExitApplicationImmediately); } bool snapshot; // // ---------------------------- Filter exception --------------------------------------- if (Filter.IsFiltering(exp, callStackFrames, out snapshot)) { return(ErrorHandlingOption.ExitApplicationImmediately); } // // initial the error object by additional data var error = new Error(exp, callStackFrames, snapshot) { IsHandled = false }; // // Store Error object CacheController.CacheTheError(error); // // Handle 'OnShowUnhandledError' events OnShowUnhandledError(exp, new UnhandledErrorEventArgs(error)); // // Alert Unhandled Error if (ErrorHandlingOption.DisplayUnhandledExceptions) { if (ErrorHandlingOption.DisplayDeveloperUI) { var msgResult = ProcessFlow.Continue; var staThread = new Thread(() => { var msg = new ExceptionViewer { Title = errorTitle }; msg.Dispatcher.Invoke(() => msgResult = msg.ShowDialog(exp)); }); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(); staThread.Join(); return(msgResult); } // // ELSE: MessageBox.Show(error.Message, errorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); } return(ErrorHandlingOption.ExitApplicationImmediately); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); var cancelButton = Template.FindName("CancelButton", this) as ImageButton; var fileButton = Template.FindName("FileButton", this) as ImageButton; var folderButton = Template.FindName("FolderButton", this) as ImageButton; var detailsButton = Template.FindName("DetailsButton", this) as ImageButton; var copyMenu = Template.FindName("CopyMenuItem", this) as ImageMenuItem; var copyImageMenu = Template.FindName("CopyImageMenuItem", this) as ImageMenuItem; var copyFilenameMenu = Template.FindName("CopyFilenameMenuItem", this) as ImageMenuItem; var copyFolderMenu = Template.FindName("CopyFolderMenuItem", this) as ImageMenuItem; if (cancelButton != null) cancelButton.Click += (s, a) => RaiseCancelClickedEvent(); //Open file. if (fileButton != null) fileButton.Click += (s, a) => { RaiseOpenFileClickedEvent(); try { if (!string.IsNullOrWhiteSpace(OutputFilename) && File.Exists(OutputFilename)) Process.Start(OutputFilename); } catch (Exception ex) { Dialog.Ok("Open File", "Error while openning the file", ex.Message); } }; //Open folder. if (folderButton != null) folderButton.Click += (s, a) => { RaiseExploreFolderClickedEvent(); try { if (!string.IsNullOrWhiteSpace(OutputFilename) && Directory.Exists(OutputPath)) Process.Start("explorer.exe", $"/select,\"{OutputFilename}\""); } catch (Exception ex) { Dialog.Ok("Explore Folder", "Error while openning the folder", ex.Message); } }; //Details. Usually when something wrong happens. if (detailsButton != null) detailsButton.Click += (s, a) => { if (Exception != null) { var viewer = new ExceptionViewer(Exception); viewer.ShowDialog(); } }; //Copy (as image and text). if (copyMenu != null) copyMenu.Click += (s, a) => { if (!string.IsNullOrWhiteSpace(OutputFilename)) { var data = new DataObject(); data.SetImage(OutputFilename.SourceFrom()); data.SetText(OutputFilename, TextDataFormat.Text); data.SetFileDropList(new StringCollection { OutputFilename }); Clipboard.SetDataObject(data, true); } }; //Copy as image. if (copyImageMenu != null) copyImageMenu.Click += (s, a) => { if (!string.IsNullOrWhiteSpace(OutputFilename)) Clipboard.SetImage(OutputFilename.SourceFrom()); }; //Copy full path. if (copyFilenameMenu != null) copyFilenameMenu.Click += (s, a) => { if (!string.IsNullOrWhiteSpace(OutputFilename)) Clipboard.SetText(OutputFilename); }; //Copy folder path. if (copyFolderMenu != null) copyFolderMenu.Click += (s, a) => { if (!string.IsNullOrWhiteSpace(OutputPath)) Clipboard.SetText(OutputPath); }; }
private void DetailsButton_Click(object sender, RoutedEventArgs e) { var errorViewer = new ExceptionViewer(Exception); errorViewer.ShowDialog(); }
private void Application_Startup(object sender, StartupEventArgs e) { #region Unhandled Exceptions AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; #endregion #region Arguments try { if (e.Args.Length > 0) { //TODO: Watch for Args... } } catch (Exception ex) { var errorViewer = new ExceptionViewer(ex); errorViewer.ShowDialog(); LogWriter.Log(ex, "Generic Exception - Arguments"); } #endregion #region Upgrade Application Settings //See http://stackoverflow.com/questions/534261/how-do-you-keep-user-config-settings-across-different-assembly-versions-in-net if (Settings.Default.UpgradeRequired) { Settings.Default.Upgrade(); Settings.Default.UpgradeRequired = false; Settings.Default.Save(); } #endregion #region Language try { if (!Settings.Default.Language.Equals("auto")) { Thread.CurrentThread.CurrentCulture = new CultureInfo(Settings.Default.Language); Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Default.Language); } } catch (Exception ex) { var errorViewer = new ExceptionViewer(ex); errorViewer.ShowDialog(); LogWriter.Log(ex, "Language Settings Exception"); } #endregion try { #region Startup if (Settings.Default.StartUp == 0) { var startup = new Startup(); Current.MainWindow = startup; startup.ShowDialog(); } else if (Settings.Default.StartUp == 4) { var edit = new Editor(); Current.MainWindow = edit; edit.ShowDialog(); } else { var editor = new Editor(); List <FrameInfo> frames = null; ExitAction exitArg = ExitAction.Exit; bool? result = null; #region Recorder or Webcam if (Settings.Default.StartUp == 1) { var rec = new Recorder(true); result = rec.ShowDialog(); exitArg = rec.ExitArg; frames = rec.ListFrames; } else if (Settings.Default.StartUp == 2) { var web = new Windows.Webcam(); result = web.ShowDialog(); exitArg = web.ExitArg; frames = web.ListFrames; } else if (Settings.Default.StartUp == 3) { var board = new Board(); result = board.ShowDialog(); exitArg = board.ExitArg; frames = board.ListFrames; } #endregion if (result.HasValue && result.Value) { #region If Close Environment.Exit(0); #endregion } else if (result.HasValue) { #region If Backbutton or Stop Clicked if (exitArg == ExitAction.Recorded) { editor.ListFrames = frames; Current.MainWindow = editor; editor.ShowDialog(); } #endregion } } #endregion } catch (Exception ex) { var errorViewer = new ExceptionViewer(ex); errorViewer.ShowDialog(); LogWriter.Log(ex, "Generic Exception - Root"); } }
private void Application_Startup(object sender, StartupEventArgs e) { #region Unhandled Exceptions AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; #endregion #region Arguments try { if (e.Args.Length > 0) { Argument.Prepare(e.Args); } } catch (Exception ex) { var errorViewer = new ExceptionViewer(ex); errorViewer.ShowDialog(); LogWriter.Log(ex, "Generic Exception - Arguments"); } #endregion #region Upgrade Application Settings //See http://stackoverflow.com/questions/534261/how-do-you-keep-user-config-settings-across-different-assembly-versions-in-net if (Settings.Default.UpgradeRequired) { Settings.Default.Upgrade(); Settings.Default.UpgradeRequired = false; Settings.Default.Save(); } #endregion #region Language try { LocalizationHelper.SelectCulture(Settings.Default.Language); } catch (Exception ex) { var errorViewer = new ExceptionViewer(ex); errorViewer.ShowDialog(); LogWriter.Log(ex, "Language Settings Exception."); } #endregion //var select = new SelectFolderDialog(); //select.ShowDialog(); //var select = new TestField(); //select.ShowDialog(); //return; try { #region Startup if (Settings.Default.StartUp == 0) { var startup = new Startup(); Current.MainWindow = startup; startup.ShowDialog(); } else if (Settings.Default.StartUp == 4 || Argument.FileNames.Any()) { var edit = new Editor(); Current.MainWindow = edit; edit.ShowDialog(); } else { var editor = new Editor(); List <FrameInfo> frames = null; var exitArg = ExitAction.Exit; bool?result = null; #region Recorder, Webcam or Border switch (Settings.Default.StartUp) { case 1: var rec = new Recorder(true); Current.MainWindow = rec; result = rec.ShowDialog(); exitArg = rec.ExitArg; frames = rec.ListFrames; break; case 2: var web = new Windows.Webcam(true); Current.MainWindow = web; result = web.ShowDialog(); exitArg = web.ExitArg; frames = web.ListFrames; break; case 3: var board = new Board(); Current.MainWindow = board; result = board.ShowDialog(); exitArg = board.ExitArg; frames = board.ListFrames; break; } #endregion if (result.HasValue && result.Value) { #region If Close Environment.Exit(0); #endregion } else if (result.HasValue) { #region If Backbutton or Stop Clicked if (exitArg == ExitAction.Recorded) { editor.ListFrames = frames; Current.MainWindow = editor; editor.ShowDialog(); } #endregion } } #endregion } catch (Exception ex) { var errorViewer = new ExceptionViewer(ex); errorViewer.ShowDialog(); LogWriter.Log(ex, "Generic Exception - Root"); } }