//Cargar private void Button_Click_2(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog opener = new Microsoft.Win32.OpenFileDialog(); opener.DefaultExt = ".2ks"; opener.Filter = "2048 Tableros |*.2ks"; Nullable <bool> result = opener.ShowDialog(); if (result == true) { string filename = opener.FileName; FileStream archivo = new FileStream(filename, FileMode.Open); try { BinaryFormatter binary = new BinaryFormatter(); Mapa map = (Mapa)binary.Deserialize(archivo); juego ventanaJuego = new juego(map, tipo, animar, 2, highsc); ventanaJuego.Show(); } catch (System.Runtime.Serialization.SerializationException) { MessageBoxButton botones = MessageBoxButton.OK; MessageBoxImage icono = MessageBoxImage.Error; MessageBox.Show("Error, archivo inválido o corrupto", "Error", botones, icono); } archivo.Close(); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { //Iniciar juego int tam = 0; if (valslider.Content is string) { tam = int.Parse((string)valslider.Content); } else if (valslider.Content is double) { tam = Convert.ToInt32(valslider.Content); } Mapa map = new Mapa(tam); juego ventanaJuego = new juego(map, tipo, this.animar, 2, highsc); ventanaJuego.Show(); }