Beispiel #1
0
        public void Install_Sets()
        {
            var ofd = new Microsoft.Win32.OpenFileDialog
            {
                Filter = "Cards set definition files (*.o8s)|*.o8s",
                Multiselect = true
            };
            if (ofd.ShowDialog() != true) return;

            //Move the definition file to a new location, so that the old one can be deleted
            string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Octgn", "Sets");
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);

            var wnd = new InstallSetsProgressDialog { Owner = Program.ClientWindow };
            ThreadPool.QueueUserWorkItem(_ =>
            {
                int current = 0, max = ofd.FileNames.Length;
                wnd.UpdateProgress(current, max, null, false);
                foreach (string setName in ofd.FileNames)
                {
                    ++current;
                    string shortName = System.IO.Path.GetFileName(setName);
                    try
                    {
                        string copyto = System.IO.Path.Combine(path, shortName);
                        if (setName.ToLower() != copyto.ToLower())
                            File.Copy(setName, copyto, true);

                        SelectedGame.InstallSet(copyto);
                        wnd.UpdateProgress(current, max, string.Format("'{0}' installed.", shortName), false);
                    }
                    catch (Exception ex)
                    {
                        wnd.UpdateProgress(current, max, string.Format("'{0}' an error occured during installation:", shortName), true);
                        wnd.UpdateProgress(current, max, ex.Message, true);
                    }
                }
            });
            wnd.ShowDialog();
            Refresh_List();
        }
Beispiel #2
0
        private void InstallCards(object sender, RoutedEventArgs e)
        {
            if(!Settings.Default.DontShowInstallNotice)
                new InstallNoticeDialog { Owner = Program.ClientWindow }.ShowDialog();

            // Open the DB
            Data.Game gameDb = (Data.Game)gamesList.SelectedItem;
            if(gameDb == null)
            {
                MessageBox.Show("Select a game in the list first");
                return;
            }

            // Get the patch file
            var ofd = new Microsoft.Win32.OpenFileDialog
            {
                Filter = "Cards set definition files (*.o8s)|*.o8s",
                Multiselect = true
            };
            if(ofd.ShowDialog() != true) return;

            var wnd = new InstallSetsProgressDialog { Owner = Program.ClientWindow };
            ThreadPool.QueueUserWorkItem(_ =>
              {
                  int current = 0, max = ofd.FileNames.Length;
                  wnd.UpdateProgress(current, max, null, false);
                  foreach(string setName in ofd.FileNames)
                  {
                      ++current;
                      string shortName = System.IO.Path.GetFileName(setName);
                      try
                      {
                          gameDb.InstallSet(setName);
                          wnd.UpdateProgress(current, max, string.Format("'{0}' installed.", shortName), false);
                      }
                      catch(Exception ex)
                      {
                          wnd.UpdateProgress(current, max, string.Format("'{0}' an error occured during installation:", shortName), true);
                          wnd.UpdateProgress(current, max, ex.Message, true);
                      }
                  }
              });
            wnd.ShowDialog();
        }