コード例 #1
0
        /// <summary>Set ScrollBar increments and bounds from map dimensions.</summary>
        public virtual void SetScrollLimits(IMapDisplayWinForms model)
        {
            if (model == null)
            {
                return;
            }
            var smallChange = Size.Ceiling(model.GridSize.Scale(MapScale));

            HorizontalScroll.SmallChange = smallChange.Width;
            VerticalScroll.SmallChange   = smallChange.Height;

            var largeChange = Size.Round(ClientSize.Scale(0.75F));

            HorizontalScroll.LargeChange = Math.Max(largeChange.Width, smallChange.Width);
            VerticalScroll.LargeChange   = Math.Max(largeChange.Height, smallChange.Height);

            var size = Hexgrid.GetSize(MapSizePixels, MapScale);

            if (AutoScrollMinSize != size)
            {
                AutoScrollMinSize        = size;
                HorizontalScroll.Maximum = Math.Min(1, Math.Max(1, Padding.Left + Padding.Right
                                                                + size.Width - ClientSize.Width));
                VerticalScroll.Maximum = Math.Min(1, Math.Max(1, Padding.Top + Padding.Bottom
                                                              + size.Height - ClientSize.Height));
                Invalidate();
            }
        }
コード例 #2
0
        /// <summary>Returns the translation transform of @this for the upper-left corner of the specified hex.</summary>
        /// <typeparam name="THex"></typeparam>
        /// <param name="this"></param>
        /// <param name="coords">Type: HexCoords - Coordinates of the hex to be painted next.</param>
        public static Matrix TranslateToHex <THex>(this IMapDisplayWinForms <THex> @this, HexCoords coords)
            where THex : IHex
        {
            var offset = @this.UpperLeftOfHex <THex>(coords);

            return(new Matrix(1, 0, 0, 1, offset.X, offset.Y));
        }
コード例 #3
0
        /// <summary>Set ScrollBar increments and bounds from map dimensions.</summary>
        public virtual void SetScrollLimits(IMapDisplayWinForms model)
        {
            if (model == null || !AutoScroll)
            {
                return;
            }
            var smallChange = Size.Ceiling(model.GridSize.Scale(MapScale));

            HorizontalScroll.SmallChange = smallChange.Width;
            VerticalScroll.SmallChange   = smallChange.Height;

            var largeChange = Size.Round(ClientSize.Scale(0.75F));

            HorizontalScroll.LargeChange = Math.Max(largeChange.Width, smallChange.Width);
            VerticalScroll.LargeChange   = Math.Max(largeChange.Height, smallChange.Height);

            var size = DataContext.Grid.GetSize(MapSizePixels, MapScale)
                       + Margin.Size;

            if (AutoScrollMinSize != size)
            {
                AutoScrollMinSize        = size;
                HorizontalScroll.Maximum = Math.Max(HorizontalScroll.Minimum,
                                                    Math.Min(HorizontalScroll.Maximum,
                                                             Margin.Horizontal + size.Width - ClientSize.Width));
                VerticalScroll.Maximum = Math.Max(VerticalScroll.Minimum,
                                                  Math.Min(VerticalScroll.Maximum,
                                                           Margin.Vertical + size.Height - ClientSize.Height));
                Invalidate();
            }
        }
コード例 #4
0
 /// <summary>Returns pixel coordinates of centre of specified hex.</summary>
 /// <param name="this"></param>
 /// <param name="coords"></param>
 /// <returns>A Point structure containing pixel coordinates for the (centre of the) specified hex.</returns>
 public static HexPoint CentreOfHex <THex>(this IMapDisplayWinForms <THex> @this, HexCoords coords)
     where THex : IHex
 => @this.UpperLeftOfHex(coords) + @this.HexCentreOffset;
コード例 #5
0
 /// <summary>Returns pixel coordinates of upper-left corner of specified hex.</summary>
 /// <param name="this"></param>
 /// <param name="coords"></param>
 /// <returns>A Point structure containing pixel coordinates for the (upper-left corner of the) specified hex.</returns>
 public static HexPoint UpperLeftOfHex <THex>(this IMapDisplayWinForms <THex> @this, HexCoords coords)
     where THex : IHex
 => new HexPoint(
     coords.User.X * @this.GridSize.Width,
     coords.User.Y * @this.GridSize.Height + (coords.User.X + 1) % 2 * @this.GridSize.Height / 2
     );
 /// <summary>.</summary>
 /// <typeparam name="THex"></typeparam>
 /// <param name="this">The map to be painted, as a <see cref="MapDisplay{THex}"/>.</param>
 /// <param name="graphics">The <see cref="Graphics"/> object for the canvas being painted.</param>
 public static void PaintUnits <THex>(this IMapDisplayWinForms <THex> @this, Graphics graphics)
     where THex : IHex
 => @this.Painter().PaintUnits(graphics);
 /// <summary>.</summary>
 /// <typeparam name="THex"></typeparam>
 /// <param name="this">The map to be painted, as a <see cref="MapDisplay{THex}"/>.</param>
 /// <param name="graphics">The <see cref="Graphics"/> object for the canvas being painted.</param>
 /// <param name="isNotShaded">The <see cref="IShadingMask"/> object for the canvas being painted.</param>
 public static void PaintShading <THex>(this IMapDisplayWinForms <THex> @this, Graphics graphics, IShadingMask isNotShaded)
     where THex : IHex
 => @this.Painter().PaintShading(graphics, isNotShaded);
 /// <summary>Paint the base layer of the display, graphics that changes rarely between refreshes.</summary>
 /// <param name="this">The map to be painted, as a <see cref="MapDisplay{THex}"/>.</param>
 /// <param name="graphics">The <see cref="Graphics"/> object for the canvas being painted.</param>
 /// <param name="hexText">.</param>
 /// <remarks>For each visible hex: perform <c>paintAction</c> and then draw its hexgrid outline.</remarks>
 public static void PaintLabels <THex>(this IMapDisplayWinForms <THex> @this, Graphics graphics,
                                       Func <HexCoords, string> hexText)
     where THex : IHex
 => @this.Painter().PaintLabels(graphics, hexText);
 /// <summary>Paint the base layer of the display, graphics that changes rarely between refreshes.</summary>
 /// <param name="this">The map to be painted, as a <see cref="MapDisplay{THex}"/>.</param>
 /// <param name="graphics">The <see cref="Graphics"/> object for the canvas being painted.</param>
 /// <param name="showHexgrid">.</param>
 /// <remarks>For each visible hex: perform <c>paintAction</c> and then draw its hexgrid outline.</remarks>
 public static void PaintMap <THex>(this IMapDisplayWinForms <THex> @this, Graphics graphics,
                                    bool showHexgrid)
     where THex : IHex
 => @this.Painter().PaintMap(graphics, showHexgrid);
 private static IMapDisplayPainter Painter <THex>(this IMapDisplayWinForms <THex> @this) where THex : IHex
 => new MapDisplayPainter <THex>(@this);
コード例 #11
0
 /// <summary></summary>
 /// <param name="model">The map to be painted, as a <see cref="IMapDisplayWinForms{THex}"/>.</param>
 public AbstractModelDisplayPainter(IMapDisplayWinForms <THex> model)
 => Model = model ?? throw new ArgumentNullException(nameof(model));
コード例 #12
0
 /// <summary>TODO</summary>
 public void SetModel(IMapDisplayWinForms model)
 {
     SetScrollLimits(DataContext.Model);
     DataContext.Model = model;
     SetMapDirty();
 }
コード例 #13
0
 /// <summary></summary>
 /// <param name="model">The map to be painted, as a <see cref="IMapDisplayWinForms{THex}"/>.</param>
 public MapDisplayPainter(IMapDisplayWinForms <THex> model) : base(model)
 {
 }