예제 #1
0
        private void NoteTitleTB_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (!string.IsNullOrEmpty(NoteTitleTB.Text) && !string.IsNullOrWhiteSpace(NoteTitleTB.Text))
                {
                    if (NoteTitleTB.Text != Current_Note.Name)
                    {
                        if (!Duplicate_Note(NoteTitleTB.Text))
                        {
                            NotesLV.Sorting = SortOrder.None;

                            Note_Changes.Remove(Current_Note.Name);
                            Note_Changes.Add(NoteTitleTB.Text, NoteBodyTB.Text);

                            Current_Note.Name = NoteTitleTB.Text;
                            Current_Note.Text = NoteTitleTB.Text;

                            NotesLV.Sorting = SortOrder.Ascending;
                            NotesLV.Sort();
                        }

                        else
                        {
                            MessageBox.Show("Duplicate note titles are not allowed.", "Duplicate Note Title", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            NoteTitleTB.Text = Current_Note.Name;
                            NoteTitleTB.Focus();
                            NoteTitleTB.SelectAll();
                        }
                    }
                }

                e.SuppressKeyPress = true;
            }
        }
예제 #2
0
        private void NoteEditor_Load(object sender, EventArgs e)
        {
            Note_Changes   = new Dictionary <string, string>();
            _lock          = false;
            Deleting_Item  = false;
            Current_Count  = 1;
            Previous_Count = 1;

            Selection_Changed = new Variable_Change_Event(false);
            Selection_Changed.Selection_Changed_EventHandler += Selection_Changed_Selection_Changed_EventHandler;

            foreach (KeyValuePair <string, string> kvp in ManagerData.Selected_Repo.Notes)
            {
                Note_Changes.Add(kvp.Key, kvp.Value);
            }

            NotesLV.Items.Clear();

            if (Note_Changes.Count > 0)
            {
                foreach (string title in Note_Changes.Keys)
                {
                    ListViewItem temp = new ListViewItem()
                    {
                        Name = title,
                        Text = title,
                    };

                    NotesLV.Items.Add(temp);
                }

                NotesLV.Select();

                BoldFont    = new System.Drawing.Font(NotesLV.Items[0].Font.FontFamily, NotesLV.Items[0].Font.Size, FontStyle.Bold);
                RegularFont = NotesLV.Items[0].Font;

                NotesLV.Items[0].Selected = true;

                Current_Note  = NotesLV.SelectedItems[0];
                Previous_Note = Current_Note;

                Current_Note.Font = BoldFont;

                NoteTitleTB.Text    = Current_Note.Name;
                NoteBodyTB.Text     = Note_Changes[Current_Note.Name];
                NoteTitleTB.Enabled = true;
                NoteBodyTB.Enabled  = true;

                DeleteNoteBT.Visible = true;
            }

            else
            {
                ListViewItem temp = new ListViewItem();
                BoldFont    = new System.Drawing.Font(temp.Font.FontFamily, temp.Font.Size, FontStyle.Bold);
                RegularFont = temp.Font;
            }
        }
예제 #3
0
        private void SaveChangesBT_Click(object sender, EventArgs e)
        {
            if (Current_Note == null)
            {
                ManagerData.Selected_Repo.Notes.Clear();
            }

            else
            {
                if (NoteTitleTB.Text != Current_Note.Name)
                {
                    if (!string.IsNullOrEmpty(NoteTitleTB.Text) && !string.IsNullOrWhiteSpace(NoteTitleTB.Text))
                    {
                        if (!Duplicate_Note(NoteTitleTB.Text))
                        {
                            Deleting_Item = true;

                            Note_Changes.Remove(Current_Note.Name);
                            Note_Changes.Add(NoteTitleTB.Text, NoteBodyTB.Text);

                            NotesLV.Sorting   = SortOrder.None;
                            Current_Note.Name = NoteTitleTB.Text;
                            Current_Note.Text = NoteTitleTB.Text;
                            NotesLV.Sorting   = SortOrder.Ascending;
                            NotesLV.Sort();

                            Deleting_Item = false;
                        }

                        else
                        {
                            MessageBox.Show("Duplicate note titles are not allowed, saving as previous title", "Duplicate Note Title", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            NoteTitleTB.Text = Current_Note.Name;
                            Note_Changes[Current_Note.Name] = NoteBodyTB.Text;
                        }
                    }
                }

                else
                {
                    Note_Changes[Current_Note.Name] = NoteBodyTB.Text;
                }

                ManagerData.Selected_Repo.Notes.Clear();

                foreach (KeyValuePair <string, string> kvp in Note_Changes)
                {
                    ManagerData.Selected_Repo.Notes.Add(kvp.Key, kvp.Value);
                }
            }

            // Write the changes to config file
            Configuration.Helpers.Serialize_Condensed_All(Properties.Settings.Default.ConfigPath);

            AutoClosingMessageBox.Show("Any changes to notes have been saved.", "Notes Saved Successfully", 1500);
        }
예제 #4
0
        private bool Store_Note()
        {
            if (Current_Note == null)
            {
                return(true);
            }

            // Previously selected note's title has been modified
            if (Current_Note.Text != NoteTitleTB.Text)
            {
                if (!Duplicate_Note(NoteTitleTB.Text))
                {
                    // Delete old entry in dictionary and add new
                    if (Note_Changes.Keys.Contains(Current_Note.Text))
                    {
                        Note_Changes.Remove(Current_Note.Text);
                    }

                    Note_Changes.Add(NoteTitleTB.Text, NoteBodyTB.Text);

                    // Modify list view
                    NotesLV.Sorting   = SortOrder.None;
                    Current_Note.Name = NoteTitleTB.Text;
                    Current_Note.Text = NoteTitleTB.Text;
                    NotesLV.Sorting   = SortOrder.Ascending;
                    NotesLV.Sort();

                    return(true);
                }

                else
                {
                    return(false);
                }
            }

            // No Change to title just store body
            else
            {
                Note_Changes[Current_Note.Text] = NoteBodyTB.Text;
                return(true);
            }
        }
예제 #5
0
        private void AddNoteBT_Click(object sender, EventArgs e)
        {
            ListViewItem temp = new ListViewItem()
            {
                Name = "blanknote",
                Text = "blanknote"
            };

            if (Duplicate_Note("blanknote"))
            {
                MessageBox.Show("A blank note already exists, please edit this note before adding another.", "Duplicate Blank Note", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotesLV.SelectedItems.Clear();
                NotesLV.Items[Get_Blank_Note_Index()].Selected = true;
                NotesLV.Select();
                NoteTitleTB.Focus();
                DeleteNoteBT.Visible = true;
            }

            else
            {
                NotesLV.Sorting = SortOrder.None;
                NotesLV.Items.Insert(0, temp);
                NotesLV.SelectedItems.Clear();
                NotesLV.Items[0].Selected = true;
                NotesLV.Select();
                NoteTitleTB.Focus();

                if (NotesLV.Items.Count == 1)
                {
                    Current_Note        = NotesLV.SelectedItems[0];
                    Current_Note.Font   = BoldFont;
                    NoteTitleTB.Enabled = true;
                    NoteBodyTB.Enabled  = true;

                    NoteTitleTB.Text = Current_Note.Name;
                    NoteBodyTB.Text  = string.Empty;
                    NotesLV.Select();
                    DeleteNoteBT.Visible = true;
                }
            }
        }
예제 #6
0
        private void DeleteNoteBT_Click(object sender, EventArgs e)
        {
            if (Current_Note != null)
            {
                DialogResult delete;

                delete = MessageBox.Show("Are you sure you want to delete \"" + Current_Note.Name + "\"?", "Delete Note", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (delete == DialogResult.Yes)
                {
                    Deleting_Item = true;
                    Note_Changes.Remove(Current_Note.Name);
                    NotesLV.Items.Remove(Current_Note);
                    Deleting_Item = false;

                    NotesLV.SelectedItems.Clear();

                    try
                    {
                        NotesLV.Items[0].Selected = true;
                    }

                    catch
                    {
                    }

                    NotesLV.Select();

                    try
                    {
                        Current_Note = NotesLV.SelectedItems[0];
                    }

                    catch
                    {
                        Current_Note = null;
                        NoteTitleTB.Clear();
                        NoteBodyTB.Clear();
                        NoteTitleTB.Enabled = false;
                        NoteBodyTB.Enabled  = false;
                    }

                    Previous_Note = null;

                    try
                    {
                        Current_Note.Font = BoldFont;
                        NoteTitleTB.Text  = Current_Note.Name;
                    }

                    catch
                    {
                    }

                    try
                    {
                        NoteBodyTB.Text = Note_Changes[Current_Note.Name];
                    }

                    catch
                    {
                    }
                }
            }

            if (NotesLV.Items.Count == 0)
            {
                DeleteNoteBT.Visible = false;
            }
        }