Exemple #1
0
        private void ChangeMapDimensions()
        {
            string inputWidth  = Microsoft.VisualBasic.Interaction.InputBox("Enter Map Width", "Change Map Dimensions");
            string inputHeight = Microsoft.VisualBasic.Interaction.InputBox("Enter Map Height", "Change Map Dimensions");
            int    width       = CurrentMap.Width;
            int    height      = CurrentMap.Height;
            bool   invalid     = false;

            if (inputWidth != null && inputWidth != "")
            {
                if (int.TryParse(inputWidth, out width))
                {
                    if (width < 1)
                    {
                        invalid = true;
                    }
                }
                else
                {
                    invalid = true;
                }
            }
            if (inputHeight != null & inputHeight != "")
            {
                if (int.TryParse(inputHeight, out height))
                {
                    if (height < 1)
                    {
                        invalid = true;
                    }
                }
                else
                {
                    invalid = true;
                }
            }
            if (invalid)
            {
                Forms.MessageBox.Show("Invalid width/height!");
            }
            else
            {
                CurrentMap.ChangeDimensions(width, height);
            }
        }