コード例 #1
0
 public MainWindow()
 {
     Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("sv-SV");
     InitializeComponent();
     _gameViewModel = new SeaBattleTrophyGameViewModel();
     SetupSeaMap();
     SetupShipOrderControl();
     SetupTurnControl();
     SetupShipStatusControl();
     SetupWindDisplay();
 }
コード例 #2
0
        private void Reset()
        {
            if (_game != null)
            {
                _game.SeaMapSizeInPixels.PropertyChanged -= HandleSeaMapSizeInPixelsPropertyChanged;
            }

            ShipGrid.Children.Clear();
            LandMassGrid.Children.Clear();
            _game = null;
        }
コード例 #3
0
        private void HandleDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var game = DataContext as SeaBattleTrophyGameViewModel;

            if (game == null)
            {
                throw new InvalidCastException("The data context should be of correct type");
            }

            Reset();

            _game = game;
            _game.SeaMapSizeInPixels.PropertyChanged += HandleSeaMapSizeInPixelsPropertyChanged;

            HandleSeaMapSizeInPixelsPropertyChanged(this, new PropertyChangedEventArgs(null));
            AddShips();
            AddLandMasses();
        }