예제 #1
0
 //Move selected items from source list to destination list
 private void moveListItems(ListBox source, ListBox destination)
 {
     //Check if an item is selected
     if (source.SelectedIndex != -1)
     {
         //Move all selected items, multiple selection enabled
         foreach (var item in source.SelectedItems)
         {
             destination.Items.Add(item);
             Stavka s = item as Stavka;
             //Check if the category of the items do not corresponds to the category of the listBox we want to place it
             if ((s.Category == "Овошје" && destination == lbRight) || (s.Category == "Зеленчук" && destination == lbLeft))
             {
                 pomoshna           = new Pomoshna();
                 pomoshna.smiley    = s.image;
                 pomoshna.text2     = s.description;
                 pomoshna.buttonYes = "Во ред";
                 pomoshna.Show();
             }
         }
         //Remove the selected items from the source list, while there are selected items
         //Must do this, because they will remain in the source list too
         while (source.SelectedItems.Count > 0)
         {
             source.Items.Remove(source.SelectedItems[0]);
         }
     }
 }
예제 #2
0
 //Move items from the Right list back to the Primary list
 private void btnMoveBackLeft_Click(object sender, EventArgs e)
 {
     moveListItems(lbRight, lbPrimary);
     pogodeniDesno = 0;
     foreach (var item in lbRight.Items)
     {
         Stavka s = item as Stavka;
         if (s.Category == lblRight.Text)
         {
             //Count correct items in Right list
             pogodeniDesno++;
         }
     }
     //Update the number of correct items in the Right list
     tbPogodeniRight.Text = pogodeniDesno.ToString();
 }
예제 #3
0
 //If validation succeeds, make new Stavka with entered info, close the form with OK result
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (tbName.Text.Trim().Length != 0 && textBoxOpis.Text.Trim().Length != 0 && cbCategory.SelectedIndex != -1 && imageLocation != "")
     {
         Stavka             = new Stavka();
         Stavka.Name        = tbName.Text;
         Stavka.Category    = cbCategory.Text;
         Stavka.description = textBoxOpis.Text;
         Stavka.image       = pictureBox.Image;
         this.DialogResult  = DialogResult.OK;
         this.Close();
     }
     else
     {
         MessageBox.Show("Мора да се внесат сите податоци");
     }
 }
예제 #4
0
 //Move selected items from Primary to the Left list
 private void btnMoveLeft_Click(object sender, EventArgs e)
 {
     moveListItems(lbPrimary, lbLeft);
     pogodeniLevo = 0;
     //Check if the category of the items corresponds to the category of the left list(label)
     foreach (var item in lbLeft.Items)
     {
         Stavka s = item as Stavka;
         if (s.Category == lblLeft.Text)
         {
             //Count correct items in list
             pogodeniLevo++;
         }
     }
     //Update the number of correct items
     tbPogodeniLeft.Text = pogodeniLevo.ToString();
 }