Ejemplo n.º 1
0
        public static DateEventCollection Load(TimeMeasureCollection timeMeasures, ContactCollection contacts)
        {
            DateEventCollection dateEventCollection;

            try
            {
                dateEventCollection = DateEventCollection.fileName.LoadAndDeserialize <DateEventCollection>();
            }
            catch
            {
                return(new DateEventCollection());
            }
            List <DateEvent> dateEventList = new List <DateEvent>();

            foreach (DateEvent dateEvent in dateEventCollection.DateEvents)
            {
                dateEvent.TimeMeasure = timeMeasures.Get(dateEvent.TimeMeasureId);
                dateEvent.Contact     = contacts.Get(dateEvent.ContactId);
                if (dateEventCollection._dateEventDictionary.ContainsKey(dateEvent.Id))
                {
                    dateEventList.Add(dateEvent);
                }
                else
                {
                    dateEventCollection._dateEventDictionary[dateEvent.Id] = dateEvent;
                }
            }
            foreach (DateEvent dateEvent in dateEventList)
            {
                dateEvent.Id = dateEventCollection.GetNextId();
                dateEventCollection._dateEventDictionary[dateEvent.Id] = dateEvent;
            }
            return(dateEventCollection);
        }
Ejemplo n.º 2
0
 private void bgwLoader_DoWork(object sender, DoWorkEventArgs e)
 {
     this.timeMeasures = TimeMeasureCollection.Generate();
     this.contacts     = ContactCollection.Load();
     this.dateEvents   = DateEventCollection.Load(this.timeMeasures, this.contacts);
     this.settings     = Settings.Load();
 }
Ejemplo n.º 3
0
 public void Recalc(ContactCollection contacts, TimeMeasureCollection timeMeasures, Settings settings)
 {
     this._dateEvents.Clear();
     this._dateEventDictionary.Clear();
     foreach (Contact contact in contacts.Contacts)
     {
         this.Add(contact, timeMeasures, settings);
     }
 }
Ejemplo n.º 4
0
        public static TimeMeasureCollection Generate()
        {
            TimeMeasureCollection measureCollection = new TimeMeasureCollection();
            string      name1        = "Seconds";
            TimeSpan    duration1    = TimeSpan.FromSeconds(1.0);
            TimeMeasure timeMeasure1 = measureCollection.Add(name1, duration1);

            timeMeasure1.Strings.Add(Measure.One, "секунда");
            timeMeasure1.Strings.Add(Measure.Few, "секунды");
            timeMeasure1.Strings.Add(Measure.Many, "секунд");
            string      name2        = "Minutes";
            TimeSpan    duration2    = TimeSpan.FromMinutes(1.0);
            TimeMeasure timeMeasure2 = measureCollection.Add(name2, duration2);

            timeMeasure2.Strings.Add(Measure.One, "минута");
            timeMeasure2.Strings.Add(Measure.Few, "минуты");
            timeMeasure2.Strings.Add(Measure.Many, "минут");
            string      name3        = "Hours";
            TimeSpan    duration3    = TimeSpan.FromHours(1.0);
            TimeMeasure timeMeasure3 = measureCollection.Add(name3, duration3);

            timeMeasure3.Strings.Add(Measure.One, "час");
            timeMeasure3.Strings.Add(Measure.Few, "часа");
            timeMeasure3.Strings.Add(Measure.Many, "часов");
            string      name4        = "Days";
            TimeSpan    duration4    = TimeSpan.FromDays(1.0);
            TimeMeasure timeMeasure4 = measureCollection.Add(name4, duration4);

            timeMeasure4.Strings.Add(Measure.One, "день");
            timeMeasure4.Strings.Add(Measure.Few, "дня");
            timeMeasure4.Strings.Add(Measure.Many, "дней");
            string      name5        = "Weeks";
            TimeSpan    duration5    = TimeSpan.FromDays(7.0);
            TimeMeasure timeMeasure5 = measureCollection.Add(name5, duration5);

            timeMeasure5.Strings.Add(Measure.One, "неделя");
            timeMeasure5.Strings.Add(Measure.Few, "недели");
            timeMeasure5.Strings.Add(Measure.Many, "недель");
            string      name6        = "Monthes";
            TimeSpan    zero1        = TimeSpan.Zero;
            TimeMeasure timeMeasure6 = measureCollection.Add(name6, zero1);

            timeMeasure6.Strings.Add(Measure.One, "месяц");
            timeMeasure6.Strings.Add(Measure.Few, "месяца");
            timeMeasure6.Strings.Add(Measure.Many, "месяцев");
            string      name7        = "Years";
            TimeSpan    zero2        = TimeSpan.Zero;
            TimeMeasure timeMeasure7 = measureCollection.Add(name7, zero2);

            timeMeasure7.Strings.Add(Measure.One, "год");
            timeMeasure7.Strings.Add(Measure.Few, "года");
            timeMeasure7.Strings.Add(Measure.Many, "лет");
            return(measureCollection);
        }
Ejemplo n.º 5
0
        public void Add(Contact contact, TimeMeasureCollection timeMeasures, Settings settings)
        {
            if (settings.UseSeconds)
            {
                TimeMeasure timeMeasure = timeMeasures.Find("Seconds");
                if (timeMeasure != null)
                {
                    this.CalculateEvents(contact, timeMeasure, settings);
                }
            }
            if (settings.UseMinutes)
            {
                TimeMeasure timeMeasure = timeMeasures.Find("Minutes");
                if (timeMeasure != null)
                {
                    this.CalculateEvents(contact, timeMeasure, settings);
                }
            }
            if (settings.UseHours)
            {
                TimeMeasure timeMeasure = timeMeasures.Find("Hours");
                if (timeMeasure != null)
                {
                    this.CalculateEvents(contact, timeMeasure, settings);
                }
            }
            if (settings.UseDays)
            {
                TimeMeasure timeMeasure = timeMeasures.Find("Days");
                if (timeMeasure != null)
                {
                    this.CalculateEvents(contact, timeMeasure, settings);
                }
            }
            if (settings.UseWeeks)
            {
                TimeMeasure timeMeasure = timeMeasures.Find("Weeks");
                if (timeMeasure != null)
                {
                    this.CalculateEvents(contact, timeMeasure, settings);
                }
            }
            if (settings.UseMonthes)
            {
                TimeMeasure timeMeasure = timeMeasures.Find("Monthes");
                if (timeMeasure != null)
                {
                    this.CalculateLongEvents(contact, timeMeasure, settings);
                }
            }
            if (!settings.UseYears)
            {
                return;
            }
            TimeMeasure timeMeasure1 = timeMeasures.Find("Years");

            if (timeMeasure1 == null)
            {
                return;
            }
            this.CalculateLongEvents(contact, timeMeasure1, settings);
        }
Ejemplo n.º 6
0
        private void Calculate()
        {
            this._settings.SecondsStep    = (int)this.nudSecondsStep.Value;
            this._settings.MinutesStep    = (int)this.nudMinutesStep.Value;
            this._settings.HoursStep      = (int)this.nudHoursStep.Value;
            this._settings.DaysStep       = (int)this.nudDaysStep.Value;
            this._settings.WeeksStep      = (int)this.nudWeeksStep.Value;
            this._settings.MonthesStep    = (int)this.nudMonthesStep.Value;
            this._settings.UseSecondsStep = this.chbSeconds.Checked;
            this._settings.UseMinutesStep = this.chbMinutes.Checked;
            this._settings.UseHoursStep   = this.chbHours.Checked;
            this._settings.UseDaysStep    = this.chbDays.Checked;
            this._settings.UseWeeksStep   = this.chbWeeks.Checked;
            this._settings.UseMonthesStep = this.chbMonthes.Checked;
            this._settings.Save();
            TimeMeasureCollection measureCollection = TimeMeasureCollection.Generate();

            this.dgvEvents.DataSource = (object)null;
            List <DateEvent> dateEventList = new List <DateEvent>();

            if (this.chbSeconds.Checked && this.nudSecondsStep.Value > Decimal.Zero)
            {
                TimeMeasure measure = measureCollection.Find("Seconds");
                if (measure != null)
                {
                    dateEventList.AddRange((IEnumerable <DateEvent>) this.GetEvents((uint)this.nudSecondsStep.Value, TimeSpan.FromSeconds((double)(uint)this.nudSecondsStep.Value), measure));
                }
            }
            if (this.chbMinutes.Checked && this.nudMinutesStep.Value > Decimal.Zero)
            {
                TimeMeasure measure = measureCollection.Find("Minutes");
                if (measure != null)
                {
                    dateEventList.AddRange((IEnumerable <DateEvent>) this.GetEvents((uint)this.nudMinutesStep.Value, TimeSpan.FromMinutes((double)(uint)this.nudMinutesStep.Value), measure));
                }
            }
            if (this.chbHours.Checked && this.nudHoursStep.Value > Decimal.Zero)
            {
                TimeMeasure measure = measureCollection.Find("Hours");
                if (measure != null)
                {
                    dateEventList.AddRange((IEnumerable <DateEvent>) this.GetEvents((uint)this.nudHoursStep.Value, TimeSpan.FromHours((double)(uint)this.nudHoursStep.Value), measure));
                }
            }
            if (this.chbDays.Checked && this.nudDaysStep.Value > Decimal.Zero)
            {
                TimeMeasure measure = measureCollection.Find("Days");
                if (measure != null)
                {
                    dateEventList.AddRange((IEnumerable <DateEvent>) this.GetEvents((uint)this.nudDaysStep.Value, TimeSpan.FromDays((double)(uint)this.nudDaysStep.Value), measure));
                }
            }
            if (this.chbWeeks.Checked && this.nudWeeksStep.Value > Decimal.Zero)
            {
                TimeMeasure measure = measureCollection.Find("Weeks");
                if (measure != null)
                {
                    dateEventList.AddRange((IEnumerable <DateEvent>) this.GetEvents((uint)this.nudWeeksStep.Value, TimeSpan.FromDays((double)(7U * (uint)this.nudWeeksStep.Value)), measure));
                }
            }
            if (this.chbMonthes.Checked && this.nudMonthesStep.Value > Decimal.Zero)
            {
                TimeMeasure measure = measureCollection.Find("Monthes");
                if (measure != null)
                {
                    dateEventList.AddRange((IEnumerable <DateEvent>) this.GetMonthEvents((int)this.nudMonthesStep.Value, measure));
                }
            }
            if (this.rbResultByDates.Checked)
            {
                dateEventList.Sort(new Comparison <DateEvent>(DateEvent.Comparer));
            }
            this.dgvEvents.DataSource = (object)dateEventList;
        }