Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
0
        private void fileExit_Click(object sender, System.EventArgs e)
        {
            EditorForm[] constEditorArray = new EditorForm[formInstances.Count];
            formInstances.CopyTo(constEditorArray);
            for (int i = 0; i < constEditorArray.Length; i++)
            {

                EditorForm edit = constEditorArray[i];

                if (edit == this)
                {
                    continue;
                }

                edit.Invoke(new VoidVoidDelegate(edit.Close));
            }

            this.Close();
        }
Esempio n. 3
0
        private void toolsOptions_Click(object sender, System.EventArgs e)
        {
            // Track changes to Xsd or Bin path or version, if it changes we need to restart/reload.
            string xsds = WixEditSettings.Instance.WixBinariesDirectory.Xsds;
            string version = WixEditSettings.Instance.WixBinariesVersion.Substring(0, 1);

            SettingsForm frm = new SettingsForm();
            frm.ShowDialog();

            if (xsds != WixEditSettings.Instance.WixBinariesDirectory.Xsds ||
                version != WixEditSettings.Instance.WixBinariesVersion.Substring(0, 1))
            {
                // Close all files...
                if (wixFiles != null || formInstances.Count > 1)
                {
                    MessageBox.Show("You must close all files first before the new setting can be applied.", "Apply settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    HandlePendingChanges(null, true);

                    this.CloseWxsFile();

                    EditorForm[] constEditorArray = new EditorForm[formInstances.Count];
                    formInstances.CopyTo(constEditorArray);
                    for (int i = 0; i < constEditorArray.Length; i++)
                    {
                        EditorForm edit = constEditorArray[i];

                        if (edit == this)
                        {
                            continue;
                        }

                        edit.Invoke(new VoidVoidDelegate(edit.ForceClose));
                    }

                    while (formInstances.Count != 1)
                    {
                        Thread.Sleep(100);
                    }

                    // and reload xsds.
                    WixFiles.ReloadXsd();

                    MessageBox.Show("Settings applied successfully.", "Apply settings", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    // and reload xsds.
                    WixFiles.ReloadXsd();
                }

                if (xsdWarningIsDone == false && WixFiles.CheckForXsd() == false)
                {
                    xsdWarningIsDone = true;

                    if (String.IsNullOrEmpty(WixEditSettings.Instance.WixBinariesDirectory.BinDirectory) ||
                    Directory.Exists(WixEditSettings.Instance.WixBinariesDirectory.BinDirectory) == false)
                    {
                        MessageBox.Show("Windows Installer XML (WiX) Toolset installation is required to run WixEdit.\r\n\r\nThe WiX installation can be downloaded from http://wix.sourceforge.net/. Please download and install WiX and specify the install location in the WixEdit options.", "Missing WiX");
                    }
                    else
                    {
                        MessageBox.Show("Please check your WiX installation!\r\n\r\nCannot find Wix.xsd! It should be located in the 'doc' subdirectory of your WiX installation. Please check your WiX installation and the XSDs location in the WixEdit options. This file is required to determine the correct xml schema for your version of WiX.", "Missing Wix.xsd");
                    }
                }
            }
        }