コード例 #1
0
ファイル: EditorForm.cs プロジェクト: xwiz/WixEdit
        private void Decompile(string fileName, OutputPanel.OnCompleteDelegate onComplete)
        {
            FileInfo msiFile = new FileInfo(fileName);

            string darkExe = WixEditSettings.Instance.WixBinariesDirectory.Dark;
            if (File.Exists(darkExe) == false)
            {
                throw new WixEditException("The executable \"dark.exe\" could not be found.\r\n\r\nPlease specify the correct path to the Wix binaries in the settings dialog.");
            }

            ProcessStartInfo psiDark = new ProcessStartInfo();
            psiDark.FileName = darkExe;
            psiDark.CreateNoWindow = true;
            psiDark.UseShellExecute = false;
            psiDark.RedirectStandardOutput = true;
            psiDark.RedirectStandardError = false;
            psiDark.Arguments = String.Format("-nologo -x \"{0}\" \"{1}\" \"{2}\"", msiFile.DirectoryName, msiFile.FullName, Path.ChangeExtension(msiFile.FullName, "wxs"));

            ShowOutputPanel();
            outputPanel.Clear();
            Update();

            outputPanel.Run(psiDark, onComplete);
        }
コード例 #2
0
ファイル: EditorForm.cs プロジェクト: xwiz/WixEdit
        private void InitializeComponent()
        {
            formInstances.Add(this);

            Text = "WiX Edit";
            Icon = new Icon(WixFiles.GetResourceStream("dialog.source.ico"));
            ClientSize = new Size(800, 600);
            MinimumSize = new Size(250, 200);

            //allow drag&drop of files
            this.AllowDrop = true;
            this.DragEnter += new DragEventHandler(EditorForm_DragEnter);
            this.DragDrop += new DragEventHandler(EditorForm_DragDrop);

            openWxsFileDialog = new OpenFileDialog();

            mainMenu = new MainMenu();
            fileMenu = new IconMenuItem();
            fileNew = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.new.bmp")));
            fileNewEmpty = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.new.bmp")));
            fileLoad = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.open.bmp")));
            fileRecent = new IconMenuItem();
            fileRecentEmpty = new IconMenuItem();
            fileRecentClean = new IconMenuItem();
            fileRecentClear = new IconMenuItem();
            fileSave = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.save.bmp")));
            fileSaveAs = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.saveas.bmp")));
            fileClose = new IconMenuItem();
            fileSeparator = new IconMenuItem("-");
            fileExit = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.exit.bmp")));

            fileNew.Text = "&New";
            fileNew.Click += new EventHandler(fileNew_Click);
            fileNew.Shortcut = Shortcut.CtrlN;
            fileNew.ShowShortcut = true;

            fileNewEmpty.Text = "New empty file";
            fileNewEmpty.Click += new EventHandler(fileNewEmpty_Click);
            fileNewEmpty.ShowShortcut = true;

            fileLoad.Text = "&Open";
            fileLoad.Click += new EventHandler(fileLoad_Click);
            fileLoad.Shortcut = Shortcut.CtrlO;
            fileLoad.ShowShortcut = true;

            fileRecentEmpty.Text = "Empty";
            fileRecentEmpty.Enabled = false;
            fileRecentEmpty.ShowShortcut = true;

            fileRecent.Text = "&Reopen";
            fileRecent.Popup += new EventHandler(fileRecent_Popup);
            fileRecent.ShowShortcut = true;
            fileRecent.MenuItems.Add(0, fileRecentEmpty);

            fileRecentClean.Text = "Remove obsolete";
            fileRecentClean.Click += new EventHandler(recentFileClean_Click);
            fileRecentClean.ShowShortcut = true;

            fileRecentClear.Text = "Remove all";
            fileRecentClear.Click += new EventHandler(recentFileClear_Click);
            fileRecentClear.ShowShortcut = true;

            fileSave.Text = "&Save";
            fileSave.Click += new EventHandler(fileSave_Click);
            fileSave.Enabled = false;
            fileSave.Shortcut = Shortcut.CtrlS;
            fileSave.ShowShortcut = true;

            fileSaveAs.Text = "Save &As";
            fileSaveAs.Click += new EventHandler(fileSaveAs_Click);
            fileSaveAs.Enabled = false;
            fileSaveAs.ShowShortcut = false;

            fileIsDirty = false;

            fileClose.Text = "&Close";
            fileClose.Click += new EventHandler(fileClose_Click);
            fileClose.Enabled = false;
            fileClose.Shortcut = Shortcut.CtrlW;
            fileClose.ShowShortcut = true;

            fileExit.Text = "&Exit";
            fileExit.Click += new EventHandler(fileExit_Click);
            fileExit.ShowShortcut = true;

            fileMenu.Text = "&File";
            fileMenu.Popup += new EventHandler(fileMenu_Popup);
            fileMenu.MenuItems.Add(0, fileNew);
            fileMenu.MenuItems.Add(1, fileNewEmpty);
            fileMenu.MenuItems.Add(2, fileLoad);
            fileMenu.MenuItems.Add(3, fileRecent);
            fileMenu.MenuItems.Add(4, fileSave);
            fileMenu.MenuItems.Add(5, fileSaveAs);
            fileMenu.MenuItems.Add(6, fileClose);
            fileMenu.MenuItems.Add(7, fileSeparator);
            fileMenu.MenuItems.Add(8, fileExit);

            mainMenu.MenuItems.Add(0, fileMenu);

            editMenu = new IconMenuItem();
            editUndo = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.undo.bmp")));
            editRedo = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.redo.bmp")));
            editFind = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.find.bmp")));
            editFindNext = new IconMenuItem();
            editFindPrev = new IconMenuItem();
            editWizard = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.wizard.bmp")));

            if (wixFiles == null ||
                WixEditSettings.Instance.ExternalXmlEditor == null ||
                File.Exists(WixEditSettings.Instance.ExternalXmlEditor) == false)
            {
                toolsExternal = new IconMenuItem();
            }
            else
            {
                Icon ico = FileIconFactory.GetFileIcon(WixEditSettings.Instance.ExternalXmlEditor);
                toolsExternal = new IconMenuItem(ico);
            }

            editUndo.Text = "&Undo";
            editUndo.Click += new EventHandler(editUndo_Click);
            editUndo.Shortcut = Shortcut.CtrlZ;
            editUndo.ShowShortcut = true;

            editRedo.Text = "&Redo";
            editRedo.Click += new EventHandler(editRedo_Click);
            editRedo.Shortcut = Shortcut.CtrlY;
            editRedo.ShowShortcut = true;

            editFind.Text = "&Find";
            editFind.Click += new EventHandler(editFind_Click);
            editFind.Shortcut = Shortcut.CtrlF;
            editFind.ShowShortcut = true;

            editFindNext.Text = "Find &Next";
            editFindNext.Click += new EventHandler(editFindNext_Click);
            editFindNext.Shortcut = Shortcut.F3;
            editFindNext.ShowShortcut = true;

            editFindPrev.Text = "Find &Previous";
            editFindPrev.Click += new EventHandler(editFindPrev_Click);
            editFindPrev.Shortcut = Shortcut.ShiftF3;
            editFindPrev.ShowShortcut = true;

            editWizard.Text = "Add Functionality";
            editWizard.Click += new EventHandler(editWizard_Click);
            editWizard.ShowShortcut = true;

            editMenu.Text = "&Edit";
            editMenu.Popup += new EventHandler(editMenu_Popup);
            editMenu.MenuItems.Add(0, editUndo);
            editMenu.MenuItems.Add(1, editRedo);
            editMenu.MenuItems.Add(2, new IconMenuItem("-"));
            editMenu.MenuItems.Add(3, editFind);
            editMenu.MenuItems.Add(4, editFindNext);
            editMenu.MenuItems.Add(5, editFindPrev);
            editMenu.MenuItems.Add(6, new IconMenuItem("-"));
            editMenu.MenuItems.Add(7, editWizard);

            mainMenu.MenuItems.Add(1, editMenu);

            toolsMenu = new IconMenuItem();
            toolsOptions = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.options.bmp")));
            buildProjectSettings = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.settings.bmp")));
            buildWixCompile = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("compile.compile.bmp")));
            buildWixInstall = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("compile.uninstall.bmp")));
            buildWixUninstall = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("compile.install.bmp")));
            buildMenu = new IconMenuItem();

            buildWixCompile.Text = "&Build MSI setup package";
            buildWixCompile.Click += new EventHandler(buildWixCompile_Click);
            buildWixCompile.Enabled = false;
            buildWixCompile.Shortcut = Shortcut.CtrlB;
            buildWixCompile.ShowShortcut = true;

            buildWixInstall.Text = "&Install MSI setup package";
            buildWixInstall.Click += new EventHandler(buildWixInstall_Click);
            buildWixInstall.Enabled = false;
            buildWixInstall.Shortcut = Shortcut.F5;
            buildWixInstall.ShowShortcut = true;

            buildWixUninstall.Text = "&Uninstall MSI setup package";
            buildWixUninstall.Click += new EventHandler(buildWixUninstall_Click);
            buildWixUninstall.Enabled = false;
            buildWixUninstall.Shortcut = Shortcut.ShiftF5;
            buildWixUninstall.ShowShortcut = true;

            buildProjectSettings.Text = "&Build Settings";
            buildProjectSettings.Click += new EventHandler(buildProjectSettings_Click);
            buildProjectSettings.Enabled = false;

            buildMenu.Text = "&Build";
            buildMenu.Popup += new EventHandler(buildMenu_Popup);
            buildMenu.MenuItems.Add(0, buildWixCompile);
            buildMenu.MenuItems.Add(1, new IconMenuItem("-"));
            buildMenu.MenuItems.Add(2, buildWixInstall);
            buildMenu.MenuItems.Add(3, buildWixUninstall);
            buildMenu.MenuItems.Add(4, new IconMenuItem("-"));
            buildMenu.MenuItems.Add(5, buildProjectSettings);

            mainMenu.MenuItems.Add(2, buildMenu);

            toolsOptions.Text = "&Options";
            toolsOptions.Click += new EventHandler(toolsOptions_Click);

            toolsExternal.Text = "Launch &External Editor";
            toolsExternal.Click += new EventHandler(toolsExternal_Click);
            toolsExternal.Shortcut = Shortcut.CtrlE;
            toolsExternal.ShowShortcut = true;

            toolsMenu.Text = "&Tools";
            toolsMenu.Popup += new EventHandler(toolsMenu_Popup);
            toolsMenu.MenuItems.Add(0, toolsExternal);
            toolsMenu.MenuItems.Add(1, new IconMenuItem("-"));
            toolsMenu.MenuItems.Add(2, toolsOptions);

            mainMenu.MenuItems.Add(3, toolsMenu);

            helpMenu = new IconMenuItem();
            helpTutorial = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.web.bmp")));
            helpMSIReference = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.web.bmp")));
            helpWiXReference = new IconMenuItem(new Bitmap(WixFiles.GetResourceStream("bmp.wix.bmp")));
            helpAbout = new IconMenuItem(new Icon(WixFiles.GetResourceStream("dialog.source.ico"), 16, 16));
            helpStateBrowser = new IconMenuItem();

            helpTutorial.Text = "WiX Tutorial";
            helpTutorial.Click += new EventHandler(helpTutorial_Click);

            helpMSIReference.Text = "Windows Installer Reference";
            helpMSIReference.Click += new EventHandler(helpMSIReference_Click);

            helpWiXReference.Text = "WiX Reference";
            helpWiXReference.Click += new EventHandler(helpWiXReference_Click);

            helpAbout.Text = "&About";
            helpAbout.Click += new EventHandler(helpAbout_Click);

            helpMenu.Text = "&Help";
            helpMenu.MenuItems.Add(helpTutorial);
            helpMenu.MenuItems.Add(helpMSIReference);
            string xsdDir = WixEditSettings.Instance.WixBinariesDirectory.Xsds;
            if (xsdDir != String.Empty &&
                File.Exists(Path.Combine(xsdDir, "WiX.chm")))
            {
                helpMenu.MenuItems.Add(helpWiXReference);
            }
            helpMenu.MenuItems.Add(new IconMenuItem("-"));
            helpMenu.MenuItems.Add(helpAbout);

            mainMenu.MenuItems.Add(helpMenu);

            // Object browser for debug purposes, just drop the statebrowser assembly next to
            // the WixEdit assembly and select the "Browse Application State" in the help menu.
            // See http://sliver.com/dotnet/statebrowser/
            try
            {
                string location = Assembly.GetExecutingAssembly().Location;
                FileInfo wixEditExe = new FileInfo(location);
                string tryPath = Path.Combine(wixEditExe.Directory.Parent.FullName, @"tools\StateBrowser\sliver.Windows.Forms.StateBrowser.dll");
                if (!File.Exists(tryPath))
                {
                    tryPath = Path.Combine(wixEditExe.Directory.Parent.Parent.FullName, @"tools\StateBrowser\sliver.Windows.Forms.StateBrowser.dll");
                }

                if (!File.Exists(tryPath))
                {
                    stateBrowserAssm = Assembly.Load("sliver.windows.forms.statebrowser, Version=1.5.0.0, Culture=neutral, PublicKeyToken=34afe62596d00324, Custom=null");
                }
                else
                {
                    stateBrowserAssm = Assembly.LoadFile(tryPath);
                }
            }
            catch (Exception) { }

            if (stateBrowserAssm != null)
            {
                helpStateBrowser.Text = "&Browse Application State";
                helpStateBrowser.Click += new EventHandler(helpStateBrowser_Click);

                helpMenu.MenuItems.Add(new IconMenuItem("-"));
                helpMenu.MenuItems.Add(helpStateBrowser);
            }

            Menu = mainMenu;

            mainPanel = new Panel();
            mainPanel.Dock = DockStyle.Fill;
            Controls.Add(mainPanel);

            resultsSplitter = new Splitter();
            resultsSplitter.Dock = DockStyle.Bottom;
            resultsSplitter.Height = 2;
            Controls.Add(resultsSplitter);

            outputPanel = new OutputPanel(this, buildMenu);
            outputPanel.Text = "Output";
            searchPanel = new SearchPanel(this, editMenu);
            searchPanel.Text = "Search Results";

            resultsPanel = new ResultsPanel(new Panel[] { outputPanel, searchPanel });
            resultsPanel.CloseClicked += new EventHandler(ResultsPanelCloseClick);
            resultsPanel.Dock = DockStyle.Bottom;
            resultsPanel.Height = 100;
            resultsPanel.Size = new Size(200, 216);

            Controls.Add(resultsPanel);

            resultsPanel.Visible = false;
            resultsSplitter.Visible = false;

            splashScreenHandler = new EventHandler(EditorForm_Activated);
            this.Activated += splashScreenHandler;
            if (formInstances.Count > 1)
            {
                splashIsDone = true;
            }
        }