Ejemplo n.º 1
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            UpdaterForm updaterForm = new UpdaterForm(engine);

            updaterForm.checkForUpdate();
            if (updaterForm.ShowDialog() == DialogResult.Yes)
            {
                DialogResult = DialogResult.Abort;
                Close();
            }
        }
Ejemplo n.º 2
0
        public WordSlideApplicationContext(Arguments args)
        {
            if (args.Options.ContainsKey("selfUpdate") && args.Args.Count > 1)
            {
                this.SelfUpdate(args.Args[0], args.Args[1]);
                ExitThread();
            }
            else if (args.Options.ContainsKey("selfUpdateFinish"))
            {
                DateTime startTime = DateTime.Now;
                while (Process.GetProcessesByName("WordSlide").Length > 1 && (DateTime.Now - startTime) < TimeSpan.FromSeconds(20))
                {
                    System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
                }
                if (Process.GetProcessesByName("WordSlide").Length > 1)
                {
                    MessageBox.Show("Timed out waiting for previous instance to exit.", "WordSlide", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Directory.Exists(args.Options["selfUpdateFinish"]))
                {
                    Directory.Delete(args.Options["selfUpdateFinish"], true);
                }
            }
            bool firstrunning = false;

            this.wordslideMutex = new System.Threading.Mutex(false, "Local\\WordSlide", out firstrunning);
            if (!firstrunning)
            {
                ExitThread();
            }
            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            this.engine = new Engine();
            if (!System.IO.File.Exists(Path.Combine(Engine.DataDirectory, "options.ini")))
            {
                this.engine.Options.AutoUpdate = (MessageBox.Show(string.Format("WordSlide can check for updates automatically on launch.{0}Would you like to enable auto updates?", Environment.NewLine), "WordSlide", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes);
                this.engine.Options.saveFile();
            }

            if (args.Args.Count > 0 && File.Exists(args.Args[0]))
            {
                this.optionsForm = new OptionsForm(engine);
                this.optionsForm.importLibrary(args.Args[0]);
            }
            if (this.engine.Options.AutoUpdate)
            {
                this.updaterForm = new UpdaterForm(engine);
                this.updaterForm.checkForUpdate(new AutoUpdateDelegate(AutoUpdateFinished));
            }

            this.ShowLauncherForm();
        }