示例#1
0
        private void BtnMapResize_Click(object sender, EventArgs e)
        {
            MapSizeInputWindow dialog = new MapSizeInputWindow(Map.Width, Map.Height);

            dialog.Location = MousePosition;
            if (dialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            if (dialog.NewWidth < Map.Width || dialog.NewHeight < Map.Height)
            {
                string oldSizeStr = "(" + Map.Width + "," + Map.Height + ")";
                string newSizeStr = "(" + dialog.NewWidth + "," + dialog.NewHeight + ")";

                if (!Confirm("The new size " + newSizeStr + " is smaller than the current size " + oldSizeStr +
                             ". This will delete objects that are out of bounds. Are you sure?"))
                {
                    return;
                }
            }

            Map.Resize(dialog.NewWidth, dialog.NewHeight);
            MapBox.AdjustSize();
            MapBox.InvalidateAllMapPositionsAndRefresh();
        }
示例#2
0
        private void LoadMap(string filename)
        {
            try
            {
                Map.Load(filename);
                UpdateMapLayerList(false);
                MapBox.AdjustSize();
                MapBox.InvalidateAllMapPositionsAndRefresh();
                TxtMapName.Text = Map.Name;
                UpdateTilePreview();

                Log("Map loaded from file " + filename);
                SetCurrentMapFile(filename);
            }
            catch (Exception ex)
            {
                ShowError("Error loading map from file " + filename + ":" +
                          Environment.NewLine + Environment.NewLine + ex.Message);
            }
        }