Beispiel #1
0
 private void okButton_Click(object sender, RoutedEventArgs e)
 {
     for (int i = SourceCollection.Count - 1; i >= 0; i--)
     {
         object o = SourceCollection[i];
         if (!SourceCollectionEdited.Contains(o))
         {
             SourceCollection.RemoveAt(i);
         }
     }
     foreach (object o in SourceCollectionEdited)
     {
         if (!SourceCollection.Contains(o))
         {
             SourceCollection.Add(o);
         }
     }
     for (int i = TargetCollection.Count - 1; i >= 0; i--)
     {
         object o = TargetCollection[i];
         if (!TargetCollectionEdited.Contains(o))
         {
             TargetCollection.RemoveAt(i);
         }
     }
     foreach (object o in TargetCollectionEdited)
     {
         if (!TargetCollection.Contains(o))
         {
             TargetCollection.Add(o);
         }
     }
     cancelButton_Click(sender, e);
 }
Beispiel #2
0
        private void deleteButton_Click(object sender, RoutedEventArgs e)
        {
            object o = sourceListBox.SelectedItem;

            if (o != null)
            {
                SourceCollectionEdited.Remove(o);
                TargetCollectionEdited.Remove(o);
            }
            UpdateCheckBoxes();
            UpdateSelectedValues();
        }
Beispiel #3
0
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            TextBox tb  = newItemText;
            string  str = tb.Text;

            if (!string.IsNullOrEmpty(str))
            {
                object obj = FindItemWithText(SourceCollectionEdited, str);
                if (obj == null)
                {
                    if (ItemType == typeof(Category))
                    {
                        Category cat = new Category(str);
                        cat.MenuCaption = str;
                        obj             = cat;
                    }
                    else if (ItemType == typeof(Contact))
                    {
                        Contact cnt = new Contact();
                        cnt.Text        = str;
                        cnt.MenuCaption = str;
                        obj             = cnt;
                    }
                    else if (ItemType == typeof(Resource))
                    {
                        Resource res = new Resource();
                        res.Text        = str;
                        res.MenuCaption = str;
                        obj             = res;
                    }
                    else if (ItemType == typeof(C1.C1Schedule.Label))
                    {
                        obj = new C1.C1Schedule.Label(str, str);
                    }
                    else if (ItemType == typeof(Status))
                    {
                        obj = new Status(str, str);
                    }
                }
                if (obj != null)
                {
                    SourceCollectionEdited.Add(obj);
                    AddOrRemoveItem(true, obj);
                }
                tb.ClearValue(TextBox.TextProperty);
            }
        }