Exemple #1
0
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if (Settings.ConfigExists())
            {
                Settings.Read();
            }
            else
            {
                if (!Settings.ReadPath())
                {
                    this.ShowMessageAsync("Ruta de ejecución", "La ruta de ejecución no ha sido autodetectada, indicala manualmente en la ventana de opciones antes de empezar a utilizar la aplicación");
                }

                //Create default profile
                Profiles.CreateDefault();

                //Save settings
                Settings.Write();
            }

            //Add local addons
            Configuration.Addons.ReadAddons();
            foreach (string addon in Configuration.Addons.LocalAddons)
            {
                Addons.Add(new Addon()
                {
                    Enabled = false, Name = addon
                });
            }
            listBox_addons.ItemsSource = Addons;

            //Add available memory allocators
            Settings.ReadAllocators();
            foreach (string allocator in Settings.Allocators)
            {
                comboBox_malloc.Items.Add(allocator);
            }

            //Add profiles
            UpdateProfiles();
            comboBox_profiles.SelectedIndex = comboBox_profiles.Items.IndexOf(Profiles.DefaultProfile); //Select default profile

            //Set accent
            ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(Settings.Accents[Settings.Accent]), ThemeManager.GetAppTheme("BaseLight"));

            //Set groupboxes preferences
            groupBox_servers.IsExpanded    = Settings.ServersGroupBox;
            groupBox_repository.IsExpanded = Settings.RepositoryGroupBox;

            //If just updated, remove updater and show notification
            if (Updater.Updated)
            {
                Updater.RemoveUpdater();
                this.ShowMessageAsync("Aplicación actualizada", "La aplicación ha sido actualizada con éxito");
            }

            //Notify if update failed
            if (Updater.UpdateFailed)
            {
                Updater.RemoveUpdater();
                this.ShowMessageAsync("Error al actualizar", "Se ha producido un error al actualizar la aplicación, vuelve a intentarlo más tarde");
            }

            //Check Java presence
            Repository.CheckJava();

            //Check Arma3Sync configuration
            if ((Repository.JavaVersion != "" || Settings.JavaPath != "") && Settings.Arma3SyncPath != "" && Settings.Arma3SyncRepository != "")
            {
                image_arma3Sync.Source           = new BitmapImage(new Uri("pack://application:,,,/Resources/a3sEnabled.png"));
                image_arma3Sync.ToolTip          = "Arma3Sync está configurado. Click para iniciar";
                tile_repositoryStatus.IsEnabled  = true;
                tile_repositoryStatus.Background = new SolidColorBrush(Colors.Orange);
                tile_repositoryStatus.ToolTip    = "Click para comprobar estado";
            }

            //Check repository for updates
            if (Settings.CheckRepository)
            {
                tile_repositoryStatus.IsEnabled = false;
                new Thread(Repository.CheckRepository).Start();
            }

            //Check servers status
            if (Settings.CheckServers)
            {
                new Thread(Servers.CheckServers).Start();
            }

            //Check for updates
            if (Settings.CheckUpdates)
            {
                new Thread(() => Updater.CheckVersion(false)).Start();
            }

            //Check local game version against server version
            label_gameVersion.Content = Settings.GetGameVersion();
            new Thread(Servers.CompareServerVersion).Start();
        }