private void MaterialForm1_Load(object sender, EventArgs e) { #region User controls reminders = new MUCReminders(); mucSettings = new MUCSettings(); theme = new MUCTheme(); timer = new MUCTimer(); importExport = new MUCImportExport(); sound = new MUCSound(); popup = new MUCResizePopup(); support = new MUCSupport(); debug = new MUCDebugMode(); newReminder = new MUCNewReminder(reminders); info = new MUCInfo(); newReminder.Visible = false; tabReminders.Controls.Add(reminders); tabReminders.Controls.Add(newReminder); tabSettings.Controls.Add(mucSettings); tabTheme.Controls.Add(theme); tabTimer.Controls.Add(timer); tabBackupImport.Controls.Add(importExport); tabSoundEffects.Controls.Add(sound); tabResizePopup.Controls.Add(popup); tabMessageCenter.Controls.Add(support); tabDebug.Controls.Add(debug); tabInfo.Controls.Add(info); reminders.Initialize(); long?id = BLLocalDatabase.Setting.Settings.CurrentTheme; if (id.HasValue && id != -1) { Themes selectedTheme = BLLocalDatabase.Theme.GetThemeById(id.Value); if (selectedTheme == null) { //Selected theme has been deleted BLIO.Log("Attempted to load a Theme that has been deleted. Theme with ID " + id.Value + " does not exist anymore"); } else { //Load theme from selectedTheme (local Db) materialSkinManager.Theme = (MaterialSkinManager.Themes)(int) selectedTheme.Mode; materialSkinManager.ColorScheme = new ColorScheme((Primary)(int)selectedTheme.Primary, (Primary)(int)selectedTheme.DarkPrimary, (Primary)(int)selectedTheme.LightPrimary, (Accent)(int)selectedTheme.Accent, (TextShade)(int)selectedTheme.TextShade); } } #endregion }
private void TimerPopup_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { BLIO.Log("TimerPopup enter pressed"); timerMinutes = 0; lblErrorText.Visible = false; try { //the "m" part of the input is unnecesary. If the input is 2h15m, //then 2h15 would produce the same output. 15m would also be the same as 15, since there is no 'h' present. tbTime.Text = tbTime.Text.ToLower().Replace("m", ""); if (tbTime.Text.ToLower().Contains('h')) { BLIO.Log("timer popup contains 'h'. Checking what's before it"); //Get the index number of the 'h' in the text int index = tbTime.Text.ToLower().IndexOf('h'); //Now get all the text before it(should be a numer) and multiply by 60 because the user input hours BLIO.Log("Parsing hours...."); timerMinutes += Convert.ToInt32(tbTime.Text.Substring(0, index)) * 60; //Now get the number after the 'h' , which should be minutes, and add it to timerMinutes //But, first check if there is actually something after the 'h' if (tbTime.Text.Length > index + 1)//+1 because .Length starts from 1, index starts from 0 { BLIO.Log("Parsing minutes...."); timerMinutes += Convert.ToInt32(tbTime.Text.Substring(index + 1, tbTime.Text.Length - (index + 1))); } } else { timerMinutes = Convert.ToInt32(tbTime.Text); } if (timerMinutes <= 0) { lblErrorText.Visible = true; lblErrorText.Text = "Invalid input time"; return; } } catch { lblErrorText.Visible = true; lblErrorText.Text = "Invalid input"; return; } BLIO.Log("Success. (" + timerMinutes + "minutes ) Creating timespan."); TimeSpan time = TimeSpan.FromMinutes(timerMinutes); MUCTimer ucTimer = MaterialForm1.Instance.timer; BLIO.Log("Setting values of (UCTimer) numericupdowns"); ucTimer.numSeconds.Text = "" + Math.Ceiling((decimal)time.Seconds / 60); ucTimer.numMinutes.Text = "" + Math.Ceiling((decimal)time.Minutes % 60); ucTimer.numHours.Text = "" + Math.Ceiling((decimal)time.Hours); ucTimer.timerNote = tbNote.Text; BLIO.Log("Values set"); ucTimer.AddTimer(timerMinutes * 60, tbNote.Text); //ucTimer.ToggleTimer(); BLIO.Log("Timer started"); this.Close(); } }