public ProblemManedger(ProblemObservable _probObs, ProblemsExecuteObservable _probExecutObs, SpeechSynthesizer _synthesizer, SettingsClass _settClass)
        {
            _problemAllObs      = _probObs;
            _problemExecutedObs = _probExecutObs;
            _problemForSpeech   = new List <Problem>();

            synthesizer = _synthesizer;
            settClass   = _settClass;

            #region -Timers-
            Interval             = new TimeSpan(0, 0, 1);
            check_timer          = new DispatcherTimer();
            check_timer.Interval = Interval;
            check_timer.Tick    += Check_timer_Tick;
            check_timer.Start();

            pause_timer          = new DispatcherTimer();
            pause_timer.Interval = new TimeSpan(0, 0, 2);
            pause_timer.Tick    += Pause_timer_Tick;

            readText_timer          = new DispatcherTimer();
            readText_timer.Interval = new TimeSpan(0, 30, 10); // должно быть из SettingsClass
            readText_timer.Tick    += ReadText_timer_Tick;
            //readText_timer.Start();
            #endregion

            readList = Speak.LoadText() ?? (new string[0]);
            CheckProblemStart();
        }
示例#2
0
        /// <summary>
        /// Десериализация сохраненных объектов
        /// </summary>
        private void DeserializesObject()
        {
            _problemObs = new ProblemObservable();
            _problemObs = (ProblemObservable)SerializeA.Deserializes(_problemObs.GetType().ToString(), _problemObs);

            _settClass = new SettingsClass();
            _settClass = (SettingsClass)SerializeA.Deserializes(_settClass.GetType().ToString(), _settClass);
            _settClass.PropertyChanged += SettClass_PropertyChanged;
        }
示例#3
0
        //
        public void AddTimeSummary(ProblemObservable _problemObs, TimePeriodType _timePerType)
        {
            foreach (TimeSummary item in this)
            {
                item.DurationMinuteSum = 0;
            }

            switch (_timePerType)
            {
            case TimePeriodType._year:
                break;

            case TimePeriodType._month:
                break;

            case TimePeriodType._week:
                break;

            case TimePeriodType._day:

                //foreach (Problem prob in _problemObs)
                //{
                //    TimeSummary _ts = this.FindMain(x => x.DateStart == ServiceMain.DateTimeFloor(prob.StartDateTime, TimePeriodType._day));

                //    if (_ts != null)
                //    {
                //        _ts.DurationMinuteSum += prob.DurationProblem.TotalMinutes;
                //    }
                //}

                CalcDurationSum(_problemObs);

                break;

            case TimePeriodType._hour:
                break;

            case TimePeriodType._minute:
                break;

            case TimePeriodType._second:
                break;

            default:
                break;
            }
        }
示例#4
0
        public void Full(Object map)
        {
            ProblemObservable pO = null;

            try
            {
                pO = (ProblemObservable)map;
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
                return;
            }

            foreach (Problem p in pO)
            {
                this.Add(p);
            }
        }
示例#5
0
        public ProblemViewModel()
        {
            _repoClasses = new RepositoryClasses();
            _problemsObs = _repoClasses.ProblemObs;
            _problemsObs.CollectionChanged       += _problemsObs_CollectionChanged;
            _problemExecuteObs                    = _repoClasses.ProblemExecuteObs;
            _problemExecuteObs.CollectionChanged += _problemExecuteObs_CollectionChanged;

            _settClass   = _repoClasses.SettClass;
            _synthesizer = _repoClasses.Synthesizer;

            //
            _timeSumObs = new TimeSummaryObservable(TimePeriodType._day, DateTime.Now);
            _timeSumObs.AddTimeSummary(_problemsObs, TimePeriodType._day);

            //
            _dateForIndicator = DateTime.Now;
            NearestProblem    = NearestProblemSet(_problemsObs[0]);
        }
示例#6
0
        private void CalcDurationSum(ProblemObservable _problemObs)
        {
            foreach (TimeSummary tsum in this)
            {
                foreach (Problem prob in _problemObs)
                {
                    if (tsum.DateStart == ServiceMain.DateTimeFloor(prob.StartDateTime, TimePeriodType._day))
                    {
                        tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes;
                    }
                    else
                    {
                        if (tsum.DateStart > prob.StartDateTime)
                        {
                            if (prob.Replay)
                            {
                                DateTime _startDateTimeProb = prob.StartDateTime;

                                // каждый день
                                if (prob.ReplayEveryday)
                                {
                                    if (prob.EndingNever)
                                    {
                                        tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes;
                                    }
                                    if (prob.EndingCount)
                                    {
                                        // сделать метод умножения TimeSpan
                                        DateTime _endDateTimeProb = prob.StartDateTime.Add(TimeSpan.FromTicks(new TimeSpan(1, 0, 0, 0).Ticks *(prob.CountReplays - 1)));

                                        if (_endDateTimeProb >= tsum.DateStart)
                                        {
                                            tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes;
                                        }
                                    }
                                    if (prob.EndingDate)
                                    {
                                        if (prob.EndDateTime >= tsum.DateStart)
                                        {
                                            tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes;
                                        }
                                    }
                                }

                                // каждую неделю
                                if (prob.ReplayEveryweek)
                                {
                                    if (prob.EndingNever)
                                    {
                                        if (prob.DayOfWeekList.Exists(x => x == tsum.DateStart.DayOfWeek))
                                        {
                                            tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes;
                                        }
                                    }
                                    if (prob.EndingCount)
                                    {
                                        for (int i = prob.CountReplays; i > 0;)
                                        {
                                            if (prob.DayOfWeekList.Exists(x => x == tsum.DateStart.DayOfWeek))
                                            {
                                                tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes;
                                                i--;
                                            }
                                        }
                                    }
                                    if (prob.EndingDate)
                                    {
                                        if (prob.EndDateTime >= tsum.DateStart)
                                        {
                                            if (prob.DayOfWeekList.Exists(x => x == tsum.DateStart.DayOfWeek))
                                            {
                                                tsum.DurationMinuteSum += prob.DurationProblem.TotalMinutes;
                                            }
                                        }
                                    }
                                }

                                // каждый месяц
                                if (prob.ReplayEverymonth)
                                {
                                }

                                // каждый год
                                if (prob.ReplaysEveryyear)
                                {
                                }

                                // другой интервал
                                if (prob.ReplayOther)
                                {
                                }
                            }
                        }
                    }
                }
            }
        }