示例#1
0
        private void cbNode_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cbNode.SelectedIndex == 0)
            {
                btnSave.Content = "Add";
                tbId.IsEnabled  = true;
                SelectedChildLinks.Clear();
                lvParents.ItemsSource = new List <Link>();
                lvChilds.ItemsSource  = new List <Link>();
                Variants = new List <Variant>();
                lvVariants.ItemsSource = Variants;
                tbId.Text            = (knowlegeBaseManager.MaxNodeId + 1).ToString();
                cbChilds.ItemsSource = GetChildItems();
            }
            else if (cbNode.SelectedIndex > 0)
            {
                btnSave.Content = "Save";
                tbId.IsEnabled  = false;
                Node node = knowlegeBaseManager.Base.Nodes.Find(x => x.Id == (int)(cbNode.SelectedItem as ContentControl).Tag);
                tbId.Text      = node.Id.ToString();
                tbId.IsEnabled = false;

                SelectedChildLinks.Clear();
                SelectedChildLinks     = new List <Link>(node.Childs);
                Variants               = new List <Variant>(node.Variants);
                lvChilds.ItemsSource   = SelectedChildLinks;
                lvVariants.ItemsSource = Variants;
                cbChilds.ItemsSource   = GetChildItems(SelectedChildLinks, node.Id);
                lvParents.ItemsSource  = knowlegeBaseManager.GetParentLinks(node.Id);
            }
            cbChilds.Items.Refresh();
            cbChilds.SelectedIndex = -1;
        }
示例#2
0
 private void btnRemoveChild_Click(object sender, RoutedEventArgs e)
 {
     if (lvChilds.SelectedIndex != -1)
     {
         int id = (lvChilds.SelectedItem as Link).Id;
         SelectedChildLinks.RemoveAll(x => x.Id == id);
         lvChilds.Items.Refresh();
         cbChilds.ItemsSource = GetChildItems(SelectedChildLinks, CurrentNodeId);
         cbChilds.Items.Refresh();
     }
 }
示例#3
0
 private void btnAddChild_Click(object sender, RoutedEventArgs e)
 {
     if (cbChilds.SelectedIndex != -1)
     {
         int id = (int)(cbChilds.SelectedItem as ContentControl).Tag;
         SelectedChildLinks.Add(new Link()
         {
             Id = id, LinkType = (LinkType)(cbChildLink.SelectedItem as ContentControl).Tag
         });
         lvChilds.Items.Refresh();
         ChildLinks.RemoveAll(x => x.Id == id);
         cbChilds.ItemsSource = GetChildItems(SelectedChildLinks, CurrentNodeId);
         cbChilds.Items.Refresh();
         tbVariantlinkname.Clear();
         tbVariantTitle.Clear();
     }
 }