// hijacking this for an easy resize dialog public NewMapDialog(Map oldMap) { this.InitializeComponent(); this.SaveButton.Content = "Resize"; this.Title = "Resize"; this.resize = true; this.OutputMap = oldMap; this.mapWidth.Text = oldMap.Width.ToString(); this.mapHeight.Text = oldMap.Height.ToString(); this.SaveButton.Click += new RoutedEventHandler(SaveButton_Click); this.CancelButton.Click += new RoutedEventHandler(CancelButton_Click); }
void SaveButton_Click(object sender, RoutedEventArgs e) { int width = int.Parse(this.mapWidth.Text); int height = int.Parse(this.mapHeight.Text); if (this.resize) { this.OutputMap.ResizeTo(width, height); } else { this.OutputMap = new Map(width, height); } this.Close(); }
void file_open_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog(); dialog.InitialDirectory = LevelsDirectory; dialog.ShowDialog(); string filename = dialog.FileName; try { this.activeMap = new Map(filename); this.activeMap.FillGrids( this.ArtBoard_Front, this.ArtBoard_Middle, this.ArtBoard_Back); } catch (Exception) { System.Windows.MessageBox.Show("Invalid file"); } this.RefreshBackground(); }
void file_new_Click(object sender, RoutedEventArgs e) { NewMapDialog dialog = new NewMapDialog(); dialog.ShowDialog(); if (dialog.OutputMap != null) { this.activeMap = dialog.OutputMap; this.ArtBoard_Back.Children.Clear(); this.ArtBoard_Middle.Children.Clear(); this.ArtBoard_Front.Children.Clear(); this.activeMap.FillGrids( this.ArtBoard_Front, this.ArtBoard_Middle, this.ArtBoard_Back); this.RefreshBackground(); } }