示例#1
0
        private TZFilterGroup CreateFilterGroup(Grid filterGrid, string name, string title, double?height)
        {
            RowDefinition row = new RowDefinition()
            {
                // Height = height == null ? new GridLength(1, GridUnitType.Star) : new GridLength((double)height)
            };

            filterGrid.RowDefinitions.Add(row);

            int rowIndex = filterGrid.RowDefinitions.Count - 1;

            //创建筛选项分组
            TZFilterGroup filterGroup = new TZFilterGroup()
            {
                Name   = name,
                Title  = title,
                Margin = new Thickness(0, 0, 0, 0)
            };

            filterGroup.SetValue(Grid.RowProperty, rowIndex);
            filterGrid.Children.Add(filterGroup);

            return(filterGroup);
        }
示例#2
0
        public void CreateFilter(int typeID)
        {
            if (filterGrid != null)
            {
                this.filterGrid.Children.Clear();
            }

            List <SystemConfig> filterConfigs = ContainerManager.SystemConfigs.GetMapElementConfigs(typeID, "FilterWindow");

            //获得元素种类信息
            SystemConfig        itemsConfig = filterConfigs.Where(t => t.Name == "Filters").FirstOrDefault();
            List <SystemConfig> fsList      = ContainerManager.SystemConfigs.GetSystemConfigs(itemsConfig);

            //List<FilterModel> FilterModelList = new List<FilterModel>();
            ////获得筛选条件
            //FilterModel filte = new FilterModel()
            //{
            //    Name = "监控类型",
            //    FilterType = "Region",
            //    Height = "150"
            //};
            //FilterModel filte1 = new FilterModel()
            //{
            //    Name = "监控来源",
            //    FilterType = "Region",
            //    Height = "150"
            //};
            //FilterModel filte2 = new FilterModel()
            //{
            //    Name = "所属乡镇",
            //    FilterType = "Region",
            //    Height = "150"
            //};
            //FilterModelList.Add(filte);
            //FilterModelList.Add(filte1);
            //FilterModelList.Add(filte2);
            //循环生成筛选条件
            foreach (var f in fsList)
            {
                List <SystemConfig> fiConfig = ContainerManager.SystemConfigs.GetSystemConfigs(f);
                //获得筛选项配置
                string filterType;
                string name;
                double?height;

                #region 获得配置信息
                filterType = fiConfig.Where(t => t.Name == "FilterType").FirstOrDefault().Value;   //f.FilterType;

                name = fiConfig.Where(t => t.Name == "Name").FirstOrDefault().Value;               //f.Name;

                string strHeight = fiConfig.Where(t => t.Name == "Height").FirstOrDefault().Value; //f.Height;

                if (!string.IsNullOrEmpty(strHeight))
                {
                    height = double.Parse(strHeight);
                }
                else
                {
                    height = null;
                }
                #endregion

                //分组名称
                //sco.Content = filterGrid;
                string groupName = fiConfig.Where(t => t.Name == "Name").FirstOrDefault().Value; //f.Name;

                //生成一级筛选分组
                TZFilterGroup filterGroup = CreateFilterGroup(filterGrid, groupName, name, height);
                this._filterValues[filterGroup.Name] = -1;

                WebAPIHelper itemDt = new WebAPIHelper();

                itemDt.GetDataCompleted += (a, b) =>
                {
                    List <JObject> typeList = b.DataResult as List <JObject>;
                    foreach (var obj in typeList)
                    {
                        Statistic statEntity = new Statistic()
                        {
                            MapElementCategoryID = 1,
                            ID       = Convert.ToInt32(obj.GetValue("ID").ToString()),
                            Name     = obj.GetValue("Name").ToString(),
                            Onlines  = 0,
                            Offlines = 0,
                            Totals   = 0
                        };
                        TZFilterGroupItem itemControl = CreateFilterGroupItem(statEntity, filterType, filterType, -1);
                        filterGroup.Items.Add(itemControl);
                    }
                };

                Dictionary <string, object> itemFilters = new Dictionary <string, object>();
                itemFilters.Add("Level", "2");

                string itemTypeUrl = string.Format("api/{0}/Query", filterType);
                itemDt.GetDataAsync <List <JObject> >(itemTypeUrl, itemFilters);
            }
        }