예제 #1
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);
        }
예제 #2
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;
        }