public void Report() { ExceptionForm form = new ExceptionForm(message, ex); if (form.ShowDialog(owner) == DialogResult.OK) { ErrorReporter reporter = new ErrorReporter(); reporter.Report(ex); } }
private void ImportFilesInComponent(TreeNode node, XmlNode componentNode, string[] files) { if (componentNode.Name == "Component") { bool mustExpand = (node.Nodes.Count == 0); CurrentTreeView.SuspendLayout(); bool foundReg = false; foreach (string file in files) { if (Path.GetExtension(file).ToLower() == ".reg") { foundReg = true; break; } } bool importRegistryFiles = false; if (foundReg == true) { DialogResult result = MessageBox.Show(this, "Import Registry (*.reg) files to Registry elements?", "Import?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { return; } else if (result == DialogResult.Yes) { importRegistryFiles = true; } } WixFiles.UndoManager.BeginNewCommandRange(); StringBuilder errorMessageBuilder = new StringBuilder(); foreach (string file in files) { FileInfo fileInfo = new FileInfo(file); try { if (fileInfo.Extension.ToLower() == ".reg" && importRegistryFiles) { RegistryImport regImport = new RegistryImport(WixFiles, fileInfo, componentNode); regImport.Import(node); } else { FileImport fileImport = new FileImport(WixFiles, fileInfo, componentNode); fileImport.Import(node); } } catch (WixEditException ex) { errorMessageBuilder.AppendFormat("{0} ({1})\r\n", fileInfo.Name, ex.Message); } catch (Exception ex) { string message = String.Format("An exception occured during the import of \"{0}\"! Please press OK to report this error to the WixEdit website, so this error can be fixed.", fileInfo.Name); ExceptionForm form = new ExceptionForm(message, ex); if (form.ShowDialog() == DialogResult.OK) { ErrorReporter reporter = new ErrorReporter(); reporter.Report(ex); } } } if (errorMessageBuilder.Length > 0) { MessageBox.Show(this, "Import failed for the following files:\r\n\r\n" + errorMessageBuilder.ToString(), "Import failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } ShowNode(componentNode); if (mustExpand) { node.Expand(); } CurrentTreeView.ResumeLayout(); } }
static void Main() { string fileToOpen = null; string[] args = Environment.GetCommandLineArgs(); if (args.Length == 2) { string xmlFile = args[1]; if (xmlFile != null && xmlFile.Length > 0) { if (File.Exists(xmlFile)) { fileToOpen = xmlFile; } else if (xmlFile == "-last" || xmlFile == "/last") { string[] recentFiles = WixEditSettings.Instance.GetRecentlyUsedFiles(); if (recentFiles.Length > 0) { fileToOpen = recentFiles[0]; } } } } Process otherProcess = FindOtherProcess(); if (otherProcess != null) { IntPtr hWnd = otherProcess.MainWindowHandle; if (fileToOpen == null) { if (IsIconic(hWnd)) { ShowWindowAsync(hWnd, SW_RESTORE); } SetForegroundWindow(hWnd); } else { CopyDataMessenger.SendMessage(hWnd, "open|" + fileToOpen); } return; } Application.EnableVisualStyles(); Application.DoEvents(); Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); try { EditorForm editorForm = null; if (fileToOpen == null) { editorForm = new EditorForm(); } else { editorForm = new EditorForm(fileToOpen); } Application.Run(editorForm); } catch (Exception ex) { string message = "Caught unhandled exception! Please press OK to report this error to the WixEdit website, so this error can be fixed."; ExceptionForm form = new ExceptionForm(message, ex); if (form.ShowDialog() == DialogResult.OK) { ErrorReporter reporter = new ErrorReporter(); reporter.Report(ex); } } }
private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { if (e.Exception.InnerException is IncludeFileChangedException) { IncludeFileChangedException ifcException = e.Exception.InnerException as IncludeFileChangedException; ifcException.UndoManager.Undo(false); if (ifcException.NotifyUser) { MessageBox.Show(String.Format("You cannot change \"{0}\"", ifcException.Command.AffectedInclude), "Cannot change includes", MessageBoxButtons.OK, MessageBoxIcon.Information); } return; } else if (e.Exception is WixEditException) { MessageBox.Show(e.Exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string message = "Unable to perform your action, an error occured! Please press OK to report this error to the WixEdit website, so this error can be fixed."; ExceptionForm form = new ExceptionForm(message, e.Exception); if (form.ShowDialog() == DialogResult.OK) { ErrorReporter reporter = new ErrorReporter(); reporter.Report(e.Exception); } }
private void ReloadAll() { try { XmlNode current = null; if (tabButtonControl != null && tabButtonControl.SelectedPanel != null) { current = ((DisplayBasePanel)tabButtonControl.SelectedPanel).GetShowingNode(); } foreach (DisplayBasePanel panel in panels) { if (panel == null) { continue; } panel.BeginInvoke(new InvokeReloadDataDelegate(panel.ReloadData)); } if (current != null) { DisplayBasePanel panel = (DisplayBasePanel)tabButtonControl.SelectedPanel; panel.BeginInvoke(new InvokeShowNodeDelegate(panel.ShowNode), new object[] { current }); } } catch (Exception ex) { string message = "Error with reloading all views, please press OK to report this error to the WixEdit website, so this error can be fixed."; ExceptionForm form = new ExceptionForm(message, ex); if (form.ShowDialog() == DialogResult.OK) { ErrorReporter reporter = new ErrorReporter(); reporter.Report(ex); } } // Make sure all events are processed here, // otherwise the order of events cannot be guaranteed... Application.DoEvents(); }