Пример #1
0
        private void addGroupButton_Click(object sender, EventArgs e)
        {
            var name = groupNameTextBox.Text.Trim();

            if (name.Length == 0)
            {
                MessageBox.Show(resmgr.GetString("__message_box_Group_name_not_empty", ci));
            }
            else
            {
                var db = new DataProcess();
                try
                {
                    db.AddGroup(name);
                    ReloadGroupsUI();
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.ToString());
                }
            }
        }
Пример #2
0
        private void addSnippetButton_Click(object sender, EventArgs e)
        {
            if (snippetContentBox.Text.Trim() == "")
            {
                MessageBox.Show(resmgr.GetString("__message_box_message_snippet_cannot_empty", ci));
                return;
            }

            if (groupListCombo.Text.Trim() == "")
            {
                MessageBox.Show(resmgr.GetString("__message_box_message_group_cannot_empty", ci));
                return;
            }

            var db = new DataProcess();
            int selectedIndex = groupListCombo.SelectedIndex;
            string name = groupListCombo.Text;
            Group selectedGroup;
            if (selectedIndex == -1)
            {
                try
                {
                    db.AddGroup(name);
                }
                catch (Exception err)
                {
                    // TODO: Catch name unique error.
                    MessageBox.Show(err.Message);
                    return;
                }
                selectedGroup = db.LoadGroup(name);
            }
            else
            {
                selectedGroup = groups[selectedIndex];
            }
            if (_currentHistory == null)
            {
                try
                {
                    db.SaveSnippet(selectedGroup, snippetContentBox.Text, nameTextBox.Text.Trim());
                    Close();
                }
                catch (Exception err) // catch potential error.
                {
                    MessageBox.Show(err.Message);
                    return;
                }
            }
            else
            {
                try
                {
                    db.UpdateSnippet(_currentHistory, selectedGroup, snippetContentBox.Text, nameTextBox.Text.Trim());
                    Close();
                }
                catch (Exception err) // catch potential error.
                {
                    MessageBox.Show(err.Message);
                    return;
                }
            }
            
        }
Пример #3
0
        private void addSnippetButton_Click(object sender, EventArgs e)
        {
            if (snippetContentBox.Text.Trim() == "")
            {
                MessageBox.Show(resmgr.GetString("__message_box_message_snippet_cannot_empty", ci));
                return;
            }

            if (groupListCombo.Text.Trim() == "")
            {
                MessageBox.Show(resmgr.GetString("__message_box_message_group_cannot_empty", ci));
                return;
            }

            var    db            = new DataProcess();
            int    selectedIndex = groupListCombo.SelectedIndex;
            string name          = groupListCombo.Text;
            Group  selectedGroup;

            if (selectedIndex == -1)
            {
                try
                {
                    db.AddGroup(name);
                }
                catch (Exception err)
                {
                    // TODO: Catch name unique error.
                    MessageBox.Show(err.Message);
                    return;
                }
                selectedGroup = db.LoadGroup(name);
            }
            else
            {
                selectedGroup = groups[selectedIndex];
            }
            if (_currentHistory == null)
            {
                try
                {
                    db.SaveSnippet(selectedGroup, snippetContentBox.Text, nameTextBox.Text.Trim());
                    Close();
                }
                catch (Exception err) // catch potential error.
                {
                    MessageBox.Show(err.Message);
                    return;
                }
            }
            else
            {
                try
                {
                    db.UpdateSnippet(_currentHistory, selectedGroup, snippetContentBox.Text, nameTextBox.Text.Trim());
                    Close();
                }
                catch (Exception err) // catch potential error.
                {
                    MessageBox.Show(err.Message);
                    return;
                }
            }
        }
Пример #4
0
 private void addGroupButton_Click(object sender, EventArgs e)
 {
     var name = groupNameTextBox.Text.Trim();
     if (name.Length == 0)
     {
         MessageBox.Show(resmgr.GetString("__message_box_Group_name_not_empty", ci));
     }
     else
     {
         var db = new DataProcess();
         try
         {
             db.AddGroup(name);
             ReloadGroupsUI();
         }
         catch (Exception err)
         {
             MessageBox.Show(err.ToString());
         }
     }
 }