Ejemplo n.º 1
0
        private static void Install()
        {
            InstallerWorker installer = new InstallerWorker();

            installer.OnError    += installer_OnError;
            installer.OnComplete += installer_OnComplete;
            installer.Install();
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            string[] args = Environment.GetCommandLineArgs();

            if (args.Length >= 2)
            {
                if (ContainsArg(args, "/quiet"))
                {
                    DetermineInstallMode(true);

                    if (InstallerData.UninstallMode)
                    {
                        Uninstall();
                    }
                    else
                    {
                        foreach (string each in args)
                        {
                            if (each.StartsWith("key=", StringComparison.InvariantCultureIgnoreCase))
                            {
                                InstallerData.ProductKey = each.Substring(5);
                                break;
                            }
                        }

                        Install();
                    }

                    return;
                }
                else if (args[1].ToLowerInvariant() == "/update")
                {
                    InstallerWorker.UpdateRegistry();
                    return;
                }
            }

            if (SingleInstance <App> .InitializeAsFirstInstance(GlobalAssemblyInfo.AssemblyName + " Setup"))
            {
                DisableProcessWindowsGhosting();

                App app = new App();
                app.DispatcherUnhandledException += app_DispatcherUnhandledException;
                app.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Ejemplo n.º 3
0
        private void timer_Tick(object sender, EventArgs e)
        {
            DispatcherTimer timer = (DispatcherTimer)sender;

            timer.Stop();
            timer.Tick -= timer_Tick;
            timer       = null;

            if (InstallerData.InstalledVersion != null &&
                InstallerData.BackwardsCompatibleTo >= InstallerData.InstalledVersion)
            {
                TaskDialog td = new TaskDialog(Window.GetWindow(this),
                                               "Version conflict",
                                               "This version of " + InstallerData.DisplayName + " is not compatible with the currently installed version. The old version will be completely uninstalled, and you will lose any cloud accounts, appointments, contacts, tasks, notes, or custom dictionaries that you may have saved.",
                                               MessageType.Exclamation, true);

                if (td.ShowDialog() == true)
                {
                    InstallerWorker installer = new InstallerWorker();
                    installer.OnProgress += installer_OnProgress;
                    installer.OnError    += installer_OnError;
                    installer.OnComplete += installer_OnComplete;
                    installer.Install();
                }
                else
                {
                    CancelSetup(null);
                }
            }
            else
            {
                InstallerWorker installer = new InstallerWorker();
                installer.OnProgress += installer_OnProgress;
                installer.OnError    += installer_OnError;
                installer.OnComplete += installer_OnComplete;
                installer.Install();
            }
        }
        //Event handler for selected tabs
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string temppath = GetTemporaryDirectory();

            SevenZip.SevenZipExtractor.SetLibraryPath(@"D:\Program Files (x86)\7-Zip\7z.dll");
            switch ((sender as TabControl).SelectedIndex)
            {
            case 0:
                //Starting tab, twiddle
                break;

            case 1:
                //We've selected the second tab and need to load the package information from the archive
                if (File.Exists(openfile))
                {
                    string tempextract_info = Path.Combine(temppath + "\\packageinfo.bpi");
                    try
                    {
                        using (FileStream myStream = new FileStream(tempextract_info, FileMode.Create))
                        {
                            var packageinfofile = new SevenZip.SevenZipExtractor(openfile);
                            packageinfofile.ExtractFile("packageinfo.bpi", myStream);
                        }
                    }
                    catch
                    {
                        MessageBox.Show("The selected package appears to be corrupt.");
                    }
                    try
                    {
                        readpackageinfo(tempextract_info);
                    }
                    catch
                    {
                        MessageBox.Show("Error reading package information.");
                    }
                    //Now extract the image
                    try
                    {
                        string tempextract_image = Path.Combine(temppath + "\\package.png");
                        using (FileStream myStream = new FileStream(tempextract_image, FileMode.Create))
                        {
                            var packageimage = new SevenZip.SevenZipExtractor(openfile);
                            packageimage.ExtractFile("package.png", myStream);
                        }
                        //Read the package information
                        readpackageinfo(tempextract_info);
                        //Load the image
                        Bitmap tempimage;
                        using (FileStream myStream = new FileStream(tempextract_image, FileMode.Open))
                        {
                            tempimage = (Bitmap)Image.FromStream(myStream);
                            this.pictureBox1.Image    = tempimage;
                            this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                        }
                    }
                    catch
                    {
                        //No error prompt, just don't load the image
                    }
                }
                break;

            case 2:
                //Try to load the contents of an archive
                if (ArchiveInfoWorker.IsBusy != true)
                {
                    progress1 = new ReadingPackage();
                    progress1.Show();
                    ArchiveInfoWorker.RunWorkerAsync();
                }
                break;

            case 3:
                //Package extraction
                if (InstallerWorker.IsBusy != true)
                {
                    progress = new InstallProgress();
                    progress.Show();
                    InstallerWorker.RunWorkerAsync();
                }
                break;
            }
        }