コード例 #1
0
        /// <summary>
        /// 查询完毕回调
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void SelectCallback(object sender, UploadStringCompletedEventArgs e)
        {
            //if (activeLayer != null && !activeLayer.Equals(m_catalog.ActiveLayerObj))
            //{//不是同一个图层,清除原来的结果
            //    tabControl1.Items.Clear();
            //}

            dataPager1.DataContext = null;
            tabControl1.Items.Clear();
            if (activeLayer != null)
            {
            }
            pageSize = activeLayer.GetPageSize();
            CLayerSelectAndGetAtt selRlt = this.activeLayer.OnLayerSelectAndGetAtt(e);


            _lastSelRlt = selRlt;
            TabItem  item;
            string   name;
            DataGrid grid     = null;
            int      maxCount = 0;

            if (selRlt.Count == null)
            {
                return;
            }
            for (int k = 0; k < selRlt.Count.Length; k++)        //GDB
            {
                for (int i = 0; i < selRlt.Count[k].Length; i++) //层
                {
                    if (selRlt.Count[k][i] > 0 && selRlt.AttDS[k].attTables != null && selRlt.AttDS[k].attTables[i].Rows != null)
                    {
                        name = activeLayer.LayerObj.LayerAccessInfo[k].LayerInfoList[i].LayerDataName;
                        if (this.FindName(name) == null)
                        {
                            item = new TabItem()
                            {
                                Header = name,
                                Name   = name
                            };
                            grid = new DataGrid()
                            {
                                Name   = "datagrid" + name + "_" + k + "_" + i,
                                Height = 221,
                                Width  = 493,
                                AutoGenerateColumns = false,
                                IsReadOnly          = true,
                                Tag = new TmpInfo()
                                {
                                    LayerIndex = i, GDBIndex = k
                                }
                            };
                            grid.MouseLeftButtonUp += new MouseButtonEventHandler(DataGrid_MouseLeftButtonUp);
                            grid.LoadingRow        += new EventHandler <DataGridRowEventArgs>(DataGrid_LoadingRow);
                            item.Content            = grid;
                            if (ContextMenuService.GetContextMenu(grid) == null)
                            {
                                ContextMenu contextMenu = GetContexMenu(k, i);
                                ContextMenuService.SetContextMenu(grid, contextMenu);
                            }
                            tabControl1.Items.Add(item);
                        }
                        else
                        {
                            item = this.FindName(name) as TabItem;
                            grid = item.Content as DataGrid;
                            grid.Columns.Clear();
                            grid.ItemsSource = null;
                        }
                        List <string> addColumnlHeadArr = new List <string>();
                        addColumnlHeadArr.Add("FID");
                        string[][] arr = new string[/*selRlt.Count[0][i]*/ selRlt.AttDS[k].attTables[i].Rows.Length + 1][];
                        arr[0] = selRlt.AttDS[k].attTables[i].Columns.FldName;

                        List <string[]> addColumnlContentArr = new List <string[]>();
                        string[]        fidArr = new string[selRlt.AttDS[k].attTables[i].Rows.Length];
                        for (int j = 0; j < selRlt.AttDS[k].attTables[i].Rows.Length; j++)
                        {
                            fidArr[j]  = selRlt.AttDS[k].attTables[i].Rows[j].FID.ToString();
                            arr[j + 1] = selRlt.AttDS[k].attTables[i].Rows[j].Values;
                        }
                        addColumnlContentArr.Add(fidArr);
                        if (maxCount < selRlt.Count[k][i])
                        {
                            maxCount = selRlt.Count[k][i];
                        }
                        BindClass bingclass = new BindClass();
                        dataPager1.DataContext = new PagedCollectionView(bingclass.ColumnDisplay(grid, arr, addColumnlHeadArr, addColumnlContentArr));
                        item.IsSelected        = true;
                    }
                }
            }
            if (maxCount > 0)
            {
                dataPager1.PageSize          = (int)Math.Ceiling(Convert.ToDouble(pageSize * pageSize) / maxCount);
                dataPager1.PageIndexChanged += new EventHandler <EventArgs>(dataPager1_PageIndexChanged);
            }
            if (tabControl1.Items.Count <= 0) //&& grid != null && grid.ItemsSource == null)
            // m_graphicsLayer.MapContainer.SetErrorText("没有符合条件的数据,请重新操作!");
            {
                MessageBox.Show("没有查询到结果,请更换条件后重试!", "提示", MessageBoxButton.OK);
            }
            else
            {
                this.Show();
            }
        }