Exemple #1
0
 /// <summary>
 /// 显示学校信息
 /// </summary>
 /// <param name="selectedNode"></param>
 private void ShowSchoolDetail(NodeEntry selectedNode)
 {
     SchoolInfoDetail.Visibility = System.Windows.Visibility.Visible;
     this.SchoolInfo.Visibility  = System.Windows.Visibility.Collapsed;
     CampusInfoDetail.Visibility = System.Windows.Visibility.Collapsed;
     AMS.Model.AMS_School school = null;
     //获取当前选中节点的Model信息
     foreach (AMS_ProvinceSchoolInfo p in ModelSchoolList)
     {
         bool isStop = false;
         foreach (AMS_School s in p.Schools)
         {
             if (s.Id == selectedNode.Id)
             {
                 school = s;
                 isStop = true;
                 break;
             }
         }
         if (isStop)
         {
             break;
         }
     }
     foreach (SchoolInfo s in SchoolInfo.SchoolInfoList)
     {
         if (s.Id == selectedNode.Id)
         {
             SchoolInfoDetail.SchoolDetail = s;
             break;
         }
     }
     SchoolInfoDetail.ConvertToCampusList(school);
 }
Exemple #2
0
 /// <summary>
 /// 获取省份信息
 /// </summary>
 /// <param name="selectedNode"></param>
 /// <returns></returns>
 private AMS_ProvinceSchoolInfo GetProvinceInfo(NodeEntry selectedNode)
 {
     AMS.Model.AMS_ProvinceSchoolInfo schoolModel = null;
     foreach (AMS_ProvinceSchoolInfo p in ModelSchoolList)
     {
         if (selectedNode.Id == p.ID)
         {
             schoolModel = p;
             return(schoolModel);
         }
     }
     return(null);
 }
Exemple #3
0
        public void TreeViewSelectedItemHandle(NodeEntry selectedNode)
        {
            if (selectedNode == null)
            {
                return;
            }
            switch (selectedNode.Type)
            {
            case NodeType.School:
                ShowSchoolDetail(selectedNode);
                break;

            case NodeType.Campus:
                CampusInfoDetail.Visibility = System.Windows.Visibility.Visible;
                SchoolInfoDetail.Visibility = System.Windows.Visibility.Collapsed;
                this.SchoolInfo.Visibility  = System.Windows.Visibility.Collapsed;
                AMS.Model.AMS_Campus campusModel = null;
                //获取当前选中节点的Model信息
                foreach (AMS_ProvinceSchoolInfo p in ModelSchoolList)
                {
                    bool isStop = false;
                    foreach (AMS_School s in p.Schools)
                    {
                        foreach (AMS_Campus campus in s.Campus)
                        {
                            if (selectedNode.Id == campus.Id)
                            {
                                campusModel = campus;
                                isStop      = true;
                                break;
                            }
                        }
                        if (isStop)
                        {
                            break;
                        }
                    }
                    if (isStop)
                    {
                        break;
                    }
                }
                this.CampusInfoDetail.ShowDeviceList(campusModel);
                this.CampusInfoDetail.ShowCampusDetail(campusModel);
                break;

            case NodeType.Province:
                ShowProvinceSchools(selectedNode);
                break;
            }
        }
Exemple #4
0
 /// <summary>
 /// 获取当前选中学校的学校节点
 /// </summary>
 /// <param name="selectedNode"></param>
 /// <returns></returns>
 private AMS_School GetSchoolModelInfo(NodeEntry selectedNode)
 {
     AMS.Model.AMS_School school = null;
     //获取当前选中节点的Model信息
     foreach (AMS_ProvinceSchoolInfo p in ModelSchoolList)
     {
         foreach (AMS_School s in p.Schools)
         {
             if (s.Id == selectedNode.Id)
             {
                 school = s;
                 return(school);
             }
         }
     }
     return(null);
 }
Exemple #5
0
        private void ShowProvinceSchools(NodeEntry selectedNode)
        {
            CampusInfoDetail.Visibility = System.Windows.Visibility.Collapsed;
            SchoolInfoDetail.Visibility = System.Windows.Visibility.Collapsed;
            this.SchoolInfo.Visibility  = System.Windows.Visibility.Visible;
            List <AMS_ProvinceSchoolInfo> selectedProvince = new List <AMS_ProvinceSchoolInfo>();

            foreach (AMS_ProvinceSchoolInfo psi in ModelSchoolList)
            {
                if (psi.ID == selectedNode.Id)
                {
                    selectedProvince.Add(psi);
                    break;
                }
            }
            SchoolInfo.ShowSchoolList(modelSchoolList);
        }
Exemple #6
0
 /// <summary>
 /// 获取当前选中校区的Model
 /// </summary>
 /// <param name="selectedNode"></param>
 /// <returns></returns>
 private AMS_Campus GetCampusModelInfo(NodeEntry selectedNode)
 {
     AMS.Model.AMS_Campus campusModel = null;
     //获取当前选中节点的Model信息
     foreach (AMS_ProvinceSchoolInfo p in ModelSchoolList)
     {
         foreach (AMS_School s in p.Schools)
         {
             foreach (AMS_Campus campus in s.Campus)
             {
                 if (selectedNode.Id == campus.Id)
                 {
                     campusModel = campus;
                     return(campusModel);
                 }
             }
         }
     }
     return(null);
 }
Exemple #7
0
 /// <summary>
 /// 获取选中节点的是设备信息
 /// </summary>
 /// <param name="selectNode"></param>
 /// <returns></returns>
 private AMS_Device GetDeviceModelInfo(NodeEntry selectedNode)
 {
     AMS.Model.AMS_Device deviceModel = null;
     //获取当前选中节点的Model信息
     foreach (AMS_ProvinceSchoolInfo p in ModelSchoolList)
     {
         foreach (AMS_School s in p.Schools)
         {
             foreach (AMS_Campus campus in s.Campus)
             {
                 foreach (AMS_Device device in campus.Device)
                 {
                     if (selectedNode.Id == device.Id)
                     {
                         deviceModel = device;
                         return(deviceModel);
                     }
                 }
             }
         }
     }
     return(null);
 }
Exemple #8
0
        /// <summary>
        /// 获取当前选中节点的信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T GetSelectNodeInfo <T>(NodeEntry selectedNode)
        {
            T model = default(T);

            switch (selectedNode.Type)
            {
            case NodeType.School:
                model = (T)(GetSchoolModelInfo(selectedNode) as object);    //如果节点是学校,则获取学校信息,返回
                break;

            case NodeType.Campus:
                model = (T)(GetCampusModelInfo(selectedNode) as object);
                break;

            case NodeType.Province:
                model = (T)(GetProvinceInfo(selectedNode) as object);
                break;

            case NodeType.Device:
                model = (T)(GetDeviceModelInfo(selectedNode) as object);
                break;
            }
            return(model);
        }
Exemple #9
0
        /// <summary>
        /// 重新刷新保持展开状态
        /// </summary>
        /// <param name="provinceSchool"></param>
        /// <param name="oldNodeList"></param>
        /// <returns></returns>
        private List <NodeEntry> RefriashschoolModelListToNodeList(List <AMS_ProvinceSchoolInfo> provinceSchool, List <NodeEntry> oldNodeList)
        {
            List <NodeEntry> provinceNodes = new List <NodeEntry>();

            for (int h = 0; h < provinceSchool.Count; h++)
            {
                List <AMS.Model.AMS_School> schools = provinceSchool[h].Schools;
                NodeEntry provinceNode = new NodeEntry();
                provinceNode.Id = provinceSchool[h].ID;
                NodeEntry oldprovinceNode = new NodeEntry();
                foreach (NodeEntry n in oldNodeList)
                {
                    if (provinceNode.Id == n.Id)
                    {
                        oldprovinceNode = n;
                        break;
                    }
                }
                if (oldprovinceNode.Id == -1)
                {
                    provinceNode.IsExpanded = false;
                }
                else
                {
                    provinceNode.IsExpanded = oldprovinceNode.IsExpanded;
                }
                provinceNode.Name              = provinceSchool[h].ProvinceName;
                provinceNode.Type              = NodeType.Province;
                provinceNode.NodeImage         = "/Image/ProvinceTreeImage.png";
                provinceNode.AddMenuName       = "添加新学校";
                provinceNode.AddMenuVisibility = "Visible";
                for (int i = 0; i < schools.Count; i++)
                {
                    NodeEntry schoolNode = new NodeEntry();
                    schoolNode.FatherNode = provinceNode;
                    schoolNode.Id         = schools[i].Id;
                    schoolNode.Num        = schools[i].Number;
                    schoolNode.Name       = schools[i].Name;
                    NodeEntry oldschoolNode = new NodeEntry();
                    foreach (NodeEntry n in oldprovinceNode.ChildNodes)
                    {
                        if (schoolNode.Id == n.Id)
                        {
                            oldschoolNode = n;
                            break;
                        }
                    }
                    if (oldschoolNode.Id == -1)
                    {
                        schoolNode.IsExpanded = false;
                    }
                    else
                    {
                        schoolNode.IsExpanded = oldschoolNode.IsExpanded;
                    }
                    schoolNode.Type                 = NodeType.School;
                    schoolNode.NodeImage            = "/Image/SchoolTreeImage.png";
                    schoolNode.AddMenuName          = "添加新校区";
                    schoolNode.AddMenuVisibility    = "Visible";
                    schoolNode.UpdataMenuName       = "修改学校信息";
                    schoolNode.UpdateMenuVisibility = "Visible";
                    schoolNode.DeleteMenuName       = "删除学校";
                    schoolNode.DeleteMenuVisibility = "Visible";
                    for (int j = 0; j < schools[i].Campus.Count; j++)
                    {
                        NodeEntry campusNode = new NodeEntry();
                        campusNode.FatherNode = schoolNode;
                        campusNode.Id         = schools[i].Campus[j].Id;
                        campusNode.Num        = schools[i].Campus[j].Number;
                        campusNode.Name       = schools[i].Campus[j].Name;
                        NodeEntry oldcampusNode = new NodeEntry();
                        foreach (NodeEntry n in oldschoolNode.ChildNodes)
                        {
                            if (campusNode.Id == n.Id)
                            {
                                oldcampusNode = n;
                                break;
                            }
                        }
                        if (oldcampusNode.Id == -1)
                        {
                            campusNode.IsExpanded = false;
                        }
                        else
                        {
                            campusNode.IsExpanded = oldcampusNode.IsExpanded;
                        }
                        campusNode.Type                 = NodeType.Campus;
                        campusNode.NodeImage            = "/Image/CampusTreeImage.png";
                        campusNode.AddMenuName          = "添加新设备";
                        campusNode.AddMenuVisibility    = "Visible";
                        campusNode.UpdataMenuName       = "修改校区信息";
                        campusNode.UpdateMenuVisibility = "Visible";
                        campusNode.DeleteMenuName       = "删除校区";
                        campusNode.DeleteMenuVisibility = "Visible";
                        for (int k = 0; k < schools[i].Campus[j].Device.Count; k++)
                        {
                            NodeEntry deviceNode = new NodeEntry();
                            deviceNode.FatherNode           = campusNode;
                            deviceNode.Id                   = schools[i].Campus[j].Device[k].Id;
                            deviceNode.Num                  = schools[i].Campus[j].Device[k].Number;
                            deviceNode.Name                 = schools[i].Campus[j].Device[k].Number;
                            deviceNode.IsExpanded           = false;
                            deviceNode.Type                 = NodeType.Device;
                            deviceNode.NodeImage            = "/Image/DeviceTreeImage.png";
                            deviceNode.UpdataMenuName       = "修改设备信息";
                            deviceNode.UpdateMenuVisibility = "Visible";
                            deviceNode.DeleteMenuName       = "删除设备";
                            deviceNode.DeleteMenuVisibility = "Visible";
                            campusNode.ChildNodes.Add(deviceNode);
                        }
                        schoolNode.ChildNodes.Add(campusNode);
                    }
                    //schoolNodes.Add(schoolNode);
                    provinceNode.ChildNodes.Add(schoolNode);
                }
                provinceNodes.Add(provinceNode);
            }
            return(provinceNodes);
        }