コード例 #1
0
            public static void DoUpgrade(ApplicationSettingsBase settings)
            {
                try
                {
                    // attempt to read the upgrade flag
                    if ((bool)settings[UpgradeFlag] == true)
                    {
                        // upgrade the settings to the latest version
                        settings.Upgrade();

                        // clear the upgrade flag
                        settings[UpgradeFlag] = false;
                        settings.Save();
                    }
                    else
                    {
                        // the settings are up to date
                    }
                }
                catch (SettingsPropertyNotFoundException ex)
                {
                    // notify the developer that the upgrade
                    // flag should be added to the settings file
                    throw ex;
                }
            }
コード例 #2
0
        internal static void MigrateUserSettings(ApplicationSettingsBase settings)
        {
            if (settings is IMigrateSettings)
            {
                IMigrateSettings customMigrator = (IMigrateSettings)settings;
                foreach (SettingsProperty property in settings.Properties)
                {
                    if (!SettingsPropertyExtensions.IsUserScoped(property))
                    {
                        continue;
                    }

                    object previousValue = settings.GetPreviousVersion(property.Name);

                    //need to do this to force the values to load before accessing the PropertyValues in order to migrate,
                    //otherwise the SettingsPropertyValue will always be null.
                    var iForceSettingsPropertyValuesToLoad = settings[property.Name];
                    var currentValue = settings.PropertyValues[property.Name];
                    MigrateProperty(customMigrator, MigrationScope.User, currentValue, previousValue);
                }
            }
            else
            {
                settings.Upgrade();
            }

            //Don't need to reload because the user settings will be current.
            SaveIfDirty(settings);
        }
コード例 #3
0
        /// <summary>
        /// 現在のアセンブリバージョンが指定バージョンより高ければSettingsをアップグレードして保存する
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="version">比較するアセンブリバージョン</param>
        public static void UpgradeSettings(ApplicationSettingsBase settings, Version version)
        {
            var currentVersion = System.Reflection.Assembly.GetCallingAssembly().GetName().Version;

            if (version < currentVersion)
            {
                settings.Upgrade();
                settings.Save();
            }
        }
コード例 #4
0
        private void Upgrade()
        {
            if (!Get("UpgradeRequired", true))
            {
                return;
            }

            _settingsBase.Upgrade();
            Set("UpgradeRequired", false);
            _settingsBase.Save();
        }
コード例 #5
0
        /// <summary>
        /// 指定したプロパティ名の値がfalseならSettingsをアップグレードして指定プロパティの値をtrueにして保存する
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="isUpgratedPropertyName">アップグレードするかのフラグを持ったプロパティ名</param>
        public static void UpgradeSettings(ApplicationSettingsBase settings, string isUpgratedPropertyName)
        {
            var isUpgrated = settings[isUpgratedPropertyName];

            if (!(isUpgrated is bool))
            {
                return;
            }
            if (!(bool)isUpgrated)
            {
                settings.Upgrade();
                settings[isUpgratedPropertyName] = true;
                settings.Save();
            }
        }
コード例 #6
0
        /// <summary>
        /// 檢查更新時載入舊版本設定參數,請先建立參數 bool _SettingUpgrade = false
        /// </summary>
        /// <param name="settings"></param>
        static public void Run(ApplicationSettingsBase settings)
        {
            //檢查是否為新版本未更新參數值
            if (Upgraded == false)
            {
                //從舊版本載入設定
                settings.Upgrade();
                //存檔
                settings.Save();

                //設定為已載入舊版本參數
                Upgraded = true;
            }

            //重載入設定參數值
            settings.Reload();
        }
コード例 #7
0
        /// <summary>
        /// Constructeur de la fenêtre principale
        /// </summary>
        public ffs2play()
        {
            // Définition de la culture par défaut
            Thread.CurrentThread.CurrentUICulture = FrenchCulture;
            // LeResourceManager prend en paramètre : nom_du_namespace.nom_de_la_ressource_principale
            RM = new System.Resources.ResourceManager("Localisation.Form1", typeof(ffs2play).Assembly);
            // Initialisation de contenu de la fenêtre
            InitializeComponent();
#if DEBUG
        #if P3D
            Text = "ffs2play P3D (version Debug)";
        #else
            Text = "ffs2play (version Debug)";
        #endif
#else
        #if P3D
            Text = "ffs2play P3D";
        #else
            Text = "ffs2play";
        #endif
#endif
            pInstance = this;
            // Préparation du bouton de connexion au simulateur
            ILConnexionFS.Images.Add(Resources.plane_red);
            ILConnexionFS.Images.SetKeyName(0, "Déconnecté");
            ILConnexionFS.Images.Add(Resources.plane_green);
            ILConnexionFS.Images.SetKeyName(1, "Connecté");
            btnConnectFS.ImageIndex = 0;

            // Préparation du bouton de connexion au serveur web
            ilServeur.Images.Add(Resources.connect2_R);
            ilServeur.Images.SetKeyName(0, "Déconnecté");
            ilServeur.Images.Add(Resources.connect2_V);
            ilServeur.Images.SetKeyName(1, "Connecté");
            btnConPirep.ImageIndex = 0;

            // Configuration par défaut de la fenêtre
            WindowState   = FormWindowState.Normal;
            StartPosition = FormStartPosition.WindowsDefaultBounds;
            SetAllowUnsafeHeaderParsing20();

            // Copy user settings from previous application version if necessary
            settings = Settings.Default;
            if ((bool)settings["UpgradeRequired"] == true)
            {
                // upgrade the settings to the latest version
                settings.Upgrade();

                // clear the upgrade flag
                settings["UpgradeRequired"] = false;
                settings.Save();
            }
            else
            {
                // the settings are up to date
            }
            // On vérifie des les données de taille et de position de la fenêtre ne sont pas vides
            // Et qu'elles sont toujours valides avec la configuration d'écran actuelle
            // Ceci pour éviter une fenêtre en dehors des limites
            if (Properties.Settings.Default.WindowPosition != Rectangle.Empty &&
                IsVisibleOnAnyScreen(Properties.Settings.Default.WindowPosition))
            {
                // Définition de la position et de la taille de la fenêtre
                StartPosition = FormStartPosition.Manual;
                DesktopBounds = Properties.Settings.Default.WindowPosition;

                // Définition de l'état de la fenêtre pour être maximisée
                // ou réduite selon la sauvegarde
                WindowState = Properties.Settings.Default.WindowState;
            }
            else
            {
                // Réinitialisation de la position à la valeur par défaut
                StartPosition = FormStartPosition.WindowsDefaultLocation;

                // Nous pouvons alors définir la taille enrégistrée si celle ci
                // Existe
                if (Properties.Settings.Default.WindowPosition != Rectangle.Empty)
                {
                    Size = Properties.Settings.Default.WindowPosition.Size;
                }
            }
            // Mise à jour de l'option Météo Automatique
            cbEnaAutoWeather.Checked = Settings.Default.MetarAutoEnable;
            // La fenêtre est configurée
            windowInitialized = true;

            log = Logger.Instance;
            log.LogMessage("ffs2play démarré");

            // Creation du contrôleur d'interface avec le simulateur
            scm = SCManager.Instance;

            // Création du contrôleur de mapping des AI

            m_Mapping = AIMapping.Instance;

            // Création du contrôleur d'inteface avec le serveur web
            pm = PirepManager.Instance;

            // Création du contrôleur d'analyse de vol
            Analyse = AnalyseurManager.Instance;

            // Création du contrôleur de connexion P2P
            P2P = P2PManager.Instance;
            if (Properties.Settings.Default.P2PEnable)
            {
                P2P.Init(true);
            }
            AcceptButton = btnSend;
            string[] arguments = Environment.GetCommandLineArgs();
            scm.openConnection();

            //Vérification de la version
            string CheckVersionURL;
#if P3D
            CheckVersionURL = "http://download.ffsimulateur2.fr/ffs2playp3d.php";
#else
            CheckVersionURL = "http://download.ffsimulateur2.fr/ffs2play.php";
#endif
            if (Properties.Settings.Default.Beta)
            {
                CheckVersionURL += "?beta";
            }
            HTTPRequestThread CheckVersion = new HTTPRequestThread(CheckVersionURL, CheckVersionCallBack);

            CheckVersion.Start();
            if (!Properties.Settings.Default.LogVisible)
            {
                scMainWindow.Panel2Collapsed = true;
                scMainWindow.Panel2.Hide();
            }
        }
コード例 #8
0
 /// <summary>
 /// Settingsをアップグレードして保存する
 /// </summary>
 /// <param name="settings"></param>
 public static void UpgradeSettings(ApplicationSettingsBase settings)
 {
     settings.Upgrade();
     settings.Save();
 }