private void RunButton_Click(object sender, RoutedEventArgs e) { _settings.Save(); DialogResult = true; Close(); }
public Program(string settingsPath) { settings = new SettingsContainer(settingsPath ?? Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "EtherSound", "Settings.json")); viewModel = new RootModel(settings.Settings); sessions = new SessionManager(settings.Settings); wsServer = new Server(viewModel, sessions, settings.Settings.WebSocketEndpoint); ready = false; SetTimer(out saveTimer, 3000, delegate { if (ready && suspendSaving == 0) { viewModel.UpdateSettings(); settings.Save(); } }); SetTimer(out cursorTimer, 1000, delegate { viewModel.UpdateCursor(); }); SetTimer(out pollTimer, 5, delegate { viewModel.Poll(); }); tapThread = new Thread(RunTapThread) { IsBackground = true }; tapThread.Start(); trayIcon = new TrayIcon(viewModel); viewModel.PropertyChanged += ModelPropertyChanged; trayIcon.VolumeControlClicked += delegate { OpenVolumeControlWindow(); }; trayIcon.SettingsClicked += delegate { OpenSettingsWindow(); }; trayIcon.ResetClicked += async delegate { await sessions.RefreshDevices().ConfigureAwait(true); sessions.RestartAll(); }; }
public static void SaveSettings() { try { SettingsContainer.LockedAction(() => { SetString("gitssh", GitCommandHelpers.GetSsh()); Repositories.SaveSettings(); SettingsContainer.Save(); }); } catch { } }
public void TestIfSavingAndLoadingWorks() { var tempFile = Path.GetTempFileName(); var settings = new BuildMonitorSettings(Guid.NewGuid().ToString()); settings.Add("Test1", "02fdb4e0-fa5d-472a-918a-fc02c48b11a8"); settings.Add("Test2", new List <String> { "Item1", "Item2" }); //settings.Add("Test3", new List<IBuildDefinition> { GetTestBuildDefinition(1), GetTestBuildDefinition(2) }); var container = new SettingsContainer <BuildMonitorSettings>(); container.Add(settings); container.Save(tempFile); var loadedContainer = SettingsContainer <BuildMonitorSettings> .Load(tempFile); Assert.IsNotNull(loadedContainer); Assert.AreEqual(container.Count, loadedContainer.Count); var loadedSettings = loadedContainer.Single(); Assert.IsNotNull(loadedSettings); Assert.AreEqual(settings.BuildProviderId, loadedSettings.BuildProviderId); Assert.AreEqual(settings.UniqueId, loadedSettings.UniqueId); Assert.AreEqual(settings.Count, loadedSettings.Count); foreach (var keyValuePair in settings) { var loadedValue = loadedSettings[keyValuePair.Key]; Assert.IsNotNull(loadedValue); var expected = keyValuePair.Value as ICollection; if (expected != null) { CollectionAssert.AreEqual(expected, loadedValue as ICollection); } else { Assert.AreEqual(keyValuePair.Value, loadedValue); } } }
public void Save() { BuildMonitorSettingsContainer.Save(this.buildMonitorSettingsFilePath); this.generalSettingsContainer.Save(this.generalSettingsFilePath); }
public static void Restart() { Settings?.Save(); Process.Start("TCC.exe", $"--restart{(ToolboxMode ? " --toolbox" : "")}"); Close(); }