private void lblExit_Click(object sender, EventArgs e) { ///this.CreateHandle this.Close(); this.Dispose(); MaterialMessageFormManager.RepositionActivePopups(); }
private void RemindMeMaterialMessageForm_FormClosing(object sender, FormClosingEventArgs e) { MaterialSkin.MaterialSkinManager.Instance.RemoveFormToManage(this); closed = true; MaterialMessageFormManager.RepositionActivePopups(); }
private void btnOk_Click(object sender, EventArgs e) { try { BLIO.Log("btnOk pressed on ExceptionPopup. textbox text = " + tbFeedback.Text); string logTxtPath = IOVariables.systemLog; string textBoxText = tbFeedback.Text; //Cant access tbNote in a thread. save the text in a variable instead if (string.IsNullOrWhiteSpace(textBoxText) || tbFeedback.ForeColor == Color.Gray) { textBoxText = "NONE_SET"; } BLOnlineDatabase.AddException(exception, DateTime.UtcNow, logTxtPath, textBoxText); if (textBoxText != null) { MaterialMessageFormManager.MakeMessagePopup("Feedback sent.\r\nThank you for taking the time!", 5); } //Set this boolean to true so that when this popup closes, we won't try to add another db entry customFeedback = true; btnOk.Enabled = false; this.Close(); this.Dispose(); } catch { } }
private void btnImport_Click(object sender, EventArgs e) { try { if (lvReminders.SelectedItems.Count > 0) { foreach (Reminder rem in GetSelectedRemindersFromListview()) { if (!File.Exists(rem.SoundFilePath)) //when you import reminders on another device, the path to the file might not exist. remove it. { rem.SoundFilePath = ""; } BLIO.Log("Pushing reminder with id " + rem.Id + " To the database"); BLReminder.PushReminderToDatabase(rem); } //Let remindme know that the listview should be refreshed BLIO.Log("Sending message WM_RELOAD_REMINDERS ...."); PostMessage((IntPtr)HWND_BROADCAST, WM_RELOAD_REMINDERS, new IntPtr(0xCDCD), new IntPtr(0xEFEF)); this.Close(); } else { MaterialMessageFormManager.MakeMessagePopup("Please select at least one reminder.", 3); } } catch (Exception ex) { MaterialExceptionPopup pop = new MaterialExceptionPopup(ex, "Error inserting reminders"); pop.Show(); BLIO.WriteError(ex, "Error inserting reminders"); } }
private async void PreviewReminder(int delay = 0) { //Set the reminder first, so that switching pages doesn't preview a different reminder. Reminder previewRem = CopyReminder(rem); if (delay > 0) { await Task.Delay(delay); } if (previewRem == null) { BLIO.Log("Reminder in PreviewReminder() is null. Interesting... ;)"); MaterialMessageFormManager.MakeMessagePopup("Could not preview that reminder. It doesn't exist anymore!", 4, "Error"); return; } BLIO.Log("Previewing reminder with id " + previewRem.Id); previewRem.Id = -1; //give the >temporary< reminder an invalid id, so that the real reminder won't be altered MaterialPopup p = new MaterialPopup(previewRem); MaterialSkin.MaterialSkinManager.Instance.AddFormToManage(p); p.TopMost = true; p.TopLevel = true; p.Show(); new Thread(() => { //Log an entry to the database, for data! try { try { BLOnlineDatabase.PreviewCount++; } catch (ArgumentException ex) { BLIO.Log("Exception at BLOnlineDatabase.PreviewCount++. -> " + ex.Message); BLIO.WriteError(ex, ex.Message, true); } finally { GC.Collect(); } } catch (ArgumentException ex) { BLIO.Log("Exception at BLOnlineDatabase.PreviewCount++. -> " + ex.Message); BLIO.WriteError(ex, ex.Message, true); } }).Start(); this.Invalidate(); this.Refresh(); }
private void btnConfirm_Click(object sender, EventArgs e) { if (tbBatch.Text.Length > 0 || cbHideReminder.Checked) { MaterialMessageFormManager.MakeMessagePopup("Advanced settings applied/updated", 5); } ucParent.AdvancedReminderFormCallback(); this.Hide(); }
private void btnReset_Click(object sender, EventArgs e) { BLIO.Log("(MUCResizePopup)btnReset_Click"); BLLocalDatabase.PopupDimension.ResetToDefaults(); MaterialMessageFormManager.MakeMessagePopup("Succesfully reset settings.", 4); FillValues(); ApplyPreviewChanges(); refreshTrackbars(); }
private void SetStatusTexts(int completedReminders, int totalReminders) { foreach (ListViewItem item in lvReminders.SelectedItems) { lvReminders.Items.Remove(item); } if (completedReminders > 0) { MaterialMessageFormManager.MakeMessagePopup("Succesfully " + this.transferType.ToString().ToLower() + "ed " + completedReminders + " reminders.", 4); } }
private bool Exportreminders() { if (GetSelectedRemindersFromListview().Count > 0) { string selectedPath = FSManager.Folders.GetSelectedFolderPath(); if (selectedPath != null) { BLIO.Log("User selected a valid path"); Exception possibleException = BLReminder.ExportReminders(GetSelectedRemindersFromListview(), selectedPath); if (possibleException == null) { BLIO.Log("No problems encountered (exception null)"); SetStatusTexts(GetSelectedRemindersFromListview().Count, BLReminder.GetReminders().Count); } else if (possibleException is UnauthorizedAccessException) { BLIO.Log("Problem encountered: Unauthorized"); if (MaterialRemindMeBox.Show("Could not save reminders to \"" + selectedPath + "\"\r\nDo you wish to place them on your desktop instead?", RemindMeBoxReason.YesNo) == DialogResult.Yes) { BLIO.Log("Trying to save to desktop instead..."); possibleException = BLReminder.ExportReminders(GetSelectedRemindersFromListview(), Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); if (possibleException != null) {//Did saving to desktop go wrong, too?? just show a message BLIO.Log("Trying to save to desktop didnt work either"); MaterialRemindMeBox.Show("Something went wrong. Could not save the reminders to your desktop.", RemindMeBoxReason.OK); return(false); } else {//Saving to desktop did not throw an exception BLIO.Log("Saved to desktop"); SetStatusTexts(GetSelectedRemindersFromListview().Count, BLReminder.GetReminders().Count); } } } else { MaterialMessageFormManager.MakeMessagePopup("Backup failed.", 6); return(false); } } else { return(false); } } else { MaterialMessageFormManager.MakeMessagePopup("Please select one or more reminder(s)", 6); } return(true); }
private void bunifuFlatButton2_Click(object sender, EventArgs e) { string text = MaterialRemindMePrompt.ShowText("Enter a message"); if (!string.IsNullOrWhiteSpace(text)) { MaterialMessageFormManager.MakeMessagePopup(text, 11); } else { MaterialMessageFormManager.MakeMessagePopup("This is a test.", 4); } }
private void tmrCheckForUpdates_Tick(object sender, EventArgs e) { try { if (showUpdateMessage && Directory.Exists(IOVariables.applicationFilesFolder + "\\old") && Directory.GetFiles(IOVariables.applicationFilesFolder + "\\old").Count() > 0) { MaterialMessageFormManager.MakeMessagePopup("RemindMe has updated!\r\nRestart RemindMe to load these changes directly.", 0); tmrCheckForUpdates.Stop(); } } catch (Exception ex) { BLIO.Log("CheckForUpdates FAILED. " + ex.GetType().ToString()); BLIO.WriteError(ex, "Error in tmrCheckForUpdates_Tick"); } }
private void btnPreview_Click(object sender, EventArgs e) { BLIO.Log("(MUCSound)btnPreview_Click"); if (lvSoundFiles.SelectedItems.Count == 1) { Songs selectedSong = BLLocalDatabase.Song.GetSongById((long)lvSoundFiles.SelectedItems[0].Tag); BLIO.Log("Attempting to preview sound file with id " + selectedSong.Id); if (btnPreview.Icon == imgPlay) { if (System.IO.File.Exists(selectedSong.SongFilePath)) { BLIO.Log("Sound file exists on the hard drive"); btnPreview.Icon = imgStop; myPlayer.URL = selectedSong.SongFilePath; mediaInfo = myPlayer.newMedia(myPlayer.URL); //Start the timer. the timer ticks when the song ends. The timer will then reset the picture of the play button if (mediaInfo.duration > 0) { tmrMusic.Interval = (int)(mediaInfo.duration * 1000); } else { tmrMusic.Interval = 1000; } tmrMusic.Start(); myPlayer.controls.play(); BLIO.Log("Playing sound."); } else { MaterialMessageFormManager.MakeMessagePopup("Could not preview the selected song. Does it still exist?", 4); } } else { BLIO.Log("Stopping sound"); btnPreview.Icon = imgPlay; myPlayer.controls.stop(); tmrMusic.Stop(); } } }
private void btnAddFiles_Click(object sender, EventArgs e) { BLIO.Log("(MUCSound)btnAddFiles_Click"); int songsAdded = 0; List <string> songPaths = FSManager.Files.GetSelectedFilesWithPath("Sound files", "*.mp3; *.wav; *.ogg; *.3gp; *.aac; *.flac; *.webm; *.aiff; *.wma; *.alac; *.m4a; *.MPEG-1; *.MPEG-2; *.MPEG-3; *.MPEG-4; *.MPEG-7; *.MPEG-21; *.MJPEG;").ToList(); if (songPaths.Count == 1 && songPaths[0] == "")//The user canceled out { return; } BLIO.Log("user selected " + songPaths.Count + " sound files."); List <Songs> songs = new List <Songs>(); foreach (string songPath in songPaths) { myPlayer.URL = songPath; mediaInfo = myPlayer.newMedia(myPlayer.URL); myPlayer.controls.play(); myPlayer.controls.stop(); Songs song = new Songs(); song.SongFileName = Path.GetFileName(songPath); song.SongFilePath = songPath; songs.Add(song); } BLLocalDatabase.Song.InsertSongs(songs); BLIO.Log("Inserted " + songs.Count + " sound files into RemindMe"); foreach (Songs song in songs) { if (!ListViewContains(song.SongFilePath)) { songsAdded++; ListViewItem item = new ListViewItem(song.SongFilePath); item.Tag = song.Id; lvSoundFiles.Items.Add(item); } } MaterialMessageFormManager.MakeMessagePopup(songsAdded + " Files added to RemindMe.", 4); MaterialForm1.Instance.mucSettings.FillSoundCombobox(); LoadSongs(); }
private void SaveChanges() { try { PopupDimensions dimension = new PopupDimensions(); dimension.FontNoteSize = (long)trbNoteFont.Value; dimension.FontTitleSize = 1; dimension.FormWidth = (long)trbWidth.Value; dimension.FormHeight = (long)trbHeight.Value; BLLocalDatabase.PopupDimension.UpdatePopupDimensions(dimension); MaterialMessageFormManager.MakeMessagePopup("Succesfully changed settings.", 4); } catch { MaterialMessageFormManager.MakeMessagePopup("Changing settings failed", 4); } }
private void btnRemoveFiles_Click(object sender, EventArgs e) { BLIO.Log("(MUCSound)btnRemoveFiles_Click"); List <Songs> toRemoveSongs = new List <Songs>(); foreach (ListViewItem selectedItem in lvSoundFiles.SelectedItems) { toRemoveSongs.Add(BLLocalDatabase.Song.GetSongById(Convert.ToInt32(selectedItem.Tag))); lvSoundFiles.Items.Remove(selectedItem); } BLLocalDatabase.Song.RemoveSongs(toRemoveSongs); if (toRemoveSongs.Count > 0) { MaterialMessageFormManager.MakeMessagePopup(toRemoveSongs.Count + " Files removed from RemindMe.", 4); MaterialForm1.Instance.mucSettings.FillSoundCombobox(); } }
private void PopupRemindMeMessage(RemindMeMessages mess) { //Update the counter on the message BLLocalDatabase.ReadMessage.MarkMessageRead(mess); BLIO.Log("Attempting to update an message with id " + mess.Id); BLOnlineDatabase.UpdateRemindMeMessageCount(mess.Id); switch (mess.NotificationType) { case "MaterialRemindMeBox": MaterialRemindMeBox.Show("RemindMe Developer", "This is a message from the developer of RemindMe.\r\n\r\n" + mess.Message.Replace("¤", Environment.NewLine), RemindMeBoxReason.OK); break; case "REMINDMEMESSAGEFORM": MaterialMessageFormManager.MakeMessagePopup(mess.Message.Replace("¤", Environment.NewLine), mess.NotificationDuration.Value, "RemindMe Developer"); break; } }
/*This was testing a custom color scheme * private void SetColorScheme() * { * * string t = BLLocalDatabase.Setting.Settings.RemindMeTheme; * RemindMeColorScheme colorTheme = BLLocalDatabase.Setting.GetColorTheme(BLLocalDatabase.Setting.Settings.RemindMeTheme); * BLIO.Log("Setting RemindMe Color scheme \"" + BLLocalDatabase.Setting.Settings.RemindMeTheme + "\""); * pnlSide.GradientBottomLeft = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[2])); * pnlSide.GradientBottomRight = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[2])); * pnlSide.GradientTopLeft = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[2])); * pnlSide.GradientTopRight = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[2])); * * * pnlMain.GradientBottomLeft = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[2])); * pnlMain.GradientBottomRight = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[2])); * pnlMain.GradientTopLeft = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[2])); * pnlMain.GradientTopRight = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[2])); * }*/ protected override void WndProc(ref Message m) { //This message will be sent when the RemindMeImporter imports reminders. if (m.Msg == WM_RELOAD_REMINDERS) { BLIO.Log("Reloading reminders after import from .remindme file"); int currentReminderCount = BLReminder.GetReminders().Count; BLReminder.NotifyChange(); if (MUCReminders.Instance != null) { MUCReminders.Instance.UpdateCurrentPage(); } if (!this.Visible) //don't make this message if RemindMe is visible, the user will see the changes if it is visible. { MaterialMessageFormManager.MakeMessagePopup(BLReminder.GetReminders().Count - currentReminderCount + " Reminder(s) succesfully imported!", 3); BLIO.Log("Created reminders succesfully imported message popup (WndProc)"); } if ((BLReminder.GetReminders().Count - currentReminderCount) > 0) { new Thread(() => { //Log an entry to the database, for data! try { BLOnlineDatabase.ImportCount++; } catch (ArgumentException ex) { BLIO.Log("Exception at BLOnlineDatabase.ImportCount++ Form1.cs . -> " + ex.Message); BLIO.WriteError(ex, ex.Message, true); } }).Start(); } } base.WndProc(ref m); }
private void SaveNewTheme(string name) { if (string.IsNullOrWhiteSpace(name)) { return; } Themes theme = new Themes(); theme.Primary = (int)Enum.Parse(typeof(Primary), cbPrimary.SelectedItem.ToString()); theme.DarkPrimary = (int)Enum.Parse(typeof(Primary), cbDarkPrimary.SelectedItem.ToString()); theme.LightPrimary = (int)Enum.Parse(typeof(Primary), cbLightPrimary.SelectedItem.ToString()); theme.Accent = (int)Enum.Parse(typeof(Accent), cbAccent.SelectedItem.ToString()); theme.TextShade = (int)Enum.Parse(typeof(TextShade), cbTextShade.SelectedItem.ToString()); theme.ThemeName = name; theme.Mode = (int)MaterialSkinManager.Instance.Theme; BLLocalDatabase.Theme.InsertTheme(theme); BLOnlineDatabase.InsertTheme(theme); ComboBoxItem item = new ComboBoxItem(theme.ThemeName, theme.Id); cbLoadTheme.Items.Add(item); cbLoadTheme.SelectedItem = item; currentSelectedTheme = theme; //Update the settings table Settings set = BLLocalDatabase.Setting.Settings; set.CurrentTheme = theme.Id; BLLocalDatabase.Setting.UpdateSettings(set); MaterialMessageFormManager.MakeMessagePopup("Succesfully saved theme \"" + name + "\" under your saved themes.", 5); }
private void LoadImportReminders() { BLIO.Log("Import button pressed. Loading reminders into listview"); remindersFromRemindMeFile.Clear(); lvReminders.Items.Clear(); string remindmeFile = FSManager.Files.GetSelectedFileWithPath("RemindMe backup file", "*.remindme"); if (remindmeFile == null || remindmeFile == "") {//user pressed cancel return; } BLIO.Log("Valid .remindme file selected"); try { List <object> toImportReminders = BLReminder.DeserializeRemindersFromFile(remindmeFile).Cast <object>().ToList(); if (toImportReminders != null) { BLIO.Log(toImportReminders.Count - 1 + " reminders in this .remindme file"); transferType = ReminderTransferType.IMPORT; foreach (object rem in toImportReminders) { if (rem.GetType() == typeof(Reminder)) { BLFormLogic.AddReminderToListview(lvReminders, (Reminder)rem, true); remindersFromRemindMeFile.Add((Reminder)rem); } } } } catch { MaterialMessageFormManager.MakeMessagePopup("Error loading reminder(s)", 6); } }
private void btnSaveTheme_Click(object sender, EventArgs e) { if (currentSelectedTheme != null) { if (MaterialRemindMeBox.Show ("Do you want to update the current theme, or save it under a new name? Press YES to update the current theme (\"" + currentSelectedTheme.ThemeName + "\"), and NO to save it under a new name.", RemindMeBoxReason.YesNo) == DialogResult.Yes) { if (currentSelectedTheme.IsDefault == 1) { MaterialRemindMeBox.Show("The selected theme is a default theme. You can't edit this theme. If you want to " + "save this theme, save it under a different name instead (Press NO after saving)"); return; } //Update current theme currentSelectedTheme.Primary = (int)Enum.Parse(typeof(Primary), cbPrimary.SelectedItem.ToString()); currentSelectedTheme.DarkPrimary = (int)Enum.Parse(typeof(Primary), cbDarkPrimary.SelectedItem.ToString()); currentSelectedTheme.LightPrimary = (int)Enum.Parse(typeof(Primary), cbLightPrimary.SelectedItem.ToString()); currentSelectedTheme.Accent = (int)Enum.Parse(typeof(Accent), cbAccent.SelectedItem.ToString()); currentSelectedTheme.TextShade = (int)Enum.Parse(typeof(TextShade), cbTextShade.SelectedItem.ToString()); currentSelectedTheme.Mode = (int)MaterialSkinManager.Instance.Theme; BLLocalDatabase.Theme.UpdateTheme(currentSelectedTheme); MaterialMessageFormManager.MakeMessagePopup("Succesfully updated theme \"" + currentSelectedTheme.ThemeName + "\"", 5); } else { SaveNewTheme(MaterialRemindMePrompt.ShowText("Give this theme a name ")); } } else //No currently selected thme, save as new theme { SaveNewTheme(MaterialRemindMePrompt.ShowText("Give this theme a name ")); } }
private void btnSend_Click(object sender, EventArgs e) { BLIO.Log("(MUCSupport)btnSend_Click"); try { BLIO.Log("Attempting to send a message to the RemindMe developer.."); //Don't do anything if there's no text if (string.IsNullOrWhiteSpace(tbNote.Text) || tbNote.Text == "Type your message here...") { return; } //Don't do anything without internet if (!BLIO.HasInternetAccess()) { MaterialMessageFormManager.MakeMessagePopup("You do not currently have an active internet connection", 3); return; } string email = tbEmail.Text; string subject = tbSubject.Text; string note = tbNote.Text; BLOnlineDatabase.InsertEmailAttempt(BLLocalDatabase.Setting.Settings.UniqueString, note, subject, email); MaterialMessageFormManager.MakeMessagePopup("Feedback Sent. Thank you!", 5); tbEmail.Text = ""; tbSubject.Text = ""; tbNote.Text = ""; label3.Focus(); BLIO.Log("Message sent!"); } catch (Exception ex) { BLIO.Log("Error in MUCSupport.btnSend_Click. Could not send the message! Exception type: " + ex.GetType().ToString() + " Stacktrace:\r\n" + ex.StackTrace); MaterialMessageFormManager.MakeMessagePopup("Something went wrong. Could not send the e-mail", 3); } }
private void tmrFadeout_Tick(object sender, EventArgs e) { if (this.Bounds.Contains(MousePosition)) //Cursor in the message? reset opacity to 1 and restart timeout timer { this.Opacity = 1; secondsPassed = 0; if (!disableFadeout) { tmrTimeout.Start(); } } else //Cursor out of the message? safely reduce opacity "slowly" { this.Opacity -= 0.02; if (this.Opacity <= 0) { tmrFadeout.Stop(); tmrFadein.Dispose(); tmrFadeout.Dispose(); tmrTimeout.Dispose(); if (!isDialog) { this.Close(); this.Dispose(); BLIO.Log("Message form (" + lblText.Text + ") disposed."); MaterialMessageFormManager.RepositionActivePopups(); } else { BLIO.Log("Message form (" + lblText.Text + ") NOT disposed. Form created dialog."); } } } }
/// <summary> /// Alternative Form_load method since form_load doesnt get called until you first double-click the RemindMe icon due to override SetVisibleCore /// </summary> private void formLoad() { try { BLIO.Log("RemindMe_Load"); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); RemindMeIcon.Text = "RemindMe " + IOVariables.RemindMeVersion; //set unique user string BLIO.WriteUniqueString(); MaterialMessageFormManager.MakeTodaysRemindersPopup(); BLIO.Log("Today's reminders popup created"); //Create an shortcut in the windows startup folder if it doesn't already exist if (!System.IO.File.Exists(IOVariables.startupFolderPath + "\\RemindMe" + ".lnk")) { FSManager.Shortcuts.CreateShortcut(IOVariables.startupFolderPath, "RemindMe", System.Windows.Forms.Application.StartupPath + "\\" + "RemindMe.exe", "Shortcut of RemindMe"); } else { WshShell shell = new WshShell(); //Create a new WshShell Interface IWshShortcut link = (IWshShortcut)shell.CreateShortcut(IOVariables.startupFolderPath + "\\RemindMe.lnk"); //Link the interface to our shortcut //shortcut does exist, let's see if the target of that shortcut isn't the old RemindMe in the programs files if (link.TargetPath.ToString().Contains("StefanGansevlesPrograms") || link.TargetPath.ToString().Contains("Program Files")) { BLIO.Log("Deleting old .lnk shortcut of RemindMe"); System.IO.File.Delete(IOVariables.startupFolderPath + "\\RemindMe.lnk"); FSManager.Shortcuts.CreateShortcut(IOVariables.startupFolderPath, "RemindMe", IOVariables.applicationFilesFolder + "RemindMe.exe", "Shortcut of RemindMe"); } } //if (Debugger.IsAttached) //Debugging ? show extra option //btnDebugMode.Visible = true; BLLocalDatabase.Song.InsertWindowsSystemSounds(); if (BLLocalDatabase.Setting.Settings.AutoUpdate == 1) //I guess some users don't want it? :( { tmrUpdateRemindMe.Start(); } //If the setup still exists, delete it System.IO.File.Delete(IOVariables.rootFolder + "SetupRemindMe.msi"); Settings set = BLLocalDatabase.Setting.Settings; //Call the timer once Thread tr = new Thread(() => { //wait a bit, then call the update timer once. It then runs every 5 minutes Thread.Sleep(5000); tmrUpdateRemindMe_Tick(null, null); BLOnlineDatabase.InsertOrUpdateUser(set.UniqueString); if (set.LastVersion == null) { set.LastVersion = IOVariables.RemindMeVersion; } BLLocalDatabase.Setting.UpdateSettings(set); }); tr.Start(); this.ShowInTaskbar = true; this.Show(); tmrInitialHide.Start(); //Random r = new Random(); //tmrCheckRemindMeMessages.Interval = (r.Next(60, 300)) * 1000; //Random interval between 1 and 5 minutes //tmrCheckRemindMeMessages.Start(); //BLIO.Log("tmrCheckRemindMeMessages.Interval = " + tmrCheckRemindMeMessages.Interval / 1000 + " seconds."); stopwatch.Stop(); BLIO.Log("formLoad() took " + stopwatch.ElapsedMilliseconds + " ms"); BLIO.Log("RemindMe loaded"); } catch (Exception ex) { BLIO.Log("Exception in formLoadAsync() -> " + ex.GetType().ToString()); BLOnlineDatabase.AddException(ex, DateTime.Now, IOVariables.systemLog); } }
private void Popup_Load(object sender, EventArgs e) { try { BLIO.Log("Popup_load"); if (BLLocalDatabase.Setting.Settings.PopupType == "SoundOnly") { //Dont initialize, just play sound PlayReminderSound(); if (rem.Id != -1) //Dont stop logic when the user is previewing an reminder { btnOk_Click(sender, e); return; } } string reminderText = rem.Note != null?rem.Note.Replace("\n", "<br>") : "( No text set )"; //White font if dark theme, Black text if light theme string color = MaterialSkin.MaterialSkinManager.Instance.Theme == MaterialSkin.MaterialSkinManager.Themes.DARK ? "#e6e6e6" : "#323232"; if (rem.Note.Contains("API{")) { TransformAPITextToValue(color, reminderText); } else { htmlLblText.Text = GetPopupHTMLText(color, reminderText); } AdvancedReminderProperties avrProps = BLLocalDatabase.AVRProperty.GetAVRProperties(rem.Id); List <AdvancedReminderFilesFolders> avrFF = BLLocalDatabase.AVRProperty.GetAVRFilesFolders(rem.Id); if (avrProps != null) //Not null? this reminder has advanced properties. { BLIO.Log("Reminder " + rem.Id + " has advanced reminder properties!"); this.Visible = avrProps.ShowReminder == 1; if (!string.IsNullOrWhiteSpace(avrProps.BatchScript)) { //if (!this.Visible) MaterialMessageFormManager.MakeMessagePopup("Activating script of Reminder:\r\n \"" + rem.Name + "\"", 3); BLIO.ExecuteBatch(avrProps.BatchScript); } } else { BLIO.Log("Reminder " + rem.Id + " does not have advanced reminder properties"); } if (avrFF != null && avrFF.Count > 0) { //Go through each action, for example c:\test , delete. c:\sometest\testFile.txt , open foreach (AdvancedReminderFilesFolders avr in avrFF) { if (avr.Action.ToString() == "Open") { BLIO.Log("Executing advanced reminder action \"Open\""); if (File.Exists(avr.Path) || Directory.Exists(avr.Path)) { System.Diagnostics.Process.Start(avr.Path); } } else if (avr.Action.ToString() == "Delete") { BLIO.Log("Executing advanced reminder action \"Delete\""); FileAttributes attr = File.GetAttributes(avr.Path); //Check if it's a file or a directory if (File.Exists(avr.Path)) { File.Delete(avr.Path); } else if (Directory.Exists(avr.Path)) { Directory.Delete(avr.Path, true); } } } } if (this.Visible) { tmrFadeIn.Start(); } else { btnOk_Click(sender, e); return; } if (rem.HttpId == null) { BLIO.Log("Attempting to parse date..."); DateTime date = Convert.ToDateTime(rem.Date.Split(',')[0]); BLIO.Log("Date succesfully converted (" + date + ")"); lblSmallDate.Text = date.ToShortDateString() + " " + date.ToShortTimeString(); } else { lblSmallDate.Text = "Conditional"; } lblRepeat.Text = BLReminder.GetRepeatTypeText(rem); if (!string.IsNullOrWhiteSpace(rem.PostponeDate)) { BLIO.Log("Reminder has a postpone date."); pbDate.BackgroundImage = Properties.Resources.RemindMeZzz; lblSmallDate.Text = Convert.ToDateTime(rem.PostponeDate) + ""; } //If some country has a longer date string, move the repeat icon/text more to the right so it doesnt overlap while (lblSmallDate.Bounds.IntersectsWith(pbRepeat.Bounds)) { pbRepeat.Location = new Point(pbRepeat.Location.X + 5, pbRepeat.Location.Y); lblRepeat.Location = new Point(lblRepeat.Location.X + 5, lblRepeat.Location.Y); } PlayReminderSound(); FlashWindowHelper.Start(this); //this.MaximumSize = this.Size; if (BLLocalDatabase.Setting.Settings.PopupType == "AlwaysOnTop") { this.TopMost = true; //Popup will be always on top. no matter what you are doing, playing a game, watching a video, you will ALWAYS see the popup. this.TopLevel = true; } else { if (rem.Id != -1) //previewreminders should be topmost { this.TopMost = false; this.WindowState = FormWindowState.Minimized; } } this.Text = rem.Name; string hexColor = ColorToHex(MaterialSkin.MaterialSkinManager.Instance.ColorScheme.AccentColor); foreach (string link in GetLinks(htmlLblText.Text)) //Add <a href> to make it into an actual link { htmlLblText.Text = htmlLblText.Text.Replace(link, "<a href=\"" + link + "\" style=\"color: " + hexColor + "\"> " + link + "</a>"); } if (rem.Date == null && rem.HttpId == null) { rem.Date = DateTime.Now.ToString(); } } catch (Exception ex) { ReminderException remEx = new ReminderException(BLReminder.ToString(rem), rem); remEx.StackTrace = ex.StackTrace; //Copy the stacktrace BLIO.WriteError(remEx, "Error loading reminder popup"); BLIO.Log("Popup_load FAILED. Exception -> " + ex.Message); } }
public void Initialize() { try { MaterialSkin.MaterialSkinManager.Themes theme = MaterialSkin.MaterialSkinManager.Instance.Theme; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); List <Reminder> corruptedReminders = BLReminder.CheckForCorruptedReminders(); if (corruptedReminders != null) { string message = "RemindMe has detected"; if (corruptedReminders.Count > 1) { message += " problems with the following reminders: \r\n"; foreach (Reminder rem in corruptedReminders) { message += "- " + rem.Name + "\r\n"; } message += "\r\nThey have been removed from your list of reminders."; } else { message += " a problem with the reminder:\r\n\"" + corruptedReminders[0].Name + "\". \r\nIt has been removed from your list of reminders."; } MaterialMessageFormManager.MakeMessagePopup(message, 0); } BLIO.Log("Loading reminders from database"); //Give initial value to newReminderUc newReminderUc = new MUCNewReminder(this); newReminderUc.Visible = false; newReminderUc.saveState = false; this.Parent.Controls.Add(newReminderUc); //MaterialForm1.Instance.ucNewReminder = newReminderUc; //BLFormLogic.AddRemindersToListview(lvReminders, BLReminder.GetReminders().Where(r => r.Hide == 0).ToList()); //Get all "active" reminders); BLIO.Log("Starting the reminder timer"); tmrCheckReminder.Start(); pnlReminders.Visible = true; pnlReminders.DragDrop += MUCReminders_DragDrop; pnlReminders.DragEnter += MUCReminders_DragEnter; int counter = 0; //List<Reminder> reminders = BLReminder.GetOrderedReminders(); List <Reminder> conditionalReminders = BLReminder.GetReminders(true).Where(r => r.HttpId != null).Where(r => r.Hide == 0).Where(r => r.Enabled == 1).ToList(); List <Reminder> activeReminders = BLReminder.GetReminders().Where(r => r.Hide == 0).OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 1).ToList(); List <Reminder> disabledReminders = BLReminder.GetReminders().Where(r => r.Hide == 0).OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 0).ToList(); //we've got postponed reminders, now do this if (BLReminder.GetReminders().Where(r => !string.IsNullOrWhiteSpace(r.PostponeDate)).ToList().Count > 0) { activeReminders = OrderPostponedReminders(); } foreach (Reminder rem in activeReminders) { if (pnlReminders.Controls.Count >= 7) { break; //Only 7 reminders on 1 page } pnlReminders.Controls.Add(new MUCReminderItem(rem)); if (counter > 0) { pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height); } counter++; } foreach (Reminder rem in conditionalReminders) { if (pnlReminders.Controls.Count >= 7) { break; //Only 7 reminders on 1 page } pnlReminders.Controls.Add(new MUCReminderItem(rem)); if (counter > 0) { pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height); } counter++; } foreach (Reminder rem in disabledReminders) { if (pnlReminders.Controls.Count >= 7) { break; } pnlReminders.Controls.Add(new MUCReminderItem(rem)); if (counter > 0) { pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height); } counter++; } if (activeReminders.Count + disabledReminders.Count < 7) //Less than 7 reminders, let's fit in some empty MUCReminderItem 's { for (int i = (activeReminders.Count + disabledReminders.Count); i < 7; i++) { pnlReminders.Controls.Add(new MUCReminderItem(null)); if (counter > 0) { pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height); } counter++; } } if (BLReminder.GetReminders().Where(r => r.Hide == 0).ToList().Count <= 7) { MaterialForm1.Instance.UpdatePageNumber(-1); //Tell MaterialForm1 that there are not more than 1 pages } else { if (theme == MaterialSkin.MaterialSkinManager.Themes.DARK) { btnNextPage.Icon = Properties.Resources.NextWhite; } else { btnNextPage.Icon = Properties.Resources.nextDark; } MaterialForm1.Instance.UpdatePageNumber(pageNumber); } //Just design, no logic here. Drags the color panel a bit down and shrink it so it doesnt overlap over the shadow MUCReminderItem itm = (MUCReminderItem)pnlReminders.Controls[0]; itm.pnlSideColor.Size = new Size(itm.pnlSideColor.Width, itm.pnlSideColor.Height - 4); itm.pnlSideColor.Location = new Point(itm.pnlSideColor.Location.X, itm.pnlSideColor.Location.Y + 4); //Http requests foreach (Reminder rem in conditionalReminders) { HttpRequests httpObj = BLLocalDatabase.HttpRequest.GetHttpRequestById((long)rem.Id); System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); timer.Interval = Convert.ToInt32(httpObj.Interval * 60000); timer.Tick += (object s, EventArgs a) => ExecuteHttpRequest(s, a, httpObj, rem); httpTimers.Add(rem, timer); timer.Start(); } stopwatch.Stop(); BLIO.Log("MUCReminders Initialize took " + stopwatch.ElapsedMilliseconds + " ms"); } catch (Exception ex) { BLIO.Log("MUCReminders.Initialize() FAILED. Type -> " + ex.GetType().ToString()); BLIO.Log("Message -> " + ex.Message); } }
private void tmrCheckReminder_Tick(object sender, EventArgs e) { try { bool isHourBeforeNotificationEnabled = BLLocalDatabase.Setting.IsHourBeforeNotificationEnabled(); if (BLReminder.GetReminders().Where(r => r.Enabled == 1).ToList().Count <= 0) { tmrCheckReminder.Stop(); //No existing reminders? no enabled reminders? stop timer. BLIO.Log("Stopping the reminder checking timer, because there are no more (enabled) reminders"); return; } //If a day has passed since the start of RemindMe, we may want to refresh the listview. //There might be reminders happening on this day, if so, we show the time of the reminder, instead of the day if (dayOfStartRemindMe < DateTime.Now.Day) { BLIO.Log("Dawn of a new day -24 hours remaining- "); UpdateCurrentPage(); dayOfStartRemindMe = DateTime.Now.Day; MaterialMessageFormManager.MakeTodaysRemindersPopup(); //Update lastOnline. If you keep RemindMe running and put your pc to sleep instead of turning it off, it would never get updated without this BLOnlineDatabase.InsertOrUpdateUser(BLLocalDatabase.Setting.Settings.UniqueString); } //We will check for reminders here every 5 seconds. foreach (Reminder rem in BLReminder.GetReminders().Where(r => r.Enabled == 1).ToList()) { //Create the popup. Do the other stuff afterwards. if ((rem.PostponeDate != null && Convert.ToDateTime(rem.PostponeDate) <= DateTime.Now) || (Convert.ToDateTime(rem.Date.Split(',')[0]) <= DateTime.Now && rem.PostponeDate == null && rem.Enabled == 1)) { //temporarily disable it. When the user postpones the reminder, it will be re-enabled. rem.Enabled = 0; BLReminder.EditReminder(rem); MakeReminderPopup(rem); UpdateCurrentPage(); } else { // -- In this part we will create popups at the users right bottom corner of the screen saying x reminder is happening in 1 hour or x minutes -- \\ if (isHourBeforeNotificationEnabled) { DateTime theDateToCheckOn; //Like this we dont need an if ánd an else with the same code if (rem.PostponeDate != null) { theDateToCheckOn = Convert.ToDateTime(rem.PostponeDate); } else { theDateToCheckOn = Convert.ToDateTime(rem.Date.Split(',')[0]); } //The timespan between the date and now. TimeSpan timeSpan = Convert.ToDateTime(theDateToCheckOn) - DateTime.Now; if (timeSpan.TotalMinutes >= 59.50 && timeSpan.TotalMinutes <= 60) { remindersToHappenInAnHour.Add(rem); } } } } string message = "You have " + remindersToHappenInAnHour.Count + " reminders set in 60 minutes:\r\n"; int count = 1; foreach (Reminder rem in remindersToHappenInAnHour) { //Don't show "reminderName in 60 minutes!" if the reminder doesn't "Show" when popped up, silent reminders. if (BLLocalDatabase.AVRProperty.GetAVRProperties(rem.Id) != null && BLLocalDatabase.AVRProperty.GetAVRProperties(rem.Id).ShowReminder != 1) { continue; } if (remindersToHappenInAnHour.Count > 1) { message += count + ") " + rem.Name + Environment.NewLine; } else { message = rem.Name + " in 60 minutes!"; } count++; } if (remindersToHappenInAnHour.Count > 1 && count > 1) //cut off the last \n { message = message.Remove(message.Length - 2, 2); if (!popupMessages.Contains(message)) //Don't create this popup if we have already created it once before { MaterialMessageFormManager.MakeMessagePopup(message, 6); } popupMessages.Add(message); } else if (remindersToHappenInAnHour.Count > 0 && count > 1) { if (!popupMessages.Contains(message)) //Don't create this popup if we have already created it once before { MaterialMessageFormManager.MakeMessagePopup(message, 6, remindersToHappenInAnHour[0]); } popupMessages.Add(message); } remindersToHappenInAnHour.Clear(); } catch (Exception ex) { BLIO.Log("CheckReminder FAILED!!! " + ex.GetType().ToString()); BLIO.WriteError(ex, "!!! Error in tmrCheckReminder_Tick"); } }