コード例 #1
0
        public static async void GetCountdown(int CountdownId)
        {
            string baseURL = $"http://pokeapi.co/api/v2/pokemon/{CountdownId}/";

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    using (HttpResponseMessage res = await client.GetAsync(baseURL))
                    {
                        using (HttpContent content = res.Content)
                        {
                            string data = await content.ReadAsStringAsync();

                            if (data != null)
                            {
                                var            dataObj   = JObject.Parse(data);
                                CountdownModel countdown = new CountdownModel(remainingTime: Int32.Parse($"{dataObj["RemainingTime"]}"));
                            }
                            else
                            {
                                Console.WriteLine("Data is null!");
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
コード例 #2
0
        public async Task <IActionResult> PutCountdownModel(long id, CountdownModel countdownModel)
        {
            if (id != countdownModel.Id)
            {
                return(BadRequest());
            }

            _context.Entry(countdownModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CountdownModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #3
0
 public void StartSubstaction(CountdownModel counter)
 {
     _counter                  = counter;
     _substractTimer           = new Timer(1000);
     _substractTimer.Elapsed  += SubstractTime;
     _substractTimer.AutoReset = true;
     _substractTimer.Enabled   = true;
 }
コード例 #4
0
        public ApplicationViewModel()
        {
            _countdownModel = new CountdownModel();

            //Sets up new CVM keeping this class, so only
            //one instance of this is ever created.
            CurrentView = new CountdownViewModel(this, _countdownModel);
        }
コード例 #5
0
 public CountdownSettingsViewModel(CountdownModel countdownModel, ApplicationViewModel applicationViewModel)
 {
     _countdownModel       = countdownModel;
     _applicationViewModel = applicationViewModel;
     MaxSeconds            = _countdownModel.MaxSeconds;
     BackCommand           = new RelayCommand(GoBack);
     ApplyCommand          = new RelayCommand(ApplySettings);
 }
コード例 #6
0
        public async Task <ActionResult <CountdownModel> > PostCountdownModel(CountdownModel countdownModel)
        {
            _context.CountdownModels.Add(countdownModel);
            await _context.SaveChangesAsync();

            Actions.DecreaseTime decreaseTime = new Actions.DecreaseTime();
            decreaseTime.StartSubstaction(countdownModel);

            return(CreatedAtAction(nameof(GetCountdownModel), new { id = countdownModel.Id }, countdownModel));
        }
コード例 #7
0
        public CountdownViewModel()
        {
            countdown        = new CountdownModel();
            timer            = new AppTimer(200);
            timer.AfterTick += AfterTick;
            timerSheets      = new ObservableCollection <TimerSheetViewModel>();
            CreateCommand    = new CountdownViewModelCreateCommand(this);

            OutputFilename = ConfigurationManager.AppSettings["Filename"];
            System.IO.File.Create(OutputFilename);
        }
コード例 #8
0
 public CountdownViewModel(SaveList saveList)
 {
     OutputFilename   = ConfigurationManager.AppSettings["Filename"];
     Countdown        = new CountdownModel();
     timer            = new AppTimer(200);
     timer.AfterTick += AfterTick;
     TimerSheets      = new ObservableCollection <TimerSheetViewModel>();
     CreateCommand    = new DelegateCommandResolver(SaveChanged, () => CanUpdate);
     System.IO.File.Create(OutputFilename);
     DoSaveList += saveList;
 }
コード例 #9
0
        public CountdownViewModel(ApplicationViewModel applicationViewModel, CountdownModel countdownModel)
        {
            CountdownModel = countdownModel;
            CountdownModel.SecondsRemaining = CountdownModel.MaxSeconds;
            StartCountdownCommand           = new RelayCommand(StartCountdown);
            StopCountdownCommand            = new RelayCommand(StopCountdown);
            SettingsCommand      = new RelayCommand(GoToSettings);
            ResetCommand         = new RelayCommand(ResetTimer);
            _isRunning           = false;
            isStartButtonEnabled = true;
            isStopButtonEnabled  = true;
            //CountdownSettingsViewModel = new CountdownSettingsViewModel(CountdownModel, _applicationViewModel);

            //Initialises AVM as the one which created it
            //so there is always only one AVM instance to easily inform
            //the main window.
            _applicationViewModel = applicationViewModel;
        }