private void timerPreview_SaveRequested(object sender, SettingIOEventArgs e) { TimerPreview preview = sender as TimerPreview; if (preview == null) { return; } var success = true; try { var id = e.Settings.Id; // Fetch the current name for the timer to be saved var currentName = e.Settings.Name; if (currentName != null && !TimerSettings.IsUntitled(currentName)) { var settingsManager = this.savedTimersToolStripItem.SettingsManager; // Fetch the old name for this timer in case it has been changed ////var oldName = settingsManager.Fetch(id).Name; // Update and save this timer settingsManager.AddOrUpdate(e.Settings); preview.Settings = settingsManager.Save(id); this.AddSavedTimersToPreviews(preview.Settings.Id, preview.Settings.Name); ////// Now, get the possible new Id ////var newId = preview.Settings.Id; ////// If the name has changed, remove it from the preview lists ////if (!oldName.Equals(currentName)) ////{ //// // Removed the old name from the dropdown and add the new name in //// this.ClearPresetFromPreviews(id, oldName); //// this.AddSavedTimersToPreviews(newId, currentName); ////} } } catch (Exception) { success = false; } if (!success) { MessageBox.Show("Could not save setting. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SaveSettings() { var name = this.Settings.Name; if (name != null && !TimerSettings.IsUntitled(name)) { this.OnSaveRequested(this.Settings); this.btnSave.BackgroundImage = ControlPanel.SaveImage; this.savePending = false; } else { MessageBox.Show("Please enter a name for this timer"); } }
/// <summary> /// Loading settings from file /// </summary> private void LoadSettings() { try { var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var settings = config.AppSettings.Settings; string path = Path.Combine(Directory.GetCurrentDirectory(), settings["settingsFileName"].Value); if (File.Exists(path)) { try { BinaryFormatter formatter = new BinaryFormatter(); using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None)) { _settings = formatter.Deserialize(fs) as TimerSettings; } SetMessageToStatusBar("Settings loaded successfully"); } catch { SetMessageToStatusBar("Error reading settings!!!"); _settings = new TimerSettings(); _settings.InitializeDefault(); } } else { SetMessageToStatusBar("The file with the settings was not found!!!"); _settings = new TimerSettings(); _settings.InitializeDefault(); } } catch (Exception ex) { SetMessageToStatusBar($"An error has occurred!!! Details: {ex.Message}"); } if (_settings != null) { hoursTextBox.Text = _settings.TimeSpan.Hours.ToString(); minutesTextBox.Text = _settings.TimeSpan.Minutes.ToString(); secondsTextBox.Text = _settings.TimeSpan.Seconds.ToString(); MessageTextBox.Text = _settings.Message; } }
private void LoadItems() { ProjectsList.Items.Clear(); ProjectsList.Text = "Загрузка..."; TimerSettings.MakeEnvironment(); ProjectsDirs = Directory.GetDirectories(TimerSettings.CompetitionProjects); Projects = new CompetitionsContainer[ProjectsDirs.Length]; for (int i = 0; i < ProjectsDirs.Length; i++) { try { Projects[i] = JsonSerializer.Deserialize <CompetitionsContainer>(File.ReadAllText(Directory.GetFiles(ProjectsDirs[i])[0])); //Projects[i] = JsonConvert.DeserializeObject<CompetitionsContainer>(File.ReadAllText(Directory.GetFiles(ProjectsDirs[i])[0])); } catch { Directory.Delete(ProjectsDirs[i], true); LoadItems(); } } ProjectsList.Items.Clear(); foreach (CompetitionsContainer CC in Projects) { ProjectsList.Items.Add("Название: " + CC.Name + (CC.Competition.Finished ? " (Завершено)" : "")); } if (Projects.Length == 0) { ProjectsList.Items.Add("Проектов нет"); ProjectsList.SelectedIndex = 0; Continue.Visible = false; DeleteCompetition.Visible = false; ModelStartBox.Visible = false; InfoBox.Visible = false; CompetitionLabel.Visible = false; } else { ProjectsList.SelectedIndex = ProjectsList.Items.Count - 1; CompetitionLabel.Text = Projects[ProjectsList.SelectedIndex].Competition.ToString(); InfoBox.Visible = true; UpdateData(); } }
public void ResetTimer(TimerSettings timerSettings) { if (!dicTimers.ContainsKey(timerSettings.TimerId)) { dicTimers[timerSettings.TimerId] = new TimerStatus(); } dicTimers[timerSettings.TimerId].EndTime = DateTime.Now + timerSettings.CounterLength; dicTimers[timerSettings.TimerId].Filename = timerSettings.FileName; dicTimers[timerSettings.TimerId].FileTitlePrefix = timerSettings.FileTitlePrefix; dicTimers[timerSettings.TimerId].FileCountdownEndText = timerSettings.FileCountdownEndText; dicTimers[timerSettings.TimerId].ClearFileOnReset = timerSettings.ClearFileOnReset; dicTimers[timerSettings.TimerId].PausedTimeLeft = 0; SaveTimers(); if (timerSettings.ClearFileOnReset) { SaveTimerToFile(timerSettings.FileName, String.Empty); } }
/// <summary>Creates a new instance of Monero API .NET's RPC manager service.</summary> /// <param name="rpcSettings">IP-related settings to use when communicating through the Monero core assemblies' RPC protocol.</param> /// <param name="timerSettings">Timer settings which can be used to alter data fetching intervals.</param> public MoneroRpcManager(IRpcSettings rpcSettings, ITimerSettings timerSettings) { if (rpcSettings == null) { rpcSettings = new RpcSettings(); } if (timerSettings == null) { timerSettings = new TimerSettings(); } RpcWebClient = new RpcWebClient(rpcSettings, timerSettings); RpcSettings = rpcSettings; TimerSettings = timerSettings; Daemon = new DaemonRpcManager(RpcWebClient); AccountManager = new AccountRpcManager(RpcWebClient); }
private void TimerSettings_Tick(object sender, EventArgs e) { if (_settingsCollapse) { SettingsPanel.Height += 10; if (SettingsPanel.Size == SettingsPanel.MaximumSize) { TimerSettings.Stop(); _settingsCollapse = false; } } else { SettingsPanel.Height -= 10; if (SettingsPanel.Size == SettingsPanel.MinimumSize) { TimerSettings.Stop(); _settingsCollapse = true; } } }
public static void SaveData() { //return; var Saver = new Thread(new ThreadStart(() => { TimerSettings.MakeEnvironment(); Directory.CreateDirectory(Path.Combine(TimerSettings.CurrentProjectFolder)); var ProjectFile = File.CreateText(Path.Combine(TimerSettings.CurrentProjectFolder, TimerSettings.Container.Name + ".json")); //string data = TimerSettings.jsonEngine ? : JsonSerializer.Serialize(TimerSettings.Container); //JsonSerializer.Serialize(TimerSettings.Container) ProjectFile.Write(JsonSerializer.Serialize(TimerSettings.Container)); //ProjectFile.Write(JsonConvert.SerializeObject(TimerSettings.Container)); ProjectFile.Close(); })); Saver.IsBackground = true; Saver.Start(); }
private void BtnSettings_Click(object sender, EventArgs e) { TimerSettings.Start(); }
public HtmlHelper(MySqlContext dbContext, IOptions <TimerSettings> timerSettings) { _dbContext = dbContext; _timerSettings = timerSettings.Value; }
public ConfigurationData() { Strings = new StringsSettings(); Network = new NetworkSettings(); DefaultChannels = new DefaultChannelSettings(); NamingRules = new NamingRulesSettings(); Timers = new TimerSettings(); FloodConditions = new FloodConditionsSettings(); }
public async Task UpdateTimerSettingsAsync(TimerSettings timerSettings) { await _timerSettingsRepository.UpdateAsync(timerSettings); _timerSettings = timerSettings; }
public async Task UpdateTimerSettingsAsync([FromBody] TimerSettingsModel model) { TimerSettings timerSettings = Mapper.Map <TimerSettings>(model); await _settingsService.UpdateTimerSettingsAsync(timerSettings); }
public async Task <TimerSettingsModel> GetTimerSettingsAsync() { TimerSettings timerSettings = await _settingsService.GetTimerSettingsAsync(); return(Mapper.Map <TimerSettingsModel>(timerSettings)); }
protected override async Task <TimeSpan> GetDelayAsync() { TimerSettings timerSettings = await _settingsService.GetTimerSettingsAsync(); return(timerSettings.Balances); }
public XGameInstaller(MiscSettings miscSettings, ClockSettings clockSettings, TimerSettings timerSettings, PlayerDataModel playerDataModel, BreaktimeSettings breaktimeSettings) { _miscSettings = miscSettings; _clockSettings = clockSettings; _timerSettings = timerSettings; _playerDataModel = playerDataModel; _breaktimeSettings = breaktimeSettings; }