Пример #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
 public Planet()
 {
     Terrain         = new Hexgrid(100, 200);
     Terrain.hWrap   = true;
     TerrainEx       = new Hexgrid(100, 200);
     TerrainEx.hWrap = true;
     Climate         = new Hexgrid(100, 200);
     Climate.hWrap   = true;
     Regions         = new List <Hexgrid>();
     Height          = 100;
     Width           = 200;
 }
Пример #3
0
 public void HexgridTest()
 {
     try
     {
         Size    GridSize = new Size(10, 10);
         Hexgrid hexgrid  = new Hexgrid(false, GridSize, 1);
         Point   p        = HexCoords.HexOrigin(GridSize, 2, 1);
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Пример #4
0
 public Planet(int height, int seed)
 {
     Terrain         = new Hexgrid(height, height * 2);
     Terrain.hWrap   = true;
     TerrainEx       = new Hexgrid(height, height * 2);
     TerrainEx.hWrap = true;
     Climate         = new Hexgrid(height, height * 2);
     Climate.hWrap   = true;
     Regions         = new List <Hexgrid>();
     Height          = height;
     Width           = height * 2;
     Seed            = seed;
 }
Пример #5
0
        /// <inheritdoc/>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            if (IsHandleCreated)
            {
//        base.OnPaint(e);

                var g      = e.Graphics;
                var scroll = Hexgrid.GetScrollPosition(AutoScrollPosition);
                if (DesignMode)
                {
                    g.FillRectangle(Brushes.Gray, ClientRectangle);  return;
                }

                g.Clear(Color.Black);
                g.DrawRectangle(Pens.Black, ClientRectangle);

                if (IsTransposed)
                {
                    g.Transform = TransposeMatrix;
                }
                g.TranslateTransform(scroll.X, scroll.Y);
                g.ScaleTransform(MapScale, MapScale);

                var state = g.Save();
                g.DrawImageUnscaled(MapBuffer, Point.Empty);

                g.Restore(state); state = g.Save();
                Model.PaintUnits(g);

                g.Restore(state); state = g.Save();
                Model.PaintShading(g);

                g.Restore(state); state = g.Save();
                Model.PaintHighlight(g);
            }
        }
Пример #6
0
 /// <summary>Returns the scroll position to center a specified hex in viewport.</summary>
 /// <param name="coordsNewCenterHex"><c>HexCoords</c> for the hex to be centered in viewport.</param>
 /// <returns>Pixel coordinates in Client reference frame.</returns>
 protected Point ScrollPositionToCenterOnHex(HexCoords coordsNewCenterHex)
 {
     return(Hexgrid.ScrollPositionToCenterOnHex(coordsNewCenterHex, VisibleRectangle));
 }
Пример #7
0
 /// <summary>Returns ScrollPosition that places given hex in the upper-Left of viewport.</summary>
 /// <param name="coordsNewULHex"><c>HexCoords</c> for new upper-left hex</param>
 /// <returns>Pixel coordinates in Client reference frame.</returns>
 public Point HexCenterPoint(HexCoords coordsNewULHex)
 {
     return(Hexgrid.HexCenterPoint(coordsNewULHex));
 }
Пример #8
0
 /// <summary><c>HexCoords</c> for a selected hex.</summary>
 /// <param name="point">Screen point specifying hex to be identified.</param>
 /// <returns>Coordinates for a hex specified by a screen point.</returns>
 /// <remarks>See "file://Documentation/HexGridAlgorithm.mht"</remarks>
 public HexCoords GetHexCoords(Point point)
 {
     return(Hexgrid.GetHexCoords(point, new Size(AutoScrollPosition)));
 }