Exemplo n.º 1
0
        private void removeButtonTab2_Click(object sender, EventArgs e) //removes texts and groups from selected group
        {
            try {
                ListViewItem    itemToMove = groupListViewTab2.SelectedItems[0];
                IGroupViewModel model      = _groupController.GetGroupByName(groupComboBox.Text);
                string          name       = model.GetName();
                if (_groupController.GetGroupByName(itemToMove.Text) != null)
                {
                    _groupController.RemoveItemFromGroup(name, itemToMove.Text);
                }
                else
                {
                    _groupController.RemoveItemFromGroup(name, itemToMove.Text);
                }
                //For debugging:
                //_analysisController.ItemIsActive(model.GetName());

                updateListViews();
                groupComboBox_SelectedIndexChanged(sender, e);
            }
            catch (Exception)
            {
                if (groupListViewTab2.SelectedItems.Count <= 0)
                {
                    string errorMessage = "You need to select an item to remove it";
                    var    form2        = new ErrorMessageDisplay(errorMessage);
                    form2.Show(this);
                }
            }
        }
Exemplo n.º 2
0
 public void editGroupName(string groupNameOld, string groupNameNew) // edit method used by the editGroup popup
 {
     if (_groupController.GetGroupByName(groupNameNew) == null)
     {
         IGroupViewModel group = _groupController.GetGroupByName(groupNameOld);
         _groupController.UpdateGroup(group.GetName(), groupNameNew);
         fillGroupComboBox();
         groupComboBox.SelectedIndex = groupComboBox.Items.IndexOf(groupNameNew);
         analysisListView.Items.Clear();
         fillGroupComboBox();
         updateAnalysisGroups();
         updateListViews();
     }
     else
     {
         string errorMessage = "You cannot change a group name to one that already exists";
         var    form2        = new ErrorMessageDisplay(errorMessage);
         form2.Show(this);
     }
 }
Exemplo n.º 3
0
 private void addButtonTab2_Click(object sender, EventArgs e)    //allows for texts and groups to be added to groups
 {
     try
     {
         IGroupViewModel model      = _groupController.GetGroupByName(groupComboBox.Text);
         ListViewItem    itemToMove = fileGroupListViewTab2.SelectedItems[0];
         string          name       = model.GetName();
         if (filesRadioButton.Checked)
         {
             _groupController.AddItemToGroup(name, itemToMove.SubItems[1].Text);
         }
         else
         {
             _groupController.AddItemToGroup(name, itemToMove.Text);
         }
         groupComboBox_SelectedIndexChanged(sender, e);
         fileGroupListViewTab2.Items.Remove(itemToMove);
         updateListViews();
     }
     catch (ArgumentException)
     {
         if (groupComboBox.Text == "")
         {
             string errorMessage = "You need to select a group or create one first";
             var    form2        = new ErrorMessageDisplay(errorMessage);
             form2.Show(this);
         }
         else if (fileGroupListViewTab2.SelectedItems.Count <= 0)
         {
             string errorMessage = "You need to select an item to add it";
             var    form2        = new ErrorMessageDisplay(errorMessage);
             form2.Show(this);
         }
         else
         {
             string errorMessage = "You cannot add a group to itself, or a text to a group that already contains it";
             var    form2        = new ErrorMessageDisplay(errorMessage);
             form2.Show(this);
         }
     }
 }