Exemple #1
0
        public void InitializeMiniMapDisplay(DisplaySettings settings)
        {
            Debug.Assert(_isMiniMap);
            _displaysettings = settings;

            Location = new Location(DisplayTypes.Shape, 500, 500, MiniMapDrawerFactory.MaxZoomLevel);
            var loc = Location;
            Display = new Display(settings, true, this, ref loc);
        }
Exemple #2
0
        /// <summary>
        /// Changes the center of the map
        /// </summary>
        private void SetCenter(object sender, Location location)
        {
            if (location != null)
            {
                if (Display == null || Display.Type != location.Display || Display.Zoom.Current != location.Zoom)
                {
                    Display = new Display(_displaysettings, _isMiniMap, this, ref location);
                }

                if (location != Location)
                {
                    Location oldLocation = Location;

                    Location = location;
                    Display.UpdateLocation(CanvasSize, oldLocation, location);

                    EventPublisher.SetMapCenter(sender, new MapLocationEventArgs(location, oldLocation, Display.Zoom));
                }
            }
            else
            {
                Debug.Assert(false, "setting location to null... let's not go there");
                Location = null;
            }
        }
Exemple #3
0
        /// <summary>
        /// Calculates the coordinates and zoom level so all villages are visible
        /// </summary>
        public Location GetSpan(Rectangle game, bool tryStayInCurrentZoom = true, int villagesExtraVisible = 5)
        {
            var middle = new Point(
                (game.Left + game.Right) / 2,
                (game.Top + game.Bottom) / 2);

            var maxVillageSize = new Size(
                CanvasSize.Width / (game.Width + villagesExtraVisible),
                CanvasSize.Height / (game.Height + villagesExtraVisible));

            // HACK: Auto switch from Icon to Shape display when using for example Center&Pinpoint
            bool couldSatisfy;
            int newZoomLevel = Display.GetMinimumZoomLevel(maxVillageSize, tryStayInCurrentZoom, out couldSatisfy);
            if (!couldSatisfy && Display.Type == DisplayTypes.Icon)
            {
                _lastIconZoom = _display.Zoom.Current;

                var location = new Location(DisplayTypes.Shape, middle, LastShapeZoom);
                Display = new Display(_displaysettings, _isMiniMap, this, ref location);

                newZoomLevel = Display.GetMinimumZoomLevel(maxVillageSize, tryStayInCurrentZoom, out couldSatisfy);
                return new Location(DisplayTypes.Shape, middle, newZoomLevel);
            }
            return new Location(Location.Display, middle, newZoomLevel);
        }