public override void PopulateRecordBar(RecordList recList) { CheckDisposed(); // The ListBar has a problem in that when it is populated for the first time the horizonal // scroll scrolls over a little ways over hiding the left most + or -. I (Rand) sent some // time searching this out and found that it is a bug in the ListView control. It is not // our bug. The scrolling happens when EnsureVisible() is called on the listview. I found // a way around it. By calling this method twice the bug goes away, it looks like the list // must be populated, cleared, then repopulated before the bug is bypassed. There are also // other things that have an effect on it, such as ClearListBar() must be before // BeginUpdate(). Also selection must be made before ExpandAll() or CollapseAll() is called. // JohnT: no, the problem is when we EnsureVisible of a node that is wider than the window. // EnsureVisble tries to show as much as possible of the label; since it won't fit, it scrolls // horizontally and hides the plus/minus. // To avoid this if it is desired to EnsureVisible, use the EnsureSelectedNodeVisible routine // (which temporarily makes the label short while calling EnsureVisible). // (I'm not sure why Rand's comment is in this exact location, so I'm not deleting it.) if (this.IsShowing) { m_fOutOfDate = false; } else { m_fOutOfDate = true; return; } XWindow window = (XWindow)m_mediator.PropertyTable.GetValue("window"); window.TreeBarControl.IsFlatList = true; window.Cursor = Cursors.WaitCursor; ListView list = (ListView)window.ListStyleRecordList; list.BeginUpdate(); window.ClearRecordBarList(); //don't want to directly clear the nodes, because that causes an event to be fired as every single note is removed! m_hvoToListViewItemTable.Clear(); AddListViewItems(recList.SortedObjects, list); try { list.Font = new System.Drawing.Font(recList.FontName, recList.TypeSize); } catch (Exception error) { ErrorReporter.ReportException(error, null, false); } UpdateSelection(recList.CurrentObject); list.EndUpdate(); if (list.SelectedItems.Count > 0) { } //list.s .EnsureVisible(); window.Cursor = Cursors.Default; }
private void m_timer_Tick(object sender, EventArgs e) { if (m_parserListener == null) { return; } m_statusLabel.Text = m_parserListener.ParserActivityString; if (m_parserListener.Connection == null) { m_statusLabel.Text = ParserStoppedMessage(); return; } Exception ex = m_parserListener.Connection.UnhandledException; if (ex != null) { m_parserListener.DisconnectFromParser(); m_statusLabel.Text = ParserStoppedMessage(); m_tryItButton.Enabled = true; var app = (IApp)m_mediator.PropertyTable.GetValue("App"); ErrorReporter.ReportException(ex, app.SettingsKey, app.SupportEmailAddress, this, false); return; } if (m_tryAWordResult != null && m_tryAWordResult.IsCompleted) { var result = (XDocument)m_tryAWordResult.AsyncState; CreateResultPage(result); m_tryAWordResult = null; // got result so enable Try It button m_tryItButton.Enabled = true; } }
// Now called by timer AND by OnIdle private void UpdateStatusPanelProgress() { var statusMessage = ParserQueueString + " " + ParserActivityString; m_propertyTable.SetProperty("StatusPanelProgress", statusMessage, true); m_propertyTable.SetPropertyPersistence("StatusPanelProgress", false); if (m_parserConnection != null) { Exception ex = m_parserConnection.UnhandledException; if (ex != null) { DisconnectFromParser(); var app = m_propertyTable.GetValue <IApp>("App"); ErrorReporter.ReportException(ex, app.SettingsKey, app.SupportEmailAddress, app.ActiveMainWindow, false); } else { string notification = m_parserConnection.GetAndClearNotification(); if (notification != null) { m_mediator.SendMessage("ShowNotification", notification); } } } if (ParserActivityString == ParserUIStrings.ksIdle_ && m_timer.Enabled) { StopUpdateProgressTimer(); } }
public void ReportNonFatalException(Exception exception, IRepeatNoticePolicy policy) { if (policy.ShouldShowErrorReportDialog(exception)) { ErrorReporter.ReportException(exception, m_registryKey, m_supportEmailAddress, m_parentForm, false); } }
public ErrorResult NotifyUserOfProblem(IRepeatNoticePolicy policy, string alternateButton1Label, ErrorResult resultIfAlternateButtonPressed, string message) { return(policy.ShouldShowMessage(message) && ErrorReporter.ReportException(new Exception(message), m_registryKey, m_supportEmailAddress, m_parentForm, false) ? ErrorResult.Abort : ErrorResult.Ignore); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Ensures the given localization is at the current version. /// </summary> /// <param name="locale">The locale representing the required localization.</param> /// <param name="caller">The form that is calling this method (used as the owner /// of the progress dialog box - can be null if progress dialog is supplied).</param> /// <param name="existingProgressDlg">The existing progress dialog box if any.</param> /// ------------------------------------------------------------------------------------ private void EnsureCurrentLocalization(string locale, Form caller, IThreadedProgress existingProgressDlg) { string localizationFile = FwDirectoryFinder.GetKeyTermsLocFilename(locale); if (!FileUtils.FileExists(localizationFile)) { return; // There is no localization available for this locale, so we're as current as we're going to get. } BiblicalTermsLocalization loc; try { loc = DeserializeBiblicalTermsLocFile(localizationFile); } catch (InstallationException e) { ErrorReporter.ReportException(e, m_app.SettingsKey, m_app.SupportEmailAddress, caller, false); return; } string resourceName = GetLocalizationResourceName(locale); if (IsResourceOutdated(resourceName, loc.Version)) { NonUndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(m_servLoc.GetInstance <IActionHandler>(), () => { existingProgressDlg.RunTask(true, UpdateLocalization, loc, locale); SetNewResourceVersion(resourceName, loc.Version); }); } }
private bool Validate(string sFilename, string sOrigFile) { try { m_progressDlg.Message = LexTextControls.ksValidatingInputFile; Validator.CheckLiftWithPossibleThrow(sFilename); return(true); } catch (LiftFormatException lfe) { string sProducer = GetLiftProducer(sOrigFile); string sMsg; if (sProducer == null) { sMsg = String.Format(LexTextControls.ksFileNotALIFTFile, sOrigFile); } else if (sFilename == sOrigFile) { sMsg = String.Format(LexTextControls.ksInvalidLiftFile, sOrigFile, sProducer); } else { sMsg = String.Format(LexTextControls.ksInvalidMigratedLiftFile, sOrigFile, sProducer); } // Show the pretty yellow semi-crash dialog box, with instructions for the // user to report the bug. Then ask the user whether to continue. IApp app = m_propertyTable.GetValue <IApp>("App"); ErrorReporter.ReportException(new Exception(sMsg, lfe), app.SettingsKey, m_propertyTable.GetValue <IFeedbackInfoProvider>("FeedbackInfoProvider").SupportEmailAddress, this, false); return(MessageBox.Show(LexTextControls.ksContinueLiftImportQuestion, LexTextControls.ksProblemImporting, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes); } }
/// <summary> /// Shows the record on idle. This is where the record is actually shown. /// </summary> /// <param name="parameter">The parameter.</param> bool ShowRecordOnIdle(object parameter) { if (IsDisposed) { return(true); } base.ShowRecord(); int msStart = Environment.TickCount; Debug.Assert(m_dataEntryForm != null); var rni = (RecordNavigationInfo)parameter; bool oldSuppressSaveOnChangeRecord = Clerk.SuppressSaveOnChangeRecord; Clerk.SuppressSaveOnChangeRecord = rni.SuppressSaveOnChangeRecord; PrepCacheForNewRecord(); Clerk.SuppressSaveOnChangeRecord = oldSuppressSaveOnChangeRecord; if (Clerk.CurrentObject == null || Clerk.SuspendLoadingRecordUntilOnJumpToRecord) { m_dataEntryForm.Hide(); m_dataEntryForm.Reset(); // in case user deleted the object it was based upon. return(true); } try { m_dataEntryForm.Show(); // Enhance: Maybe do something here to allow changing the templates without the starting the application. ICmObject obj = Clerk.CurrentObject; if (m_showDescendantInRoot) { // find the root object of the current object while (obj.Owner != Clerk.OwningObject) { obj = obj.Owner; } } m_dataEntryForm.ShowObject(obj, m_layoutName, m_layoutChoiceField, Clerk.CurrentObject, ShouldSuppressFocusChange(rni)); } catch (Exception error) { if (m_mediator.PropertyTable.GetBoolProperty("DoingAutomatedTest", false)) { throw; } //don't really need to make the program stop just because we could not show this record. IApp app = (IApp)m_mediator.PropertyTable.GetValue("App"); ErrorReporter.ReportException(error, app.SettingsKey, m_mediator.FeedbackInfoProvider.SupportEmailAddress, null, false); } int msEnd = Environment.TickCount; Debug.WriteLineIf(RuntimeSwitches.RecordTimingSwitch.TraceInfo, "ShowRecord took " + (msEnd - msStart) + " ms", RuntimeSwitches.RecordTimingSwitch.DisplayName); return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Reports an exception that is thrown during attempt to load valid characters. In /// test mode (where we have no UI), the exception is merely stored. /// </summary> /// ------------------------------------------------------------------------------------ private static void ReportError(Exception e) { if (!s_fTestingMode) { ErrorReporter.ReportException(e, null, false); } s_lastException = e; }
protected override void ShowRecord() { //todo: add the document view name to the task label //todo: fast machine, this doesn't really seem to do any good. I think maybe the parts that //are taking a longtime are not getting Breath(). //todo: test on a machine that is slow enough to see if this is helpful or not! using (ProgressState progress = FwXWindow.CreatePredictiveProgressState(m_mediator, this.m_vectorName)) { progress.Breath(); Debug.Assert(m_rootSite != null); progress.Breath(); base.ShowRecord(); Clerk.SaveOnChangeRecord(); progress.Breath(); if (Clerk.CurrentObject == null) { m_rootSite.Hide(); return; } try { progress.SetMilestone(); m_rootSite.Show(); using (new WaitCursor(this)) { IChangeRootObject root = m_rootSite as IChangeRootObject; if (root != null && !Clerk.SuspendLoadingRecordUntilOnJumpToRecord) { root.SetRoot(Clerk.CurrentObject.Hvo); } } } catch (Exception error) { if (m_mediator.PropertyTable.GetBoolProperty("DoingAutomatedTest", false)) { throw; } else //don't really need to make the program stop just because we could not show this record. { IApp app = (IApp)m_mediator.PropertyTable.GetValue("App"); ErrorReporter.ReportException(error, app.SettingsKey, m_mediator.FeedbackInfoProvider.SupportEmailAddress, null, false); } } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Catches and displays a otherwise unhandled exception. /// </summary> /// <param name="sender">sender</param> /// <param name="eventArgs">Exception</param> /// <remarks> we override this because for a configurable application, sometimes you just /// want to tell the person writing a configuration that they made a typo.</remarks> /// ------------------------------------------------------------------------------------ protected override void HandleTopLevelError(object sender, ThreadExceptionEventArgs eventArgs) { CheckDisposed(); if (BasicUtils.IsUnsupportedCultureException(eventArgs.Exception)) // LT-8248 { Logger.WriteEvent("Unsupported culture: " + eventArgs.Exception.Message); return; } ErrorReporter.ReportException(eventArgs.Exception); // if (eventArgs.Exception is ConfigurationException) // ((ConfigurationException)eventArgs.Exception).ShowDialog(); // else // base.HandleTopLevelError(sender, eventArgs); }
private void m_timer_Tick(object sender, EventArgs e) { m_statusLabel.Text = m_parserListener.ParserActivityString; if (m_parserListener.Connection == null) { m_statusLabel.Text = ParserStoppedMessage(); return; } Exception ex = m_parserListener.Connection.UnhandledException; if (ex != null) { m_parserListener.DisconnectFromParser(); m_statusLabel.Text = ParserStoppedMessage(); m_tryItButton.Enabled = true; var app = (IApp)m_mediator.PropertyTable.GetValue("App"); ErrorReporter.ReportException(ex, app.SettingsKey, app.SupportEmailAddress, this, false); return; } if (m_tryAWordResult != null && m_tryAWordResult.IsCompleted) { var message = (string)m_tryAWordResult.AsyncState; string sOutput; if (!message.TrimStart().StartsWith("<")) { // It's an error message. sOutput = Path.GetTempFileName(); var writer = new StreamWriter(sOutput); writer.WriteLine("<!DOCTYPE html>"); writer.WriteLine("<body>"); writer.WriteLine(message); writer.WriteLine("</body>"); writer.WriteLine("</html>"); writer.Close(); } else { sOutput = m_webPageInteractor.ParserTrace.CreateResultPage((string)m_tryAWordResult.AsyncState); } m_htmlControl.URL = sOutput; m_tryAWordResult = null; // got result so enable Try It button m_tryItButton.Enabled = true; } }
private void m_timer_Tick(object sender, EventArgs e) { if (m_parserListener == null) { return; } m_statusLabel.Text = m_parserListener.ParserActivityString; if (m_parserListener.Connection == null) { m_statusLabel.Text = ParserStoppedMessage(); return; } Exception ex = m_parserListener.Connection.UnhandledException; if (ex != null) { m_parserListener.DisconnectFromParser(); m_statusLabel.Text = ParserStoppedMessage(); m_tryItButton.Enabled = true; var iree = ex as InvalidReduplicationEnvironmentException; if (iree != null) { string msg = String.Format(ParserUIStrings.ksHermitCrabReduplicationProblem, iree.Morpheme, iree.Message); MessageBox.Show(this, msg, ParserUIStrings.ksBadAffixForm, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var app = (IApp)m_mediator.PropertyTable.GetValue("App"); ErrorReporter.ReportException(ex, app.SettingsKey, app.SupportEmailAddress, this, false); } return; } if (m_tryAWordResult != null && m_tryAWordResult.IsCompleted) { var result = (XDocument)m_tryAWordResult.AsyncState; CreateResultPage(result); m_tryAWordResult = null; // got result so enable Try It button m_tryItButton.Enabled = true; } }
// Now called by timer AND by OnIdle private void UpdateStatusPanelProgress() { var statusMessage = ParserQueueString + " " + ParserActivityString; m_mediator.PropertyTable.SetProperty("StatusPanelProgress", statusMessage); m_mediator.PropertyTable.SetPropertyPersistence("StatusPanelProgress", false); if (m_parserConnection != null) { Exception ex = m_parserConnection.UnhandledException; if (ex != null) { DisconnectFromParser(); var iree = ex as InvalidReduplicationEnvironmentException; if (iree != null) { string msg = String.Format(ParserUIStrings.ksHermitCrabReduplicationProblem, iree.Morpheme, iree.Message); MessageBox.Show(Form.ActiveForm, msg, ParserUIStrings.ksBadAffixForm, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var app = (IApp)m_mediator.PropertyTable.GetValue("App"); ErrorReporter.ReportException(ex, app.SettingsKey, app.SupportEmailAddress, app.ActiveMainWindow, false); } } else { string notification = m_parserConnection.GetAndClearNotification(); if (notification != null) { m_mediator.SendMessage("ShowNotification", notification); } } } if (ParserActivityString == ParserUIStrings.ksIdle_ && m_timer.Enabled) { StopUpdateProgressTimer(); } }
public void ReportNonFatalExceptionWithMessage(Exception error, string message, params object[] args) { ErrorReporter.ReportException(new Exception(string.Format(message, args), error), m_registryKey, m_supportEmailAddress, m_parentForm, false); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Reports a ValidCharacters load exception. /// </summary> /// <param name="e">The exception.</param> /// ------------------------------------------------------------------------------------ void LoadException(ArgumentException e) { ErrorReporter.ReportException(e, SettingsKey, SupportEmailAddress); }
static void Main(string[] args) { Form window = null; var needCleanup = true; try { // needed to access proper registry values FwRegistryHelper.Initialize(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); switch (args.FirstOrDefault()) { case "-i": case "-install": case "--install": // If we have any custom character data, install it! FwUtils.InitializeIcu(); var customCharsFile = CharEditorWindow.CustomCharsFile; if (File.Exists(customCharsFile)) { new PUAInstaller().InstallPUACharacters(customCharsFile); } break; case "--cleanup": // If the second argument is a Process ID (int), wait up to five minutes for the proces to exit and then clean up; // otherwise, silently do nothing. needCleanup = false; int pid; if (int.TryParse(args.LastOrDefault(), out pid)) { var iterationCount = 0; while (Process.GetProcesses().Any(p => p.Id == pid) && iterationCount < 300) { // wait 1s then try again Thread.Sleep(1000); iterationCount++; } if (iterationCount < 300) { DeleteTemporaryFiles(); } } break; case null: // There were no arguments (the program was double-clicked or opened through the Start menu); run the graphical interface FwUtils.InitializeIcu(); window = new CharEditorWindow(); Application.Run(window); break; default: // An unrecognized argument was passed MessageBox.Show("Only one command line argument is recognized:" + Environment.NewLine + "\t-i means to install the custom character definitions (as a command line program).", "Unicode Character Editor"); break; } } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Unicode Character Properties Editor"); } catch (Exception ex) { // Be very, very careful about changing stuff here. Code here MUST not throw exceptions, // even when the application is in a crashed state. try { ErrorReporter.ReportException(ex, null, null, window, true); } catch { MessageBox.Show(ex.Message, "Unicode Character Properties Editor"); } } finally { window?.Dispose(); LogFile.Release(); if (needCleanup) { StartCleanup(); } } }
private void MakeSubControl(XmlNode configuration, Size parentSizeHint, bool isFirst) { XmlNode dynLoaderNode = configuration.SelectSingleNode("dynamicloaderinfo"); if (dynLoaderNode == null) { throw new ArgumentException("Required 'dynamicloaderinfo' XML node not found, while trying to make control for MultiPane.", "configuration"); } string contentAssemblyPath = XmlUtils.GetManditoryAttributeValue(dynLoaderNode, "assemblyPath"); string contentClass = XmlUtils.GetManditoryAttributeValue(dynLoaderNode, "class"); try { Control subControl = (Control)DynamicLoader.CreateObject(contentAssemblyPath, contentClass); if (subControl.AccessibleName == null) { subControl.AccessibleName = contentClass; } if (!(subControl is IxCoreColleague)) { throw new ApplicationException( "XCore can only handle controls which implement IxCoreColleague. " + contentClass + " does not."); } if (!(subControl is IXCoreUserControl)) { throw new ApplicationException( "XCore can only handle controls which implement IXCoreUserControl. " + contentClass + " does not."); } subControl.SuspendLayout(); subControl.Dock = DockStyle.Fill; // we add this before Initializing so that this child control will have access // to its eventual height and width, in case it needs to make initialization // decisions based on that. for example, if the child is another multipane, it // will use this to come up with a reasonable default location for its splitter. if (subControl is MultiPane) { MultiPane mpSubControl = subControl as MultiPane; mpSubControl.ParentSizeHint = parentSizeHint; // cause our subcontrol to inherit our DefaultPrintPane property. mpSubControl.DefaultPrintPaneId = m_defaultPrintPaneId; } // we add this before Initializing so that this child control will have access // to its eventual height and width, in case it needs to make initialization // decisions based on that. for example, if the child is another multipane, it // will use this to come up with a reasonable default location for its splitter. if (subControl is PaneBarContainer) { PaneBarContainer mpSubControl = subControl as PaneBarContainer; mpSubControl.ParentSizeHint = parentSizeHint; // cause our subcontrol to inherit our DefaultPrintPane property. mpSubControl.DefaultPrintPaneId = m_defaultPrintPaneId; } XmlNode parameters = null; if (configuration != null) { parameters = configuration.SelectSingleNode("parameters"); } ((IxCoreColleague)subControl).Init(m_mediator, parameters); // in normal situations, colleagues add themselves to the mediator when // initialized. in this case, we don't want this colleague to add itself // because we want it to be subservient to this "papa" control. however, since // this control is only experimental, I'm loathe to change the interfaces in // such a way as to tell a colleague that it should not add itself to the // mediator. so, for now, we will just do this hack and remove the colleague // from the mediator. m_mediator.RemoveColleague((IxCoreColleague)subControl); if (isFirst) { subControl.AccessibleName += ".First"; FirstControl = subControl; } else { subControl.AccessibleName += ".Second"; SecondControl = subControl; } subControl.ResumeLayout(false); } catch (Exception error) { string s = "Something went wrong trying to create a " + contentClass + "."; XWindow window = (XWindow)m_mediator.PropertyTable.GetValue("window"); ErrorReporter.ReportException(new ApplicationException(s, error), window.ApplicationRegistryKey, m_mediator.FeedbackInfoProvider.SupportEmailAddress); } }
public void ReportFatalMessageWithStackTrace(string message, object[] args) { ErrorReporter.ReportException(new Exception(string.Format(message, args)), m_registryKey, m_supportEmailAddress, m_parentForm, true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Reports a load exception in the scrDataSource. /// </summary> /// <param name="e">The exception.</param> /// ------------------------------------------------------------------------------------ void scrDataSource_LoadException(ArgumentException e) { ErrorReporter.ReportException(e, m_app.SettingsKey, m_app.SupportEmailAddress, ParentForm, false); }
/// <summary> /// show a dialog or output to the error log, as appropriate. /// </summary> /// <param name="error">the exception you want to report</param> /// <param name="isLethal">set to <c>true</c> if the error is lethal, otherwise /// <c>false</c>.</param> public void ReportException(Exception error, bool isLethal) { m_synchronizeInvoke.Invoke(() => ErrorReporter.ReportException(error, null, null, null, isLethal)); }