Пример #1
0
        public DownloadedSettings downloadXML()
        {
            Exception          exception;
            DownloadedSettings m = null;

            try
            {
                bool flag = false;
                ++this.downloadCount;
                flag                 = true;
                this.webClient       = new WebClient();
                this.webClient.Proxy = (IWebProxy)null;
                try
                {
                    String path = System.Reflection.Assembly.GetExecutingAssembly().Location.Replace("PhoenixLoader.exe", "addons.json");
                    String json = File.ReadAllText(path);
                    m = JsonConvert.DeserializeObject <DownloadedSettings>(json);
                }
                catch (Exception ex)
                {
                    String path = System.Reflection.Assembly.GetExecutingAssembly().Location.Replace(System.AppDomain.CurrentDomain.FriendlyName, "addons.json");
                    String json = File.ReadAllText(path);
                    m = JsonConvert.DeserializeObject <DownloadedSettings>(json);
                }
            }
            catch (Exception ex)
            {
                exception = ex;
                int num = (int)MessageBox.Show("Fehler beim lesen der Mods.xml.");
            }
            return(m);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                this.InitializeComponent();
                try
                {
                    this.settings = new ConfigSettings();
                    if (!ConfigManager.doesConfigExist())
                    {
                        ConfigManager.writeConfig(this.settings);
                        this.settings = ConfigManager.readConfig();
                    }
                    else
                    {
                        this.settings = ConfigManager.readConfig();
                    }

                    if (settings.downloadPath.Equals("http://jpjd.jp.ohost.de/legionlauncher/addons.json"))
                    {
                        settings.downloadPath = "http://www.legion-arma3.de/legionlauncher/addons.json";
                    }
                    textDownloadPath.Text = settings.downloadPath;
                    try
                    {
                        this.getDownloadableAddons();
                    }
                    catch (Exception ex)
                    {
                    }
                    this.textPath.Text = settings.path;
                    this.path          = this.textPath.Text;
                    this.checkIfExeIsThere();

                    DispatcherTimer dispatcherTimer = new DispatcherTimer();
                    dispatcherTimer.Tick    += new EventHandler(this.dispatcherTimer_Tick);
                    dispatcherTimer.Interval = new TimeSpan(0, 0, 10);
                    dispatcherTimer.Start();
                    DownloadedSettings downloadedSettings = this.downloader.downloadXML();
                    if (downloadedSettings != null)
                    {
                        //this.listEvents.SelectedIndex = 0;
                    }
                    else
                    {
                        int num = (int)System.Windows.MessageBox.Show("Konnte keine Verbindung zum Server herstellen. Bitte stellen sie sicher das kein Antivirenprogramm das Programm blockiert.");
                    }
                    this.getFieldOfView();
                    this.comboServer.SelectedIndex = 0;
                    this.setValuesFromConfig(this.settings);
                }
                catch (Exception ex)
                {
                    int num = (int)System.Windows.MessageBox.Show("Unbekannter Fehler beim starten. Bitte kontaktieren sie www.arama3-legion.de            " + ex.Message);
                }
            }
            catch (Exception ex)
            {
                ErrorWriter.writeError("Error during loadup: " + ex.Message + " # " + ex.Source + " ### " + ex.InnerException.Message + " # " + ex.InnerException.Source);
            }
        }
        private void getDownloadableAddons()
        {
            try
            {
                if (this.currentDownloadCount != 0)
                {
                    return;
                }
                List <System.Windows.Controls.CheckBox> list = new List <System.Windows.Controls.CheckBox>();
                foreach (System.Windows.Controls.CheckBox checkBox in (IEnumerable)this.listAllPheonixAddons.Items)
                {
                    list.Add(checkBox);
                }
                this.listAllPheonixAddons.Items.Clear();
                this.downloader = new Downloader(this);
                downloader.downloadAddonsJson(textDownloadPath.Text);
                DownloadedSettings downloadedSettings = this.downloader.downloadXML();

                if (version != downloadedSettings.version)
                {
                    System.Windows.MessageBox.Show("Es ist die neue Version " + downloadedSettings.version + " erschienen. Diese kann auf der Homepage geladen werden.");
                }

                if (downloadableAddons != null)
                {
                    this.downloadableAddons = downloadedSettings.addons;
                    foreach (DownloadableAddon addon in this.downloadableAddons)
                    {
                        if (true)//!this.getAllAddons().Contains(addon.fileName.Substring(0, addon.fileName.LastIndexOf("."))) && this.isNewerVersionOfAddonUploaded(addon))
                        {
                            System.Windows.Controls.CheckBox checkBox1 = new System.Windows.Controls.CheckBox();
                            foreach (System.Windows.Controls.CheckBox checkBox2 in list)
                            {
                                if ((checkBox2.Content as string).Equals(addon.name))
                                {
                                    checkBox1.IsChecked = checkBox2.IsChecked;
                                    checkBox1.IsEnabled = checkBox2.IsEnabled;
                                }
                            }

                            /*bool? isChecked = this.checkAutoUpdateAddons.IsChecked;
                             * if ((!isChecked.GetValueOrDefault() ? 0 : (isChecked.HasValue ? 1 : 0)) != 0)
                             *  checkBox1.IsEnabled = false;*/
                            checkBox1.Content = (object)addon.name;
                            if (addon.size != 0L)
                            {
                                System.Windows.Controls.CheckBox checkBox2 = checkBox1;
                                string str = string.Concat(new object[4]
                                {
                                    checkBox2.Content,
                                    (object)" - ",
                                    (object)this.downloader.doubleToShortenedString((double)addon.size / 1000000.0),
                                    (object)"MB"
                                });
                                checkBox2.Content = (object)str;
                            }
                            checkBox1.Tag        = (object)addon;
                            checkBox1.Foreground = (Brush)Brushes.White;
                            this.listAllPheonixAddons.Items.Add((object)checkBox1);
                            //isChecked = this.checkAutoUpdateAddons.IsChecked;

                            /*if ((!isChecked.GetValueOrDefault() ? 0 : (isChecked.HasValue ? 1 : 0)) != 0 && this.isCurrentlyRightDirectory)
                             * {
                             *  this.downloader.downloadAddon(addon);
                             ++this.currentDownloadCount;
                             * }*/
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.stopDownloadingModsXml = true;
            }
        }