Ejemplo n.º 1
0
        /// <summary>
        /// For Polygons do not repeat first point in the last point
        /// </summary>
        /// <param name="name"></param>
        /// <param name="mercatorPoints"></param>
        /// <param name="isClosed"></param>
        public EditableFeatureLayer(string name, Geometry mercatorGeometry, Transform toScreen, Func <double, double> screenToMap, Model.EditableFeatureLayerOptions options = null)
        {
            //this._isNewDrawingMode = isNewDrawing;
            this.Options = options ?? Model.EditableFeatureLayerOptions.CreateDefault();

            this.Options.RequestHandleIsEdgeLabelVisibleChanged = () =>
            {
                //what if editable feature layer was already removed from map?
                UpdateEdgeLables();
            };

            this.LayerName = name;

            this._webMercatorGeometry = mercatorGeometry;

            this.LayerId = Guid.NewGuid();

            this._toScreen = toScreen;

            this._screenToMap = screenToMap;

            this.VisibleRange = ScaleInterval.All;

            //this.VisualParameters = new VisualParameters(_mercatorGeometry.IsRingBase() ? _fill : null, _stroke, 3, 1);
            this.VisualParameters = Options.Visual;


            this._feature = GetDefaultEditingPath();

            this._pathGeometry = new PathGeometry();

            MakePathGeometry();

            this._feature.Data = this._pathGeometry;

            //if
            //{
            //    this._feature.MouseUp += (sender, e) => { this.RegisterMapOptionsForNewPath(e); };
            //}
            if (!Options.IsNewDrawing)
            {
                this._feature.MouseRightButtonDown += (sender, e) => { this.RegisterMapOptionsForEditPath(e); };
            }

            var layerType = Options.IsNewDrawing ? LayerType.EditableItem : LayerType.MoveableItem | LayerType.EditableItem;

            this._primaryVerticesLayer = new SpecialPointLayer("vert", new List <Locateable>(), 1, ScaleInterval.All, layerType)
            {
                AlwaysTop = true
            };

            this._primaryVerticesLayer.RequestSelectedLocatableChanged = (l) => this.RequestSelectedLocatableChanged?.Invoke(l);

            this._midVerticesLayer = new SpecialPointLayer("int. vert", new List <Locateable>(), .7, ScaleInterval.All, layerType)
            {
                AlwaysTop = true
            };

            this._edgeLabelLayer = new SpecialPointLayer("edge length", new List <Locateable>(), .9, ScaleInterval.All, layerType)
            {
                AlwaysTop = false
            };

            this._primaryVerticesLabelLayer = new SpecialPointLayer("vert length", new List <Locateable>(), .9, ScaleInterval.All, layerType)
            {
                AlwaysTop = false
            };

            ReconstructLocateables();

            if (Options.IsNewDrawing)
            {
                //add virtual vertex which show last point
                this.AddSemiVertex((Point)(mercatorGeometry.Points == null ? mercatorGeometry.Geometries.Last().Points.Last() : mercatorGeometry.Points.Last()));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// For Polygons do not repeat first point in the last point
 /// </summary>
 /// <param name="name"></param>
 /// <param name="mercatorPoints"></param>
 /// <param name="isClosed"></param>
 public EditableFeatureLayer(string name, List <Point> mercatorPoints, Transform toScreen, Func <double, double> screenToMap, GeometryType type, Model.EditableFeatureLayerOptions options = null)
     : this(name, Geometry.Create(mercatorPoints /*.Cast<IPoint>().ToArray()*/, type, SridHelper.WebMercator), toScreen, screenToMap, options)
 {
 }