public static object GetSettings(Type t) { //Ensure that the static constructor of the type has ran. RuntimeHelpers.RunClassConstructor(t.TypeHandle); if (s_DefaultLoaderMap.ContainsKey(t)) { if (s_DefaultLoaderMap[t].CachedObject != null) { return(s_DefaultLoaderMap[t].CachedObject); } SettingsEntry e = s_DefaultLoaderMap[t]; if (e.CachedObject == null) { e.CachedObject = GetSettings( s_DefaultLoaderMap[t].FileLoader, t, s_DefaultLoaderMap[t].DefaultFile ); } s_DefaultLoaderMap[t] = e; return(e.CachedObject); } EventManager <ErrorEvent> .SendEvent(new SettingsLoaderNotFoundEvent( t )); return(null); }
public bool SaveSetting(SettingsEntry settingsToSave) { try { var settings = JsonSerializer.Serialize(settingsToSave); if (!Directory.Exists(SettingsDirectory)) { Directory.CreateDirectory(SettingsDirectory); } File.WriteAllText(Path.Combine(SettingsDirectory, settingsToSave.Name + ".mailSettings"), settings); var hasSetting = Settings.FirstOrDefault(e => e.Name == settingsToSave.Name); if (hasSetting == null) { Settings.Add(new SettingsMetaEntry() { Name = settingsToSave.Name, Path = Path.Combine(SettingsDirectory, settingsToSave.Name + ".mailSettings"), ValidLoading = true }); } LoadedSettings = settingsToSave; return(true); } catch (Exception e) { return(false); } }
public MainForm() { InitializeComponent(); #region Init of Manual Parser ClipboardParserSettings.FillData(tTemplates); cmbTemplate.DisplayMember = "DisplayName"; cmbTemplate.ValueMember = "Regex"; bsLogParserSettingsByType.DataSource = tTemplates; #endregion dictMatchingSettingsByType = SettingsEntry.ReadFromFile(@"AutomaticParsing\Settings\LogMatchingSettings.xml"); var sbRegexText = new StringBuilder(); var settings = dictMatchingSettingsByType.Values; foreach (var s in settings) { sbRegexText.AppendFormat("({0})", s.LogFileNameMask); if (s != settings.Last()) { sbRegexText.Append("|"); } } this.rgxMatchFilenames = new Regex(sbRegexText.ToString()); }
public SettingsPage() { ViewModel.SaveCompleted += HandleSaveCompleted; ViewModel.SaveFailed += HandleSaveFailed; var usernameLabel = new MediumBlueLabel(_gitHubUserName); var usernameEntry = new SettingsEntry(_gitHubUserName) { ReturnType = ReturnType.Next, ReturnCommand = new Command(() => _tokenEntry.Focus()) }; usernameEntry.SetBinding(Xamarin.Forms.Entry.TextProperty, nameof(ViewModel.UsernameEntryText)); var tokenLabel = new MediumBlueLabel(_gitHubApiToken); _tokenEntry = new SettingsEntry(_gitHubApiToken) { IsPassword = true, ReturnType = ReturnType.Go }; _tokenEntry.SetBinding(Xamarin.Forms.Entry.TextProperty, nameof(ViewModel.TokenEntryText)); _tokenEntry.SetBinding(Xamarin.Forms.Entry.ReturnCommandProperty, nameof(ViewModel.SaveCommand)); var saveButton = new BlueButton { Text = "Save" }; saveButton.SetBinding(Button.CommandProperty, nameof(ViewModel.SaveCommand)); var cancelButton = new BlueButton { Text = "Cancel" }; cancelButton.Clicked += HandleCancelButtonClicked; On <iOS>().SetUseSafeArea(true); BackgroundColor = ColorConstants.LightBlue; Title = "Settings"; Content = new StackLayout { Padding = new Thickness(20), Spacing = 1, Children = { usernameLabel, usernameEntry, tokenLabel, _tokenEntry, saveButton, cancelButton } }; }
private static void OnColorChanged(SettingsEntry entry) { int tier = int.Parse(entry.GetName()); ColorManager.SetColor(tier, ZatColorToUnity(entry.color)); ColorManager.Update(); }
public static void RegisterDefaultLoader( Type t, SettingsLoader loader, SettingsCategory category, string defaultFileName) { s_DefaultLoaderMap[t] = new SettingsEntry( Path.Combine(category.GetCategoryDirectory(), defaultFileName), loader ); }
private static void OnColorPresetChanged(SettingsEntry entry) { Dictionary <int, UnityEngine.Color> preset = inst.c_Coloring.preset; foreach (int tier in preset.Keys) { ColorManager.SetColor(tier, preset[tier]); } ColorManager.Update(); }
private void InitSettings() { SettingsEntry privacyEntry = new SettingsEntry("Privacy", new PrivacyPanelPage(), FlyoutDimension.Narrow); SettingsContractWrapper privacyWrapper = new SettingsContractWrapper( (Brush)App.Current.Resources["ApplicationForegroundThemeBrush"], (Brush)App.Current.Resources["ApplicationPageBackgroundThemeBrush"], (Brush)App.Current.Resources["ApplicationPageBackgroundThemeBrush"], new BitmapImage(new Uri("ms-appx:/Assets/30x30.png")), privacyEntry); }
private void InitSettings() { SettingsEntry privacyEntry = new SettingsEntry("Privacy", new PrivacyPanelPage(), FlyoutDimension.Narrow); SettingsContractWrapper privacyWrapper = new SettingsContractWrapper( (Brush)App.Current.Resources["ApplicationForegroundThemeBrush"], (Brush)App.Current.Resources["ApplicationPageBackgroundThemeBrush"], (Brush)App.Current.Resources["ApplicationPageBackgroundThemeBrush"], new BitmapImage(new Uri("ms-appx:/Assets/30x30.png")), privacyEntry); }
public bool LoadSettings(SettingsMetaEntry settings) { try { LoadedSettings = JsonSerializer.Deserialize <SettingsEntry>(File.ReadAllText(settings.Path)); return(true); } catch (Exception e) { return(false); } }
private IEnumerator CheckBags(ulong playerID, SettingsEntry settings) { foreach (var entity in SleepingBag.sleepingBags) { if (entity.OwnerID == playerID) { SetCooldown(entity, settings); } } yield break; }
public void Assure_nonvalid_int_thows_exception() { try { SettingsEntry entry = new SettingsEntry("test", "hundre"); var intValue = entry.ValueAsInt(); Assert.Fail(); } catch (ArgumentException argumentException) { argumentException.Message.ShouldBe("The value was not convertable to int: hundre"); } }
public virtual void NewSetting(SettingsEntry entry) { if (entry == null) throw new ArgumentException("Cannot add null entry"); var existing = settings.Where(e => e.Name == entry.Name).FirstOrDefault(); if (existing == null) { settings.Add(entry); entry.Configuration = this; } else { existing.Vals = entry.Vals; } }
// IMPORTANT you want to put this method in your App.cs and call it from your apps constructor! private void InitSettings() { // make settings entries // first make a pretty normal settings entry, using the SettingsPanel control // this control contains a button that opens a file picker.. SettingsEntry optionsEntry = new SettingsEntry("Options", new SettingsPanelPage(), FlyoutDimension.Narrow); // set up the two entries with the settings contract wrapper SettingsContractWrapper wrapper = new SettingsContractWrapper( (Brush)App.Current.Resources["ApplicationForegroundThemeBrush"], //the foreground color of all flyouts (Brush)App.Current.Resources["ApplicationPageBackgroundThemeBrush"], //the background color of all flyouts (Brush)App.Current.Resources["ApplicationPageBackgroundThemeBrush"], //the theme brush of the app new BitmapImage(new Uri("ms-appx:/Assets/SmallLogo.png")), optionsEntry); }
/// <summary> /// Gets the parameter. /// </summary> /// <param name="entities">The edc.</param> /// <param name="index">The parameter index.</param> /// <returns></returns> public static string GetParameter(Entities entities, SettingsEntry index) { Settings _ret = (from _sx in entities.Settings where _sx.KeyValue == (index.ToString()) select _sx).FirstOrDefault(); if (_ret == null) { _ret = new Settings() { KeyValue = index.ToString(), Title = m_DefaultSettings[index] }; entities.Settings.InsertOnSubmit(_ret); entities.SubmitChanges(); } return(_ret.Title); }
public static void RegisterDefaultLoader( Type t, SettingsLoader loader, SettingsCategory category, string defaultFile, object defaultValues) { s_DefaultLoaderMap[t] = new SettingsEntry( Path.Combine(category.GetCategoryDirectory(), defaultFile), loader ); if (!DefaultFileExists(t)) { SaveSettings(loader, defaultValues, s_DefaultLoaderMap[t].DefaultFile); } }
public SettingsTabWine() { Entries = new SettingsEntry[] { startupTypeSetting = new SettingsEntry <WineStartupType>("Installation Type", "Choose how XIVLauncher will start and manage your game installation.", () => Program.Config.WineStartupType ?? WineStartupType.Managed, x => Program.Config.WineStartupType = x), new SettingsEntry <string>("Wine Binary Path", "Set the path XIVLauncher will use to run applications via wine.\nIt should be an absolute path to a folder containing wine64 and wineserver binaries.", () => Program.Config.WineBinaryPath, s => Program.Config.WineBinaryPath = s) { CheckVisibility = () => startupTypeSetting.Value == WineStartupType.Custom }, new SettingsEntry <bool>("Enable GameMode", "Enable launching with GameMode optimizations.", () => Program.Config.GameModeEnabled ?? true, b => Program.Config.GameModeEnabled = b) { CheckValidity = b => { if (b == true && !File.Exists("/usr/lib/libgamemodeauto.so.0")) { return("GameMode not detected."); } return(null); } }, new SettingsEntry <bool>("Enable DXVK ASYNC", "Enable PROTON DXVK ASYNC patch.", () => Program.Config.DxvkAsyncEnabled ?? true, b => Program.Config.DxvkAsyncEnabled = b), new SettingsEntry <bool>("Enable ESync", "Enable eventfd-based synchronization.", () => Program.Config.ESyncEnabled ?? true, b => Program.Config.ESyncEnabled = b), new SettingsEntry <bool>("Enable FSync", "Enable fast user mutex (futex2).", () => Program.Config.FSyncEnabled ?? true, b => Program.Config.FSyncEnabled = b) { CheckValidity = b => { if (b == true && (Environment.OSVersion.Version.Major < 5 && (Environment.OSVersion.Version.Minor < 16 || Environment.OSVersion.Version.Major < 6))) { return("Kernel 5.16 or higher is required for FSync."); } return(null); } }, new SettingsEntry <Dxvk.DxvkHudType>("DXVK Overlay", "Configure how much of the DXVK overlay is to be shown.", () => Program.Config.DxvkHudType, type => Program.Config.DxvkHudType = type), new SettingsEntry <string>("WINEDEBUG Variables", "Configure debug logging for wine. Useful for troubleshooting.", () => Program.Config.WineDebugVars ?? string.Empty, s => Program.Config.WineDebugVars = s) }; }
public async Task InitialHttp2StreamWindowSize_SentInSettingsFrame() { const int WindowSize = 123456; using Http2LoopbackServer server = Http2LoopbackServer.CreateServer(); using var handler = CreateHttpClientHandler(); GetUnderlyingSocketsHttpHandler(handler).InitialHttp2StreamWindowSize = WindowSize; using HttpClient client = CreateHttpClient(handler); Task <HttpResponseMessage> clientTask = client.GetAsync(server.Address); Http2LoopbackConnection connection = await server.AcceptConnectionAsync().ConfigureAwait(false); SettingsFrame clientSettingsFrame = await connection.ReadSettingsAsync().ConfigureAwait(false); SettingsEntry entry = clientSettingsFrame.Entries.First(e => e.SettingId == SettingId.InitialWindowSize); Assert.Equal(WindowSize, (int)entry.Value); }
public static void SwitchSettings(SettingsEntry entry, int index) { var xml = new XmlDocument(); xml.Load(settingsFile); var newValue = 0; switch (entry) { case SettingsEntry.Volume: newValue = SupportedVolumes[index]; Volume = newValue; VolumeIndex = index; break; case SettingsEntry.Resolution: var newResolution = SupportedResolutions[index]; Width = newResolution.X; Height = newResolution.Y; ResolutionIndex = index; xml.GetElementsByTagName("Width")[0].InnerText = newResolution.X.ToString(); xml.GetElementsByTagName("Height")[0].InnerText = newResolution.Y.ToString(); xml.Save(settingsFile); return; default: newValue = SupportedGameSizes[index]; GameSize = newValue; GameSizeIndex = index; break; } xml.GetElementsByTagName(entry.ToString())[0].InnerText = newValue.ToString(); xml.Save(settingsFile); }
private void SetCooldown(SleepingBag entity, SettingsEntry info) { if (info == null) { return; } if (entity.ShortPrefabName.Contains("bed")) { entity.secondsBetweenReuses = info.bed; entity.unlockTime = info.unlockTimeBed + UnityEngine.Time.realtimeSinceStartup; } else { entity.secondsBetweenReuses = info.bag; entity.unlockTime = info.unlockTimeBag + UnityEngine.Time.realtimeSinceStartup; } entity.SendNetworkUpdate(); }
private void SaveCurrentStateExecute(object sender) { SimpleWorkAsync(async() => { var textService = IoC.Resolve <ITextService>(); var persistantSettingsService = IoC.Resolve <PersistantSettingsService>(); var settingsToSave = persistantSettingsService.LoadedSettings; if (persistantSettingsService.LoadedSettings != null) { var overwriteState = (await DialogCoordinator.Instance.ShowMessageAsync(this, textService.Compile("Application.Storage.OverwriteExisting.Title", CultureInfo.CurrentUICulture, out _).ToString(), textService.Compile("Application.Storage.OverwriteExisting.Message", CultureInfo.CurrentUICulture, out _, new FormattableArgument(persistantSettingsService.LoadedSettings.Name, false)).ToString(), MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary, new MetroDialogSettings() { AffirmativeButtonText = textService.Compile("Application.Affirmative", CultureInfo.CurrentUICulture, out _).ToString(), NegativeButtonText = textService.Compile("Application.Negative", CultureInfo.CurrentUICulture, out _).ToString(), FirstAuxiliaryButtonText = textService.Compile("Application.Cancel", CultureInfo.CurrentUICulture, out _).ToString() } )); if (overwriteState == MessageDialogResult.Negative) { settingsToSave = new SettingsEntry(); } if (overwriteState == MessageDialogResult.Canceled) { return; } } else { settingsToSave = new SettingsEntry(); } if (settingsToSave.Name == null) { var name = (await DialogCoordinator.Instance.ShowInputAsync(this, textService.Compile("Application.Storage.Filename.Title", CultureInfo.CurrentUICulture, out _).ToString(), textService.Compile("Application.Storage.Filename.Message", CultureInfo.CurrentUICulture, out _).ToString())); if (string.IsNullOrWhiteSpace(name)) { return; } settingsToSave.Name = name; } foreach (var wizardStepBaseViewModel in Steps) { var saveSetting = await wizardStepBaseViewModel.SaveSetting(); foreach (var setting in saveSetting) { settingsToSave.Values[setting.Key] = setting.Value; } } persistantSettingsService.SaveSetting(settingsToSave); }); }
public ProjectConfigViewModel(CIProject project, Configuration config) { this.Project = project; this.SelectedSetting = config.GetSetting(CISettingsViewModel.GetProjectSelectedSettingName(project)); this.initialSelectedState = Boolean.Parse(SelectedSetting.Value); }
public static void Update(SettingsEntry entry) { Settings.inst.Proxy.UpdateSetting(entry, OnSuccesfulSettingUpdate, OnUnsuccesfulSettingUpdate); }
public void Add(SettingsEntry entity) { Context.SettingsEntrySet.AddObject(entity); }
public void Update(int id, SettingsEntry entity) { var existing = GetById(id); existing.Name = entity.Name; existing.Value = entity.Value; }
public void Assure_valid_ints_are_parsed_correctly() { SettingsEntry entry = new SettingsEntry("test", "100"); var intValue = entry.ValueAsInt(); intValue.ShouldBe(100); }
public virtual Configuration Clone() { var copy = new Configuration(); copy.Name = Name; copy.IsConfigured = IsConfigured; copy.Id = Id; foreach (var setting in Settings) { var settingCopy = new SettingsEntry(); settingCopy.Name = setting.Name; var vals = new List<string>(); foreach (var val in setting.Vals) vals.Add(val); settingCopy.Vals = vals; copy.settings.Add(settingCopy); } return copy; }
public void Save(SettingsEntry entry) { AppSettings.AddOrUpdateValue(DailyLimtSettingsKey, entry.DailyLimit); AppSettings.AddOrUpdateValue(MonthlyLimitSettingsKey, entry.MonthlyLimit); AppSettings.AddOrUpdateValue(EmailKey, entry.Email); }
private void TryLoadSpecificSetting(SettingsEntry setting) { if (setting != null) { try { SetSpecificSettingOnViewModel(setting); } catch (Exception exception) { LogError(exception); } } }
private void SetSpecificSettingOnViewModel(SettingsEntry setting) { var settingsValue = Boolean.Parse(setting.Value.Trim()); uiInvoker.Invoke(() => { switch (setting.Name) { case FIRSTNAME_ENTRY_NAME: teamMembersSettingsViewModel.FirstnameIsChecked = settingsValue; break; case SURNAME_ENTRY_NAME: teamMembersSettingsViewModel.SurnameIsChecked = settingsValue; break; case MIDDLENAME_ENTRY_NAME: teamMembersSettingsViewModel.MiddlenameIsChecked = settingsValue; break; case USERNAME_ENTRY_NAME: teamMembersSettingsViewModel.UsernameIsChecked = settingsValue; break; } }); UpdateVisibilityOnViewModel(); }
private static void UpdateSlider(SettingsEntry entry) { entry.slider.label = entry.slider.value.ToString(); Update(entry); }