Exemple #1
0
        public static ILegendCommand CreateSelectByDrawing <T>(MapPresenter map, VectorLayer layer) where T : class, ISqlGeometryAware
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarVectorPenConvert,
                Layer      = layer,
                ToolTip    = "انتخاب عوارض محدودهٔ ترسیم",
            };

            result.Command = new RelayCommand(async param =>
            {
                var options = EditableFeatureLayerOptions.CreateDefaultForDrawing(false, false);

                options.IsOptionsAvailable = false;

                var drawingResult = await map.GetDrawingAsync(Model.DrawMode.Polygon, options);

                if (!drawingResult.HasNotNullResult())
                {
                    return;
                }

                var features = layer.GetFeatures <T>(drawingResult.Result.AsSqlGeometry());

                if (features == null)
                {
                    return;
                }

                var newLayer = new Model.Map.SelectedLayer <T>(layer)
                {
                    ShowSelectedOnMap = true
                };

                if (features != null)
                {
                    newLayer.Features = new System.Collections.ObjectModel.ObservableCollection <T>(features);
                }

                map.AddSelectedLayer(newLayer);
            });

            return(result);
        }
Exemple #2
0
        public static LegendCommand CreateShowAttributeTable <T>(MapPresenter map, VectorLayer layer) where T : class, ISqlGeometryAware
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarPageText,
                Layer      = layer,
                ToolTip    = "اطلاعات توصیفی",
            };

            result.Command = new RelayCommand((param) =>
            {
                if (layer == null || map == null)
                {
                    return;
                }

                //System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew();

                //System.Diagnostics.Debug.WriteLine($"Command start");

                var features = (layer as VectorLayer).GetFeatures <T>();

                //var list = new List<SqlIndex250k>() {
                //    new SqlIndex250k(new Msh.Common.Mapping.Index250k()),
                //    new SqlIndex250k(new Msh.Common.Mapping.Index250k()),
                //    new SqlIndex250k(new Msh.Common.Mapping.Index250k()),
                //    new SqlIndex250k(new Msh.Common.Mapping.Index250k()),
                //    new SqlIndex250k(new Msh.Common.Mapping.Index250k())};

                //watch.Stop();
                //System.Diagnostics.Debug.WriteLine($"Get Features finished {watch.ElapsedMilliseconds}");
                //watch.Restart();

                var newLayer = new Model.Map.SelectedLayer <T>(layer);

                //newLayer.RequestSave = l =>
                //{
                //    layer.sou
                //};

                if (features == null)
                {
                    newLayer.Features = new System.Collections.ObjectModel.ObservableCollection <T>();
                }
                else
                {
                    newLayer.Features = new System.Collections.ObjectModel.ObservableCollection <T>(features);
                }


                map.AddSelectedLayer(newLayer);


                //map.SelectedLayers.Add(newLayer);

                //map.CurrentLayer = newLayer;

                //watch.Stop();
                //System.Diagnostics.Debug.WriteLine($"map.SelectedLayers.Add {watch.ElapsedMilliseconds}");
            });

            return(result);
        }