public OptionsWindows()
 {
     /* if (gameOptions == null)
      * {
      *   if (File.Exists("GameOptions.xml"))
      *   {
      *       using(var stream = File.OpenRead("GameOptions.xml"))
      *       {
      *           var serializer = new XmlSerializer(typeof(GameOptions));
      *           gameOptions = serializer.Deserialize(stream) as GameOptions;
      *       }
      *   }
      *   else
      *   {
      *       gameOptions = new GameOptions();
      *   }
      * }
      * DataContext = gameOptions;*/
     gameOptions = GameOptions.Create();
     DataContext = gameOptions;
     InitializeComponent();
 }
Beispiel #2
0
        private void CommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Command == ApplicationCommands.Close)
            {
                this.Close();
            }
            if (e.Command == GameViewModel.StartGameCommand)
            {
                var model           = new GameViewModel();
                var startGameDialog = new StartGameWindow();
                var options         = GameOptions.Create();
                startGameDialog.DataContext = options;
                var result = startGameDialog.ShowDialog();
                if (result.HasValue && result.Value == true)
                {
                    options.Save();
                    model.StartNewGame();
                    DataContext = model;
                }
            }

            if (e.Command == GameOptions.OptionsCommand)
            {
                var dialog = new OptionsWindow();
                var result = dialog.ShowDialog();
                if (result.HasValue && result.Value == true)
                {
                    DataContext = new GameViewModel(); // Clear current game
                }
            }

            if (e.Command == GameViewModel.ShowAboutCommand)
            {
                var dialog = new AboutWindow();
                dialog.ShowDialog();
            }

            e.Handled = true;
        }
Beispiel #3
0
 public OptionsWindow()
 {
     gameOptions = GameOptions.Create();
     DataContext = gameOptions;
     InitializeComponent();
 }
Beispiel #4
0
 public GameViewModel()
 {
     Players     = new List <Player>();
     gameOptions = GameOptions.Create();
 }