/// <summary> /// Get setting. /// </summary> /// <param name="setting">The setting.</param> /// <returns>Returns boolean setting.</returns> public bool GetBit(AvailableSettings setting) { var bitValue = this.unitOfWork.SettingRepository.GetById(setting).BitValue; if (!bitValue.HasValue) { throw new ArgumentException("Bit value of the setting cannot be read", "setting"); } return(bitValue.Value); }
/// <summary> /// Get setting. /// </summary> /// <param name="setting">The setting.</param> /// <returns>Returns integer setting.</returns> public int GetInt(AvailableSettings setting) { var intValue = this.unitOfWork.SettingRepository.GetById(setting).IntValue; if (!intValue.HasValue) { throw new ArgumentException("Int value of the setting cannot be read", "setting"); } return(intValue.Value); }
/// <summary> /// This returns a StringCollection with the names of recently used settings /// for the given report /// /// </summary> /// <returns>the list of names of recently used settings, which exist at the moment /// </returns> public StringCollection GetRecentlyUsedSettings() { StringCollection ReturnValue; String SettingName; StringCollection AvailableSettings; System.Int32 Counter; ReturnValue = new StringCollection(); if (("RptStg" + FReportName).Length > 32) { throw new Exception(String.Format("Report name ({0}) is too long for the settings", FReportName)); } // get names of recently used settings from the database ReturnValue = StringHelper.StrSplit(TUserDefaults.GetStringDefault("RptStg" + FReportName, ""), ","); // remove settings that are not available anymore AvailableSettings = GetAvailableSettings(); Counter = 0; while (Counter < ReturnValue.Count) { SettingName = ReturnValue[Counter]; if (!AvailableSettings.Contains(SettingName)) { ReturnValue.Remove(SettingName); } else { Counter = Counter + 1; } } // we might to fill up with reports from the directory, that have not been used yet Counter = 0; while ((Counter < AvailableSettings.Count) && (ReturnValue.Count < MAX_NUMBER_OF_RECENT_SETTINGS)) { SettingName = AvailableSettings[Counter]; if (!ReturnValue.Contains(SettingName)) { ReturnValue.Add(SettingName); } Counter = Counter + 1; } return(ReturnValue); }
public AvailableSettings GetAvailableSettings() { AvailableSettings availablesettings = new AvailableSettings(); V45Packet cmdPack = new V45Packet(V45Packet.V45Commands.cmdGetAvailableSettings, new byte[0], sender, receiver); var packet = SendMessage(cmdPack); availablesettings.Count = BitConverter.ToUInt16(packet.Payload, 0); availablesettings.Settings = new UInt16[availablesettings.Count]; for (int i = 0; i < availablesettings.Count; i++) { availablesettings.Settings[i] = BitConverter.ToUInt16(packet.Payload, i * 3 + 2); var tmp = packet.Payload[i * 3 + 3]; } return(availablesettings); }
/// <summary> /// Only place from which any setting can be set. Writes to IsolatedStorage /// </summary> /// <param name="setting">Setting to set</param> public static void SetValueForSetting(AvailableSettings setting, object value) { switch (setting) { case AvailableSettings.HasPassword: (new ApplicationSettingsHelper<Boolean>("HasPassword", (bool)defaultSettings[AvailableSettings.HasPassword])).Value = (bool)value; break; case AvailableSettings.Password: (new ApplicationSettingsHelper<String>("Password", defaultSettings[AvailableSettings.HasPassword].ToString())).Value = value.ToString(); break; } }
/// <summary> /// Only place from which any setting can be obtained. Retrieves from IsolatedStorage /// </summary> /// <param name="setting">Setting to retrieve</param> /// <returns>Value of the setting if found, else null</returns> public static object GetValueForSetting(AvailableSettings setting) { switch (setting) { case AvailableSettings.HasPassword: return (new ApplicationSettingsHelper<Boolean>("HasPassword", (bool)defaultSettings[AvailableSettings.HasPassword])).Value; case AvailableSettings.Password: return (new ApplicationSettingsHelper<String>("Password", defaultSettings[AvailableSettings.HasPassword].ToString())).Value; } return null; }
/// <summary> /// Get setting. /// </summary> /// <param name="setting">The setting.</param> /// <returns>Returns string setting.</returns> public string Get(AvailableSettings setting) { return(this.unitOfWork.SettingRepository.GetById(setting).NvValue); }