Пример #1
0
        public static string GetSettingValue(SettingEnum setting)
        {
            var    settingName  = SettingHelper.GetString(setting);
            string settingValue = null;

            using (var dbConnection = new SQLiteConnection(DataSource))
            {
                dbConnection.Open();
                using (var transaction = dbConnection.BeginTransaction())
                {
                    using (var command = new SQLiteCommand(dbConnection))
                    {
                        command.CommandText = "SELECT setting_value FROM setting WHERE setting_name = ?";
                        command.Parameters.Add(new SQLiteParameter(DbType.String, "setting_name")
                        {
                            Value = settingName
                        });

                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                if (reader["setting_value"] != null && !Convert.IsDBNull(reader["setting_value"]))
                                {
                                    settingValue = Convert.ToString(reader["setting_value"]);
                                }
                            }
                        }
                    }
                    transaction.Commit();
                }
            }

            return(settingValue);
        }
Пример #2
0
        private void UpdateSetting(SettingEnum setting)
        {
            switch (setting)
            {
            case SettingEnum.HeaderVisibility:
                if (!Settings.Default.HeaderVisibility)
                {
                    HexEdit.HeaderVisibility = Visibility.Collapsed;
                }
                else
                {
                    HexEdit.HeaderVisibility = Visibility.Visible;
                }

                Settings.Default.HeaderVisibility = HexEdit.HeaderVisibility == Visibility.Visible;
                break;

            case SettingEnum.ReadOnly:
                HexEdit.ReadOnlyMode = Settings.Default.ReadOnly;

                HexEdit.ClearAllChange();
                HexEdit.RefreshView();
                break;
            }
        }
Пример #3
0
        public static void SetSettingValue(SettingEnum setting, string value)
        {
            var settingName = SettingHelper.GetString(setting);

            using (var dbConnection = new SQLiteConnection(DataSource))
            {
                dbConnection.Open();
                using (var transaction = dbConnection.BeginTransaction())
                {
                    using (var command = new SQLiteCommand(dbConnection))
                    {
                        command.CommandText = "UPDATE setting SET setting_value = ? WHERE setting_name = ?";
                        command.Parameters.Add(new SQLiteParameter(DbType.String, "setting_value")
                        {
                            Value = value
                        });
                        command.Parameters.Add(new SQLiteParameter(DbType.String, "setting_name")
                        {
                            Value = settingName
                        });

                        command.ExecuteNonQuery();
                    }

                    transaction.Commit();
                }
            }
        }
Пример #4
0
        private void UpdateSetting(SettingEnum setting)
        {
            switch (setting)
            {
            case SettingEnum.HeaderVisibility:
                HexEdit.HeaderVisibility = !Settings.Default.HeaderVisibility
                        ? Visibility.Collapsed
                        : Visibility.Visible;
                Settings.Default.HeaderVisibility = HexEdit.HeaderVisibility == Visibility.Visible;
                break;

            case SettingEnum.ReadOnly:
                HexEdit.ReadOnlyMode = Settings.Default.ReadOnly;

                HexEdit.ClearAllChange();
                HexEdit.RefreshView();
                break;

            case SettingEnum.StatusBarVisibility:
                HexEdit.StatusBarVisibility = !Settings.Default.StatusBarVisibility
                        ? Visibility.Collapsed
                        : Visibility.Visible;

                Settings.Default.StatusBarVisibility = HexEdit.StatusBarVisibility == Visibility.Visible;
                break;
            }
        }
Пример #5
0
        public void SetSetting <T>(SettingEnum settingEnum, T value)
        {
            var strName   = settingEnum.ToString();
            var strValue  = Equals(value, default(T)) ? null : value.ToString();
            var newValues = Data.Where(pair => !Equals(pair.Key, strName)).ToList();

            newValues.Add(new KeyValuePair <string, string>(strName, strValue));
            Data = ImmutableSortedList.FromValues(newValues);
        }
Пример #6
0
 public string GetSetting(Guid userID, SettingEnum setting)
 {
     Guid setID  = Setting.GetSettingID(setting);
     using (CommonDomain domain = new CommonDomain())
     {
         UserSetting us = domain.UserSettings.Where(u => u.UserID == userID && u.SettingID == setID).SingleOrDefault();
         if (us == null) return string.Empty;
         else return us.Value;
     }
 }
Пример #7
0
 public static Guid GetSettingID(SettingEnum value)
 {
     switch (value)
     {
         case SettingEnum.MainGridAreaSize:
             return MainGridAreaSize;
         default:
             return Guid.Empty;
     }
 }
Пример #8
0
		private static void SetSingleProperty(SettingEnum setting, String value)
		{
			if (Settings.ContainsKey(setting))
			{
				Settings[setting] = value;
			}
			else
			{
				Settings.Add(setting, value);
			}
		}
        public static T Get <T>(this ISettingsProvider provider, SettingEnum setting)
        {
            Type?type = typeof(T);

            if (type.IsValueType)
            {
                type = Nullable.GetUnderlyingType(typeof(T));
                if (type == null)
                {
                    throw new ArgumentException("Type parameter must be a type accepting null values.", nameof(T));
                }
            }

            var value = provider[setting.ToString()];

            return(value != null ? (T)Convert.ChangeType(value, type, CultureInfo.InvariantCulture) : default);
Пример #10
0
        public T GetSetting <T>(SettingEnum settingEnum, T defaultValue)
        {
            string stringValue;

            if (!Data.TryGetValue(settingEnum.ToString(), out stringValue))
            {
                return(defaultValue);
            }
            if (null == stringValue)
            {
                return(default(T));
            }
            if (typeof(T).IsEnum)
            {
                return((T)Enum.Parse(typeof(T), stringValue));
            }
            return((T)Convert.ChangeType(stringValue, typeof(T)));
        }
Пример #11
0
 public void SaveSetting(Guid userID, SettingEnum setting, string value)
 {
     Guid setID = Setting.GetSettingID(setting);
     using (CommonDomain domain = new CommonDomain())
     {
         UserSetting us = domain.UserSettings.Where(u => u.UserID == userID && u.SettingID == setID).SingleOrDefault();
         if (us == null)
         {
             us = new UserSetting();
             us.ID = Guid.NewGuid();
             us.UserID = userID;
             us.SettingID = setID;
             us.Value = value;
             domain.UserSettings.InsertOnSubmit(us);
             domain.SubmitChanges();
         }
         else
         {
             us.Value = value;
             domain.SubmitChanges();
         }
     }
 }
Пример #12
0
        public static string GetString(SettingEnum setting)
        {
            switch (setting)
            {
            case SettingEnum.MassRenameString:
                return("mass_rename_string");

            case SettingEnum.StartupRefresh:
                return("startup_refresh");

            case SettingEnum.AutoFetchGooglePlay:
                return("auto_fetch_google_play");

            case SettingEnum.GroupResults:
                return("group_results");

            case SettingEnum.SubdirGroup:
                return("subdir_group");

            case SettingEnum.RefreshDays:
                return("refresh_days");

            case SettingEnum.WindowLocX:
                return("window_loc_x");

            case SettingEnum.WindowLocY:
                return("window_loc_y");

            case SettingEnum.WindowSizeWidth:
                return("window_size_width");

            case SettingEnum.WindowSizeHeight:
                return("window_size_height");

            case SettingEnum.WindowMaximized:
                return("window_maximized");

            case SettingEnum.WindowMinimized:
                return("window_minimized");

            case SettingEnum.LicenceEmail:
                return("licence_email");

            case SettingEnum.LicenceCode:
                return("licence_code");

            case SettingEnum.ExportDelimiter:
                return("export_delimiter");

            case SettingEnum.ExportFilename:
                return("export_filename");

            case SettingEnum.BottomPanelHeight:
                return("bottom_panel_height");

            case SettingEnum.ColumnWidthFilename:
                return("column_width_filename");

            case SettingEnum.ColumnWidthPackage:
                return("column_width_package");

            case SettingEnum.ColumnWidthInternalname:
                return("column_width_internalname");

            case SettingEnum.ColumnWidthGoogleplayname:
                return("column_width_googleplayname");

            case SettingEnum.ColumnWidthCategory:
                return("column_width_category");

            case SettingEnum.ColumnWidthLocalversion:
                return("column_width_localversion");

            case SettingEnum.ColumnWidthLatestversion:
                return("column_width_latestversion");

            case SettingEnum.ColumnWidthPrice:
                return("column_width_price");

            case SettingEnum.ColumnWidthGoogleplayfetch:
                return("column_width_googleplayfetch");

            case SettingEnum.ColumnSortIndex:
                return("column_sort_index");

            default:
                throw new NotImplementedException();
            }
        }
Пример #13
0
partial         void OnLoaded()
        {
            if (this.ID == MainGridAreaSize) Value = SettingEnum.MainGridAreaSize;
            else Value = SettingEnum.Nothing;
        }
Пример #14
0
 /// <summary>
 /// Sets setting value
 /// </summary>
 public void SetConfig(object value, SettingEnum name)
 {
     settings.Find(item => item.Name.Equals(name)).Value = Convert.ChangeType(value, value.GetType());
 }
Пример #15
0
 /// <summary>
 /// Gets setting with boolean value
 /// </summary>
 public bool GetBoolValue(SettingEnum name)
 {
     return(Convert.ToBoolean(settings.Find(item => item.Name.Equals(name)).Value));
 }
Пример #16
0
 /// <summary>
 /// Gets setting with int value
 /// </summary>
 public int GetIntValue(SettingEnum name)
 {
     return(Convert.ToInt32(settings.Find(item => item.Name.Equals(name)).Value));
 }
Пример #17
0
 /// <summary>
 /// Gets setting with string value
 /// </summary>
 public string GetStringValue(SettingEnum name)
 {
     return((string)settings.Find(item => item.Name.Equals(name)).Value);
 }
Пример #18
0
 public Setting(SettingEnum name, object value)
 {
     this.Name  = name;
     this.Value = value;
 }