void ExecuteCommandSelectPolygonPoint(object o) { var point = zoomManager.RecalcZoomDiv(FieldView.GetCurrentMousePos()); if (SelectedField != null) { SelectedField.Polygon.DeselectAll(); } if (SelectedField != null && SelectedField.Polygon.Select(point))//this means that it has selected point of current field { FieldView.RefreshView(); return; } SelectedField = null; foreach (var field in World.Fields.OrderByDescending(r => r.ZOrder)) { if (field.Polygon.Select(point)) { SelectedField = field; break; } else if (field.Polygon.IsInPoly(point)) { SelectedField = field; SelectedField.Polygon.SelectAll(); break; } } FieldView.RefreshView(); }
void ExecutePerformAction(object o) { if (!CanExecutePerformAction(o)) { return; } var point = FieldView.GetCurrentMousePos(); var location = zoomManager.RecalcZoomDiv(point); _currentClickableAction.Perform(location); _currentClickableAction.Dispose(); _currentClickableAction = null; }
void ExecuteAddNewImmediately(object o) { if (CurrentPolygon != null) { CurrentPolygon.DeselectAll(); } var hSize = 20; var location = FieldView.GetCurrentMousePos(); var polygon = new FieldPolygon(); polygon.AddPoint(new Vector2(location.X - hSize, location.Y - hSize)); polygon.AddPoint(new Vector2(location.X + hSize, location.Y - hSize)); polygon.AddPoint(new Vector2(location.X + hSize, location.Y + hSize)); polygon.AddPoint(new Vector2(location.X - hSize, location.Y + hSize)); commitPoly(polygon); FieldView.RefreshView(); }
void ExecuteCommandSelectPolygonPointMany(object o) { // todo rewrite var point = zoomManager.RecalcZoomDiv(FieldView.GetCurrentMousePos()); if (SelectedField != null)//this means that it has selected point of current field { var poly = SelectedField.Polygon; if (poly.IsNearToSelected(point)) { deselect(point); FieldView.RefreshView(); return; } else if (poly.Select(point)) { FieldView.RefreshView(); return; } } if (SelectedField != null) { SelectedField.Polygon.DeselectAll(); } foreach (var field in World.Fields) { if (field == SelectedField) { continue; } if (field.Polygon.Select(point)) { SelectedField = field; break; } } FieldView.RefreshView(); }