Esempio n. 1
0
        private void PlayReminderSound()
        {
            //Play the sound
            if (rem.SoundFilePath != null && rem.SoundFilePath != "")
            {
                if (System.IO.File.Exists(rem.SoundFilePath))
                {
                    BLIO.Log("SoundFilePath not null / empty and exists on the hard drive!");
                    myPlayer.URL = rem.SoundFilePath;

                    if (rem.Id == -1) //timer, set the volume set by the user
                    {
                        myPlayer.settings.volume = (int)BLLocalDatabase.Setting.Settings.TimerVolume;
                    }

                    myPlayer.controls.play();
                    BLIO.Log("Playing sound");
                }
                else
                {
                    BLIO.Log("SoundFilePath not null / empty but doesn't exist on the hard drive!");
                    MaterialRemindMeBox.Show("Could not play " + Path.GetFileNameWithoutExtension(rem.SoundFilePath) + " located at \"" + rem.SoundFilePath + "\" \r\nDid you move,rename or delete the file ?\r\nThe sound effect has been removed from this reminder. If you wish to re-add it, select it from the drop-down list.", RemindMeBoxReason.OK);
                    //make sure its removed from the reminder
                    rem.SoundFilePath = "";
                }
            }
        }
Esempio n. 2
0
        private void MaterialForm1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!shouldClose)
            {
                BLIO.Log("lblExit_Click (X) (kinda)");
                this.Opacity = 0;
                this.Hide();

                e.Cancel = true;
                return;
            }

            BLIO.Log("MaterialForm1_FormClosing   [" + e.CloseReason + "]");
            BLIO.DumpLogTxt();

            if (MUCTimer.RunningTimers.Count > 0)
            {
                if (MaterialRemindMeBox.Show("You have (" + MUCTimer.RunningTimers.Count + ") active timers running.\r\n\r\nAre you sure you wish to close RemindMe? These timers will not be saved\r\n\r\nClick here to convert these Timers into Reminders and close RemindMe", RemindMeBoxReason.YesNo, false, FormStartPosition.CenterScreen) == DialogResult.No)
                {
                    e.Cancel    = true;
                    shouldClose = false;
                    return;
                }
            }

            //Makes the mouseclick a little bit less laggy
            new Thread(() =>
            {
                Environment.Exit(0);
            }).Start();
        }
Esempio n. 3
0
 private void cbAdvancedReminders_Click(object sender, EventArgs e)
 {
     if (cbAdvancedReminders.Checked)
     {
         MaterialRemindMeBox.Show("You now have access to advanced reminders.\r\nA new button has appeared at the top-right corner when creating/editing reminders.");
     }
 }
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            BLIO.Log("Toolstrip option clicked: Permanentely delete (" + rem.Id + ")");
            if (MaterialRemindMeBox.Show("Are you really sure you wish to permanentely delete \"" + rem.Name + "\" ?", RemindMeBoxReason.YesNo) == DialogResult.Yes)
            {
                BLIO.Log("Permanentely deleting reminder with id " + rem.Id + " ...");
                BLReminder.PermanentelyDeleteReminder(rem);
                BLIO.Log("Reminder permanentely deleted.");

                this.Reminder = null;
                MUCReminders.Instance.UpdateCurrentPage(rem);

                new Thread(() =>
                {
                    //Log an entry to the database, for data!
                    try
                    {
                        BLOnlineDatabase.PermanentelyDeleteCount++;
                    }
                    catch (ArgumentException ex)
                    {
                        BLIO.Log("Exception at BLOnlineDatabase.PermanentelyDeleteCount++. -> " + ex.Message);
                        BLIO.WriteError(ex, ex.Message, true);
                    }
                    finally
                    {
                        GC.Collect();
                    }
                }).Start();
            }
            else
            {
                BLIO.Log("Permanent deletion of reminder " + rem.Id + " cancelled.");
            }
        }
Esempio n. 5
0
        private void cbAutoUpdate_CheckedChanged(object sender, EventArgs e)
        {
            Settings set = BLLocalDatabase.Setting.Settings;

            if (!cbAutoUpdate.Checked)
            {
                if (MaterialRemindMeBox.Show("Attention!", "Are you sure you want to disable auto-update? Newer versions of RemindMe will contain new features and/or fixes to problems in previous versions\r\n\r\nIt is recommended to keep this feature on!", RemindMeBoxReason.YesNo) == DialogResult.Yes)
                {
                    //ask for confirmation
                    set.AutoUpdate = 0;
                    MaterialForm1.Instance.tmrUpdateRemindMe.Stop();
                }
                else
                {
                    cbAutoUpdate.Checked = true;
                }
            }
            else
            {
                set.AutoUpdate = cbAutoUpdate.Checked ? 1 : 0;
                MaterialForm1.Instance.tmrUpdateRemindMe.Start();
            }

            BLLocalDatabase.Setting.UpdateSettings(set);
        }
Esempio n. 6
0
        private void btnOldRemindMeTheme_Click(object sender, EventArgs e)
        {
            if (MaterialRemindMeBox.Show("Are you sure you want to switch to the old RemindMe UI?", RemindMeBoxReason.YesNo) == DialogResult.Yes)
            {
                bool doRestart = true;

                if (MUCTimer.RunningTimers.Count > 0)
                {
                    if (MaterialRemindMeBox.Show("You have (" + MUCTimer.RunningTimers.Count + ") active timers running.\r\n\r\nAre you sure you wish to close RemindMe? These timers will not be saved", RemindMeBoxReason.YesNo) == DialogResult.No)
                    {
                        doRestart = false;
                    }
                }

                if (doRestart)
                {
                    Settings set = BLLocalDatabase.Setting.Settings;
                    set.MaterialDesign = 0;
                    BLLocalDatabase.Setting.UpdateSettings(set);
                    MaterialForm1.Instance.shouldClose = true;

                    MUCTimer.RunningTimers.Clear();
                    Application.Restart();
                }
            }
        }
 public static DialogResult Show(string text, string title, RemindMeBoxReason buttons, bool showDontRemindOption = false, FormStartPosition position = FormStartPosition.CenterParent)
 {
     newMessageBox = new MaterialRemindMeBox(text, title, buttons, showDontRemindOption);
     newMessageBox.StartPosition = position;
     MaterialSkin.MaterialSkinManager.Instance.AddFormToManage(newMessageBox);
     newMessageBox.ShowDialog();
     BLIO.Log("Closing RemindMeBox with result " + result);
     return(result);
 }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        private async void btnTest_Click(object sender, EventArgs e)
        {
            try
            {
                btnTest.Text = "Executing...";
                if (string.IsNullOrWhiteSpace(tbHeaders.Text))
                {
                    tbHeaders.Text = "{ }";
                }

                JObject response = null;
                switch (cbType.SelectedItem.ToString())
                {
                case "GET": response = await BLIO.HttpRequest("GET", tbUrl.Text, tbHeaders.Text);

                    break;

                case "POST": response = await BLIO.HttpRequest("POST", tbUrl.Text, tbHeaders.Text, tbBody.Text);

                    break;
                }
                if (response != null)
                {
                    btnTest.Text = "Test";
                    string message = "API Connection: Success\r\n\r\n";
                    int    count   = 1;
                    try
                    {
                        foreach (var cond in Conditions)
                        {
                            HttpCondition condit = new HttpCondition(cond, response);
                            message += "Condition " + count + ": " + condit.Evaluate() + "\r\n";

                            count++;
                        }
                    }
                    catch { }
                    MaterialRemindMeBox.Show(message);
                }
            }
            catch (Exception ex)
            {
                MaterialRemindMeBox.Show("Failure! " + ex.Message);
            }
            finally
            {
                btnTest.Text = "Test";
            }
        }
Esempio n. 10
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (cbAfterPopup.SelectedItem == null) //Default: stop
            {
                cbAfterPopup.SelectedItem = cbAfterPopup.Items[0];
            }

            if (!string.IsNullOrWhiteSpace(tbUrl.Text) && !ValidHttpConfiguration)
            {
                MaterialRemindMeBox.Show("Please fill in each field in the 'Rule' section to set up whenever this reminder is supposed to turn on.\r\n\r\n'Interval' Is also required");
                return;
            }


            MaterialForm form = (MaterialForm)this.Parent.Parent.Parent;

            form.Hide();
            parent.AdvancedReminderFormCallback();
        }
Esempio n. 11
0
        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;
            }
        }
Esempio n. 12
0
        private void MaterialForm1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.End && !mainTabControl.Controls.Contains(tabDebug))
            {
                tmrDebugMode.Stop();
                tmrDebugMode.Start();
                endKeyPressed++;
                if (endKeyPressed >= 3)
                {
                    tmrDebugMode.Stop();
                    endKeyPressed = 0;
                    BLIO.Log("end key pressed 3 times. Show dialog for debug mode");
                    if (MaterialRemindMeBox.Show("Enable debug mode?", RemindMeBoxReason.YesNo) == DialogResult.Yes)
                    {
                        BLIO.Log("Debug mode enabled");

                        mainTabControl.Controls.Add(tabDebug);
                    }
                }
            }
        }
Esempio n. 13
0
        private void hideReminderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BLIO.Log("Toolstrip option clicked: Hide (" + rem.Id + ")");

            string message = "You can hide reminders with this option. The reminder will not be deleted, you just won't be able to see it"
                             + " in the list of reminders. This creates a sense of surprise.\r\n\r\nDo you wish to hide this reminder?";

            BLIO.Log("Attempting to hide reminder(s)");
            if (BLLocalDatabase.Setting.HideReminderOptionEnabled || MaterialRemindMeBox.Show(message, RemindMeBoxReason.YesNo, true) == DialogResult.Yes)
            {
                //Enable the hide flag here
                rem.Hide = 1;
                BLIO.Log("Marked reminder with id " + rem.Id + " as hidden");
                BLReminder.EditReminder(rem);
                this.Reminder = null;
                MUCReminders.Instance.UpdateCurrentPage();

                new Thread(() =>
                {
                    //Log an entry to the database, for data!
                    try
                    {
                        BLOnlineDatabase.HideCount++;
                    }
                    catch (ArgumentException ex)
                    {
                        BLIO.Log("Exception at BLOnlineDatabase.HideCount++. -> " + ex.Message);
                        BLIO.WriteError(ex, ex.Message, true);
                    }
                    finally
                    {
                        GC.Collect();
                    }
                }).Start();
            }
            else
            {
                BLIO.Log("Attempting to hide reminder(s) failed.");
            }
        }
Esempio n. 14
0
        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 "));
            }
        }
Esempio n. 15
0
        private void btnDeleteTheme_Click(object sender, EventArgs e)
        {
            if (cbLoadTheme.SelectedItem == null)
            {
                return;
            }

            ComboBoxItem c = (ComboBoxItem)cbLoadTheme.SelectedItem;

            if (c == null || c.Value == null)
            {
                return;
            }

            Themes selectedTheme = BLLocalDatabase.Theme.GetThemeById((long)c.Value);

            if (selectedTheme == null)
            {
                return;
            }

            if (MaterialRemindMeBox.Show
                    ("Are you sure you want to delete the theme \"" + selectedTheme.ThemeName + "\" ?", RemindMeBoxReason.YesNo) == DialogResult.Yes)
            {
                BLLocalDatabase.Theme.DeleteThemeById(selectedTheme.Id);

                //Reset currentTheme in table `Settings` to -1
                Settings set = BLLocalDatabase.Setting.Settings;
                set.CurrentTheme = -1;
                BLLocalDatabase.Setting.UpdateSettings(set);

                cbLoadTheme.Items.Remove(cbLoadTheme.SelectedItem);
                cbLoadTheme.Text = "";
                LoadTheme(BLLocalDatabase.Theme.GetThemes()[0]);
            }
        }
        private void RemindMeImporter_Load(object sender, EventArgs e)
        {
            BLIO.Log("RemindmeImporter_load");
            this.MaximumSize = this.Size;


            if (!HasFileAccess(this.remindmeFile)) //Do not attempt to launch the importer form if we can't open the file
            {
                BLIO.Log("Error opening .remindme file, no rights");
                MaterialRemindMeBox.Show("Can not open this .remindme file from " + Path.GetDirectoryName(this.remindmeFile) + ". Insufficient rights.", RemindMeBoxReason.OK);
                this.Close();
            }
            else
            {
                try
                {
                    BLIO.Log("Deserializing reminders.....");
                    List <object> deSerializedReminders = BLReminder.DeserializeRemindersFromFile(remindmeFile);
                    BLIO.Log(deSerializedReminders.Count - 1 + " reminders deserialized!");
                    this.Text += " (" + (deSerializedReminders.Count - 1) + " Reminders)"; //-1 because of country code
                    foreach (object rem in deSerializedReminders)
                    {
                        if (rem.GetType() == typeof(Reminder))
                        {
                            Reminder reminder = (Reminder)rem;
                            BLIO.Log(reminder.Name + " Loaded into RemindMeImporter from the .remindme file.");
                            remindersFromRemindMeFile.Add((Reminder)rem);
                        }
                        else
                        {
                            BLIO.Log("Language code" + languageCode + " read from the .remindme file!");
                            languageCode = rem.ToString(); //The language code stored in the .remindme file, "en-Us" for example
                        }
                    }

                    if (languageCode != "") //Don't need to do this when exporting.
                    {
                        BLIO.Log("Going through the reminder list once more....");
                        foreach (object rem in remindersFromRemindMeFile)
                        {
                            if (rem.GetType() == typeof(Reminder))
                            {
                                Reminder remm = (Reminder)rem;
                                //Fix the date if the .remindme file has a different time format than the current system
                                BLIO.Log("(" + remm.Name + ") Fixing the date to match the language code " + languageCode);
                                remm.Date = BLDateTime.ConvertDateTimeStringToCurrentCulture(remm.Date, languageCode);
                            }
                        }
                    }

                    if (remindersFromRemindMeFile != null)
                    {
                        BLIO.Log("Adding the reminders from the .remindme file to the listview....");
                        BLFormLogic.AddRemindersToListview(lvReminders, remindersFromRemindMeFile, true);
                        BLIO.Log("Done!");
                    }
                    else
                    {
                        BLIO.Log("Failed to load reminders.");
                        this.Text = "Failed to load reminders.";
                    }
                }
                catch (Exception ex)
                {
                    MaterialRemindMeBox.Show("Something has gone wrong loading reminders from this .remindme file.\r\nThe file might be corrupt", RemindMeBoxReason.OK);
                    BLIO.Log("Error loading reminders from .remindme file written to error log");
                    BLIO.WriteError(ex, "Error loading reminders from .remindme file");
                    Application.Exit();
                }
            }
            BLIO.Log("RemindmeImporter loaded !");
        }