示例#1
0
        private bool TestExpression()
        {
            var success = false;

            MapWinGIS.Table tbl = Shapefile.Table;
            if (textQuery.Text == string.Empty)
            {
                return(true);
            }
            else
            {
                object result = null;
                string err    = string.Empty;

                if (tbl.Query(textQuery.Text, ref result, ref err))
                {
                    lblResult.Foreground = Brushes.Green;
                    int[] arr = result as int[];
                    if (arr != null)
                    {
                        lblResult.Content = "Number of shapes = " + arr.Length.ToString();

                        // updating shapefile selection
                        //if (_selectionMode)
                        //{
                        //    ArrayList options = new ArrayList();
                        //    options.Add("1 - New selection");
                        //    options.Add("2 - Add to selection");
                        //    options.Add("3 - Exclude from selection");
                        //    options.Add("4 - Invert in selection");
                        //    string s = string.Format("Number of shapes = {0}. Choose the way to update selection", arr.Length);
                        //}
                    }
                    success = (arr != null && arr.Length > 0);
                }
                else
                {
                    if (err.ToLower() == "selection is empty")
                    {
                        lblResult.Foreground = Brushes.Blue;
                        lblResult.Content    = err;
                    }
                    else
                    {
                        lblResult.Foreground = Brushes.Red;
                        lblResult.Content    = err;
                    }
                }
            }
            return(success);
        }
示例#2
0
        private void ShowValues(int fieldIndex)
        {
            if (Shapefile.NumFields - 1 < fieldIndex)
            {
                return;
            }
            _isString = Shapefile.get_Field(fieldIndex).Type == FieldType.STRING_FIELD;
            MapWinGIS.Table tbl = Shapefile.Table;

            ShapefileFieldSummary sfs = new ShapefileFieldSummary();

            for (int x = 0; x < Shapefile.NumShapes; x++)
            {
                string rowEntry = "";
                if (Shapefile.CellValue[fieldIndex, x] != null)
                {
                    if (_isString)
                    {
                        rowEntry = (string)Shapefile.CellValue[fieldIndex, x];
                        if (rowEntry.Length == 0)
                        {
                            rowEntry = "[Blank]";
                        }
                    }
                    else
                    {
                        Object obj = Shapefile.CellValue[fieldIndex, x];
                        rowEntry = obj.ToString();
                    }
                }

                if (!sfs.FieldEntriesAndCount.Keys.Contains(rowEntry))
                {
                    sfs.FieldEntriesAndCount.Add(rowEntry, 1);
                }
                else
                {
                    sfs.FieldEntriesAndCount[rowEntry]++;
                }
            }

            dgvValues.DataContext = sfs.FieldEntriesAndCount.OrderBy(t => t.Key);
            dgvValues.Columns.Clear();
            dgvValues.Columns.Add(new DataGridTextColumn {
                Header = "Cell value", Binding = new Binding("Key")
            });
            dgvValues.Columns.Add(new DataGridTextColumn {
                Header = "Count", Binding = new Binding("Value")
            });
        }