public SpecialPointLayer GetLayer(double scale) { var images = _source.Get(scale); var locatables = new List <Locateable>(); foreach (var imageGroup in images) { var locatable = new Locateable(); locatable.AncherFunction = AncherFunctionHandlers.CenterCenter; locatable.X = imageGroup.Center.WebMercatorLocation.X; locatable.Y = imageGroup.Center.WebMercatorLocation.Y; //locatable.Element = new Common.View.MapMarkers.CountableImageMarker(imageSymbol, imageGroup.Frequency.ToString()); locatable.Element = _viewMaker(imageGroup.Frequency.ToString()); locatable.OnRequestHandleMouseDown += (sender, e) => { this.OnRequestMouseDownHandle.SafeInvoke(imageGroup); }; locatables.Add(locatable); } return(new SpecialPointLayer(LayerName, locatables)); }
private void UpdateMidPoints(Point point, Point newPoint, int pointIndex, RecursiveCollection <Locateable> midCollection) { try { var displacement = new Point((newPoint.X - point.X) / 2.0, (newPoint.Y - point.Y) / 2.0); var length = midCollection.Values.Count; var leftIndex = GetLeftMidPointIndex(pointIndex, length); var rightIndex = GetRightMidPointIndex(pointIndex, length); Locateable left = leftIndex == int.MinValue ? null : midCollection.Values[leftIndex]; if (left != null) { left.X = left.X + displacement.X; left.Y = left.Y + displacement.Y; } Locateable right = rightIndex == int.MinValue ? null : midCollection.Values[rightIndex]; if (right != null) { right.X = right.X + displacement.X; right.Y = right.Y + displacement.Y; } } catch (Exception ex) { } }
private Locateable ToSecondaryLocateable(IPoint first, IPoint second) { var webMercatorPoint = new Point((first.X + second.X) / 2.0, (first.Y + second.Y) / 2.0); //var element = new View.MapMarkers.Circle(.6); var element = Options.MakeSecondaryVertex(); var locateable = new Locateable(Model.AncherFunctionHandlers.CenterCenter) { Element = element, X = webMercatorPoint.X, Y = webMercatorPoint.Y }; element.MouseLeftButtonDown += (sender, e) => { webMercatorPoint.X = locateable.X; webMercatorPoint.Y = locateable.Y; if (!TryInsertPoint(webMercatorPoint, first, second, this._webMercatorGeometry)) { throw new NotImplementedException(); } RequestRefresh?.Invoke(this); }; return(locateable); }
private Locateable ToPrimaryLocateable(IPoint point) { var webMercatorPoint = point; var element = Options.MakePrimaryVertex(); var locateable = new Locateable(Model.AncherFunctionHandlers.CenterCenter) { Element = element, X = webMercatorPoint.X, Y = webMercatorPoint.Y, Id = Guid.NewGuid(), CanBeUsedAsEditingPoint = true }; locateable.RequestChangeIsSelected = (isSelected) => { ((IMapMarker)locateable.Element).IsSelected = isSelected; }; if (Options.IsNewDrawing) { //Finish Drawing if click on any point locateable.Element.MouseDown += (sender, e) => { if (e.LeftButton == MouseButtonState.Pressed) { this.OnRequestFinishDrawing.SafeInvoke(this); e.Handled = true; } }; } else { element.MouseRightButtonDown += (sender, e) => { //locateable.IsSelected = true; this._primaryVerticesLayer.SelectLocatable(locateable.Element); RegisterMapOptionsForVertices(e, webMercatorPoint, locateable); }; } locateable.OnPositionChanged += (sender, e) => { UpdateLineSegment(webMercatorPoint as Point, new Point(locateable.X, locateable.Y)); webMercatorPoint.X = locateable.X; webMercatorPoint.Y = locateable.Y; UpdateEdgeLables(); UpdateCoordinate(locateable); }; return(locateable); }
private void RegisterMapOptionsForVertices(MouseButtonEventArgs e, IPoint point, Locateable locateable) { var presenter = new Jab.Common.Presenters.MapOptions.MapOptionsPresenter( rightToolTip: _copy, leftToolTip: _displayCoordinates, middleToolTip: _delete, rightSymbol: IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarPageCopy, leftSymbol: IRI.Jab.Common.Assets.ShapeStrings.CustomShapes.xY, middleSymbol: IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarDelete); presenter.RightCommandAction = i => { var geodetic = MapProjects.WebMercatorToGeodeticWgs84(presenter.Location); Clipboard.SetDataObject($"{geodetic.X.ToString("n4")},{geodetic.Y.ToString("n4")}"); this.RemoveMapOptions(); }; presenter.LeftCommandAction = i => { //RequestFinishEditing?.Invoke(this._mercatorGeometry); if (_primaryVerticesLabelLayer.Items.Any(l => l.Id == locateable.Id)) { _primaryVerticesLabelLayer.Remove(locateable.Id); } else { var element = new View.MapMarkers.CoordinateMarker(locateable.X, locateable.Y); var auxLocateable = new Locateable(Model.AncherFunctionHandlers.CenterLeft) { Element = element, X = point.X, Y = point.Y, Id = locateable.Id }; _primaryVerticesLabelLayer.Items.Add(auxLocateable); } this.RemoveMapOptions(); }; presenter.MiddleCommandAction = i => { this._primaryVerticesLabelLayer.Remove(locateable.Id); TryDeleteVertex(point, this._webMercatorGeometry, _webMercatorGeometry.Type == GeometryType.Polygon); this.RequestRefresh?.Invoke(this); this.RemoveMapOptions(); }; RequestRightClickOptions?.Invoke(new View.MapOptions.MapThreeOptions(false), e, presenter); }
private void UpdateCoordinate(Locateable locatable) { var locatables = this._primaryVerticesLabelLayer.Get(locatable.Id); foreach (var item in locatables) { (item.Element as View.MapMarkers.CoordinateMarker).MercatorLocation = new Point(locatable.X, locatable.Y); item.X = locatable.X; item.Y = locatable.Y; } }
private void Remove(Locateable mainLocateable) { if (_mainLocateables.Count <= 2) { return; } var index = _mainLocateables.IndexOf(mainLocateable); if (index > 0) { _controlLocateables.RemoveAt(2 * index - 1); _controlLayer.Items.RemoveAt(2 * index - 1); if (index == _mainLocateables.Count - 1) { _controlLocateables.RemoveAt(2 * index - 2); _controlLayer.Items.RemoveAt(2 * index - 2); } else { _controlLocateables.RemoveAt(2 * index - 1); _controlLayer.Items.RemoveAt(2 * index - 1); } } else { _controlLocateables.RemoveAt(0); _controlLocateables.RemoveAt(0); _controlLayer.Items.RemoveAt(0); _controlLayer.Items.RemoveAt(0); } _mainLocateables.Remove(mainLocateable); _mainLayer.Items.Remove(mainLocateable); mercatorPolyline.RemoveAt(index); Refresh(); }
private void Add(Locateable mainLocateable) { var index = _mainLocateables.IndexOf(mainLocateable); if (index == 0) { return; } var point = new Point((mainLocateable.X + _mainLocateables[index - 1].X) / 2.0, (mainLocateable.Y + _mainLocateables[index - 1].Y) / 2.0); var newMainLocateable = AsLocateable(point, Colors.Green); newMainLocateable.OnPositionChanged += mainLocateable_OnPositionChanged; newMainLocateable.Element.MouseRightButtonDown += (sender, e) => { mainElement_MouseRightButtonDown(newMainLocateable, e); }; var newControl1 = AsLocateable(point, Colors.Gray); newControl1.OnPositionChanged += controlLocateable_OnPositionChanged; var newControl2 = AsLocateable(point, Colors.Gray); newControl2.OnPositionChanged += controlLocateable_OnPositionChanged; _mainLocateables.Insert(index, newMainLocateable); mercatorPolyline.Insert(index, point); _controlLocateables.Insert(2 * index - 1, newControl2); _controlLocateables.Insert(2 * index - 1, newControl1); Refresh(); }
//public int ZIndex { get; set; } //private FrameworkElement visualElement; //public FrameworkElement Element //{ // get { return this.visualElement; } // set // { // this.visualElement = value; // BindWithFrameworkElement(value); // OnPropertyChanged("Element"); // } //} //public bool IsLabeled(double mapScale) //{ // return this.Labels != null && this.Labels.IsLabeled(1.0 / mapScale); //} //private LabelParameters _labels; //public LabelParameters Labels //{ // get { return _labels; } // set // { // _labels = value; // OnPropertyChanged("Labels"); // } //} //public Func<SqlGeometry, SqlGeometry> PositionFunc { get; set; } //private VisualParameters _visualParameters; //public VisualParameters VisualParameters //{ // get { return _visualParameters; } // set // { // _visualParameters = value; // OnPropertyChanged("VisualParameters"); // } //} //private Geometry _pointSymbol; //public Geometry PointSymbol //{ // get { return _pointSymbol; } // set // { // _pointSymbol = value; // OnPropertyChanged("PointSymbol"); // } //} //private ImageSource _imageSymbol; //public ImageSource ImageSymbol //{ // get { return _imageSymbol; } // set // { // _imageSymbol = value; // OnPropertyChanged("Symbol"); // } //} public SpecialPointLayer(string name, Locateable item, double opacity = 1, ScaleInterval visibleRange = null, LayerType type = LayerType.Complex) : this(name, new List <Locateable>() { item }, opacity, visibleRange, type) { }