Example #1
0
 public void SerializeObject(string filename, SettingsState objectToSerialize)
 {
     Stream stream = File.Open(filename, FileMode.Create);
     BinaryFormatter bFormatter = new BinaryFormatter();
     bFormatter.Serialize(stream, objectToSerialize);
     stream.Close();
 }
Example #2
0
        private void StartGame()
        {
            Serializer serializer = new Serializer();
            SettingsState state = new SettingsState();

            state.tidFortoning = numericUpDownTimeFade.Value;
            state.tidFoerFortoning = numericUpDownTimeNotification.Value;
            state.tidVist = NumericUpDownTimeShown.Value;
            state.tidVend = numericUpDownTimeTurn.Value;
            state.screen = (string)listBoxSkærme.SelectedItem;
            serializer.SerializeObject("settings.bin", state);
            if (listBoxSkærme.SelectedItem == null)
            {
                GlobalValues.currentScreen = Screen.AllScreens.First(s => s.Primary);
            }
            else
            {
                GlobalValues.currentScreen = Screen.AllScreens.First(s => s.DeviceName == listBoxSkærme.SelectedItem.ToString());
            }

            this.Hide();
            using (var game = new Vendespillet())
                game.Run();
            this.Show();
        }