/// <summary> /// Handles the Mouse Up situation /// </summary> /// <param name="e"></param> protected override void OnMouseUp(GeoMouseArgs e) { e.Map.IsZoomedToMaxExtent = false; bool handled = false; _currentPoint = e.Location; Map.Invalidate(); if (_isDragging) { if (_geoStartPoint != null && _startPoint != e.Location) { IEnvelope env = new Envelope(_geoStartPoint.X, e.GeographicLocation.X, _geoStartPoint.Y, e.GeographicLocation.Y); if (Math.Abs(e.X - _startPoint.X) > 1 && Math.Abs(e.Y - _startPoint.Y) > 1) { e.Map.ViewExtents = env.ToExtent(); handled = true; } } } _isDragging = false; if (handled == false) { Rectangle r = e.Map.MapFrame.View; int w = r.Width; int h = r.Height; if (e.Button == MouseButtons.Left) { r.Inflate(-r.Width / 4, -r.Height / 4); // The mouse cursor should anchor the geographic location during zoom. r.X += (e.X / 2) - w / 4; r.Y += (e.Y / 2) - h / 4; } else { r.Inflate(r.Width / 2, r.Height / 2); r.X += w / 2 - e.X; r.Y += h / 2 - e.Y; } e.Map.MapFrame.View = r; e.Map.MapFrame.ResetExtents(); } base.OnMouseUp(e); Map.IsBusy = false; }
private void LoadFeatureFromGeomProperty(DbSet dbSet, PropertyInfo propertyGeom) { Envelope env = new Envelope(); IDataService dataService = ServiceLocator.Current.GetInstance<IDataService>(); EntityTableInfo tableInfo = dataService.GetEntityTableInfo(dbSet.ElementType); this.Lines.DataTable = this.CreateDataTable(dbSet.ElementType); this.Points.DataTable = this.CreateDataTable(dbSet.ElementType); this.Polygons.DataTable = this.CreateDataTable(dbSet.ElementType); PropertyInfo propertyId = dbSet.ElementType.GetProperty("Id"); foreach (Object obj in dbSet) { Object data = propertyGeom.GetValue(obj); if (data != null) { String strData = data.ToString(); Geometry geometry = this.CreateGeometryFromWkt(strData); if (geometry != null) { env.ExpandToInclude(geometry.Envelope); if (geometry is LineString || geometry is MultiLineString) { IFeature feature = this.Lines.AddFeature(geometry); System.Data.DataRow row = this.Lines.DataTable.NewRow(); row.BeginEdit(); row["Id"] = (Int64)propertyId.GetValue(obj); this.Lines.DataTable.Rows.Add(row); feature.DataRow = row; row.EndEdit(); } else if (geometry is Point) { IFeature feature = this.Points.AddFeature(geometry); System.Data.DataRow row = this.Points.DataTable.NewRow(); row.BeginEdit(); row["Id"] = (Int64)propertyId.GetValue(obj); this.Points.DataTable.Rows.Add(row); feature.DataRow = row; row.EndEdit(); } else if (geometry is Polygon) { IFeature feature = this.Polygons.AddFeature(geometry); System.Data.DataRow row = this.Polygons.DataTable.NewRow(); row.BeginEdit(); row["Id"] = (Int64)propertyId.GetValue(obj); this.Polygons.DataTable.Rows.Add(row); feature.DataRow = row; row.EndEdit(); } } } } this.Extent = env.ToExtent(); }
private void LoadTemplate(TemplateViewModel template) { template.Nodes.Clear(); this.Map.Layers.Clear(); DbSet<SigNode> nodeSet = this.DataService.GetDbSet<SigNode>(); List<TemplateNodeLayerViewModel> layersNodes = new List<TemplateNodeLayerViewModel>(); this.RecurseLoadTemplate(nodeSet, template, template.Nodes, -1, layersNodes); Envelope env = new Envelope(); layersNodes = (from ln in layersNodes where ln.Model.SigLayer != null orderby ln.Model.SigLayer.MapOrder select ln).ToList(); foreach (TemplateNodeLayerViewModel layersNode in layersNodes) { layersNode.CreateLayers(); if (layersNode.Envelope != null) { env.ExpandToInclude(layersNode.Envelope); } foreach (IMapLayer mapLayer in layersNode.Layers) { this.Map.Layers.Add(mapLayer); } } this.Map.ViewExtents = env.ToExtent(); }