Example #1
0
        // 添加标注
        private void LabelDefinition_Layers_CheckBox(object sender, RoutedEventArgs e)
        {
            MenuItem    menuItem = sender as MenuItem;
            ContextMenu cm       = menuItem.Parent as ContextMenu;
            int         index    = int.Parse(cm.Name.Substring(16));

            // 获取字段
            FeatureLayer tempLayer = (FeatureLayer)myMapView.Map.OperationalLayers[index];

            Esri.ArcGISRuntime.Data.FeatureTable tempTable = tempLayer.FeatureTable;
            List <string> fieldNames = new List <string>();

            for (int i = 0; i < tempTable.Fields.Count; i++)
            {
                fieldNames.Add(tempTable.Fields[i] + "");
            }
            ArcGISApp1.Controls.OtherTool.LabelDefinedCsy.fieldSource = fieldNames;
            ArcGISApp1.Controls.OtherTool.LabelDefinedCsy.index       = index;

            StackPanel s = (StackPanel)mainWindow.FindName("AddLabelTool");
            // 关闭其余工具条
            Canvas            userControlsLayoutCsy = (Canvas)mainWindow.FindName("userControlsLayoutCsy");
            List <StackPanel> tools = ArcGISApp1.Utils.GetChildNode.GetChildObjects <StackPanel>(userControlsLayoutCsy);

            for (int i = 0; i < tools.Count(); i++)
            {
                tools[i].Visibility = Visibility.Collapsed;
            }
            s.Visibility = Visibility.Visible;
        }
Example #2
0
        // 添加要素
        private async void add2SHP_Click(object sender, RoutedEventArgs e)
        {
            if (table.CanAdd() && layersComboBox.Items.Count >= 1 && curSelGraphic != null && layersComboBox.SelectedIndex >= 0)
            {
                // 图层
                featureLayer = (FeatureLayer)(myMapView.Map.OperationalLayers[layersComboBox.SelectedIndex]);
                // 属性表
                table = featureLayer.FeatureTable;

                QueryParameters query = new QueryParameters();
                query.WhereClause = string.Format("upper(FID) = \"0\"");
                FeatureQueryResult queryResult = await table.QueryFeaturesAsync(query);

                IEnumerator <Feature> resultFeatures = queryResult.GetEnumerator();
                List <Feature>        features       = new List <Feature>();
                while (resultFeatures.MoveNext())
                {
                    features.Add(resultFeatures.Current);
                }

                Feature tempGeoElement = features[0];

                Feature addFeature = table.CreateFeature(features[0].Attributes, curSelGraphic.Geometry);
                await table.AddFeatureAsync(addFeature);

                t1.Text = "要素保存成功!";
            }
        }
Example #3
0
        private void layersComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            featureLayer = (FeatureLayer)(myMapView.Map.OperationalLayers[layersComboBox.SelectedIndex]);
            // 属性表
            table = featureLayer.FeatureTable;

            if (layersComboBox.SelectedIndex >= 0)
            {
                choose2SHP.IsEnabled = true;
            }
        }
Example #4
0
        private async void MainWindow_Click(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            if (count == 0)
            {
                count      = 1;
                _downPoint = e.Location;
                //_downPointP = e.Position;
                //dragSelectRectangle.Margin = new Thickness(0, 0, 0, 0);
                //dragSelectRectangle.Width = 0;
                //dragSelectRectangle.Height = 0;
            }
            else
            {
                count = 0;
                var _endpoint = e.Location;

                try
                {
                    double   tolerance    = 0.0001;
                    double   mapTolerance = tolerance /** myMapView.UnitsPerPixel*/;
                    MapPoint geometry     = new MapPoint((_downPoint.X + _endpoint.X) / 2, (_downPoint.Y + _endpoint.Y) / 2, myMapView.SpatialReference);
                    if (myMapView.IsWrapAroundEnabled)
                    {
                        geometry = (MapPoint)GeometryEngine.NormalizeCentralMeridian(geometry);
                    }
                    Envelope        selectionEnvelope = new Envelope(geometry, Math.Abs(_downPoint.X - _endpoint.X), Math.Abs(_downPoint.Y - _endpoint.Y) /*geometry.X - mapTolerance, geometry.Y - mapTolerance, geometry.X + mapTolerance, geometry.Y + mapTolerance,*/ /*myMapView.Map.SpatialReference*/);
                    QueryParameters queryParams       = new QueryParameters()
                    {
                        Geometry = selectionEnvelope
                    };

                    FeatureLayer       tempLayer = (FeatureLayer)(myMapView.Map.OperationalLayers[0]);
                    FeatureQueryResult fr        = await tempLayer.SelectFeaturesAsync(queryParams, Esri.ArcGISRuntime.Mapping.SelectionMode.New);

                    IEnumerator <Feature> frr      = fr.GetEnumerator();
                    List <Feature>        features = new List <Feature>();
                    while (frr.MoveNext())
                    {
                        features.Add(frr.Current);
                    }

                    // 查看属性
                    Esri.ArcGISRuntime.Data.FeatureTable tempTable = (Esri.ArcGISRuntime.Data.FeatureTable)tempLayer.FeatureTable;
                    long          row        = tempTable.NumberOfFeatures;
                    int           col        = tempTable.Fields.Count;
                    List <String> fieldNames = new List <string>();
                    for (int i = 0; i < col; i++)
                    {
                        fieldNames.Add(tempTable.Fields[i] + "");
                    }

                    StackPanel  stackPanel = new StackPanel();
                    WrapPanel[] wrapPanels = new WrapPanel[row];

                    // 字段名
                    WrapPanel wrapPanelField = new WrapPanel()
                    {
                        Margin = new Thickness()
                        {
                            Left   = 10,
                            Top    = 1,
                            Right  = 10,
                            Bottom = 1
                        }
                    };
                    for (int i = 0; i < col; i++)
                    {
                        Button button = new Button()
                        {
                            Content    = fieldNames[i],
                            ToolTip    = fieldNames[i],
                            Width      = 60,
                            Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 100, 183, 134))
                        };
                        wrapPanelField.Children.Add(button);
                    }
                    stackPanel.Children.Add(wrapPanelField);

                    // 记录
                    for (int i = 0; i < row; i++)
                    {
                        wrapPanels[i] = new WrapPanel()
                        {
                            Margin = new Thickness()
                            {
                                Left   = 10,
                                Top    = 1,
                                Right  = 10,
                                Bottom = 1
                            }
                        };
                        for (int j = 0; j < col; j++)
                        {
                            Button button = new Button()
                            {
                                Width   = 60,
                                Content = features[i].GetAttributeValue(fieldNames[j]),
                                ToolTip = features[i].GetAttributeValue(fieldNames[j])
                            };
                            wrapPanels[i].Children.Add(button);
                        }
                        stackPanel.Children.Add(wrapPanels[i]);
                    }

                    ScrollViewer scrollViewer = new ScrollViewer();
                    scrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Visible;
                    scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                    scrollViewer.Content = stackPanel;

                    var window = new Window();
                    window.Content               = scrollViewer;
                    window.SizeToContent         = SizeToContent.WidthAndHeight;
                    window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                    window.MaxHeight             = 700;
                    window.MaxWidth              = 1000;

                    window.Title = "要素多选属性表";
                    window.Show();
                }
                catch
                {
                    t1.Text = "要素多选发生错误";
                }
            }
        }
Example #5
0
        // 打开属性表
        private async void OpenFeatureTableWindow_Layers_CheckBox(object sender, RoutedEventArgs e)
        {
            MenuItem     menuItem  = sender as MenuItem;
            ContextMenu  cm        = menuItem.Parent as ContextMenu;
            int          index     = int.Parse(cm.Name.Substring(16));
            FeatureLayer tempLayer = (FeatureLayer)myMapView.Map.OperationalLayers[index];

            Esri.ArcGISRuntime.Data.FeatureTable tempTable = tempLayer.FeatureTable;

            QueryParameters query = new QueryParameters();

            query.WhereClause = string.Format("upper(FID) >= 0");
            FeatureQueryResult queryResult = await tempTable.QueryFeaturesAsync(query);

            IEnumerator <Feature> resultFeatures = queryResult.GetEnumerator();
            List <Feature>        features       = new List <Feature>();

            while (resultFeatures.MoveNext())
            {
                features.Add(resultFeatures.Current);
            }

            long          row        = tempTable.NumberOfFeatures;
            int           col        = tempTable.Fields.Count;
            List <String> fieldNames = new List <string>();

            for (int i = 0; i < col; i++)
            {
                fieldNames.Add(tempTable.Fields[i] + "");
            }

            StackPanel stackPanel = new StackPanel();

            WrapPanel[] wrapPanels = new WrapPanel[row];

            // 字段名
            WrapPanel wrapPanelField = new WrapPanel()
            {
                Margin = new Thickness()
                {
                    Left   = 10,
                    Top    = 1,
                    Right  = 10,
                    Bottom = 1
                }
            };

            for (int i = 0; i < col; i++)
            {
                Button button = new Button()
                {
                    Content    = fieldNames[i],
                    ToolTip    = fieldNames[i],
                    Width      = 60,
                    Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 100, 183, 134))
                };
                wrapPanelField.Children.Add(button);
            }
            stackPanel.Children.Add(wrapPanelField);

            // 记录
            for (int i = 0; i < row; i++)
            {
                wrapPanels[i] = new WrapPanel()
                {
                    Margin = new Thickness()
                    {
                        Left   = 10,
                        Top    = 1,
                        Right  = 10,
                        Bottom = 1
                    }
                };
                for (int j = 0; j < col; j++)
                {
                    Button button = new Button()
                    {
                        Width   = 60,
                        Content = features[i].GetAttributeValue(fieldNames[j]),
                        ToolTip = features[i].GetAttributeValue(fieldNames[j])
                    };
                    wrapPanels[i].Children.Add(button);
                }
                stackPanel.Children.Add(wrapPanels[i]);
            }

            ScrollViewer scrollViewer = new ScrollViewer();

            scrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Visible;
            scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.Content = stackPanel;

            var window = new Window();

            window.Content               = scrollViewer;
            window.SizeToContent         = SizeToContent.WidthAndHeight;
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.MaxHeight             = 700;
            window.MaxWidth              = 1000;

            window.Title = check[index].Content + "属性表";
            window.Show();
        }
        private async void sureBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FeatureLayer tempLayer = (FeatureLayer)myMapView.Map.OperationalLayers[index];
                Esri.ArcGISRuntime.Data.FeatureTable tempTable = tempLayer.FeatureTable;

                // 语句
                QueryParameters query = new QueryParameters();
                query.WhereClause = string.Format(inTxt.Text);

                FeatureQueryResult queryResult = await tempTable.QueryFeaturesAsync(query);

                IEnumerator <Feature> resultFeatures = queryResult.GetEnumerator();
                List <Feature>        features       = new List <Feature>();
                while (resultFeatures.MoveNext())
                {
                    features.Add(resultFeatures.Current);
                }

                MessageBox.Show(inTxt.Text + "\n" + features.Count + "\n" + query.WhereClause);

                //long row = tempTable.NumberOfFeatures;
                long          row        = features.Count;
                int           col        = tempTable.Fields.Count;
                List <String> fieldNames = new List <string>();
                for (int i = 0; i < col; i++)
                {
                    fieldNames.Add(tempTable.Fields[i] + "");
                }

                StackPanel  stackPanel = new StackPanel();
                WrapPanel[] wrapPanels = new WrapPanel[row];

                // 字段名
                WrapPanel wrapPanelField = new WrapPanel()
                {
                    Margin = new Thickness()
                    {
                        Left   = 10,
                        Top    = 1,
                        Right  = 10,
                        Bottom = 1
                    }
                };
                for (int i = 0; i < col; i++)
                {
                    Button button = new Button()
                    {
                        Content    = fieldNames[i],
                        ToolTip    = fieldNames[i],
                        Width      = 60,
                        Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 100, 183, 134))
                    };
                    wrapPanelField.Children.Add(button);
                }
                stackPanel.Children.Add(wrapPanelField);

                // 记录
                for (int i = 0; i < row; i++)
                {
                    wrapPanels[i] = new WrapPanel()
                    {
                        Margin = new Thickness()
                        {
                            Left   = 10,
                            Top    = 1,
                            Right  = 10,
                            Bottom = 1
                        }
                    };
                    for (int j = 0; j < col; j++)
                    {
                        Button button = new Button()
                        {
                            Width   = 60,
                            Content = features[i].GetAttributeValue(fieldNames[j]),
                            ToolTip = features[i].GetAttributeValue(fieldNames[j])
                        };
                        wrapPanels[i].Children.Add(button);
                    }
                    stackPanel.Children.Add(wrapPanels[i]);
                }

                var window = new Window();
                window.Content               = stackPanel;
                window.SizeToContent         = SizeToContent.WidthAndHeight;
                window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                window.Title = "属性查询结果";
                window.Show();
            }
            catch (Exception ex2)
            {
                MessageBox.Show("查询错误!\n" + ex2.Message + "\n");
            }
        }