Ejemplo n.º 1
0
        private void ConfirmButton_Click(object sender, RoutedEventArgs ev)
        {
            ProgressHandler handler = new ProgressHandler();
            Thread          t       = new Thread(delegate()
            {
                HttpWebRequest request   = (HttpWebRequest)WebRequest.Create("http://www.modapi.de/app/archives/" + this.newVersion + ".zip");
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream s            = response.GetResponseStream();
                byte[] buffer       = new byte[4096];
                MemoryStream memory = new MemoryStream();
                int count           = 0;
                long current        = 0;
                float progress      = 0f;
                handler.Task        = "Download";
                while ((count = s.Read(buffer, 0, buffer.Length)) > 0)
                {
                    memory.Write(buffer, 0, count);
                    current         += count;
                    progress         = (float)((((double)current / (double)response.ContentLength)) * 70.0);
                    handler.Progress = progress;
                }

                memory.Position  = 0;
                ZipFile zip      = ZipFile.Read(memory);
                string directory = "./_update";
                int n            = 0;
                handler.Task     = "Extracting";
                foreach (ZipEntry e in zip)
                {
                    try
                    {
                        e.Extract(directory, ExtractExistingFileAction.OverwriteSilently);
                    }
                    catch (Exception ex3)
                    {
                    }
                    n += 1;
                    handler.Progress = 70f + ((float)n / (float)zip.Count) * 30f;
                }

                Process p            = new Process();
                p.StartInfo.FileName = "Updater.exe";
                p.StartInfo.Verb     = "runas";
                p.Start();
                Environment.Exit(0);
            });

            ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "Update", handler);
            if (!window.Completed)
            {
                window.ShowSubWindow();
                window.Show();
                Close();
            }
            t.Start();
        }
Ejemplo n.º 2
0
        private void StartGame(object sender, RoutedEventArgs e)
        {
            List <Data.Mod> mods = new List <Data.Mod>();

            foreach (ListViewItem i in Mods.Mods)
            {
                ModViewModel vm = (ModViewModel)i.DataContext;
                if (vm != null && vm.Selected)
                {
                    ModVersionViewModel vm2 = (ModVersionViewModel)vm.SelectedVersion.DataContext;
                    if (vm2 != null)
                    {
                        mods.Add(vm2.mod);
                    }
                }
            }
            ProgressHandler progressHandler = new ProgressHandler();

            progressHandler.OnComplete += (object o, EventArgs ex) => {
                if (Configuration.GetString("UseSteam") == "true" && App.Game.GameConfiguration.SteamAppID != "")
                {
                    Process p = new Process();
                    p.StartInfo.FileName  = Configuration.GetPath("Steam") + System.IO.Path.DirectorySeparatorChar + "Steam.exe";
                    p.StartInfo.Arguments = "-applaunch " + App.Game.GameConfiguration.SteamAppID;
                    p.Start();
                }
                else
                {
                    Process p = new Process();
                    p.StartInfo.FileName = App.Game.GamePath + System.IO.Path.DirectorySeparatorChar + App.Game.GameConfiguration.SelectFile;
                    p.Start();
                }
            };

            Thread thread = new Thread(delegate()
            {
                App.Game.ApplyMods(mods, progressHandler);
            });

            ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "ApplyMods", progressHandler, null, true);
            if (!window.Completed)
            {
                window.ShowSubWindow();
                window.Show();
            }
            thread.Start();
        }
Ejemplo n.º 3
0
 private void CreateMod(object sender, RoutedEventArgs e)
 {
     if (CurrentModProjectViewModel != null)
     {
         ProgressHandler progressHandler = new ProgressHandler();
         Thread          thread          = new Thread(delegate() {
             CurrentModProjectViewModel.Project.Create(progressHandler);
         });
         ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "CreateMod", progressHandler);
         if (!window.Completed)
         {
             window.ShowSubWindow();
             window.Show();
         }
         thread.Start();
     }
 }
Ejemplo n.º 4
0
        private void StartGame(object sender, RoutedEventArgs e)
        {
            List<Data.Mod> mods = new List<Data.Mod>();
            foreach (ListViewItem i in Mods.Mods)
            {
                ModViewModel vm = (ModViewModel)i.DataContext;
                if (vm != null && vm.Selected)
                {
                    ModVersionViewModel vm2 = (ModVersionViewModel)vm.SelectedVersion.DataContext;
                    if (vm2 != null)
                    {
                        mods.Add(vm2.mod);
                    }
                }
            }
            ProgressHandler progressHandler = new ProgressHandler();
            progressHandler.OnComplete += (object o, EventArgs ex) => {
                if (Configuration.GetString("UseSteam") == "true" && App.Game.GameConfiguration.SteamAppID != "")
                {

                    Process p = new Process();
                    p.StartInfo.FileName = Configuration.GetPath("Steam") + System.IO.Path.DirectorySeparatorChar + "Steam.exe";
                    p.StartInfo.Arguments = "-applaunch "+App.Game.GameConfiguration.SteamAppID;
                    p.Start();
                }
                else
                {
                    Process p = new Process();
                    p.StartInfo.FileName = App.Game.GamePath + System.IO.Path.DirectorySeparatorChar + App.Game.GameConfiguration.SelectFile;
                    p.Start();
                }
            };

            Thread thread = new Thread(delegate()
            {
                App.Game.ApplyMods(mods, progressHandler);

            });
            ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "ApplyMods", progressHandler, null, true);
            if (!window.Completed)
            {
                window.ShowSubWindow();
                window.Show();
            }
            thread.Start();
        }
Ejemplo n.º 5
0
 private void CreateMod(object sender, RoutedEventArgs e)
 {
     if (CurrentModProjectViewModel != null)
     {
         ProgressHandler progressHandler = new ProgressHandler();
         Thread thread = new Thread(delegate() {
             CurrentModProjectViewModel.Project.Create(progressHandler);
         });
         ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "CreateMod", progressHandler);
         if (!window.Completed)
         {
             window.ShowSubWindow();
             window.Show();
         }
         thread.Start();
     }
 }