public MainWindowViewModel() { _client = new HttpClient(); _baseURL = "https://localhost:44351/api/MasterMind"; _gameId = -1; Attempts = new ObservableCollection <Attempt>(); GetValidCharacters(); CreateGameCommand = new GeneralNoParameterCommand(CreateGame); AttemptGameCommand = new GeneralNoParameterCommand(() => { ValueOne = string.IsNullOrWhiteSpace(ValueOne) ? "A" : ValueOne.ToUpper(); ValueTwo = string.IsNullOrWhiteSpace(ValueTwo) ? "A" : ValueTwo.ToUpper(); ValueThree = string.IsNullOrWhiteSpace(ValueThree) ? "A" : ValueThree.ToUpper(); ValueFour = string.IsNullOrWhiteSpace(ValueFour) ? "A" : ValueFour.ToUpper(); OnPropertyChanged("ValueOne"); OnPropertyChanged("ValueTwo"); OnPropertyChanged("ValueThree"); OnPropertyChanged("ValueFour"); string completeAttempt = $"{_gameId}_{ValueOne}{ValueTwo}{ValueThree}{ValueFour}"; AttemptGame(completeAttempt); }); }
public void UpdateView(ValueThree<int, int, int> state) { if (InvokeRequired) { Invoke(new Action<ValueThree<int, int, int>>(UpdateView), state); return; } //авто обновление можно делать только, если не редактируется текущее значение if (_lockAutoUpdate == 0) { try { itbPan.IntegerValue = state.Value1; itbTilt.IntegerValue = state.Value2; itbZoom.IntegerValue = state.Value3; } finally { //освободим лок, он мог установится, когда мы инициализировали данные Interlocked.Exchange(ref _lockAutoUpdate, 0); } } }