public void TearDown()
 {
     this.setting = null;
     this.settingType = default(SettingType);
     this.settingValue = null;
     this.possibleValues = null;
 }
 public void SetUp()
 {
     this.settingType = this.GetSettingType();
     this.settingValue = this.GetDefaultValue();
     this.possibleValues = this.GetAllowedValues();
     this.invalidValues = this.GetInvalidValues();
 }
예제 #3
0
파일: BaseService.cs 프로젝트: G-Rad/nzblog
        protected virtual bool ShouldUpdateInternal(ApplicationSettingType applicationSettingType, SettingType settingType)
        {
            Logger.Trace("ShouldUpdate started. Application setting: {0}", applicationSettingType);

            var lastUpdate = _applicationSettingsProvider.GetSettingOrDefault<DateTime?>(applicationSettingType);

            if (!lastUpdate.HasValue)
            {
                Logger.Trace("Application settins is empty. Start fetching settings from DB");

                lastUpdate = _settingsRepository.GetSetting<DateTime>(settingType);

                Logger.Trace("Application settins have been fetched from DB. Last update was {0}", lastUpdate);

                _applicationSettingsProvider.SaveSetting(applicationSettingType, lastUpdate.ToString());

                Logger.Trace("Last updating time has been saved to application state");
            }

            var result = ((DateTime.Now - (DateTime)lastUpdate).TotalSeconds > 21600);

            Logger.Trace("Result of ShouldUpdate is {0}", result);

            return result;
        }
예제 #4
0
 /// <summary>
 /// Constructor which takes two arguments.
 /// </summary>
 /// <param name="type">The Setting Type of the ISetting object</param>
 /// <param name="value">The value for the ISetting object</param>
 /// <param name="validValues">Collection of valid values for this SettingType</param>
 /// <param name="valueErrorMessage">The error message to be thrown, if an InvalidSettingValueException occurs</param>
 protected Setting(SettingType type, object value, object[] validValues, string valueErrorMessage)
 {
     this.Type = type;
     this.Value = value;
     this.validValues = validValues;
     this.valueErrorMessage = valueErrorMessage;
 }
예제 #5
0
 public Setting_Item(Object parent, SettingType item)
 {
     InitializeComponent();
     this.ownParent = parent;
     settingItem = item;
     InitIconAndText();
 }
예제 #6
0
 public ISettings GetSettings(SettingType s)
 {
     switch (s)
     {
         case SettingType.Baisc:
             try
             {
                 return JsonConvert.DeserializeObject<BasicSettings>(File.ReadAllText(Path.Combine(settingsPath, basicSettingsFile))) ?? new BasicSettings();
             }
             catch
             {
                 return new BasicSettings();
             }
         case SettingType.Event:
             try
             {
                 return JsonConvert.DeserializeObject<EventSettings>(File.ReadAllText(Path.Combine(settingsPath, eventSettingsFile))) ?? new EventSettings();
             }
             catch
             {
                 return new EventSettings();
             }
         default:
             throw new ArgumentException("Unsupported settings type");
     }
 }
 public static bool TryParseIndexAndType(string value, out int index, out SettingType type)
 {
     var m = textValueRegex.Match(value);
     index = 0;
     type = SettingType.None;
     if (m.Success)
     {
         type = (SettingType)Enum.Parse(typeof(SettingType), m.Groups["type"].Value);
         index = int.Parse(m.Groups["num"].Value);
         if (m.Groups["ext"].Success)
         {
             if (type == SettingType.DPad)
             {
                 type = SettingType.DPadButton;
                 switch (m.Groups["ext"].Value)
                 {
                     case "Up": index = (index - 1) * 4 + 1; break;
                     case "Right": index = (index - 1) * 4 + 2; break;
                     case "Down": index = (index - 1) * 4 + 3; break;
                     case "Left": index = (index - 1) * 4 + 4; break;
                 }
             }
         }
     }
     return m.Success;
 }
예제 #8
0
 public void FromSetting(string value, string key)
 {
     Match m;
     if (frmRegex.IsMatch(value))
     {
         m = frmRegex.Match(value);
         _Type = (SettingType)Enum.Parse(typeof(SettingType), m.Groups["type"].Value);
         _Index = int.Parse(m.Groups["num"].Value);
         if (m.Groups["ext"].Success)
         {
             if (_Type == SettingType.DPad)
             {
                 _Type = SettingType.DPadButton;
                 switch (m.Groups["ext"].Value)
                 {
                     case "Up": _Index = (_Index - 1) * 4 + 1; break;
                     case "Right": _Index = (_Index - 1) * 4 + 2; break;
                     case "Down": _Index = (_Index - 1) * 4 + 3; break;
                     case "Left": _Index = (_Index - 1) * 4 + 4; break;
                 }
             }
         }
     }
     if (iniRegex.IsMatch(value))
     {
         m = iniRegex.Match(value);
         string t = m.Groups["type"].Value;
         string n = m.Groups["neg"].Value;
         _Index = int.Parse(m.Groups["num"].Value);
         if (key.Contains("Analog") && !key.Contains("Button")) t = SettingName.SType.Axis;
         if (key.Contains("D-pad POV")) t = SettingName.SType.DPad;
         if (t == SettingName.SType.Axis && Index == 7) _Index = 0;
         switch (t)
         {
             case SettingName.SType.Axis :
                 _Type = n == "-" ? SettingType.IAxis : SettingType.Axis;
                 break;
             case SettingName.SType.Slider:
                 _Type = n == "-" ? SettingType.ISlider : SettingType.Slider;
                 break;
             case SettingName.SType.HAxis:
                 _Type = n == "-" ? SettingType.IHAxis : SettingType.HAxis;
                 break;
             case SettingName.SType.HSlider:
                 _Type = n == "-" ? SettingType.IHSlider : SettingType.HSlider;
                 break;
             case SettingName.SType.DPad:
                 _Type = SettingType.DPad;
                 break;
             case SettingName.SType.DPadButton:
                 _Type = SettingType.DPadButton;
                 break;
             default:
                 _Type = SettingType.Button;
                 break;
         }
         if (_Index == 0) _Type = SettingType.None;
     }
 }
예제 #9
0
 public TestbedSetting(string argName, SettingType argType, bool argValue)
 {
     name = argName;
     settingsType = argType;
     enabled = argValue;
     constraintType = ConstraintType.BOOLEAN;
     min = max = value = 0;
 }
예제 #10
0
 public Setting_Item(Object parent, HostType type) // for host config
 {
     InitializeComponent();
     this.ownParent = parent;
     hostType = type;
     settingItem = SettingType.Host;
     InitIconAndText();
 }
예제 #11
0
		public string GetSetting(SettingType type, string xPath, string defaultValue)
		{
			XmlNode xmlNode = _xmlDocument.SelectSingleNode(String.Format("{0}/{1}/{2}", Root, type, xPath));
			if (xmlNode != null)
			{
				return xmlNode.InnerText;
			}
			return defaultValue;
		}
예제 #12
0
 public Setting(FieldInfo field, SettingType type, string group)
 {
     Type = type;
     Name = field.Name;
     Group = group;
     DisplayNameAttribute.GetDisplayName(field, ref DisplayName);
     HelpTextAttribute.GetHelpText(field, ref HelpText);
     GroupAttribute.GetGroup(field, ref Group);
     UseAsShaderConstant = UseAsShaderConstantAttribute.UseFieldAsShaderConstant(field);
 }
예제 #13
0
 public TestbedSetting(string argName, SettingType argType, int argValue, int argMinimum, int argMaximum)
 {
     name = argName;
     settingsType = argType;
     value = argValue;
     min = argMinimum;
     max = argMaximum;
     constraintType = ConstraintType.RANGE;
     enabled = false;
 }
예제 #14
0
		public void PutSetting(SettingType type, string xPath, string value)
		{
			string path = String.Format("{0}/{1}/{2}", Root, type, xPath);
			XmlNode xmlNode = _xmlDocument.SelectSingleNode(path);
			if (xmlNode == null)
			{
				xmlNode = CreateMissingNode(path);
			}
			xmlNode.InnerText = value;
			_xmlDocument.Save(_documentPath);
		}
 public static bool TryParseIndexAndType(string value, out int index, out SettingType type)
 {
     var m = frmRegex.Match(value);
     index = 0;
     type = SettingType.None;
     if (m.Success)
     {
         type = (SettingType)Enum.Parse(typeof(SettingType), m.Groups["type"].Value);
         index = int.Parse(m.Groups["num"].Value);
     }
     return m.Success;
 }
예제 #16
0
        public SettingsAttribute(string friendlyName, object defaultValue, SettingType type, string category)
        {
            m_FriendlyName = friendlyName;
            m_Type = type;
            m_Category = category;

            if (defaultValue.GetType().IsArray) {
                MethodInfo mi = typeof(Array).GetMethods().Where(x => x.Name == "AsReadOnly").Single();
                m_DefaultValue = mi.MakeGenericMethod(defaultValue.GetType().GetElementType()).Invoke(null, new[] { defaultValue });
            } else
                m_DefaultValue = defaultValue;
        }
		public void FromSetting(string value, string key)
		{
			int index = 0;
			SettingType type = SettingType.None;
			var success = TryParseIndexAndType(value, out index, out type);
			if (success)
			{
				_Type = type;
				_Index = index;
			}
			// Try to convert setting from ini value.
			var m = iniValueRegex.Match(value);
			if (m.Success)
			{
				string t = m.Groups["type"].Value;
				string n = m.Groups["neg"].Value;
				_Index = int.Parse(m.Groups["num"].Value);
				if (key.Contains("Analog") && !key.Contains("Button") && t == "") t = SettingName.SType.Axis;
				if (key.Contains("D-pad POV")) t = SettingName.SType.DPad;
				if (t == SettingName.SType.Axis && Index == 7) _Index = 0;
				switch (t)
				{
					case SettingName.SType.Axis:
						_Type = n == "-" ? SettingType.IAxis : SettingType.Axis;
						break;
					case SettingName.SType.Slider:
						_Type = n == "-" ? SettingType.ISlider : SettingType.Slider;
						break;
					case SettingName.SType.HAxis:
						_Type = n == "-" ? SettingType.IHAxis : SettingType.HAxis;
						break;
					case SettingName.SType.HSlider:
						_Type = n == "-" ? SettingType.IHSlider : SettingType.HSlider;
						break;
					case SettingName.SType.DPad:
						_Type = SettingType.DPad;
						break;
					case SettingName.SType.DPadButton:
						_Type = SettingType.DPadButton;
						break;
					default:
						_Type = SettingType.Button;
						break;
				}
				if (_Index == 0) _Type = SettingType.None;
			}
		}
예제 #18
0
파일: Settings.cs 프로젝트: joydeba/sn_rm
        public object GetValue(string settingName, SettingType settingType)
        {
            string str = getValue(settingName);

            object val;

            if (str == null)
            {
                throw new Exception("SettingName not found");
            }
            else if (settingType == SettingType.String)
            {
                val = str;
            }
            else if (settingType == SettingType.Int32)
            {
                try
                {
                    val = Int32.Parse(str);
                }
                catch
                {
                    throw new Exception("SettingType mismatch");
                }
            }
            else if (settingType == SettingType.Color)
            {
                try
                {
                    val = Color.FromArgb(Int32.Parse(str));
                }
                catch
                {
                    throw new Exception("SettingType mismatch");
                }
            }
            else
            {
                throw new Exception("SettingType not defined");
            }

            return val;
        }
예제 #19
0
 public void UpdateHostChosen(HostType host, SettingType item)
 {
     if (host == hostType && item == settingItem)
     {
         isChosen = true;
         this.Background = COLOR_ITEM_CHOSEN;
         this.label_text.Foreground = Brushes.White;
     }
     else
     {
         isChosen = false;
         this.Background = COLOR_MOUSE_LEAVE;
         this.label_text.Foreground = Brushes.Black;
     }
 }
예제 #20
0
 public bool SettingEnabled(SettingType settingType, string userId) =>
 this.context.UserSettings
 .Any(s => s.Type == settingType && s.UserId == userId && s.Enabled);
예제 #21
0
파일: Settings.cs 프로젝트: nagilum/myscue
        /// <summary>
        /// Update, or create, a new setting.
        /// </summary>
        /// <param name="name">Name of the setting.</param>
        /// <param name="value">String value of the setting.</param>
        /// <param name="type">Data type of the setting. Defaults to String.</param>
        public static void Set(string name, string value, SettingType type = SettingType.String)
        {
            Setting setting = Settings.settings.SingleOrDefault(s => s.Name == name && s.Type == type.ToString());

              if (setting != null) {
            setting.Value = value;
            setting.Changed = true;
              }
              else {
            Settings.settings.Add(
              new Setting() {
            ID = 0,
            Name = name,
            Type = type.ToString(),
            Value = value,
            Changed = true
              });
              }

              Settings.Save();
        }
예제 #22
0
        public void FromSetting(string value, string key)
        {
            Match m = frmRegex.Match(value);

            if (m.Success)
            {
                _Type  = (SettingType)Enum.Parse(typeof(SettingType), m.Groups["type"].Value);
                _Index = int.Parse(m.Groups["num"].Value);
                if (m.Groups["ext"].Success)
                {
                    if (_Type == SettingType.DPad)
                    {
                        _Type = SettingType.DPadButton;
                        switch (m.Groups["ext"].Value)
                        {
                        case "Up": _Index = (_Index - 1) * 4 + 1; break;

                        case "Right": _Index = (_Index - 1) * 4 + 2; break;

                        case "Down": _Index = (_Index - 1) * 4 + 3; break;

                        case "Left": _Index = (_Index - 1) * 4 + 4; break;
                        }
                    }
                }
            }
            m = iniRegex.Match(value);
            if (m.Success)
            {
                string t = m.Groups["type"].Value;
                string n = m.Groups["neg"].Value;
                _Index = int.Parse(m.Groups["num"].Value);
                if (key.Contains("Analog") && !key.Contains("Button") && t == "")
                {
                    t = SettingName.SType.Axis;
                }
                if (key.Contains("D-pad POV"))
                {
                    t = SettingName.SType.DPad;
                }
                if (t == SettingName.SType.Axis && Index == 7)
                {
                    _Index = 0;
                }
                switch (t)
                {
                case SettingName.SType.Axis:
                    _Type = n == "-" ? SettingType.IAxis : SettingType.Axis;
                    break;

                case SettingName.SType.Slider:
                    _Type = n == "-" ? SettingType.ISlider : SettingType.Slider;
                    break;

                case SettingName.SType.HAxis:
                    _Type = n == "-" ? SettingType.IHAxis : SettingType.HAxis;
                    break;

                case SettingName.SType.HSlider:
                    _Type = n == "-" ? SettingType.IHSlider : SettingType.HSlider;
                    break;

                case SettingName.SType.DPad:
                    _Type = SettingType.DPad;
                    break;

                case SettingName.SType.DPadButton:
                    _Type = SettingType.DPadButton;
                    break;

                default:
                    _Type = SettingType.Button;
                    break;
                }
                if (_Index == 0)
                {
                    _Type = SettingType.None;
                }
            }
        }
예제 #23
0
 public void PutSetting(SettingType type, string xPath, int value)
 {
     PutSetting(type, xPath, Convert.ToString(value));
 }
예제 #24
0
 public Setting GetSetting(SettingType setType)
 {
     return(_integratedProvider.GetSetting(setType));
 }
예제 #25
0
 public async Task <List <Setting> > GetListSettingList(SettingType type)
 {
     return(await _settingRepository.FindAll(a => a.Type == type).ToListAsync());
 }
예제 #26
0
 public SettingAttribute(SettingType type)
 {
     Type = type;
 }
예제 #27
0
        public async Task <ActionResult> Delete(SettingType type)
        {
            await _settingsService.DeleteAsync(type);

            return(NoContent());
        }
예제 #28
0
 public T GetData <T>(SettingType type)
 {
     return(_serializer.Deserialize <T>(Get(type).Data));
 }
예제 #29
0
        public void SetUp()
        {
            // setup db models
            _dbAssetType = new AssetType {
                Id = 1, Name = "a", IsActive = true
            };
            _dbAsset = new Asset
            {
                Id          = 2,
                AssetTypeId = _dbAssetType.Id,
                AssetType   = _dbAssetType, // setup include
                Name        = "b",
                IsActive    = true
            };
            _dbSettingType = new SettingType {
                Id = 3, Name = "c", IsActive = true
            };
            _dbAssetSetting = new AssetSetting
            {
                Id            = 4,
                AssetId       = _dbAsset.Id,
                Asset         = _dbAsset,       // setup include
                SettingTypeId = _dbSettingType.Id,
                SettingType   = _dbSettingType, // setup include
                Value         = "d",
                IsActive      = true
            };
            _dbTransactionType = new TransactionType {
                Id = 5, Name = "e", IsActive = true
            };
            _dbTransactionCategory = new TransactionCategory {
                Id = 6, Name = "f", IsActive = true
            };
            _dbTransactionDescription = new TransactionDescription {
                Id = 7, Name = "g", IsActive = true
            };
            _dbAssetTransaction = new AssetTransaction
            {
                Id                       = 8,
                AssetId                  = _dbAsset.Id,
                Asset                    = _dbAsset,                  // setup include
                TransactionTypeId        = _dbTransactionType.Id,
                TransactionType          = _dbTransactionType,        // setup include
                TransactionCategoryId    = _dbTransactionCategory.Id,
                TransactionCategory      = _dbTransactionCategory,    // setup include
                TransactionDescriptionId = _dbTransactionDescription.Id,
                TransactionDescription   = _dbTransactionDescription, // setup include
                DueDate                  = new DateTime(1234, 5, 6),
                ClearDate                = new DateTime(1234, 7, 8),
                Amount                   = 1.23M,
                Note                     = "abc",
                IsActive                 = true
            };

            // setup DbContext
            Setup_FakeDbContext();

            // setup uow
            _fakeUnitOfWork = new UnitOfWork(_fakeDbContext);

            // setup service
            _service = new AccountTransactionService(_fakeUnitOfWork);
        }
예제 #30
0
 public Setting Get(SettingType type)
 {
     return(_executor.Query <Setting>("[dbo].[Setting_Get]", new { type }));
 }
 public bool GetSetting(SettingType type, string xPath, bool defaultValue)
 {
     return(Convert.ToBoolean(GetSetting(type, xPath, Convert.ToString(defaultValue))));
 }
 public int GetSetting(SettingType type, string xPath, int defaultValue)
 {
     return(Convert.ToInt32(GetSetting(type, xPath, Convert.ToString(defaultValue))));
 }
예제 #33
0
        public void FromSetting(string value, string key)
        {
            int         index   = 0;
            SettingType type    = SettingType.None;
            var         success = TryParseIndexAndType(value, out index, out type);

            if (success)
            {
                _Type  = type;
                _Index = index;
            }
            // Try to convert setting from ini value.
            var m = iniValueRegex.Match(value);

            if (m.Success)
            {
                string t = m.Groups["type"].Value;
                string n = m.Groups["neg"].Value;
                _Index = int.Parse(m.Groups["num"].Value);
                if (key.Contains("Analog") && !key.Contains("Button") && t == "")
                {
                    t = SettingName.SType.Axis;
                }
                if (key.Contains("D-pad POV"))
                {
                    t = SettingName.SType.DPad;
                }
                if (t == SettingName.SType.Axis && Index == 7)
                {
                    _Index = 0;
                }
                switch (t)
                {
                case SettingName.SType.Axis:
                    _Type = n == "-" ? SettingType.IAxis : SettingType.Axis;
                    break;

                case SettingName.SType.Slider:
                    _Type = n == "-" ? SettingType.ISlider : SettingType.Slider;
                    break;

                case SettingName.SType.HAxis:
                    _Type = n == "-" ? SettingType.IHAxis : SettingType.HAxis;
                    break;

                case SettingName.SType.HSlider:
                    _Type = n == "-" ? SettingType.IHSlider : SettingType.HSlider;
                    break;

                case SettingName.SType.DPad:
                    _Type = SettingType.DPad;
                    break;

                case SettingName.SType.DPadButton:
                    _Type = SettingType.DPadButton;
                    break;

                default:
                    _Type = SettingType.Button;
                    break;
                }
                if (_Index == 0)
                {
                    _Type = SettingType.None;
                }
            }
        }
예제 #34
0
 private Setting(string setting, SettingType type)
 {
     this.setting = setting;
     this.type    = type;
 }
예제 #35
0
 public void SetSettingValue <TValue>(SettingType settingType, TValue value)
 {
     DependencyService.Get <IDataService>().UpdateSettingToDb(settingType, value);
 }
예제 #36
0
 /// <summary>
 /// Get string representation of enum setting type
 /// </summary>
 public static string GetKey(SettingType s)
 {
     return(KeyMap[s]);
 }
예제 #37
0
파일: Setting.cs 프로젝트: zuhuizou/wojilu
 public Setting(String title, String value, String description, SettingCategory category, SettingType dataType)
 {
     _title       = title;
     _value       = value;
     _description = description;
     _category    = category;
     _dataType    = dataType.ToString();
 }
예제 #38
0
 private SettingModel GetSetting(SettingType settingType)
 {
     return(DependencyService.Get <IDataService>().GetSettingFromDb(settingType));
 }
예제 #39
0
        public IActionResult GetSettingValueByType(SettingType type)
        {
            var result = Executor.GetQuery <GetSettingsByTypeQuery>().Process(q => q.Execute(type));

            return(Ok(result?.Value));
        }
예제 #40
0
파일: PPacket.cs 프로젝트: Eveldee/PRemote
 public override string ToString()
 {
     return(SettingType.ToString() + "=" + Data.ToString());
 }
예제 #41
0
 public void WriteSetting(SettingType type, string val)
 {
     writer.Write((int)type);
     writer.Write(val);
     writer.Flush();
 }
예제 #42
0
        /// <summary>
        /// Create a new Setting
        /// </summary>
        /// <param name="name">The name of this setting</param>
        /// <param name="description">The description of this setting. Useful for displaying to the user on the preferences screen</param> 
        /// <param name="category">The category of this setting</param>
        /// <param name="type">The type of this setting</param>
        /// <param name="value">The value of this setting</param>
        public Setting(string name, string description, string category, SettingType type, object value)
        {
            Name = name;
            Description = description;
            Category = category;

            switch (type)
            {
                case SettingType.boolean:
                    if (value is bool)
                    {
                        boolean = (bool)value;
                    }
                    else
                    {
                        if (!Setting.AllowSerialize) throw new ArgumentException("Setting of type \"boolean\" was passed an incorrect value");
                    }
                    break;

                case SettingType.text:
                    if (value is string)
                    {
                        text = (string)value;
                    }
                    else
                    {
                        if (!Setting.AllowSerialize) throw new ArgumentException("Setting of type \"text\" was passed an incorrect value");
                    }
                    break;

                case SettingType.integer:
                    if (value is int)
                    {
                        integer = (int)value;
                    }
                    else
                    {
                        if (value is long)
                        {
                            long longValue = (long)value;
                            integer = (int)longValue;
                        }
                        else
                        {
                            if (!Setting.AllowSerialize) throw new ArgumentException("Setting of type \"integer\" was passed an incorrect value");
                        }
                    }
                    break;

                case SettingType.collection:
                    if (value is List<string>)
                    {
                        collection = new List<string>();
                        foreach(var item in (List<string>)value)
                        {
                            collection.Add(item);
                        }
                        break;
                    }

                    if (value is List<string> || value is Newtonsoft.Json.Linq.JArray)
                    {
                        collection = new List<string>();
                        foreach (var item in (Newtonsoft.Json.Linq.JArray)value)
                        {
                            string stringToAdd = ((Newtonsoft.Json.Linq.JValue)item).Value as string;

                            collection.Add(stringToAdd);
                        }
                        break;
                    }

                    if (!Setting.AllowSerialize) throw new ArgumentException("Setting of type \"collection\" was passed an incorrect value");
                    break;

                default:
                    if (!Setting.AllowSerialize) throw new ArgumentException("Unknown setting type encountered: " + value.GetType().ToString());
                    break;
            }

            Type = type;
        }
예제 #43
0
        public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command)
        {
            SettingType changed = SettingType.NONE;

            ChannelSettings thisChannel = bot.GetChannelSettings(channel);

            bool setValue = false;

            if (terms != null && terms.Length >= 1)
            {
                if (terms.Contains("useeicons"))
                    changed = SettingType.UseEicons;
                if (terms.Contains("greetnewusers"))
                    changed = SettingType.GreetNewUsers;
                if (terms.Contains("allowtablerolls"))
                    changed = SettingType.AllowTableRolls;
                if (terms.Contains("allowcustomtablerolls"))
                    changed = SettingType.AllowCustomTableRolls;
                if (terms.Contains("allowtableinfo"))
                    changed = SettingType.AllowTableInfo;
                if (terms.Contains("allowchips"))
                    changed = SettingType.AllowChips;
                if (terms.Contains("allowgames"))
                    changed = SettingType.AllowGames;
                if (terms.Contains("usevcaccount"))
                    changed = SettingType.UseVcAccountForChips;
                if (terms.Contains("startupchannel"))
                    changed = SettingType.StartupChannel;
                if (terms.Contains("startwith500chips"))
                    changed = SettingType.StartWith500Chips;
                if (terms.Contains("onlyopaddchips"))
                    changed = SettingType.OnlyOpAddChips;
                if (terms.Contains("onlyopbotcommands"))
                    changed = SettingType.OnlyOpBotCommands;
                if (terms.Contains("onlyopdeckcontrols"))
                    changed = SettingType.OnlyOpDeckControls;
                if (terms.Contains("onlyoptablecommands"))
                    changed = SettingType.OnlyOpTableCommands;

                if (terms.Contains("on") || terms.Contains("true"))
                    setValue = true;
                if (terms.Contains("off") || terms.Contains("false"))
                    setValue = false;
            }

            switch (changed)
            {
                case SettingType.NONE:
                    break;
                case SettingType.UseEicons:
                    thisChannel.UseEicons = setValue;
                    break;
                case SettingType.GreetNewUsers:
                    thisChannel.GreetNewUsers = setValue;
                    break;
                case SettingType.AllowTableRolls:
                    thisChannel.AllowTableRolls = setValue;
                    break;
                case SettingType.AllowCustomTableRolls:
                    thisChannel.AllowCustomTableRolls = setValue;
                    break;
                case SettingType.AllowTableInfo:
                    thisChannel.AllowTableInfo = setValue;
                    break;
                case SettingType.AllowChips:
                    thisChannel.AllowChips = setValue;
                    break;
                case SettingType.AllowGames:
                    thisChannel.AllowGames = setValue;
                    break;
                case SettingType.UseVcAccountForChips:
                    thisChannel.UseVcAccountForChips = setValue;
                    break;
                case SettingType.StartupChannel:
                    thisChannel.StartupChannel = setValue;
                    break;
                case SettingType.StartWith500Chips:
                    thisChannel.StartWith500Chips = setValue;
                    break;
                case SettingType.OnlyOpAddChips:
                    {
                        if(thisChannel.ChipsClearance != ChipsClearanceLevel.DicebotAdmin)
                        {
                            if(setValue)
                            {
                                thisChannel.ChipsClearance = ChipsClearanceLevel.ChannelOp;
                            }
                            else
                            {
                                thisChannel.ChipsClearance = ChipsClearanceLevel.NONE;
                            }
                        }
                    }
                    break;
                case SettingType.OnlyOpBotCommands:
                    thisChannel.OnlyChannelOpsCanUseAnyBotCommands = setValue;
                    break;
                case SettingType.OnlyOpDeckControls:
                    thisChannel.OnlyChannelOpsCanUseDeckControls = setValue;
                    break;
                case SettingType.OnlyOpTableCommands:
                    thisChannel.OnlyChannelOpsCanUseTableCommands = setValue;
                    break;
            }

            if (changed == SettingType.NONE)
            {
                string output = "Setting not found. Be sure to specify which setting to change, followed by 'true' or 'false'. Settings use the same name displayed in the !viewsettings command.";

                bot.SendMessageInChannel(output, channel);
            }
            else
            {
                Utils.WriteToFileAsData(bot.SavedChannelSettings, Utils.GetTotalFileName(BotMain.FileFolder, BotMain.ChannelSettingsFileName));

                string output = "(Channel setting updated) " + Utils.GetCharacterUserTags(characterName) + " set " + changed + " to " + setValue;

                if (changed == SettingType.OnlyOpAddChips && thisChannel.ChipsClearance == ChipsClearanceLevel.DicebotAdmin)
                {
                    output = "(" + changed + " Channel setting cannot be updated for this channel) ";
                }

                bot.SendMessageInChannel(output, channel);
            }
        }
예제 #44
0
 public void UpdateHostChosen(HostType host, SettingType item)
 {
     if (host == hostType && item == settingItem)
     {
         isChosen = true;
         this.Background = COLOR_ITEM_CHOSEN;
     }
     else
     {
         isChosen = false;
         this.Background = COLOR_MOUSE_LEAVE;
     }
 }
예제 #45
0
    public void InitView(Action <GameState, Dictionary <string, object> > onChangeState, SettingType settingType, GameState beforeGameState, UserData userData)
    {
        _onChangeState     = onChangeState;
        _currentUserData   = userData;
        _textViewName.text = settingType == SettingType.Save ? VIEW_NAME_SAVE : VIEW_NAME_LOAD;
        var userDatas = PlayerPrefsUtil.GetValue <UserData[]>(KEY_USER_DATA_LIST);

        if (userDatas == null || userDatas.Length <= 0)
        {
            _userDataList = new List <UserData>();
            for (int i = 0; i < 5; i++)
            {
                var index = i;
                _userDataList.Add(new UserData(index + 1));
            }
        }
        else
        {
            _userDataList = userDatas.ToList();
        }

        ScreenCapture.CaptureScreenshot($"{RESOURCES_SCREEN_SHOT_PATH} {TEST_SCREEN_SHOT_NAME}.png");
        cacheScreenShot = ResourceManager.Instance.LoadScreenShot(TEST_SCREEN_SHOT_NAME);



        gameObject.SetActive(true);
        _currentSettingType = settingType;

        if (_gameDataPanelList == null)
        {
            _gameDataPanelList = new List <GameDataPanel>();
        }


        UpdateGameDataPanel();


        _buttonOK.onClick.RemoveAllListeners();
        _buttonOK.onClick.AddListener(delegate {
            OnClickOkButton();
        });

        _buttonCancel.onClick.RemoveAllListeners();
        _buttonCancel.onClick.AddListener(delegate {
            _objConfirmation.SetActive(false);
        });
        _buttonReturn.onClick.RemoveAllListeners();
        _buttonReturn.onClick.AddListener(delegate {
            gameObject.SetActive(false);
            _onChangeState(beforeGameState, new Dictionary <string, object>());
        });
    }
예제 #46
0
 public ClientSetCameraSettingPacket(Setting setting, SettingType type, object value)
 {
     this.setting = setting;
     this.type    = type;
     this.value   = value;
 }
예제 #47
0
 internal Setting(string name, SettingType type)
 {
     this.name = name;
     this.type = type;
 }
예제 #48
0
 /// <summary>
 /// 实例化一个设置对象
 /// </summary>
 /// <param name="name">设置项名称</param>
 /// <param name="type">设置项类型</param>
 /// <param name="description">设置项描述</param>
 public Setting(string name, SettingType type, string description)
 {
     Name        = name;
     Type        = type;
     Description = description;
 }
예제 #49
0
파일: Settings.cs 프로젝트: nagilum/myscue
        /// <summary>
        /// Fetches a string value from the memory and returns the given default-value if not present.
        /// </summary>
        /// <param name="name">Name of the setting.</param>
        /// <param name="defaultValue">The return value if the setting doesn't exist yet. Defaults to ""</param>
        /// <param name="type">Data type of the setting. Defaults to String.</param>
        /// <returns>The string from settings or default value.</returns>
        public static string Get(string name, string defaultValue = "", SettingType type = SettingType.String)
        {
            string value = defaultValue;

              Setting setting = Settings.settings.SingleOrDefault(s => s.Name == name && s.Type == type.ToString());

              if (setting != null) {
            value = setting.Value;
              }
              else {
            DataRow dataRow = SQLite.SingleOrDefault(
              "settings",
              "value",
              new List<SQLiteCondition>() {
              new SQLiteCondition() { ColumnName = "username", ColumnValue = WindowsIdentity.GetCurrent().Name},
              new SQLiteCondition() { ColumnName = "name", ColumnValue = name},
              new SQLiteCondition() { ColumnName = "type", ColumnValue = type.ToString()}
            });

            if (dataRow != null) {
              value = dataRow["value"].ToString();
            }
            else {
              Settings.Set(name, value, type);
            }
              }

              return value;
        }
 public SetterAttribute(SettingType settingType)
 {
     SettingType = settingType;
 }
예제 #51
0
 public override IList<ISetting> ToList(SettingType settingType)
 {
     switch (settingType)
     {
         case SettingType.Office:
             {
                 return ToList<GlobalSettings, office>(settingType).ToArray();
             }
         case SettingType.Global:
         case SettingType.Forum:
             {
                 return ToList<GlobalSettings, GlobalSettingEntity>(settingType).ToArray();
             }
         default:
             {
                 return new List<ISetting>();
             }
     }
 }
예제 #52
0
 private async void NavLinksList_ItemClick(object sender, ItemClickEventArgs e)
 {
     var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
     await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         var item = (e.ClickedItem as NavLink);
         chosenHost = item.HostType;
         settingType = item.SettingType;
         StatusPanel.Visibility = Visibility.Collapsed;
         switch (item.SettingType)
         {
             case SettingType.Account:
                 //ReloadListAccount();
                 Grid_setting_limitation.Visibility = Visibility.Collapsed;
                 Grid_setting_host.Visibility = Visibility.Collapsed;
                 Grid_setting_account.Visibility = Visibility.Visible;
                 PageTitleAccount.Text = item.Title;
                 list_command.Visibility = Visibility.Collapsed;
                 break;
             case SettingType.Host:
                 RefreshHostSetting(chosenHost);
                 Grid_setting_limitation.Visibility = Visibility.Collapsed;
                 Grid_setting_host.Visibility = Visibility.Visible;
                 PageTitleHost.Text = item.Title;
                 Grid_setting_account.Visibility = Visibility.Collapsed;
                 list_command.Visibility = Visibility.Visible;
                 break;
             case SettingType.Limitation:
                 Grid_setting_limitation.Visibility = Visibility.Visible;
                 PageTitleLimitation.Text = item.Title;
                 Grid_setting_host.Visibility = Visibility.Collapsed;
                 Grid_setting_account.Visibility = Visibility.Collapsed;
                 list_command.Visibility = Visibility.Visible;
                 RefreshLimitationValues();
                 break;
         }
     });
 }
예제 #53
0
 public void SetSetting(SettingType setting, string nVal)
 {
     Settings[setting] = nVal;
 }
예제 #54
0
 public string GetSetting(SettingType setting)
 {
     return(Settings[setting]);
 }
예제 #55
0
        public void DisplaySetting(string title, HostType host, SettingType item)
        {
            chosenHost = host;
            switch (item)
            {
                case SettingType.Account:
                    Grid_setting_limitation.Visibility = Visibility.Collapsed;
                    Grid_setting_account_type.Visibility = Visibility.Collapsed;
                    Grid_setting_account.Visibility = Visibility.Visible;
                    break;
                case SettingType.Host:

                    RefreshHostSetting(chosenHost);

                    label_host.Content = title;
                    Grid_setting_limitation.Visibility = Visibility.Collapsed;
                    Grid_setting_account_type.Visibility = Visibility.Visible;
                    Grid_setting_account.Visibility = Visibility.Collapsed;
                    break;
                case SettingType.Limitation:
                    Grid_setting_limitation.Visibility = Visibility.Visible;
                    Grid_setting_account_type.Visibility = Visibility.Collapsed;
                    Grid_setting_account.Visibility = Visibility.Collapsed;
                    break;
            }

            foreach (UIElement control in panel_left.Children)
            {
                if (control is Setting_Item)
                {
                    ((Setting_Item)control).UpdateHostChosen(host, item);
                }
            }
        }
예제 #56
0
 public SettingEventArgs(SettingType settingType, object obj)
 {
     this.SettingType = settingType;
     this.Content     = obj;
 }
예제 #57
0
파일: Settings.cs 프로젝트: joydeba/sn_rm
        public void SetValue(string settingName, SettingType settingType, object value)
        {
            foreach (DataRow dr in this.table.Rows)
            {
                if ((string)dr["Name"] == settingName)
                {
                    if (settingType == SettingType.String)
                    {
                        dr["Value"] = (string)value;
                    }
                    else if (settingType == SettingType.Int32)
                    {
                        dr["Value"] = ((int)value).ToString();
                    }
                    else if (settingType == SettingType.Color)
                    {
                        dr["Value"] = ((Color)value).ToArgb().ToString();
                    }

                    return;
                }              
            }

            throw new Exception("SettingName not found");
        }
예제 #58
0
        public async Task <SettingDto> Get(SettingType type)
        {
            SettingDto result = await _settingsService.GetByTypeAsync(type);

            return(result);
        }
예제 #59
0
        //public override IList<ISetting> ToList(SettingType settingType)
        //{
        //    return (IList<ISetting>)ToList<PersonalSettings, PersonalSettingEntity>(SettingType.Personal);
        //}
        public override IList<ISetting> ToList(SettingType type)
        {
            if (type != SettingType.Personal)
                throw new Exception("PersonSettingsInterceptor can't handle non-personal settings");

            List<PersonalSettingEntity> setings_col = new List<PersonalSettingEntity>();
            BindingFlags flags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public;

            try
            {
                foreach (PropertyInfo property in typeof(PersonalSettings).GetProperties(flags))
                {
                    object[] attr_obj = property.GetCustomAttributes(typeof(PersonalSettingAttribute), false);
                    if (attr_obj.Length == 0)
                        continue;

                    object set_value = property.GetValue(this, null);
                    ISetting setting = Load((PersonalSettingAttribute)attr_obj[0]);
                    if (setting == null)
                        setings_col.Add(new PersonalSettingEntity((PersonalSettingAttribute)attr_obj[0], set_value));
                    else
                        setings_col.Add((PersonalSettingEntity)setting);

                    //if (!m_Cache.TryGetValue(((PersonalSettingAttribute)attr_obj[0]).SettingName, out setting))
                    //    setings_col.Add(new PersonalSettingEntity((PersonalSettingAttribute)attr_obj[0], set_value));
                    //else
                    //    setings_col.Add((PersonalSettingEntity)setting);
                }
            }
            catch
            {
                return new List<ISetting>();
            }

            return setings_col.ToArray();
        }
예제 #60
0
 public void Show(SettingType st)
 {
     settingType = st;
     startButton.Initialize(settingType);
     settingBoardState = SettingBoardState.Showing;
 }