public Layer() { Name = ""; Visible = true; MapObjects = new List <MapObject>(); GEOBounds = new GEORect(0.0, 0.0, 0.0, 0.0); }
private void Map_MouseUp(object sender, MouseEventArgs e) { switch (CurrentTool) { case Tool.Select: double Dx1 = Math.Abs(MouseDownPosition.X - e.X); double Dy1 = Math.Abs(MouseDownPosition.Y - e.Y); if (Dx1 < shake && Dy1 < shake) { GEOPoint searchCenter = ScreenToMap(e.Location); double xMin = searchCenter.X - shake / 2 / MapScale; double xMax = searchCenter.X + shake / 2 / MapScale; double yMin = searchCenter.Y - shake / 2 / MapScale; double yMax = searchCenter.Y + shake / 2 / MapScale; GEORect searchRect = new GEORect(xMin, xMax, yMin, yMax); MapObject result = FindObject(searchRect); } break; case Tool.Pan: IsMouseDown = false; Cursor = Cursors.Default; break; case Tool.ZoomIn: cosmeticLayer.Clear(); double Dx = Math.Abs(MouseDownPosition.X - e.X); double Dy = Math.Abs(MouseDownPosition.Y - e.Y); if (Dx > shake || Dy > shake) { GEOPoint newCenter = ScreenToMap(new System.Drawing.Point((e.X + MouseDownPosition.X) / 2, (e.Y + MouseDownPosition.Y) / 2)); MapCenter = newCenter; if (Width / Dx > Height / Dy) { MapScale *= Width / Dx; } else { MapScale *= Height / Dy; } } else { MapCenter = ScreenToMap(MouseDownPosition); MapScale *= 2; Cursor = Cursors.Cross; } IsMouseDown = false; Refresh(); break; case Tool.ZoomOut: IsMouseDown = false; MapCenter = ScreenToMap(MouseDownPosition); MapScale /= 2; Refresh(); break; } }
public static bool IsExist(GEORect geoRect) { if (geoRect.XMin == 0.0 && geoRect.XMax == 0.0 && geoRect.YMin == 0.0 && geoRect.YMax == 0.0) { return(false); } return(true); }
private MapObject FindObject(GEORect searchRect) { for (int i = CountMapObjects() - 1; i > 0; --i) { if (MapObjects[i].IsInside(searchRect)) { return(MapObjects[i]); } } return(null); }
private MapObject FindObject(GEORect searchRect) { MapObject result = null; for (int i = Layers.Count - 1; i > 0; --i) { Layer layer = Layers[i]; if (layer.Visible) { for (int j = layer.CountMapObjects() - 1; j > 0; --j) { result = layer.FindObject(searchRect); } } } return(result); }
public static GEORect Union(GEORect geoRect1, GEORect geoRect2) { if (!IsExist(geoRect1)) { return(geoRect2); } else if (!IsExist(geoRect2)) { return(geoRect1); } else if (!IsExist(geoRect1) && !IsExist(geoRect2)) { return(new GEORect(0.0, 0.0, 0.0, 0.0)); } double xMin = Math.Min(geoRect1.XMin, geoRect2.XMin); double xMax = Math.Max(geoRect1.XMax, geoRect2.XMax); double yMin = Math.Min(geoRect1.YMin, geoRect2.YMin); double yMax = Math.Max(geoRect1.YMax, geoRect2.YMax); return(new GEORect(xMin, xMax, yMin, yMax)); }
public override bool IsInside(GEORect geoRect) { }
public void AddMapObject(MapObject mapObject) { mapObject.Layer = this; MapObjects.Add(mapObject); GEOBounds = GEORect.Union(GEOBounds, mapObject.GEOBounds); }
public abstract bool IsInside(GEORect geoRect);
public static bool IsCrossLines(GEORect geoRect, Line line) { }
public static bool IsIntersect(GEORect geoRect1, GEORect geoRect2) { }