Example #1
0
        public override string GetDisplayText(FormatInfo format, object editValue)
        {
            var displayText = string.Empty;
            var period      = editValue as PeriodsSet;

            if (period != null)
            {
                displayText = period.ToString(format.FormatString, SeparatorChar);
            }
            else
            {
                var s = editValue as string;
                if (s != null)
                {
                    displayText = PeriodsSet.Parse(s).ToString(format.FormatString, SeparatorChar);
                }
            }
            var e = new CustomDisplayTextEventArgs(editValue, displayText);

            if (format != EditFormat)
            {
                RaiseCustomDisplayText(e);
            }
            return(e.DisplayText);
        }
        public virtual PeriodsSet GetCopy()
        {
            PeriodsSet result = new PeriodsSet();

            foreach (Period period in periods)
            {
                result.Add(period);
            }
            return(result);
        }
 public User(string name, string city, int age)
 {
     this.name  = name;
     this.city  = city;
     this.age   = age;
     periodsSet = new PeriodsSet();
     periodsSet.MergeWith(DateTime.Today, DateTime.Today);
     // periodsSet.MergeWith(DateTime.Today.AddDays(5), DateTime.Today.AddDays(8));
     periodsString = periodsSet.ToString();
 }
        public static PeriodsSet Parse(string str, IFormatProvider format, char separatorChar)
        {
            PeriodsSet result = new PeriodsSet();

            string[] periodSet = string.Format("{0}", str).Split(separatorChar);
            foreach (string periodStr in periodSet)
            {
                Period dp = Period.Parse(periodStr, format);
                if (dp != null)
                {
                    result.Add(dp);
                }
            }
            return(result);
        }
Example #5
0
        protected override bool IsNullValue(object editValue)
        {
            var value = editValue as PeriodsSet;

            if (value != null)
            {
                return(value.Periods.Count == 0);
            }
            var s = editValue as string;

            if (s == null)
            {
                return(false);
            }

            return(PeriodsSet.Parse(s).Periods.Count == 0);
        }
Example #6
0
        protected override void AcceptPopupValue(object val)
        {
            if (PopupForm != null)
            {
                var calendar = ((PopupDatePeriodEditForm)PopupForm).Calendar;
                var periods  = new PeriodsSet();
                foreach (var range in calendar.SelectedRanges)
                {
                    periods.Periods.Add(new Period(range.StartDate, range.EndDate.AddSeconds(-1)));
                }
                if (val == null && calendar.SelectedRanges.Count == 0)
                {
                    periods.Periods.Add(new Period(DateTime.MinValue));
                }

                EditValue = periods;
                calendar.SelectedRanges.Clear();
            }
        }
Example #7
0
 public DatePeriodEdit()
 {
     EditValue = new PeriodsSet();
 }