private static void Handle(Exception ex) { Console.WriteLine(ex); if (!disableIME) { disableIME = true; OutputHandler outputHandler = new OutputHandler(); outputHandler.Show("Error calling IME: " + ex.Message + "\nIME is disabled.", "IME error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <remarks> /// Loads a file from the specified stream. /// </remarks> /// <param name="fileName">The name of the file to open. Used to find the correct highlighting strategy /// if autoLoadHighlighting is active, and sets the filename property to this value.</param> /// <param name="stream">The stream to actually load the file content from.</param> /// <param name="autoLoadHighlighting">Automatically load the highlighting for the file</param> /// <param name="autodetectEncoding">Automatically detect file encoding and set Encoding property to the detected encoding.</param> public void LoadFile(string fileName, Stream stream, bool autoLoadHighlighting, bool autodetectEncoding) { if (stream == null) { throw new ArgumentNullException("stream"); } BeginUpdate(); document.TextContent = string.Empty; document.UndoStack.ClearAll(); document.BookmarkManager.Clear(); if (autoLoadHighlighting) { try { document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(fileName); } catch (HighlightingDefinitionInvalidException ex) { OutputHandler outputHandler = new OutputHandler(); outputHandler.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (autodetectEncoding) { Encoding encoding1 = Encoding; Document.TextContent = Util.FileReader.ReadFileContent(stream, ref encoding1); Encoding = encoding1; } else { using (StreamReader reader = new StreamReader(fileName, Encoding)) { Document.TextContent = reader.ReadToEnd(); } } FileName = fileName; Document.UpdateQueue.Clear(); EndUpdate(); OptionsChanged(); Refresh(); }
protected virtual void OnReloadHighlighting(object sender, EventArgs e) { if (Document.HighlightingStrategy != null) { try { Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(Document.HighlightingStrategy.Name); } catch (HighlightingDefinitionInvalidException ex) { OutputHandler outputHandler = new OutputHandler(); outputHandler.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } OptionsChanged(); } }
public static void ShowOutput(string text) { OutputHandler outputHandler = new OutputHandler(); outputHandler.Show(text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }