Ejemplo n.º 1
0
        public override void OnNextClicked()
        {
            bool ok = true;

            DirectoryInfo info = new DirectoryInfo(this.targetDirTextBox.Text);

            if (!info.Exists)
            {
                try
                {
                    info.Create();
                    info.Delete();
                }

                catch
                {
                    ok = false;
                    string title   = PdnInfo.GetBareProductName();
                    string message = PdnResources.GetString("SetupWizard.InstallDirPage.BadDirError.Message");
                    MessageBox.Show(this, message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            if (ok)
            {
                WizardHost.SetMsiProperty(PropertyNames.TargetDir, this.targetDirTextBox.Text);
                WizardHost.GoToPage(typeof(ReadyToInstallPage));
            }

            base.OnNextClicked();
        }
Ejemplo n.º 2
0
 private void agreeButton_CheckedChanged(object sender, System.EventArgs e)
 {
     if (WizardHost != null)
     {
         WizardHost.SetNextEnabled(agreeButton.Checked);
     }
 }
Ejemplo n.º 3
0
        public override void OnNextClicked()
        {
            IntroPage.UserChoseQuickSetup = this.quickRB.Checked; // license page uses this to determine where to go for 'Next' button press

            WizardHost.GoToPage(typeof(LicensePage));
            base.OnNextClicked();
        }
Ejemplo n.º 4
0
        private void ShowAddAcceleratorsWizard()
        {
            using (var host = new WizardHost
            {
                Text = @"Add Accelerators Wizard",
                ShowFirstButton = false,
                ShowLastButton = false
            })
            {
                foreach (var page in InitializeSolutionInfo.InitializePages())
                {
                    host.WizardPages.Add(page);
                }
                host.LoadWizard();
                if (host.ShowDialog() == DialogResult.OK)
                {
                    var results = host.SaveResults;
                    var info    = InitializeSolutionInfo.InitializeSolution(results);

                    Execute(info);
                }

                host.Close();
            }
        }
Ejemplo n.º 5
0
        private void PrepMsi(string msiPath, string dstDir, PaintDotNet.SystemLayer.ProcessorArchitecture platform, Hashtable msiProperties)
        {
            string dstMsiExt  = "." + platform.ToString().ToLower() + ".msi";
            string dstMsiName = Path.ChangeExtension(msiPath, dstMsiExt);

            if (!Directory.Exists(dstDir))
            {
                Directory.CreateDirectory(dstDir);
            }

            string dstMsiPath = Path.Combine(dstDir, dstMsiName);

            this.statusText.Text = dstMsiName;
            WizardHost.Update();

            File.Copy(msiPath, dstMsiPath, true);
            ++this.progressBar.Value;

            Msi.SetMsiTargetPlatform(dstMsiPath, platform);
            ++this.progressBar.Value;

            foreach (string key in msiProperties.Keys)
            {
                string value = (string)msiProperties[key];
                Msi.SetMsiProperties(dstMsiPath, Msi.PropertyTable, new string[1] {
                    key
                }, new string[1] {
                    value
                });
                ++this.progressBar.Value;
            }

            ++this.progressBar.Value;
        }
Ejemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            WizardHost host = new WizardHost();

            host.Text             = "My Wizard";
            host.WizardCompleted += new WizardHost.WizardCompletedEventHandler(host_WizardCompleted);
            host.WizardPages.Add(1, new Page1());
            host.WizardPages.Add(2, new Page2());
            host.WizardPages.Add(3, new Page3());
            host.LoadWizard();
            host.ShowDialog();
        }
Ejemplo n.º 7
0
        public override void OnNextClicked()
        {
            choseButton      = true;
            choseAgreeButton = agreeButton.Checked;

            if (IntroPage.UserChoseQuickSetup)
            {
                WizardHost.GoToPage(typeof(InstallingPage));
            }
            else
            {
                WizardHost.GoToPage(typeof(OptionsPage));
            }

            base.OnNextClicked();
        }
Ejemplo n.º 8
0
        protected override void OnLoad(EventArgs e)
        {
            if (WizardHost != null)
            {
                WizardHost.HeaderText               = PdnResources.GetString("SetupWizard.LicensePage.HeaderText");
                this.agreeButton.Font               = WizardHost.NormalTextFont;
                this.agreeButton.ForeColor          = WizardHost.TextColor;
                this.introText.Font                 = WizardHost.NormalTextFont;
                this.introText.ForeColor            = WizardHost.TextColor;
                this.dontAgreeButton.Font           = WizardHost.NormalTextFont;
                this.dontAgreeButton.ForeColor      = WizardHost.TextColor;
                this.licenseAgreementText.Font      = WizardHost.FixedWidthFont;
                this.licenseAgreementText.ForeColor = WizardHost.TextColor;
                WizardHost.SetNextEnabled(agreeButton.Checked);
            }

            base.OnLoad(e);
        }
Ejemplo n.º 9
0
        protected override void OnLoad(EventArgs e)
        {
            if (WizardHost != null)
            {
                WizardHost.HeaderText        = PdnResources.GetString("SetupWizard.OptionsPage.HeaderText");
                this.launchHandlingText.Font = WizardHost.NormalTextFont;

                this.jpgPngBmpCheckBox.Font      = WizardHost.NormalTextFont;
                this.jpgPngBmpCheckBox.ForeColor = WizardHost.TextColor;
                this.jpgPngBmpCheckBox.Checked   = ("1" == WizardHost.GetMsiProperty(PropertyNames.JpgPngBmpEditor, "1"));

                this.tgaCheckBox.Font      = WizardHost.NormalTextFont;
                this.tgaCheckBox.ForeColor = WizardHost.TextColor;
                this.tgaCheckBox.Checked   = ("1" == WizardHost.GetMsiProperty(PropertyNames.TgaEditor, "1"));

                this.desktopShortcutCheckBox.Font      = WizardHost.NormalTextFont;
                this.desktopShortcutCheckBox.ForeColor = WizardHost.TextColor;
                this.desktopShortcutCheckBox.Checked   = ("1" == WizardHost.GetMsiProperty(PropertyNames.DesktopShortcut, "1"));

                this.updatesText.Font      = WizardHost.NormalTextFont;
                this.updatesText.ForeColor = WizardHost.TextColor;

                this.checkForUpdatesCheckBox.Font      = WizardHost.NormalTextFont;
                this.checkForUpdatesCheckBox.ForeColor = WizardHost.TextColor;
                this.checkForUpdatesCheckBox.Checked   = ("1" == WizardHost.GetMsiProperty(PropertyNames.CheckForUpdates, "1"));

                this.checkForBetasCheckBox.Font      = WizardHost.NormalTextFont;
                this.checkForBetasCheckBox.ForeColor = WizardHost.TextColor;
                this.checkForBetasCheckBox.Checked   = ("1" == WizardHost.GetMsiProperty(PropertyNames.CheckForBetas, PropertyNames.CheckForBetasDefault));

                if (!PdnInfo.IsFinalBuild)
                {
                    this.checkForBetasCheckBox.Checked = true;
                }

                if (!checkForUpdatesCheckBox.Checked)
                {
                    this.checkForBetasCheckBox.Checked = false;
                    this.checkForBetasCheckBox.Enabled = false;
                }
            }
            base.OnLoad(e);
        }
Ejemplo n.º 10
0
        private void CreateMSIs()
        {
            Hashtable msiProperties = WizardHost.MsiProperties;

            this.progressBar.Maximum = 2 * (3 + msiProperties.Count);

            const string msiPath    = "PaintDotNet.msi";
            string       desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            string       dstDir     = Path.Combine(desktopDir, "PaintDotNetMsi");

            PrepMsi(msiPath, dstDir, PaintDotNet.SystemLayer.ProcessorArchitecture.X86, msiProperties);
            PrepMsi(msiPath, dstDir, PaintDotNet.SystemLayer.ProcessorArchitecture.X64, msiProperties);

            string finishedTextFormat = PdnResources.GetString("SetupWizard.CreateMsiPage.IntroText.Text.Finished");
            string finishedText       = string.Format(finishedTextFormat, dstDir);

            this.introText.Text  = finishedText;
            this.statusText.Text = string.Empty;

            WizardHost.SetFinished(true);
        }
Ejemplo n.º 11
0
        protected override void OnLoad(EventArgs e)
        {
            if (WizardHost != null)
            {
                WizardHost.HeaderText = PdnResources.GetString("SetupWizard.InstallDirPage.HeaderText");

                string targetDir = WizardHost.GetMsiProperty(PropertyNames.TargetDir, null);
                this.targetDirTextBox.Text      = targetDir;
                this.targetDirTextBox.ForeColor = WizardHost.TextColor;

                this.introText.Font      = WizardHost.NormalTextFont;
                this.introText.ForeColor = WizardHost.TextColor;

                this.folderLabel.Font      = WizardHost.NormalTextFont;
                this.folderLabel.ForeColor = WizardHost.TextColor;

                this.browseButton.Font = WizardHost.NormalTextFont;
            }

            base.OnLoad(e);
        }
Ejemplo n.º 12
0
        public ActionResult Index(string Command, string Step)
        {
            host = new WizardHost(new Workflow1(), bookmarkhistory);

            Dictionary <string, object>  input  = new Dictionary <string, object>();
            IDictionary <string, object> output = new Dictionary <string, object>();

            input["Context"] = workflowcontext;
            switch (Command)
            {
            case "Start":
                output = host.Start(input);
                break;

            case "Next":
                output = host.Next(input);
                break;

            case "Back":
                output = host.Back(input);
                break;

            case "GoTo":
                output = host.GoTo(input, Step);
                break;

            default:
                output = host.Start(input);
                break;
            }
            bookmarkhistory             = host.GetBookmarkHistory();
            workflowcontext             = output["Context"] as WorkFlowContext;
            ViewData                    = workflowcontext.ViewData;
            ViewData["bookmarkhistory"] = bookmarkhistory;
            ViewData["currentbookmark"] = host.GetCurrentBookmark();
            ViewData["PartialViewName"] = workflowcontext.ViewName;
            return(View());
        }
Ejemplo n.º 13
0
        protected override void OnLoad(EventArgs e)
        {
            this.progressBar.Minimum = 0;

            if (WizardHost != null)
            {
                WizardHost.HeaderText     = PdnResources.GetString("SetupWizard.CreateMsiPage.HeaderText");
                this.introText.Text       = PdnResources.GetString("SetupWizard.CreateMsiPage.IntroText.Text.Creating");
                this.introText.ForeColor  = WizardHost.TextColor;
                this.introText.Font       = WizardHost.NormalTextFont;
                this.introText.ForeColor  = WizardHost.TextColor;
                this.statusText.Font      = WizardHost.NormalTextFont;
                this.statusText.ForeColor = WizardHost.TextColor;

                WizardHost.SetNextEnabled(false);
                WizardHost.SetBackEnabled(false);
                WizardHost.SetCancelEnabled(false);

                this.BeginInvoke(new Procedure(CreateMSIs));
            }

            base.OnLoad(e);
        }
Ejemplo n.º 14
0
        protected override void OnLoad(EventArgs e)
        {
            if (WizardHost != null)
            {
                WizardHost.HeaderText    = PdnResources.GetString("SetupWizard.IntroPage.HeaderText");
                this.introText.Font      = WizardHost.NormalTextFont;
                this.introText.ForeColor = WizardHost.TextColor;
                Font normalFont = WizardHost.NormalTextFont;
                Font rbFont     = Utility.CreateFont(normalFont.Name, normalFont.Size, normalFont.Style | FontStyle.Bold);
                this.quickRB.Font                = rbFont;
                this.quickRB.ForeColor           = WizardHost.TextColor;
                this.quickDescription.Font       = WizardHost.NormalTextFont;
                this.quickDescription.ForeColor  = WizardHost.TextColor;
                this.customRB.Font               = rbFont;
                this.customRB.ForeColor          = WizardHost.TextColor;
                this.customDescription.Font      = WizardHost.NormalTextFont;
                this.customDescription.ForeColor = WizardHost.TextColor;
                this.copyrightLabel.Font         = WizardHost.FootNoteFont;
                this.copyrightLabel.ForeColor    = WizardHost.TextColor;
                WizardHost.SetBackEnabled(false);
            }

            base.OnLoad(e);
        }
Ejemplo n.º 15
0
 public override void OnNextClicked()
 {
     WizardHost.GoToPage(typeof(InstallingPage));
     base.OnNextClicked();
 }
Ejemplo n.º 16
0
 public override void OnNextClicked()
 {
     WizardHost.Close();
     base.OnNextClicked();
 }
Ejemplo n.º 17
0
        private void DoInstallation()
        {
            WizardHost.SetNextEnabled(false);
            WizardHost.SetBackEnabled(false);
            WizardHost.SetCancelEnabled(false);

            IntPtr hWnd = this.Handle;

            uint result = NativeMethods.MsiSetInternalUI(
                NativeConstants.INSTALLUILEVEL_BASIC | NativeConstants.INSTALLUILEVEL_HIDECANCEL,
                ref hWnd);

            // value of result is discarded

            string ourDir = PdnInfo.GetApplicationDir();
            string originalPackagePath = Path.Combine(ourDir, msiName);
            string targetDir           = WizardHost.GetMsiProperty(PropertyNames.TargetDir, null);
            string stagingDir          = Path.Combine(targetDir, stagingDirName);

            // The 'old' target dir is read from the registry.
            // This way if they are reinstalling to a new directory, we will propertly uninstall and cleanup
            // from the old directory.
            // The 'old' target dir defaults to the 'new' target dir (in case of new installation)
            string oldTargetDir  = WizardHost.GetMsiProperty(PropertyNames.TargetDir, targetDir, true);
            string oldStagingDir = Path.Combine(oldTargetDir, stagingDirName);

            // Uninstallers should skip certain parts of cleanup when we're going to turn around
            // and install a newer version right away
            WizardHost.SetMsiProperty(PropertyNames.SkipCleanup, "0");

            // Uninstall anything already in the staging directory (should only be the previous version)
            if (Directory.Exists(oldStagingDir))
            {
                this.infoText.Text = this.uninstallingText;
                WizardHost.SetMsiProperty(PropertyNames.SkipCleanup, "1");

                foreach (string filePath in Directory.GetFiles(oldStagingDir, "*.msi"))
                {
                    uint result2 = NativeMethods.MsiInstallProduct(
                        filePath,
                        "REMOVE=ALL " +
                        PropertyNames.SkipCleanup + "=1 " +
                        PropertyNames.DesktopShortcut + "=" + WizardHost.GetMsiProperty(PropertyNames.DesktopShortcut, "1"));
                }
            }

            // Proceed with installation
            this.infoText.Text = this.installingText;

            Directory.CreateDirectory(stagingDir);
            string msiPath        = Path.Combine(stagingDir, msiName);
            string dstPackagePath = GetOriginalMsiName(msiPath);

            // Copy the MSI to the Staging directory before installing. This way it will always
            // be available when Windows Installer needs to refer to it.
            FileInfo info = new FileInfo(originalPackagePath);

            info.CopyTo(dstPackagePath, true);

            // Keep an open file handle so that setupngen.exe cannot delete the file.
            // This happens if the current installation of Paint.NET

            // We need to set the Target Platform property of the MSI before we install it.
            // This way if the user types "C:\Program Files\Whatever" on an x64 system, it will
            // not get redirected over to "C:\Program Files (x86)\Whatever"
            Msi.SetMsiTargetPlatform(dstPackagePath, PaintDotNet.SystemLayer.Processor.NativeArchitecture);

            string commandLine1 = WizardHost.GetMsiCommandLine();
            string commandLine  = commandLine1;

            if (commandLine.Length > 0)
            {
                commandLine += " ";
            }

            commandLine += PropertyNames.QueueNgen + "=1";

            // Install newest package
            result = NativeMethods.MsiInstallProduct(dstPackagePath, commandLine);

            if (result == NativeConstants.ERROR_SUCCESS ||
                result == NativeConstants.ERROR_SUCCESS_REBOOT_INITIATED ||
                result == NativeConstants.ERROR_SUCCESS_REBOOT_REQUIRED)
            {
                ShowBanners();

                WizardHost.SaveMsiProperties();

                // clean up staging dir
                string msiFileName = Path.GetFileName(dstPackagePath);
                foreach (string filePath in Directory.GetFiles(stagingDir, "*.msi"))
                {
                    string fileName = Path.GetFileName(filePath);

                    if (0 != string.Compare(msiFileName, fileName, true, CultureInfo.InvariantCulture))
                    {
                        File.Delete(filePath);
                    }
                }

                // Run "ngen.exe executeQueuedItems", aka "Optimizing performance for your system..."
                if (Application.VisualStyleState == VisualStyleState.ClientAreaEnabled ||
                    Application.VisualStyleState == VisualStyleState.ClientAndNonClientAreasEnabled)
                {
                    this.progressBar.Style   = ProgressBarStyle.Marquee;
                    this.progressBar.Visible = true;
                }

                string       ngenExe = PdnInfo.GetNgenPath();
                const string ngenArg = "executeQueuedItems";

                try
                {
                    this.infoText.Text = this.optimizingText;
                    ProcessStartInfo psi = new ProcessStartInfo(ngenExe, ngenArg);
                    psi.UseShellExecute = false;
                    psi.CreateNoWindow  = true;
                    Process process = Process.Start(psi);

                    while (!process.HasExited)
                    {
                        System.Threading.Thread.Sleep(10);
                        Application.DoEvents();
                    }
                }

                catch
                {
                    // If this fails, do not fail the installation
                }

                // Try to write locale setting to registry
                try
                {
                    Settings.SystemWide.SetString("LanguageName", CultureInfo.CurrentUICulture.Name);
                }

                catch (Exception)
                {
                    // Ignore errors, however
                }

                SystemSounds.Beep.Play();

                WizardHost.SetFinished(true);
                this.progressBar.Visible = false;

                // set text to indicate success
                WizardHost.HeaderText = PdnResources.GetString("SetupWizard.InstallingPage.HeaderText.Success");
                string infoFormat;

                if (result == NativeConstants.ERROR_SUCCESS)
                {
                    WizardHost.RebootRequired = false;
                    infoFormat = PdnResources.GetString("SetupWizard.InstallingPage.InfoText.Text.Success.Format");
                }
                else
                {
                    WizardHost.RebootRequired = true;
                    infoFormat = PdnResources.GetString("SetupWizard.InstallingPage.InfoText.Text.Success.RebootRequired.Format");
                }

                this.infoText.Text = string.Format(infoFormat, this.appName);
                WizardHost.SetBackEnabled(false);
            }
            else
            {
                WizardHost.SetFinished(true);
                this.progressBar.Visible = false;

                // set text to indicate failure
                WizardHost.HeaderText = PdnResources.GetString("SetupWizard.InstallingPage.HeaderText.Failure");
                string infoFormat  = PdnResources.GetString("SetupWizard.InstallingPage.InfoText.Text.Failure.Format");
                string errorString = NativeMethods.FormatMessageW(result);
                this.errorLabel.Font    = WizardHost.NormalTextFont;
                this.errorLabel.Visible = true;
                this.errorLabel.Text    = errorString;
                this.infoText.Text      = string.Format(infoFormat, this.appName) + " (" + result.ToString() + ")";
                WizardHost.SetBackEnabled(false);
            }
        }
Ejemplo n.º 18
0
 private void jpgPngBmpCheckBox_CheckedChanged(object sender, System.EventArgs e)
 {
     WizardHost.SetMsiProperty(PropertyNames.JpgPngBmpEditor, jpgPngBmpCheckBox.Checked ? "1" : "0");
 }
Ejemplo n.º 19
0
 private void tgaCheckBox_CheckedChanged(object sender, System.EventArgs e)
 {
     WizardHost.SetMsiProperty(PropertyNames.TgaEditor, tgaCheckBox.Checked ? "1" : "0");
 }
Ejemplo n.º 20
0
 private void checkForBetasCheckBox_CheckedChanged(object sender, System.EventArgs e)
 {
     WizardHost.SetMsiProperty(PropertyNames.CheckForBetas, checkForBetasCheckBox.Checked ? "1" : "0");
 }
Ejemplo n.º 21
0
 private void desktopShortcutCheckBox_CheckedChanged(object sender, System.EventArgs e)
 {
     WizardHost.SetMsiProperty(PropertyNames.DesktopShortcut, desktopShortcutCheckBox.Checked ? "1" : "0");
 }
        static void Main(string[] args)
        {
            IDictionary <string, object> output = new Dictionary <string, object>()
            {
            };

            //Workflow1 wf = new Workflow1();
            //Activity1 wf = new Activity1();
            Wizard     wf   = new Wizard();
            WizardHost host = new WizardHost(wf);
            Dictionary <string, object> input = new Dictionary <string, object>();

            input["Input"] = "Step3";
            Console.WriteLine("--------WorkFlow Output Started------------");

            output = host.Start(input);
            Console.WriteLine("--------WorkFlow Output Ended------------");
            CustomBookmark currentbm = host.GetCurrentBookmark();
            bool           Continue  = true;

            while (Continue)
            {
                Console.WriteLine("Select a command from below.");
                Console.WriteLine("1: Start");
                if (currentbm.HasNext)
                {
                    Console.WriteLine("2: Next");
                }
                if (currentbm.HasBack)
                {
                    Console.WriteLine("3: Back");
                }
                Console.WriteLine("4: GoTo  (Enter Step ID after a space)");
                Console.WriteLine("0: Exit");
                string[] inputstr = Console.ReadLine().Split(' ');

                String cmd = inputstr[0];

                Console.WriteLine("--------WorkFlow Output Started------------");
                switch (cmd)
                {
                case "1":
                    host.Start(input);
                    break;

                case "2":
                    host.Next(input);
                    break;

                case "3":
                    host.Back(input);
                    break;

                case "4":
                    string stepid = inputstr[1];
                    host.GoTo(input, new CustomBookmark {
                        StepID = stepid
                    });
                    break;

                case "0":
                    Continue = false;
                    break;

                default:
                    Console.WriteLine("Command Not Supported");
                    break;
                }
                List <CustomBookmark> bmlist = host.GetBookmarkHistory();
                currentbm = host.GetCurrentBookmark();
                // if (currentbm.StepID == "2") input["Input"] = "Step3";
                Console.WriteLine("--------WorkFlow Output Ended . Step ID :" + currentbm.StepID + " ------------");
            }
        }