コード例 #1
0
        private void SetIntoShared()
        {
            var editor = GetSharedPreferences(PreferencesName, FileCreationMode.Private).Edit();
            var list   = new List <string>();

            foreach (var data in DataRepository.GetInstance().CheckedData)
            {
                list.Add(data.Id);
            }

            var selectorInterval = FindViewById <EditText>(Resource.Id.selectorInterval);
            var selectorTime     = FindViewById <EditText>(Resource.Id.selectorTime);

            int.TryParse(selectorInterval.Text, out int interval);
            int.TryParse(selectorTime.Text, out int showingTime);

            TimingRepository.GetInstance().Interval    = interval;
            TimingRepository.GetInstance().ShowingTime = showingTime;

            editor.PutStringSet(DataKey, list);
            editor.PutInt(IntervalKey, interval);
            editor.PutInt(ShowingKey, showingTime);
            editor.Apply();

            RunOnUiThread(OnBackPressed);
        }
コード例 #2
0
        public void RunTimer()
        {
            if (_isTimerStarted)
            {
                return;
            }

            int   interval = TimingRepository.GetInstance().Interval;
            Timer timer    = new Timer(interval * 1000 * 60);

            timer.Elapsed += NextInterval;
            timer.Start();

            ShowNext();
        }
コード例 #3
0
        private async Task StartAfterReboot(AlarmerImplementation alarmer)
        {
            AlarmRepository        _alarmRepo              = new AlarmRepository();
            TimingRepository       _timingRepository       = new TimingRepository();
            CustomActionRepository _customActionRepository = new CustomActionRepository();

            try
            {
                var alarmList = await _alarmRepo.GetListAsync();

                if (alarmList != null && alarmList.Count > 0)
                {
                    foreach (var alarm in alarmList)
                    {
                        var timings = await _timingRepository.QueryAsync().Where(w => w.AlarmId == alarm.Id).ToArrayAsync();

                        var customs = await _customActionRepository.QueryAsync().Where(w => w.AlarmId == alarm.Id).ToArrayAsync();

                        var alarmOption = new AlarmOptions
                        {
                            EndDate         = alarm.EndDate,
                            AdditionalTimes = timings.Select(s => s.Time).ToArray(),
                            AlarmSequence   = alarm.AlarmSequence,
                            DaysOfWeek      = alarm.DaysOfWeek,
                            Interval        = alarm.Interval,
                            TotalAlarmCount = alarm.TotalAlarmCount
                        };

                        var notification = new NotificationOptions
                        {
                            EnableSound     = alarm.EnableSound,
                            EnableVibration = alarm.EnableVibration,
                            LargeIcon       = alarm.LargeIcon,
                            SmallIcon       = alarm.SmallIcon,
                            CustomActions   = customs.Select(s => { return(new CustomAction {
                                    Icon = s.Icon, Name = s.Name
                                }); }).ToArray()
                        };

                        alarmer.Schedule(alarm.Id, alarm.Title, alarm.Message, alarm.StartDate, alarmOption, notification, isNew: false);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #4
0
        public void SetData(string id)
        {
            var showingTime = TimingRepository.GetInstance().ShowingTime;
            var data        = DataRepository.GetInstance().GetDataById(id);

            _view.SetColor((int)_red, (int)_green, (int)_blue);
            _view.SetTitle(data.Name);

            _redTick   = (255 - data.Red) * 1.0 / (showingTime * 60);
            _greenTick = (255 - data.Green) * 1.0 / (showingTime * 60);
            _blueTick  = (255 - data.Blue) * 1.0 / (showingTime * 60);
            int tick = 17;

            Timer timerChange = new Timer(tick);
            Timer timerEnd    = new Timer(showingTime * 1020);

            timerChange.AutoReset = true;
            timerChange.Elapsed  += NextChange;

            timerEnd.Elapsed += GoBack;

            timerChange.Start();
            timerEnd.Start();
        }
コード例 #5
0
 public static TimingRepository GetInstance()
 {
     return(_instance ?? (_instance = new TimingRepository()));
 }
コード例 #6
0
 public void ChangeInterval(int interval)
 {
     TimingRepository.GetInstance().Interval = interval;
 }
コード例 #7
0
 public void ChangeShowingTime(int time)
 {
     TimingRepository.GetInstance().ShowingTime = time;
 }
コード例 #8
0
 public AlarmerImplementation()
 {
     _alarmRepo              = new AlarmRepository();
     _timingRepository       = new TimingRepository();
     _customActionRepository = new CustomActionRepository();
 }