Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
                }
            }
        }
Beispiel #3
0
        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();
        }