Exemplo n.º 1
0
        public void Save_File(SettingsType type, string filename)
        {
            var dest = Result(filename);

            type.Save(dest, CreatePerson());
            Assert.That(File.Exists(dest), Is.True);
        }
 public void SelectTab(SettingsType tabType)
 {
     for (int i = 0; i < _settingTabsList.Length; i++)
     {
         _settingTabsList[i].SetTab(tabType);
     }
 }
Exemplo n.º 3
0
        private string getFileName(SettingsType pType, string pCompanyName, string pApplicationName)
        {
            string dirName;

            if (pType == SettingsType.User)
            {
                dirName = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            }
            else
            {
                dirName = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
            }

            if ((pCompanyName != null) && (pCompanyName.Length > 0))
            {
                dirName = Path.Combine(dirName, pCompanyName);
            }

            if ((pApplicationName != null) && (pApplicationName.Length > 0))
            {
                dirName = Path.Combine(dirName, pApplicationName);
            }

            if (pType == SettingsType.User)
            {
                return(Path.Combine(dirName, "UserSettings.config"));
            }
            else
            {
                return(Path.Combine(dirName, "AppSettings.config"));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Load the mod settings. Loads the settings from {ModManager.PathSettings}/{Metadata.Name}.yaml by default.
        /// </summary>
        public virtual void LoadSettings()
        {
            if (SettingsType == null)
            {
                return;
            }

            _Settings = (ModSettings)SettingsType.GetConstructor(ModManager._EmptyTypeArray).Invoke(ModManager._EmptyObjectArray);

            string extension = ".yaml";

            string path = Path.Combine(ModManager.PathSettings, Metadata.Name + extension);

            if (!File.Exists(path))
            {
                return;
            }

            try {
                using (Stream stream = File.OpenRead(path))
                    using (StreamReader reader = new StreamReader(path))
                        _Settings = (ModSettings)YamlHelper.Deserializer.Deserialize(reader, SettingsType);
            } catch {
            }
        }
 protected MoonpigTestBase(LaunchPage launchTarget, SettingsType settingsType = SettingsType.ProjectBound)
     : base((int)launchTarget)
 {
     TestBaseNamespace     = "Ravitej.Automation.Sample.Ui.Tests";
     TestResultsBaseFolder = "Moonpig";
     _settingsType         = settingsType;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Save setting value
        /// </summary>
        /// <param name="settingsType">type of setting</param>
        /// <param name="value">value you want to save</param>
        public static void SetSetting(SettingsType settingsType, dynamic value)
        {
            if (settingTypes.TryGetValue(settingsType, out SettingsValueType valueType))
            {
                switch (valueType)
                {
                case SettingsValueType.FLOAT:
                    if (value is float || value is int)
                    {
                        PlayerPrefs.SetFloat(settingsType.ToString(), (float)value);
                    }
                    // TODO: log error
                    break;

                case SettingsValueType.INT:
                    if (value is int || value is float)
                    {
                        PlayerPrefs.SetInt(settingsType.ToString(), (int)value);
                    }
                    // TODO: log error
                    break;

                case SettingsValueType.STRING:
                    if (value is string)
                    {
                        PlayerPrefs.SetString(settingsType.ToString(), (string)value);
                    }
                    // TODO: log error
                    break;
                }
            }
        }
Exemplo n.º 7
0
        private void SetGeneratorSettings()
        {
            string       wrpSettingsPath = Utility.FindFabricResourceFile(Constant.WrpSettingsFilename);
            SettingsType wrpSettings     = System.Fabric.Interop.Utility.ReadXml <SettingsType>(wrpSettingsPath);

            this.ClusterManifestGeneratorSettings = GenerateSettings(wrpSettings, this.Topology);
        }
 public void Write(SettingsType key, object value)
 {
     lock (locker)
     {
         dbService.SettingsSetValue(key, Converter.ToString(value));
     }
 }
Exemplo n.º 9
0
        public static void SaveConnection(CmsInstance value, SettingsType type)
        {
            // Save as the last session
            var name = "lastsession" + (type == SettingsType.ForImport ? "Import" : "Export");

            SetProperty(name, SerializeCmsInstance(value));

            var found    = false;
            var sessions = GetConnections(type);

            foreach (var session in sessions)
            {
                if (session.Server == value.Server && session.Instance == value.Instance)
                {
                    session.Key      = value.Key;
                    session.Username = value.Username;
                    SaveConnections(sessions, type);
                    found = true;
                }
            }
            if (!found)
            {
                // Not found, so append our item
                var list = sessions.ToList();
                list.Add(value);
                SaveConnections(list.ToArray(), type);
            }

            Settings.Default.Save();
        }
Exemplo n.º 10
0
        public virtual void OnInputInitialize()
        {
            if (SettingsType == null)
            {
                return;
            }

            object settings = _Settings;

            if (settings == null)
            {
                return;
            }

            foreach (PropertyInfo prop in SettingsType.GetProperties())
            {
                if (!prop.CanRead)
                {
                    continue;
                }

                if (typeof(ButtonBinding).IsAssignableFrom(prop.PropertyType))
                {
                    InitializeButtonBinding(settings, prop);
                }
                else if (false)
                {
                    // TODO: JoystickBindings
                }
            }
        }
Exemplo n.º 11
0
        // public DataSourceXml(): this(new XmlSerializerSettings())
        /// <summary>
        /// Initializes a new instance of the <see cref="DataSourceXml"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <exception cref="ArgumentOutOfRangeException">type - null</exception>
        public DataSourceXml(SettingsType type)
        {
            switch (type)
            {
            case SettingsType.DataTransfer:
                Settings = new XmlSerializerSettings()
                {
                    Indent = false, NullValueHandling = XmlNullValueHandling.Ignore, OmitXmlDeclaration = true
                };
                break;

            case SettingsType.ManualEditing:
                Settings = new XmlSerializerSettings()
                {
                    Indent = true, NullValueHandling = XmlNullValueHandling.Include, OmitXmlDeclaration = false
                };
                break;

            case SettingsType.Both:
                Settings = new XmlSerializerSettings()
                {
                    Indent = true, NullValueHandling = XmlNullValueHandling.Ignore, OmitXmlDeclaration = false
                };
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Deserializes the next block of data.
        /// </summary>
        /// <param name="serializedData">The serialized data.</param>
        /// <param name="settings">The settings.</param>
        /// <returns>The deserialization result.</returns>
        private static DeserializationResult DeserializeBlock(BinaryData serializedData, Settings settings)
        {
            if (serializedData == null || serializedData.Left == 0)
            {
                return(DeserializationResult.EndOfData);
            }

            SettingsType settingsType = serializedData.PeekSettingsType();

            Log.DevDebug(typeof(BinarySettings), "DeserializeBlock", applySettings, settingsType);

            switch (settingsType)
            {
            case SettingsType.StandardService:
                return(DeserializeStandardServiceSettings(serializedData, settings));

            case SettingsType.HiddenService:
                return(DeserializeHiddenServiceSettings(serializedData, settings));

            case SettingsType.ServiceRanges:
                return(DeserializeRangeSettings(serializedData, settings));

            case SettingsType.Compatibility:
                return(DeserializeCompatibilitySettings(serializedData, settings));

            default:
                throw new InvalidOperationException("Unknown settings type: " + settingsType.ToString());
            }
        }
Exemplo n.º 13
0
        public virtual void OnInputDeregister()
        {
            if (SettingsType == null)
            {
                return;
            }

            object settings = _Settings;

            foreach (PropertyInfo prop in SettingsType.GetProperties())
            {
                if (!prop.CanRead)
                {
                    continue;
                }

                if (typeof(ButtonBinding).IsAssignableFrom(prop.PropertyType))
                {
                    if (!(prop.GetValue(settings) is ButtonBinding binding))
                    {
                        continue;
                    }

                    binding.Button?.Deregister();
                }
                else if (false)
                {
                    // TODO: JoystickBindings
                }
            }
        }
Exemplo n.º 14
0
 public static void OpenWindow(SettingsType _Settings)
 {
     m_CameraSettings       = _Settings;
     m_CameraWindow         = (GeneralCameraSettings)GetWindow(typeof(GeneralCameraSettings));
     m_CameraWindow.minSize = new Vector2(250, 250);
     m_CameraWindow.Show();
 }
        /// <summary>
        /// Fills all settings: SettingsStr, SettingsXml and DebugMode
        /// InitSettings() should be the first line of code in Page_Load().
        /// If settings is missing settingsExists is set to false
        /// Note: It is not mandatory to use InitSettings() in the
        /// Page_Load() - The programmer can just leave it out if he
        /// decides that he is not going to use the setting system that
        /// class OneFileModule provides.
        /// </summary>
        /// <param name="settingsType">Type of the settings.</param>
        protected void InitSettings(SettingsType settingsType)
        {
            _settingsType = settingsType;
            if (_settingsType == SettingsType.Off)
            {
                return;
            }

            _debugMode   = "True" == Settings["Debug Mode"].ToString();
            _xmlFileName = Settings["XML settings file"].ToString();

            _settingsExists = true;

            if (_settingsType == SettingsType.Str || _settingsType == SettingsType.StrAndXml)
            {
                _settingsStr = Settings["Settings string"].ToString();
                if (_settingsStr == string.Empty)
                {
                    _settingsExists = false;
                    Controls.Add(new LiteralControl("<br><span class='Error'>Settings string is missing</span><br>"));
                }
            }

            if (_settingsType == SettingsType.Xml || _settingsType == SettingsType.StrAndXml)
            {
                _settingsXml = new XmlDocument();
                if (GetSettingsXml(ref _settingsXml, _xmlFileName) == false)
                {
                    _settingsExists = false;
                    Controls.Add(new LiteralControl("<br>" + "<span class='Error'>XML " + General.GetString("FILE_NOT_FOUND").Replace("%1%", _xmlFileName) + "<br>"));
                }
            }
        }
Exemplo n.º 16
0
 public string Load_Stream(SettingsType type, string filename)
 {
     using (var reader = new StreamReader(Example(filename)))
     {
         return(type.Load <Person>(reader.BaseStream).Name);
     }
 }
Exemplo n.º 17
0
 public static void OpenWindow(SettingsType setting)
 {
     dataSetting    = setting;
     window         = (GeneralSettings)GetWindow(typeof(GeneralSettings));
     window.minSize = new Vector2(250, 200);
     window.Show();
 }
Exemplo n.º 18
0
        public void Clear()
        {
            d_settings = new SettingsType();

            d_externalProjectFile = null;
            d_filename            = null;
        }
Exemplo n.º 19
0
        /// <summary>
        /// Populates a Panel with all available settings for a given SettingsType
        /// </summary>
        /// <param name="name"></param>
        /// <param name="settingsType"></param>
        /// <returns></returns>
        private Panel CreateSettingsTabPagePanel(SettingsType settingsType)
        {
            FlowLayoutPanel pnlDisplay = new FlowLayoutPanel()
            {
                Size          = tabSettingsGroups.ClientRectangle.Size,
                FlowDirection = FlowDirection.TopDown,
            };

            var settings = Settings.GetSettingsByCategoryTag(settingsType);

            foreach (var setting in settings)
            {
                // If the setting has a display condition attached and it is currently marked as NotDisplayed, skip
                if (Attribute.IsDefined(setting, typeof(DisplaySettingConditionAttribute)) &&
                    !setting.GetCustomAttribute <DisplaySettingConditionAttribute>().Display)
                {
                    continue;
                }

                var ctrl = PropertyControl(setting);
                ctrl.Width = pnlDisplay.ClientRectangle.Width;
                pnlDisplay.Controls.Add(ctrl);
            }

            return(pnlDisplay);
        }
Exemplo n.º 20
0
        private void CreateFileWatcher(SettingsType a_SettingsType)
        {
            try
            {
                string _Path = EnumeratorParser.GetStringValue(a_SettingsType);
                if (a_SettingsType.Equals(SettingsType.TraneObjectMaps))
                {
                    _FullPath = string.IsNullOrEmpty(ConfigurationManager.AppSettings["TraneObjectMapFolder"]) ? Path.Combine(@"C:\SPGateway\Metadata\", _Path) : ConfigurationManager.AppSettings["TraneObjectMapFolder"] + _Path;
                }
                else
                {
                    _FullPath = string.IsNullOrEmpty(ConfigurationManager.AppSettings["PersistenceDirectory"]) ? Path.Combine(@"C:\SPGateway\Settings\", _Path) : ConfigurationManager.AppSettings["PersistenceDirectory"] + _Path;
                }

                _FileDirectory = Path.GetDirectoryName(_FullPath);
                _Filter        = Path.GetFileName(_FullPath);
                FileSystemWatcher a_FileWatcher = new FileSystemWatcher(_FileDirectory, _Filter);
                a_FileWatcher.NotifyFilter        = NotifyFilters.LastWrite;
                a_FileWatcher.Changed            += _FileChanged_Event;
                a_FileWatcher.EnableRaisingEvents = true;
            }
            catch (Exception ex)
            {
                if (_Logger != null)
                {
                    _Logger.LogIf(COMPONENT_NAME, TraceLevel.Error, ex);
                }
            }
        }
Exemplo n.º 21
0
        protected override void ProcessRecord()
        {
            SettingsType type = SettingsType.General;

            Enum.TryParse <SettingsType>(Type, out type);

            switch (type)
            {
            case SettingsType.General:
                ProcessImpl(
                    (filter, top, skip) => Api.Settings.GetSettings(filter: filter, top: top, skip: skip, count: false),
                    dto => Setting.FromDto(dto));
                break;

            case SettingsType.Authentication:
                ProcessImpl(
                    filter => Api.Settings.GetAuthenticationSettings().Value,
                    dto => Setting.FromDto(dto));
                break;

            case SettingsType.Web:
                ProcessImpl(
                    filter => Api.Settings.GetWebSettings().Value,
                    dto => Setting.FromDto(dto));
                break;
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// Task change
 /// </summary>
 /// <param name="taskType">Control, Reward or Punishment task</param>
 /// <param name="settingsType">what is being changed</param>
 /// <param name="newValue"></param>
 public Change(TaskType taskType, SettingsType settingsType, int newValue)
 {
     IsTask       = true;
     TaskChange   = taskType;
     SettingsType = settingsType;
     NewValue     = newValue;
 }
    void OpenSetting(SettingsType settingType)
    {
        _selectedTab = settingType;
        switch (settingType)
        {
        case SettingsType.Language:
            _currentSettings.SaveLanguageSettings(_currentSettings.CurrentLocale);
            break;

        case SettingsType.Graphics:
            _graphicsComponent.Setup();
            break;

        case SettingsType.Audio:
            _audioComponent.Setup(_currentSettings.MusicVolume, _currentSettings.SfxVolume, _currentSettings.MasterVolume);
            break;

        default:
            break;
        }

        _languageComponent.gameObject.SetActive(settingType == SettingsType.Language);
        _graphicsComponent.gameObject.SetActive((settingType == SettingsType.Graphics));
        _audioComponent.gameObject.SetActive(settingType == SettingsType.Audio);
        _settingTabFiller.SelectTab(settingType);
    }
Exemplo n.º 24
0
        /// <summary>
        /// Saves the current settings
        /// </summary>
        /// <param name="Mode">mode to save settings as. Use zero to not change the mode</param>
        /// <returns>this instance</returns>
        public AppSettings SaveSettings(SettingsType Mode = 0)
        {
            var Data = Tools.ToXML(this);

            //Auto detect mode
            if (Mode == 0)
            {
                Restrictions = null;
                if (File.Exists(PortableSettingsFile))
                {
                    File.WriteAllText(PortableSettingsFile, Data);
                    Type       = SettingsType.Portable;
                    KeyStorage = Path.Combine(Path.GetDirectoryName(PortableSettingsFile), "Keys");
                }
                else
                {
                    //Create settings directory
                    var DirName = Path.GetDirectoryName(UserSettingsFile);
                    try
                    {
                        Directory.CreateDirectory(DirName);
                    }
                    catch
                    {
                        //Don't care
                    }
                    File.WriteAllText(UserSettingsFile, Data);
                    Type       = SettingsType.Local;
                    KeyStorage = Path.Combine(Path.GetDirectoryName(UserSettingsFile), "Keys");
                }
            }
            else
            {
                switch (Mode)
                {
                case SettingsType.Local:
                    Restrictions = null;
                    KeyStorage   = Path.Combine(Path.GetDirectoryName(UserSettingsFile), "Keys");
                    File.WriteAllText(UserSettingsFile, Data);
                    break;

                case SettingsType.Global:
                    KeyStorage = Path.Combine(Path.GetDirectoryName(GlobalSettingsFile), "Keys");
                    File.WriteAllText(GlobalSettingsFile, Data);
                    break;

                case SettingsType.Portable:
                    Restrictions = null;
                    KeyStorage   = Path.Combine(Path.GetDirectoryName(PortableSettingsFile), "Keys");
                    File.WriteAllText(PortableSettingsFile, Data);
                    break;

                default:
                    throw new NotImplementedException($"The given {nameof(SettingsType)} value is invalid");
                }
                Type = Mode;
            }
            return(this);
        }
Exemplo n.º 25
0
        static DataTable GetSettingsTable(int id, SettingsType type)
        {
            var       modules     = new ModuleController();
            Hashtable settings    = null;
            DataTable returnValue = null;

            switch (type)
            {
            case SettingsType.ModuleSettings:
                settings    = modules.GetModuleSettings(id);
                returnValue = new DataTable(DataSetTableName.Settings);
                break;

            case SettingsType.TabModuleSettings:
                settings    = modules.GetTabModuleSettings(id);
                returnValue = new DataTable(DataSetTableName.TabSettings);
                break;
            }

            var sortedSettings = new SortedList <string, string>();

            if (settings != null)
            {
                foreach (DictionaryEntry item in settings)
                {
                    sortedSettings.Add(item.Key.ToString(), item.Value.ToString());
                }
            }


            var dc = new DataColumn(SettingsTableColumn.Setting, typeof(string))
            {
                ColumnMapping = MappingType.Attribute
            };

            if (returnValue != null)
            {
                returnValue.Columns.Add(dc);
            }

            dc = new DataColumn(SettingsTableColumn.Value, typeof(string))
            {
                ColumnMapping = MappingType.Attribute
            };
            if (returnValue != null)
            {
                returnValue.Columns.Add(dc);

                foreach (var key in sortedSettings.Keys)
                {
                    var row = returnValue.NewRow();
                    row[SettingsTableColumn.Setting] = key;
                    row[SettingsTableColumn.Value]   = sortedSettings[key];
                    returnValue.Rows.Add(row);
                }
                return(returnValue);
            }
            return(null);
        }
Exemplo n.º 26
0
 public void BeginSaveSettings(SettingsType type)
 {
     _worker = new Thread(() => SaveSettings(type))
     {
         IsBackground = true
     };
     _worker.Start();
 }
Exemplo n.º 27
0
 internal RTAntenna(Object a)
 {
     actualRTAntenna            = a;
     IsBrokenField              = actualRTAntennaType.GetField("IsRTBroken");
     ActivatedField             = actualRTAntennaType.GetField("IsRTActive");
     ConsumptionMultiplierField = SettingsType.GetField("ConsumptionMultiplier");
     EnergyCostField            = actualRTAntennaType.GetField("EnergyCost");
 }
Exemplo n.º 28
0
 public ISetting For(SettingsType type)
 {
     if (_settingsModel.Settings.ContainsKey(type))
     {
         return(_settingsModel.Settings[type]);
     }
     return(null);
 }
 public static void SetBaselineField(SettingsType type, int newValue)
 {
     if (type != SettingsType.TaskNumber)
     {
         return;
     }
     Changes.Add(new Change(type, newValue));
 }
Exemplo n.º 30
0
        public static void OpenWindow(SettingsType setting)
        {
            dataSetting = setting;

            window         = CreateInstance(typeof(GeneralSettings)) as GeneralSettings;
            window.minSize = new Vector2(300, 300);
            window.ShowUtility();
        }
        static DataTable GetSettingsTable(int id, SettingsType type)
        {
            var modules = new ModuleController();
            Hashtable settings = null;
            DataTable returnValue = null;

            switch (type)
            {
                case SettingsType.ModuleSettings:
                    settings = modules.GetModuleSettings(id);
                    returnValue = new DataTable(DataSetTableName.Settings);
                    break;
                case SettingsType.TabModuleSettings:
                    settings = modules.GetTabModuleSettings(id);
                    returnValue = new DataTable(DataSetTableName.TabSettings);
                    break;
            }

            var sortedSettings = new SortedList<string, string>();
            if (settings != null)
                foreach (DictionaryEntry item in settings)
                {
                    sortedSettings.Add(item.Key.ToString(), item.Value.ToString());
                }


            var dc = new DataColumn(SettingsTableColumn.Setting, typeof (string))
                         {ColumnMapping = MappingType.Attribute};
            if (returnValue != null) returnValue.Columns.Add(dc);

            dc = new DataColumn(SettingsTableColumn.Value, typeof (string)) {ColumnMapping = MappingType.Attribute};
            if (returnValue != null)
            {
                returnValue.Columns.Add(dc);

                foreach (var key in sortedSettings.Keys)
                {
                    var row = returnValue.NewRow();
                    row[SettingsTableColumn.Setting] = key;
                    row[SettingsTableColumn.Value] = sortedSettings[key];
                    returnValue.Rows.Add(row);
                }
                return returnValue;
            }
            return null;
        }
Exemplo n.º 32
0
        /// <summary>
        /// Creates a new instance of the Formatter class
        /// </summary>
        public XmlIts1Formatter ()
	    {
            this.ValidateConformance = true;
            this.CreateRequiredElements = false;
            GenerateInMemory = true;
            this.GraphAides = new List<IStructureFormatter>(4);
            //this.Settings = SettingsType.DefaultLegacy;
            #if WINDOWS_PHONE
            this.Settings = SettingsType.AllowFlavorImposing | SettingsType.AllowSupplierDomainImposing | SettingsType.AllowUpdateModeImposing;
            #else
            this.Settings = Environment.ProcessorCount > 1 ? SettingsType.DefaultMultiprocessor : SettingsType.DefaultUniprocessor;
            #if DEBUG
            System.Diagnostics.Trace.TraceInformation("{0}", this.Settings);
            #endif
            #endif
	    }
Exemplo n.º 33
0
        /// <summary>
        /// Fills all settings: SettingsStr, SettingsXml and DebugMode
        ///   InitSettings() should be the first line of code in Page_Load().
        ///   If settings is missing settingsExists is set to false
        ///   Note: It is not mandatory to use InitSettings() in the
        ///   Page_Load() - The programmer can just leave it out if he
        ///   decides that he is not going to use the setting system that
        ///   class OneFileModule provides.
        /// </summary>
        /// <param name="settingsType">
        /// Type of the settings.
        /// </param>
        protected void InitSettings(SettingsType settingsType)
        {
            this._settingsType = settingsType;
            if (this._settingsType == SettingsType.Off)
            {
                return;
            }

            this._debugMode = "True" == this.Settings["Debug Mode"].ToString();
            this._xmlFileName = this.Settings["XML settings file"].ToString();

            this._settingsExists = true;

            if (this._settingsType == SettingsType.Str || this._settingsType == SettingsType.StrAndXml)
            {
                this._settingsStr = this.Settings["Settings string"].ToString();
                if (this._settingsStr == string.Empty)
                {
                    this._settingsExists = false;
                    this.Controls.Add(
                        new LiteralControl("<br /><span class='Error'>Settings string is missing</span><br />"));
                }
            }

            if (this._settingsType == SettingsType.Xml || this._settingsType == SettingsType.StrAndXml)
            {
                this._settingsXml = new XmlDocument();
                if (this.GetSettingsXml(ref this._settingsXml, this._xmlFileName) == false)
                {
                    this._settingsExists = false;
                    this.Controls.Add(
                        new LiteralControl(
                            string.Format(
                                "<br /><span class='Error'>XML {0}<br />",
                                General.GetString("FILE_NOT_FOUND").Replace("%1%", this._xmlFileName))));
                }
            }
        }
Exemplo n.º 34
0
 public SettingsProvider(SettingsType settingsType)
 {
     _settingsType = settingsType;
     MaxValue = 100;
 }
        internal override void Initialize()
        {
            base.Initialize();

            if (this.Arguments == null || this.Arguments.Count != 2)
            {
                throw new ParseException(Resource.SettingsMissingArguments);
            }

            this.settingsType = (SettingsType)Enum.Parse(typeof(SettingsType), this.Arguments[0]);
            this.settingsValue = this.Arguments[1];
        }
Exemplo n.º 36
0
 public ClientSettings GetSettings(SettingsType settingsType)
 {
     //TODO: Rewrite it to get from DB
        return new ClientSettings();
 }
Exemplo n.º 37
0
 /// <summary>
 /// Returns a settings path updated with current deets
 /// </summary>
 /// <param name="weights">if it's a weights file or otherwise just a settings file</param>
 /// <returns>path to settings</returns>
 public static string GetSettingsPath(SettingsType type, bool pvp)
 {
     return Logging.ApplicationPath + "\\Settings\\EquipMe\\EquipMe_" + StyxWoW.Me.Name + "_" + EquipMe.GetSpecName() + (pvp && Styx.Logic.Battlegrounds.IsInsideBattleground ? "_PVP" : "") + "_" + type.ToString() + ".xml";
 }
Exemplo n.º 38
0
 public ClientSettings GetSettings(SettingsType settingsType)
 {
     return _worker.GetSettings(settingsType);
 }
        public void UpdateSettings(SettingsType theType, object theSetting)
        {
            //collect them from the Application Resources Collection
            theSettings = App.Current.Resources["UserPreferences"] as UserSettings;

            switch (theType)
            {
                case SettingsType.AddCustomServer:
                case SettingsType.RemoveCustomServer:
                    //don't all any duplicates
                    theSettings.CustomServers.RemoveAll(cs => cs.ServerId == ((CustomServer)theSetting).ServerId);

                    if (theType == SettingsType.AddCustomServer)
                    {
                        theSettings.CustomServers.Add(theSetting as CustomServer);
                    }
                    break;
                case SettingsType.AddServerCredentials:
                case SettingsType.RemoveServerCredentials:
                    //get a serverdetail object
                    ServerDetails addMe = theSetting as ServerDetails;

                    //don't allow duplicate username for this server
                    theSettings.Servers.RemoveAll(sd => sd.ServerId == addMe.ServerId && sd.Username.Equals(addMe.Username, StringComparison.InvariantCultureIgnoreCase));

                    if (theType == SettingsType.AddServerCredentials)
                    {
                        theSettings.Servers.Add(addMe);
                    }
                    break;
                default:
                    //update the setting
                    theSettings.GetType().GetProperty(theType.ToString()).SetValue(theSettings, theSetting, null);
                    break;
            }

            App.Current.Resources["UserPreferences"] = theSettings;

            BinaryFormatter bf = new BinaryFormatter();
            LauncherEncryption myEncryption = new LauncherEncryption();
            IsolatedStorageFile inFile = IsolatedStorageFile.GetUserStoreForAssembly();

            //and save that into the file
            using (MemoryStream msOut = new MemoryStream())
            using (IsolatedStorageFileStream outStream = new IsolatedStorageFileStream("settings.cfg", FileMode.OpenOrCreate, System.IO.FileAccess.Write, inFile))
            using (BinaryWriter bwOut = new BinaryWriter(outStream))
            {
                //serialize it
                bf.Serialize(msOut, theSettings);

                //encrypt it and write it out
                bwOut.Write(myEncryption.Encrypt(msOut.ToArray()));
            }
        }