예제 #1
0
        public void LoadStandInfo()
        {
            rootModel.Children.Clear();
            treeModelCollection.Clear();

            List<Model.TB_StandardInfo> standInfoList = standardBLL.GetModelList("");

            Task task = new Task(() =>
            {
                //加载导入的测试参考值
                List<Model.TB_StandardInfo> importedlevel1List = Stand.StandConfig.GetParentStandList();
                if (importedlevel1List!=null)
                {
                    foreach (var item in importedlevel1List)
                    {
                        StandInfoTreeDataModel treeModel = new StandInfoTreeDataModel();
                        treeModel.ParentModel = rootModel;
                        treeModel.StandInfo = item;
                        treeModel.DefaultIcon = "/DSJL;component/Assets/Images/folder.png";
                        treeModel.OpenedIcon = "/DSJL;component/Assets/Images/folder_opened.png";

                        List<Model.TB_StandardInfo> importedChildList = Stand.StandConfig.GetChildStandInfo(item.Stand_Name);
                        foreach (var item2 in importedChildList)
                        {
                            StandInfoTreeDataModel childTreeModel = new StandInfoTreeDataModel();
                            childTreeModel.ParentModel = treeModel;
                            childTreeModel.StandInfo = item2;
                            childTreeModel.DefaultIcon = "/DSJL;component/Assets/Images/file.png";
                            childTreeModel.OpenedIcon = "/DSJL;component/Assets/Images/file.png";

                            treeModel.Children.Add(childTreeModel);
                        }
                        item.Stand_Name += "(导入)";
                        rootModel.Children.Add(treeModel);
                    }
                }

                var level1List = from items in standInfoList where items.Stand_Level ==1 orderby items.ID select items;
                var level2List= from items in standInfoList where items.Stand_Level == 2 orderby items.ID select items;
                foreach (var item in level1List)
                {
                    StandInfoTreeDataModel treeModel = new StandInfoTreeDataModel();
                    treeModel.ParentModel = rootModel;
                    treeModel.StandInfo = item;
                    treeModel.DefaultIcon = "/DSJL;component/Assets/Images/folder.png";
                    treeModel.OpenedIcon = "/DSJL;component/Assets/Images/folder_opened.png";

                    var childList = from standItem in level2List where standItem.Stand_ParentID == item.ID select standItem;

                    foreach (var item2 in childList)
                    {
                        StandInfoTreeDataModel childTreeModel= new StandInfoTreeDataModel();
                        childTreeModel.ParentModel = treeModel;
                        childTreeModel.StandInfo = item2;
                        childTreeModel.DefaultIcon = "/DSJL;component/Assets/Images/file.png";
                        childTreeModel.OpenedIcon = "/DSJL;component/Assets/Images/file.png";

                        treeModel.Children.Add(childTreeModel);
                    }
                    rootModel.Children.Add(treeModel);

                }
                this.Dispatcher.Invoke(new Action(() =>
                {
                    treeModelCollection.Add(rootModel);
                    tree.ItemsSource = treeModelCollection;
                }));
            });
            task.Start();
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 public void RefrenshChildren()
 {
     children.Clear();
     List<Model.TB_StandardInfo> standInfoModelList;
     switch (standInfo.Stand_Level)
     {
         case -1:
             standInfoModelList = standInfoBLL.GetModelList("stand_level=1");
             foreach (Model.TB_StandardInfo standInfoModel in standInfoModelList)
             {
                 StandInfoTreeDataModel treeModel = new StandInfoTreeDataModel();
                 treeModel.parentModel = this;
                 treeModel.StandInfo = standInfoModel;
                 treeModel.DefaultIcon = "/DSJL;component/Assets/Images/folder.png";
                 treeModel.OpenedIcon = "/DSJL;component/Assets/Images/folder_opened.png";
                 children.Add(treeModel);
             }
             break;
         case 1:
             standInfoModelList = standInfoBLL.GetModelList("stand_level=2 and Stand_ParentID=" + standInfo.ID);
             foreach (Model.TB_StandardInfo standInfoModel in standInfoModelList)
             {
                 StandInfoTreeDataModel treeModel = new StandInfoTreeDataModel();
                 treeModel.parentModel = this;
                 treeModel.StandInfo = standInfoModel;
                 treeModel.DefaultIcon = "/DSJL;component/Assets/Images/file.png";
                 treeModel.OpenedIcon = "/DSJL;component/Assets/Images/file.png";
                 children.Add(treeModel);
             }
             break;
     }
 }
예제 #3
0
 void editWindow_AddSuccessEvent(object sender, RoutedEventArgs e)
 {
     List<Model.TB_StandardInfo> standInfoList = standardBLL.GetModelList(string.Format("stand_parentid={0}", selectedItem.Stand_Level == -1 ? 0 : selectedItem.ID));
     if (standInfoList?.Count>0)
     {
         StandInfoTreeDataModel treeModel = new StandInfoTreeDataModel();
         treeModel.ParentModel = selectedTreeItem;
         treeModel.StandInfo = standInfoList.Last();
         if (selectedItem.Stand_Level == -1)
         {
             treeModel.DefaultIcon = "/DSJL;component/Assets/Images/folder.png";
             treeModel.OpenedIcon = "/DSJL;component/Assets/Images/folder_opened.png";
         }
         else if (selectedItem.Stand_Level == 1)
         {
             treeModel.DefaultIcon = "/DSJL;component/Assets/Images/file.png";
             treeModel.OpenedIcon = "/DSJL;component/Assets/Images/file.png";
         }
         selectedTreeItem.Children.Add(treeModel);
         selectedTreeItem.IsExpanded = true;
     }
 }