Пример #1
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            UIThread.Dispatcher = this.Dispatcher;

            Patcher.PatchDownloadProgress += new Patcher.PatchDownloadProgressDelegate(Patcher_OnPatchDownloadProgress);
            Patcher.PatchApplyProgress    += new Patcher.PatchApplyProgressDelegate(Patcher_OnPatchApplyProgress);
            Patcher.PatchUnzipProgress    += new Patcher.PatchUnzipProgressDelegate(Patcher_OnPatchUnzipProgress);
            Patcher.PatchArrived          += new Patcher.PatchArrivedDelegate(Patcher_OnPatchArrived);
            Patcher.ClientIsCurrent       += new EventHandler(Patcher_OnClientIsCurrent);
            Patcher.PatchNotesArrived     += new Patcher.PatchNotesArrivedDelegate(Patcher_PatchNotesArrived);
            Patcher.Initialize();

            // Start patch process in one second.
            m_Timer.Interval = TimeSpan.FromSeconds(1);
            m_Timer.Tick    += new EventHandler(StartPatch);
            m_Timer.Start();
        }
Пример #2
0
        /// <summary>
        /// Starts the patch process, via m_Timer.  the use of the timer tends to make the patch client startup sequence feel smoother on many systems.
        /// </summary>
        private void StartPatch(object sender, EventArgs e)
        {
            m_Timer.Stop();

            // see if we're doing a manual patch job.
            string[] args = Environment.GetCommandLineArgs();
            if (args != null && args.Length > 1)
            {
                string patchFile = args[1];
                if (!File.Exists(patchFile) || (!patchFile.EndsWith(".patch")))
                {
                    MessageBox.Show("The file " + patchFile + " does not seem to be a valid patch file.");
                    Application.Current.Shutdown();
                }

                // We have a manual patch file.  apply it.
                //Log.LogMsg("Applying patch file " + patchFile);
                Patcher.ApplyLocalPatch(patchFile);
                return;
            }

            Patcher.ConnectToPatchServer();
        }