コード例 #1
0
        /// <summary>
        /// Must override this, this is the bit that does the saving to file.  Called when Settings.Save() is called
        /// </summary>
        /// <param name="context"></param>
        /// <param name="collection"></param>
        public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
        {
            //grab the values from the collection parameter and update the values in our dictionary.
            foreach (SettingsPropertyValue value in collection)
            {
                var setting = new SettingStruct()
                {
                    value       = (value.PropertyValue == null ? String.Empty : value.SerializedValue.ToString()),
                    name        = value.Name,
                    serializeAs = value.Property.SerializeAs.ToString()
                };

                if (!SettingsDictionary.ContainsKey(value.Name))
                {
                    SettingsDictionary.Add(value.Name, setting);
                }
                else
                {
                    SettingsDictionary[value.Name] = setting;
                }
            }

            //now that our local dictionary is up-to-date, save it to disk.
            SaveValuesToFile();
        }
コード例 #2
0
        /// <summary>
        /// Loads the values of the file into memory.
        /// </summary>
        private void LoadValuesFromFile()
        {
            if (!File.Exists(ConfigPath))
            {
                //if the config file is not where it's supposed to be create a new one.
                throw new Exception("Config file not found: " + ConfigPath);
            }

            //load the xml
            var configXml = XDocument.Load(ConfigPath);

            //get all of the <setting name="..." serializeAs="..."> elements.
            var settingElements = configXml.Element(CONFIG).Element(APPLICATION_SETTINGS).Element(typeof(Properties_Settings).FullName).Elements(SETTING);

            //iterate through, adding them to the dictionary, (checking for nulls, xml no likey nulls)
            //using "String" as default serializeAs...just in case, no real good reason.
            foreach (var element in settingElements)
            {
                var newSetting = new SettingStruct()
                {
                    name        = element.Attribute(NAME) == null ? String.Empty : element.Attribute(NAME).Value,
                    serializeAs = element.Attribute(SERIALIZE_AS) == null ? "String" : element.Attribute(SERIALIZE_AS).Value,
                    value       = element.Value ?? String.Empty
                };

                if (newSetting.serializeAs == "Xml")
                {
                    var e = (XElement)element.Nodes().First();
                    newSetting.value = e.LastNode.ToString() ?? String.Empty;
                }
                ;

                SettingsDictionary.Add(element.Attribute(NAME).Value, newSetting);
            }
        }
コード例 #3
0
        /// <summary>
        /// Loads the values of the file into memory.
        /// </summary>
        private void LoadValuesFromFile()
        {
            if (!File.Exists(UserConfigPath))
            {
                //if the config file is not where it's supposed to be create a new one.
                CreateEmptyConfig();
            }

            //load the xml
            var configXml = XDocument.Load(UserConfigPath);

            //get all of the <setting name="..." serializeAs="..."> elements.
            var settingElements = configXml.Element(CONFIG).Element(USER_SETTINGS).Element(typeof(Properties.Settings).FullName).Elements(SETTING);

            //iterate through, adding them to the dictionary, (checking for nulls, xml no likey nulls)
            //using "String" as default serializeAs...just in case, no real good reason.
            foreach (var element in settingElements)
            {
                var newSetting = new SettingStruct()
                {
                    name        = element.Attribute(NAME) == null ? String.Empty : element.Attribute(NAME).Value,
                    serializeAs = element.Attribute(SERIALIZE_AS) == null ? "String" : element.Attribute(SERIALIZE_AS).Value,
                    value       = element.Value ?? String.Empty
                };
                SettingsDictionary.Add(element.Attribute(NAME).Value, newSetting);
            }
        }
コード例 #4
0
ファイル: SettingWindow.cs プロジェクト: MatrixHan/XHSJ
 bool IsCanChangeKey(SettingStruct data)
 {
     if (!data.canChange)
     {
         MessageWindow.Message(51, 107, values: MessageData.GetMessage(data.name_id));
     }
     return(data.canChange);
 }
コード例 #5
0
        public Game(string filePath = "")
        {
            if (filePath.Contains("-t"))
            {
                LevelEV.TESTROOM_LEVELTYPE = GameTypes.LevelType.TOWER;
                filePath = filePath.Replace("-t", "");
            }
            else if (filePath.Contains("-d"))
            {
                LevelEV.TESTROOM_LEVELTYPE = GameTypes.LevelType.DUNGEON;
                filePath = filePath.Replace("-d", "");
            }
            else if (filePath.Contains("-g"))
            {
                LevelEV.TESTROOM_LEVELTYPE = GameTypes.LevelType.GARDEN;
                filePath = filePath.Replace("-g", "");
            }
            if (Thread.CurrentThread.CurrentCulture.Name != "en-US")
            {
                Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US", false);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US", false);
            }
            m_commandLineFilePath = filePath;
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            EngineEV.ScreenWidth  = 1320;
            EngineEV.ScreenHeight = 720;
            Window.Title          = "Rogue Legacy Enhanced";
            ScreenManager         = new RCScreenManager(this);
            SaveManager           = new SaveGameManager(this);
            IsFixedTimeStep       = false;
            graphics.SynchronizeWithVerticalRetrace = !LevelEV.SHOW_FPS;
            Window.AllowUserResizing = false;
            if (!LevelEV.ENABLE_OFFSCREEN_CONTROL)
            {
                InactiveSleepTime = default(TimeSpan);
            }
            PhysicsManager  = new PhysicsManager();
            EquipmentSystem = new EquipmentSystem();
            EquipmentSystem.InitializeEquipmentData();
            EquipmentSystem.InitializeAbilityCosts();
            GameConfig = default(SettingStruct);
            var form = Control.FromHandle(Window.Handle) as Form;

            if (form != null)
            {
                form.FormClosing += FormClosing;
            }
            GraphicsDeviceManager.PreparingDeviceSettings += ChangeGraphicsSettings;
            SleepUtil.DisableScreensaver();
        }
コード例 #6
0
        /// <summary>
        /// merge from the default settings.
        /// </summary>
        private void MergeFromDefaultSettings(SettingsPropertyValueCollection values)
        {
            needMerge = false;
            foreach (SettingsPropertyValue vv in Properties.Settings.Default.PropertyValues)
            {
                if (values[vv.Name] != null)
                {
                    values.Remove(vv.Name);
                    values.Add(vv);
                    var setting = new SettingStruct()
                    {
                        value       = (vv.PropertyValue == null ? String.Empty : vv.PropertyValue.ToString()),
                        name        = vv.Name,
                        serializeAs = vv.Property.SerializeAs.ToString()
                    };
                    settingsDictionary[vv.Name] = setting;
                }
            }

            SaveValuesToFile();
        }
コード例 #7
0
        /// <summary>
        /// Must override this, this is the bit that does the saving to file.  Called when Settings.Save() is called
        /// </summary>
        /// <param name="context"></param>
        /// <param name="collection"></param>
        public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
        {
            //grab the values from the collection parameter and update the values in our dictionary.
            foreach (SettingsPropertyValue value in collection)
            {
                try
                {
                    Type t = GetType(value.Property.PropertyType.FullName);

                    var setting = new SettingStruct()
                    {
                        value = (value.PropertyValue == null ? String.Empty
                                 //: value.PropertyValue.ToString()),
                            : (string)(TypeDescriptor.GetConverter(t).ConvertToInvariantString(value.PropertyValue))),

                        name        = value.Name,
                        serializeAs = value.Property.SerializeAs.ToString()
                    };

                    if (!SettingsDictionary.ContainsKey(value.Name))
                    {
                        SettingsDictionary.Add(value.Name, setting);
                    }
                    else
                    {
                        SettingsDictionary[value.Name] = setting;
                    }
                }
                catch (Exception ee)
                {
                    Console.WriteLine(ee.Message);
                }
            }

            //now that our local dictionary is up-to-date, save it to disk.
            SaveValuesToFile();
        }
コード例 #8
0
        /// <summary>
        /// Loads the values of the file into memory.
        /// </summary>
        private void LoadValuesFromFile()
        {
            if (!File.Exists(UserConfigPath))
            {
                //if the config file is not where it's supposed to be create a new one.
                CreateEmptyConfig();
            }

            try
            {
                //load the xml
                var configXml = XDocument.Load(UserConfigPath);

                //get all of the <setting name="..." serializeAs="..."> elements.
                var settingElements = configXml.Element(CONFIG).Element(USER_SETTINGS).Element(typeof(Properties.Settings).FullName).Elements(SETTING);

                //iterate through, adding them to the dictionary, (checking for nulls, xml no likey nulls)
                //using "String" as default serializeAs...just in case, no real good reason.
                foreach (var element in settingElements)
                {
                    var newSetting = new SettingStruct()
                    {
                        name = element.Attribute(NAME) == null ? String.Empty : element.Attribute(NAME).Value,
                        serializeAs = element.Attribute(SERIALIZE_AS) == null ? "String" : element.Attribute(SERIALIZE_AS).Value,
                        value = element.Value ?? String.Empty
                    };
                    SettingsDictionary.Add(element.Attribute(NAME).Value, newSetting);
                }
            }
            catch
            {
                if (File.Exists(UserConfigPath))
                    File.Delete(UserConfigPath);
            }
        }
コード例 #9
0
        /// <summary>
        /// Must override this, this is the bit that does the saving to file.  Called when Settings.Save() is called
        /// </summary>
        /// <param name="context"></param>
        /// <param name="collection"></param>
        public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
        {
            //grab the values from the collection parameter and update the values in our dictionary.
            foreach (SettingsPropertyValue value in collection)
            {
                var setting = new SettingStruct()
                {
                    value = (value.PropertyValue == null ? String.Empty : value.SerializedValue.ToString()),
                    name = value.Name,
                    serializeAs = value.Property.SerializeAs.ToString()
                };

                if (!SettingsDictionary.ContainsKey(value.Name))
                {
                    SettingsDictionary.Add(value.Name, setting);
                }
                else
                {
                    SettingsDictionary[value.Name] = setting;
                }
            }

            //now that our local dictionary is up-to-date, save it to disk.
            SaveValuesToFile();
        }
コード例 #10
0
 private static void SerializeColorAndPutToSetting(SettingsPropertyValue value, ref SettingStruct setting)
 {
     var color = (Color)value.PropertyValue;
     if (color.IsKnownColor)
     {
         setting.value = color.Name;
     }
     else
     {
         setting.value = ColorTranslator.ToHtml(Color.FromArgb(color.ToArgb()));
     }
 }
コード例 #11
0
        /// <summary>
        /// Must override this, this is the bit that does the saving to file.  Called when Settings.Save() is called
        /// </summary>
        /// <param name="context"></param>
        /// <param name="collection"></param>
        public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
        {
            //grab the values from the collection parameter and update the values in our dictionary.
            foreach (SettingsPropertyValue value in collection)
            {
                var setting = new SettingStruct()
                {
                    //value = (value.PropertyValue == null ? String.Empty : value.PropertyValue.ToString()),
                    name = value.Name,
                    serializeAs = value.Property.SerializeAs.ToString()
                };

                if (ShouldEncrypt(value.Property))
                {
                    setting.value = (value.PropertyValue == null ? String.Empty : Crypto.EncryptString(Crypto.ToSecureString(value.PropertyValue.ToString())));
                }
                else
                {
                    setting.value = (value.PropertyValue == null ? String.Empty : value.PropertyValue.ToString());
                    try
                    {
                        if (value.PropertyValue.GetType() == typeof (System.Drawing.Color))
                        {
                            SerializeColorAndPutToSetting(value, ref setting);
                        }
                    }
                    catch // Replace this try{}catch{} with appropriate collection
                    {

                    }
                }

                if (!SettingsDictionary.ContainsKey(value.Name))
                {
                    SettingsDictionary.Add(value.Name, setting);
                }
                else
                {
                    SettingsDictionary[value.Name] = setting;
                }
            }

            //now that our local dictionary is up-to-date, save it to disk.
            SaveValuesToFile();
        }
コード例 #12
0
        /// <summary>
        /// Loads the values of the file into memory.
        /// </summary>
        private void LoadValuesFromFile()
        {
            if (!File.Exists(UserConfigPath))
            {
                // If the config file is not where it's supposed to be create a new one:
                CreateEmptyConfig();
            }

            // Load the XML:
            var configXml = LoadConfiguration();

            // Get all of the <setting name="..." serializeAs="..."> elements:
            var settingElements = configXml.Element(CONFIG).Element(USER_SETTINGS).Element(typeof(Settings).FullName).Elements(SETTING);

            // Iterate through, adding them to the dictionary, (checking for nulls, XML no likey nulls),
            // using "String" as default serializeAs...just in case, no real good reason:
            foreach (var element in settingElements)
            {
                var newSetting = new SettingStruct()
                {
                    name = element.Attribute(NAME) == null ? String.Empty : element.Attribute(NAME).Value,
                    serializeAs = element.Attribute(SERIALIZE_AS) == null ? "String" : element.Attribute(SERIALIZE_AS).Value,
                    value = element.Value ?? String.Empty
                };
                SettingsDictionary.Add(element.Attribute(NAME).Value, newSetting);
            }
        }