/// <summary> /// Shows error /// </summary> /// <param name="e">Error exception</param> public static void ShowError(Exception e) { IErrorHandler eh = Diagram.UI.StaticExtensionDiagramUI.ErrorHandler; if (eh != null) { eh.ShowError(e, 1); return; } string err = ResourceService.Resources.GetControlResource("Error", controlResources); if (!(e is DiagramException)) { WindowsExtensions.ControlExtensions.ShowMessageBoxModal(null, e.Message, err, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DiagramException de = e as DiagramException; Form f = null; if (Diagram.UI.StaticExtensionDiagramUI.ErrorHandler is Form) { f = Diagram.UI.StaticExtensionDiagramUI.ErrorHandler as Form; } FormHelp fh = new FormHelp(e.Message, e, null); fh.ShowDialog(f); }
private void ButtonHelp_Click(object sender, EventArgs e) { using (FormHelp formHelp = new FormHelp()) { formHelp.ShowDialog(); } }
private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { FormHelp f2 = new FormHelp(); f2.ShowDialog(); }
protected override void OnHelpRequested(HelpEventArgs e) { base.OnHelpRequested(e); using (FormHelp formHelp = new FormHelp()) { formHelp.ShowDialog(); } }
/// <summary> /// Shows error /// </summary> /// <param name="form">Parent form</param> /// <param name="e">Inners exception</param> /// <param name="r">Resources</param> public static void ShowError(this Form form, Exception e, Dictionary <string, object>[] r) { Exception ex = e; if (ex.InnerException != null) { ex = ex.InnerException; } /* IErrorHandler eh = PureDesktop.ErrorHandler; * if (eh != null) * { * eh.ShowError(e); * return; * }*/ string message = ex.Message; string url = null; if (ex is INamedObject) { INamedObject n = ex as INamedObject; url = n.Name; } if (url == null) { if (errorResources != null) { string s = message; if (errorResources.ContainsKey(message)) { s = errorResources[message]; } if (s != null) { url = s; } else { int n = message.Length; IDictionaryEnumerator en = resources.GetEnumerator(); en.Reset(); while (en.MoveNext()) { string key = en.Key as string; string val = en.Value as string; if (val.Length <= n) { if (message.Substring(0, val.Length).Equals(val)) { s = errorResources[key] as string; if (s != null) { url = s; break; } } } } } } } string path = null; Stream stream = null; FormHelp f = null; if (r != null) { message = ResourceService.Resources.GetControlResource(ex.Message, r); } if (url != null) { string filename = url; try { path = currentDirectory + "Help\\" + filename; stream = File.OpenRead(path); stream.Close(); f = new FormHelp(message, ex, path); f.Left = form.Left + form.Width / 2 - f.Width / 2; f.Top = form.Top + form.Width / 2 - f.Width / 2; f.ShowDialog(form); return; } catch (Exception) { } } if (message.Equals(ex.Message)) { path = currentDirectory + "Help\\SystemError.htm"; try { stream = File.OpenRead(path); stream.Close(); } catch (Exception) { } try { message = ResourceService.Resources.GetControlResource("System error : ", r) + message + ResourceService.Resources.GetControlResource(" contact developer", r); f = new FormHelp(message, ex, path); f.Left = form.Left + form.Width / 2 - f.Width / 2; f.Top = form.Top + form.Width / 2 - f.Width / 2; f.ShowDialog(form); return; } catch (Exception) { } return; } /* if (url != null) * { * string filename = url; * try * { * path = currentDirectory + "Help\\" + filename; * stream = File.OpenRead(path); * stream.Close(); * f = new FormHelp(message, e, path); * f.Left = form.Left + form.Width / 2 - f.Width / 2; * f.Top = form.Top + form.Width / 2 - f.Width / 2; * f.ShowDialog(form); * return; * } * catch (Exception) * { * //ex = ex; * } * }*/ f = new FormHelp(message, ex, null); if (form != null) { f.Left = form.Left + form.Width / 2 - f.Width / 2; f.Top = form.Top + form.Width / 2 - f.Width / 2; } f.ShowDialog(form); return; }