// METHODS #region Commands private void ShowCabinetOrRegistrateMethod(object obj) { if (IsAuthorized(obj)) { cabinetWindow = new CabinetWindow() { DataContext = this }; cabinetWindow.ShowDialog(); } else { logInWindow = new LogInWindow() { DataContext = this }; logInWindow.ShowDialog(); } }
// CONSTRUCTORS /// <summary> /// Basic constructor with 1 parametr /// </summary> /// <param name="dataAccessService">Programs dataAccessService</param> public ApplicationViewModel(IDataAccessService dataAccessService) { this.dataAccessService = dataAccessService; this.sessionTimer = new DispatcherTimer() { Interval = System.TimeSpan.FromSeconds(1) }; this.randomizer = new System.Random(); this.isDataRequireUpdate = true; this.gameRunning = false; this.gameTime = System.TimeSpan.FromSeconds(0); this.orders = new ObservableCollection <Order>(); this.champions = null; #region Window Initialize logInWindow = null; cabinetWindow = null; #endregion #region Commands Initialize logIn = new RelayCommand(LogInMethod, IsNotAuthorized); logOut = new RelayCommand(LogOutMethod, IsAuthorized); signUp = new RelayCommand(SignUpMethod, IsNotAuthorized); startGame = new RelayCommand(StartGameMethod, AuthorizedAndGameIsNotRunning); executeOrder = new RelayCommand(ExecuteOrderMethod, GameRunningAndOrderSelected); searchOrder = new RelayCommand(SearchOrderMethod, GameRunning); removeOrder = new RelayCommand(RemoveOrderMethod, GameRunningAndOrderSelected); showCabinetOrRegistrate = new RelayCommand(ShowCabinetOrRegistrateMethod, GameIsNotRunning); showScores = new RelayCommand(ShowScoresMethod); #endregion sessionTimer.Tick += SessionTimer_Tick; }