Ejemplo n.º 1
0
        private void CheckXmlClick(object sender, RoutedEventArgs e)
        {
            var wnd = new Windows.ChangeSetsProgressDialog("Testing xml...")
            {
                Owner = Program.MainWindowNew
            };
            String urlLink = urlBox.Text;
            bool   is_ok   = false;

            ThreadPool.QueueUserWorkItem(_ =>
            {
                try
                {
                    int current = 0, max = 10;
                    wnd.UpdateProgress(current, max, "Retrieving xml...", false);
                    XmlSetParser xmls = new XmlSetParser(urlLink);
                    current++;
                    XmlSimpleValidate validator = new XmlSimpleValidate(xmls);
                    validator.CheckVerboseXml(wnd, max, game);
                    is_ok = true;
                }
                catch (Exception ex)
                {
                    wnd.UpdateProgress(10, 10, string.Format("Caught exception when retrieving / parsing xml: '{0}'", ex.Message), false);
                }
            });
            wnd.ShowDialog();
            button3.IsEnabled = is_ok;
            button2.IsEnabled = is_ok;
        }
Ejemplo n.º 2
0
        private void DownloadAndInstallClick(object sender, RoutedEventArgs e)
        {
            var wnd = new Windows.ChangeSetsProgressDialog("Downloading and installing...")
            {
                Owner = Program.MainWindowNew
            };
            String urlLink = urlBox.Text;

            ThreadPool.QueueUserWorkItem(_ =>
            {
                try
                {
                    int max = 6;
                    wnd.UpdateProgress(0, max, "Retrieving xml...", false);
                    XmlSetParser xmls = new XmlSetParser(urlLink);
                    XmlInstaller xmli = new XmlInstaller(xmls);
                    xmli.installSet(wnd, max, game);
                }
                catch (Exception ex)
                {
                    wnd.UpdateProgress(6, 6, string.Format("Caught exception: '{0}'", ex.Message), false);
                }
            });
            wnd.ShowDialog();
        }
Ejemplo n.º 3
0
        private void CheckXmlClick(object sender, RoutedEventArgs e)
        {
            var wnd = new Windows.ChangeSetsProgressDialog("Testing xml...") {Owner = Program.MainWindowNew};
            String urlLink = urlBox.Text;
            bool is_ok = false;
            ThreadPool.QueueUserWorkItem(_ =>
                                             {
                                                 try
                                                 {
                                                     int current = 0, max = 10;
                                                     wnd.UpdateProgress(current, max, "Retrieving xml...", false);
                                                     XmlSetParser xmls = new XmlSetParser(urlLink);
                                                     current++;
                                                     XmlSimpleValidate validator = new XmlSimpleValidate(xmls);
                                                     validator.CheckVerboseXml(wnd, max, game);
                                                     is_ok = true;
                                                 }
                                                 catch (Exception ex)
                                                 {
                                                     wnd.UpdateProgress(10, 10, string.Format("Caught exception when retrieving / parsing xml: '{0}'", ex.Message), false);
                                                 }

                                             });
            wnd.ShowDialog();
            button3.IsEnabled = is_ok;
            button2.IsEnabled = is_ok;
        }
Ejemplo n.º 4
0
 public void DeletedSelected()
 {
     var wnd = new Windows.ChangeSetsProgressDialog("Removing Sets...") { Owner = Program.MainWindow };
     System.Collections.IList items = lbSetList.SelectedItems;
     ThreadPool.QueueUserWorkItem(_ =>
     {
         int current = 0, max = items.Count;
         wnd.UpdateProgress(current, max, null, false);
         wnd.ShowMessage("Set Removal can take some time. Please be patient.");
         foreach (Set s in items)
         {
             ++current;
             try
             {
                 wnd.ShowMessage(string.Format("Removing '{0}' ...", s.Name));
                 SelectedGame.DeleteSet(s);
                 wnd.UpdateProgress(current, max,
                                    string.Format("'{0}' removed.", s.Name),
                                    false);
             }
             catch (Exception ex)
             {
                 wnd.UpdateProgress(current, max,
                                    string.Format(
                                        "'{0}' an error occured during removal:",
                                        s.Name), true);
                 wnd.UpdateProgress(current, max, ex.Message, true);
             }
         }
     });
     wnd.ShowDialog();
     RefreshList();
 }
Ejemplo n.º 5
0
        public void DeletedSelected()
        {
            if (SelectedGame == null)
            {
                return;
            }
            var wnd = new Windows.ChangeSetsProgressDialog("Removing Sets...")
            {
                Owner = Program.MainWindowNew
            };

            System.Collections.IList items = lbSetList.SelectedItems;
            ThreadPool.QueueUserWorkItem(_ =>
            {
                int current = 0, max = items.Count;
                wnd.UpdateProgress(current, max, null, false);
                wnd.ShowMessage("Set Removal can take some time. Please be patient.");
                foreach (Set s in items)
                {
                    ++current;
                    try
                    {
                        wnd.ShowMessage(string.Format("Removing '{0}' ...", s.Name));
                        SelectedGame.DeleteSet(s);
                        wnd.UpdateProgress(current, max,
                                           string.Format("'{0}' removed.", s.Name),
                                           false);
                    }
                    catch (Exception ex)
                    {
                        wnd.UpdateProgress(current, max,
                                           string.Format(
                                               "'{0}' an error occured during removal:",
                                               s.Name), true);
                        wnd.UpdateProgress(current, max, ex.Message, true);
                    }
                }
            });
            wnd.ShowDialog();
            RefreshList();
        }
Ejemplo n.º 6
0
        public void InstallSets()
        {
            var ofd = new 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 = Path.Combine(Prefs.DataDirectory, "Games", SelectedGame.Id.ToString(), "Sets");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            var wnd = new Windows.ChangeSetsProgressDialog("Installing Sets...")
            {
                Owner = Program.MainWindow
            };

            ThreadPool.QueueUserWorkItem(_ =>
            {
                int current = 0, max = ofd.FileNames.Length;
                wnd.UpdateProgress(current, max, null, false);
                foreach (string setName in ofd.FileNames)
                {
                    ++current;
                    string shortName = Path.GetFileName(setName);
                    try
                    {
                        if (shortName != null)
                        {
                            string copyto = 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();
            RefreshList();
        }
Ejemplo n.º 7
0
        public void InstallSets()
        {
            if (SelectedGame == null)
                return;
            var ofd = new 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(Prefs.DataDirectory, "Games", SelectedGame.Id.ToString(), "Sets");
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);

            var wnd = new Windows.ChangeSetsProgressDialog("Installing Sets...") { Owner = Program.MainWindowNew };
            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
                    {
                        if (shortName != null)
                        {
                            string copyto = Path.Combine(path, shortName);
                            if (setName.ToLower() != copyto.ToLower())
                                File.Copy(setName, copyto, true);
                            SetManager.Get().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();
            RefreshList();
        }
Ejemplo n.º 8
0
        private void DownloadAndInstallClick(object sender, RoutedEventArgs e)
        {
            var wnd = new Windows.ChangeSetsProgressDialog("Downloading and installing...") { Owner = Program.MainWindowNew };
            String urlLink = urlBox.Text;
            ThreadPool.QueueUserWorkItem(_ =>
            {
                try
                {
                    int max = 6;
                    wnd.UpdateProgress(0, max, "Retrieving xml...", false);
                    XmlSetParser xmls = new XmlSetParser(urlLink);
                    XmlInstaller xmli = new XmlInstaller(xmls);
                    xmli.installSet(wnd, max, game);

                }
                catch (Exception ex)
                {
                    wnd.UpdateProgress(6, 6, string.Format("Caught exception: '{0}'", ex.Message), false);
                }

            });
            wnd.ShowDialog();
        }