public Form1() { BLIO.Log("Construct Form"); InitializeComponent(); instance = this; AppDomain.CurrentDomain.SetData("DataDirectory", IOVariables.databaseFile); BLIO.CreateSettings(); BLIO.CreateDatabaseIfNotExist(); //User controls that will be loaded into the "main" panel ucReminders = new UCReminders(); ucImportExport = new UCImportExport(); ucSound = new UCSound(); ucOverlay = new UCSettings(); ucResizePopup = new UCResizePopup(); ucSupport = new UCSupport(); ucDebug = new UCDebugMode(); ucTimer = new UCTimer(); //Turn them invisible ucImportExport.Visible = false; ucSound.Visible = false; ucOverlay.Visible = false; ucResizePopup.Visible = false; ucSupport.Visible = false; ucDebug.Visible = false; ucTimer.Visible = false; //Add all of them(invisible) to the panel pnlMain.Controls.Add(ucImportExport); pnlMain.Controls.Add(ucSound); pnlMain.Controls.Add(ucOverlay); pnlMain.Controls.Add(ucResizePopup); pnlMain.Controls.Add(ucSupport); pnlMain.Controls.Add(ucDebug); pnlMain.Controls.Add(ucTimer); pnlMain.Controls.Add(ucReminders); ucReminders.Visible = true; ucReminders.Initialize(); m_GlobalHook = Hook.GlobalEvents(); m_GlobalHook.KeyUp += GlobalKeyPress; //Set the Renderer of the menustrip to our custom renderer, which sets the highlight and border collor to DimGray, which is the same //As the menu's themselves, which means you will not see any highlighting color or border. This renderer also makes the text of the selected //toolstrip items white. RemindMeTrayIconMenuStrip.Renderer = new MyToolStripMenuRenderer(); UpdateInformation.Initialize(); formLoadAsync(); Thread.Sleep(2000); RemindMeIcon.Visible = true; BLIO.Log("Form constructed"); }
private void TimerPopup_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { BLIO.Log("TimerPopup enter pressed"); timerMinutes = 0; lblErrorText.Visible = false; UCTimer ucTimer = Form1.Instance.ucTimer; try { if (tbTime.Text.ToLower().Contains('h')) { BLIO.Log("timer popup contains 'h'. Checking what's before it"); //Text without the 'm'. We know the number after 'h' is in minutes, no need to keep it in the string string tbText = tbTime.Text.Replace("m", ""); //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 (tbText.Length > index + 1)//+1 because .Length starts from 1, index starts from 0 { BLIO.Log("Parsing minutes...."); timerMinutes += Convert.ToInt32(tbText.Substring(index + 1, tbText.Length - (index + 1))); } } else { timerMinutes = Convert.ToInt32(tbTime.Text); } if (timerMinutes <= 0 || timerMinutes >= 1440) //<= 0 OR >= 24 hours(1 day), return. If you want to set a quick timer for more than a day, maybe set a reminder instead.. { lblErrorText.Visible = true; lblErrorText.Text = "Invalid input time. (up to 24 hours)"; return; } } catch (Exception ex) { lblErrorText.Visible = true; lblErrorText.Text = "Invalid input"; return; } BLIO.Log("Success. (" + timerMinutes + "minutes ) Creating timespan."); TimeSpan time = TimeSpan.FromMinutes(timerMinutes); BLIO.Log("Setting values of (UCTimer) numericupdowns"); ucTimer.numSeconds.Value = Math.Ceiling((decimal)time.Seconds / 60); ucTimer.numMinutes.Value = Math.Ceiling((decimal)time.Minutes % 60); ucTimer.numHours.Value = 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.Dispose(); } }
public Form1() { BLIO.Log("=== Initializing RemindMe Version " + IOVariables.RemindMeVersion + " ==="); LogWindowsInfo(); //Windows version info etc LogCultureInfo(); //Datetime info in their country Cleanup(); AppDomain.CurrentDomain.SetData("DataDirectory", IOVariables.databaseFile); BLIO.CreateSettings(); BLIO.CreateDatabaseIfNotExist(); InitializeComponent(); //-- instance = this; //User controls that will be loaded into the "main" panel ucReminders = new UCReminders(); ucImportExport = new UCImportExport(); ucSound = new UCSound(); ucSettings = new UCSettings(); ucResizePopup = new UCResizePopup(); ucSupport = new UCSupport(); ucDebug = new UCDebugMode(); ucTimer = new UCTimer(); ucTheme = new UCTheme(); //Turn them invisible ucImportExport.Visible = false; ucSound.Visible = false; ucSettings.Visible = false; ucResizePopup.Visible = false; ucSupport.Visible = false; ucDebug.Visible = false; ucTimer.Visible = false; ucTheme.Visible = false; //Add all of them(invisible) to the panel pnlMain.Controls.Add(ucImportExport); pnlMain.Controls.Add(ucSound); pnlMain.Controls.Add(ucSettings); pnlMain.Controls.Add(ucResizePopup); pnlMain.Controls.Add(ucSupport); pnlMain.Controls.Add(ucDebug); pnlMain.Controls.Add(ucTimer); pnlMain.Controls.Add(ucTheme); pnlMain.Controls.Add(ucReminders); ucReminders.Visible = true; ucReminders.Initialize(); m_GlobalHook = Hook.GlobalEvents(); m_GlobalHook.KeyDown += GlobalKeyPressDown; m_GlobalHook.KeyUp += GlobalKeyPressUp; //Set the Renderer of the menustrip to our custom renderer, which sets the highlight and border collor to DimGray, which is the same //As the menu's themselves, which means you will not see any highlighting color or border. This renderer also makes the text of the selected //toolstrip items white. RemindMeTrayIconMenuStrip.Renderer = new MyToolStripMenuRenderer(); UpdateInformation.Initialize(); FormLoad(); SystemEvents.PowerModeChanged += OnPowerChange; RemindMeIcon.Visible = true; //Update LastOnline every 5 minutes tmrPingActivity.Start(); tmrDumpLogTxtContents.Start(); tmrEnableDatabaseAccess.Start(); SetButtonSpacing(); BLIO.Log("=== Initializing RemindMe Complete ==="); }
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); UCTimer ucTimer = Form1.Instance.ucTimer; BLIO.Log("Setting values of (UCTimer) numericupdowns"); ucTimer.numSeconds.Value = Math.Ceiling((decimal)time.Seconds / 60); ucTimer.numMinutes.Value = Math.Ceiling((decimal)time.Minutes % 60); ucTimer.numHours.Value = 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(); } }