示例#1
0
文件: Form1.cs 项目: ushalin/OpenRA
        void ResizeClicked(object sender, EventArgs e)
        {
            using (var rd = new ResizeDialog())
            {
                rd.MapWidth.Value     = surface1.Map.MapSize.X;
                rd.MapHeight.Value    = surface1.Map.MapSize.Y;
                rd.CordonLeft.Value   = surface1.Map.Bounds.Left;
                rd.CordonTop.Value    = surface1.Map.Bounds.Top;
                rd.CordonRight.Value  = surface1.Map.Bounds.Right;
                rd.CordonBottom.Value = surface1.Map.Bounds.Bottom;

                if (DialogResult.OK != rd.ShowDialog())
                {
                    return;
                }

                surface1.Map.ResizeCordon((int)rd.CordonLeft.Value,
                                          (int)rd.CordonTop.Value,
                                          (int)rd.CordonRight.Value,
                                          (int)rd.CordonBottom.Value);

                if ((int)rd.MapWidth.Value != surface1.Map.MapSize.X || (int)rd.MapHeight.Value != surface1.Map.MapSize.Y)
                {
                    surface1.Map.Resize((int)rd.MapWidth.Value, (int)rd.MapHeight.Value);
                    surface1.Bind(surface1.Map, surface1.TileSet, surface1.TileSetRenderer, surface1.Palette, surface1.PlayerPalette);                          // rebind it to invalidate all caches
                }

                surface1.Invalidate();
            }
        }
        void ResizeClicked(object sender, EventArgs e)
        {
            using (var rd = new ResizeDialog())
            {
                rd.width.Value = surface1.Map.MapSize.X;
                rd.height.Value = surface1.Map.MapSize.Y;
                rd.cordonLeft.Value = surface1.Map.Bounds.Left;
                rd.cordonTop.Value = surface1.Map.Bounds.Top;
                rd.cordonRight.Value = surface1.Map.Bounds.Right;
                rd.cordonBottom.Value = surface1.Map.Bounds.Bottom;

                if (DialogResult.OK != rd.ShowDialog())
                    return;

                surface1.Map.ResizeCordon((int)rd.cordonLeft.Value,
                    (int)rd.cordonTop.Value,
                    (int)rd.cordonRight.Value,
                    (int)rd.cordonBottom.Value);

                if ((int)rd.width.Value != surface1.Map.MapSize.X || (int)rd.height.Value != surface1.Map.MapSize.Y)
                {
                    surface1.Map.Resize((int)rd.width.Value, (int)rd.height.Value);
                    surface1.Bind(surface1.Map, surface1.TileSet, surface1.Palette);	// rebind it to invalidate all caches
                }

                surface1.Invalidate();
            }
        }