Example #1
0
 public static void Save(Huone huone)
 {
     try
     {
         Stream        writeStream = new FileStream("Huone.bin", FileMode.Create, FileAccess.Write, FileShare.None);
         XmlSerializer serializer  = new XmlSerializer(typeof(Huone));
         serializer.Serialize(writeStream, huone);
         writeStream.Close();
     }
     catch (UnauthorizedAccessException)
     {
         MessageBox.Show("Can't open file for writing (UnauthorizedAccessException)");
     }
     catch (ArgumentNullException)
     {
         MessageBox.Show("Opened stream is null (ArgumentNullException)");
     }
     catch (ArgumentException)
     {
         MessageBox.Show("Opened stream is not writable (ArgumentException)");
     }
     catch (IOException)
     {
         MessageBox.Show("An IO error happend (IOException)");
     }
     catch (Exception)
     {
         MessageBox.Show("Some other exception happend (Exception)");
     }
 }
Example #2
0
        public static void Exit(Huone h, Window w)
        {
            SoundPlayer click = new System.Media.SoundPlayer(Properties.Resources.click);

            click.Play();
            MainWindow main = new harjoitus.View.MainWindow();

            w.Close();
            main.ShowDialog();
        }
Example #3
0
 public static void NewGame(Huone h, Avain a1, Avain a2, Avain a3, TextBlock m)
 {
     a1.NewKey();
     a2.NewKey();
     a3.NewKey();
     h.Avaimet.Add(a1);
     h.Avaimet.Add(a2);
     h.Avaimet.Add(a3);
     h.KeyAmount = 0;
     Toiminta.MessageWork(h.KeyAmount, m);
 }
Example #4
0
        public void KeyDisappear(Huone h, Button myButton, Image i1, Image i2, Image i3, TextBlock m)
        {
            SoundPlayer audio = new SoundPlayer(harjoitus.Properties.Resources.success);

            audio.Play();
            myButton.Visibility = Visibility.Hidden;
            IsFound             = true;
            h.KeyAmount++;
            Toiminta.MenuKeys(h.KeyAmount, i1, i2, i3);
            Toiminta.MessageWork(h.KeyAmount, m);
        }
Example #5
0
 public static void LoadGame(Huone h, Avain a1, Avain a2, Avain a3, Button b1, Button b2, Button b3, Image i1, Image i2, Image i3, TextBlock m)
 {
     if (a1.IsFound == true)
     {
         b1.Visibility = Visibility.Hidden;
         a1.IsFound    = true;
     }
     if (a2.IsFound == true)
     {
         b2.Visibility = Visibility.Hidden;
         a2.IsFound    = true;
     }
     if (a3.IsFound == true)
     {
         b3.Visibility = Visibility.Hidden;
         a3.IsFound    = true;
     }
     MenuKeys(h.KeyAmount, i1, i2, i3);
     MessageWork(h.KeyAmount, m);
 }