Beispiel #1
0
 void lbListOfCatsInGroup_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete && e.Shift)
     {
         for (int i = lbListOfCatsInGroup.SelectedIndex; i < sCodesOnDisplay.Length - 1; i++)
         {
             sCodesOnDisplay[i] = sCodesOnDisplay[i + 1];
         }
         Array.Resize <string>(ref sCodesOnDisplay, sCodesOnDisplay.Length - 1);
         lbListOfCatsInGroup.Items.RemoveAt(lbListOfCatsInGroup.SelectedIndex);
         if (lbListOfCatGroups.Items.Count > 0)
         {
             lbListOfCatGroups.SelectedIndex = 0;
         }
         else
         {
             sEngine.DeleteCategoryGroup(lbListOfCatGroups.Items[lbListOfCatGroups.SelectedIndex].ToString());
             lbListOfCatGroups.Items.RemoveAt(lbListOfCatGroups.SelectedIndex);
             lbListOfCatGroups.SelectedIndex = 0;
             lbListOfCatGroups.Focus();
         }
         sEngine.AddEditCategoryGroup(lbListOfCatGroups.Items[lbListOfCatGroups.SelectedIndex].ToString(), sCodesOnDisplay);
     }
     else if (e.KeyCode == Keys.Insert)
     {
         frmSingleInputBox fGetCat = new frmSingleInputBox("Enter the category code, of press F5 to choose a category. Leave blank to cancel.", ref sEngine);
         fGetCat.GettingCategory = true;
         if (fGetCat.Response != "$NONE")
         {
             Array.Resize <string>(ref sCodesOnDisplay, sCodesOnDisplay.Length + 1);
             sCodesOnDisplay[sCodesOnDisplay.Length - 1] = fGetCat.Response;
             sEngine.AddEditCategoryGroup(lbListOfCatGroups.Items[lbListOfCatGroups.SelectedIndex].ToString(), sCodesOnDisplay);
         }
     }
     else if (e.KeyCode == Keys.Escape)
     {
         lbListOfCatGroups.Focus();
     }
 }