コード例 #1
0
        virtual public async void Save(PomodoroTimerSetting setting)
        {
            StorageFile file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);

            using (var stream = await file.OpenStreamForWriteAsync())
            {
                XmlSerializer serializer = new XmlSerializer(typeof(PomodoroTimerSetting));
                serializer.Serialize(stream, setting);
            }
        }
コード例 #2
0
        public MainContainer()
        {
            pomodoroTimerModelSetting = new PomodoroTimerSetting();
            pomodoroModelTimer = new PomodoroTimer(pomodoroTimerModelSetting);

            PomodoroTimerSettings = new PomodoroViewModelTimerSettings(pomodoroTimerModelSetting);
            PomodoroTimer = new PomodoroViewModelTimer(pomodoroModelTimer);

            ViewModelCommand command = new ViewModelCommand(PomodoroTimer, "IsStopped");
            command.Predicate = o => PomodoroTimer.IsStopped;
            command.Action = o => loaderSaver.Save(pomodoroTimerModelSetting);
            SaveSettingCommand = command;
        }
コード例 #3
0
        /// <summary>
        /// Создать таймер для помодоро
        /// </summary>
        /// <param name="setting">Найстройки для таймера</param>
        public PomodoroTimer(PomodoroTimerSetting setting)
        {
            Setting = setting ?? new PomodoroTimerSetting();

            CurrentPeriod = 1;

            timer = new DispatcherTimer();
            timer.Tick += timer_Tick;
            timer.Interval = TimeSpan.FromSeconds(1);

            PlayState = new PlayState(this);
            StopState = new StopState(this);
            PauseState = new PauseState(this);

            Updated += (o, e) => { };   // Делаем пустой обработчик что бы не проверять на null

            GoToState(StopState);
        }
コード例 #4
0
        virtual public PomodoroTimerSetting Load()
        {
            StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;

            Stream stream = null;
            PomodoroTimerSetting setting;
            try
            {

               stream = local.OpenStreamForReadAsync(filename).Result;

               using (StreamReader reader = new StreamReader(stream))
               {
                   XmlSerializer serializer = new XmlSerializer(typeof(PomodoroTimerSetting));
                   setting = (PomodoroTimerSetting)serializer.Deserialize(reader);
               }
            }
            catch (IOException exception)
            {
                setting = new PomodoroTimerSetting();
            }
            return setting;
        }
コード例 #5
0
 public PomodoroViewModelTimerSettings(PomodoroTimerSetting pomodoroTimerModelSetting)
 {
     this.pomodoroTimerModelSetting = pomodoroTimerModelSetting;
 }