/// <summary>
        /// Populates the drop downs.
        /// </summary>
        private void PopulateDropDowns()
        {
            EnsureChildControls();
            _ddlLastCurrent.Items.Clear();
            _ddlLastCurrent.Items.Add(new ListItem(string.Empty, SlidingDateRangeType.All.ConvertToInt().ToString()));

            SlidingDateRangeType[] sortedTypes = new SlidingDateRangeType[]
            {
                SlidingDateRangeType.Current,
                SlidingDateRangeType.Previous,
                SlidingDateRangeType.Last,
                SlidingDateRangeType.Next,
                SlidingDateRangeType.Upcoming,
                SlidingDateRangeType.DateRange
            };

            foreach (var slidingType in sortedTypes)
            {
                if (this.EnabledSlidingDateRangeTypes.Contains(slidingType))
                {
                    _ddlLastCurrent.Items.Add(new ListItem(slidingType.ConvertToString(), slidingType.ConvertToInt().ToString()));
                }
            }

            _ddlTimeUnitTypeSingular.Items.Clear();
            _ddlTimeUnitTypePlural.Items.Clear();

            foreach (var item in this.EnabledSlidingDateRangeUnits)
            {
                _ddlTimeUnitTypeSingular.Items.Add(new ListItem(item.ConvertToString(), item.ConvertToInt().ToString()));
                _ddlTimeUnitTypePlural.Items.Add(new ListItem(item.ConvertToString().Pluralize(), item.ConvertToInt().ToString()));
            }

            ddl_SelectedIndexChanged(null, null);
        }
        /// <summary>
        /// Gets the help HTML that explains usage of the SlidingDateRange picker with examples
        /// </summary>
        /// <param name="currentDateTime">The current date time.</param>
        /// <returns></returns>
        public static string GetHelpHtml(DateTime currentDateTime)
        {
            SlidingDateRangePicker helperPicker = new SlidingDateRangePicker();

            SlidingDateRangeType[] slidingDateRangeTypesForHelp = new SlidingDateRangeType[] { SlidingDateRangeType.Current, SlidingDateRangeType.Previous, SlidingDateRangeType.Last, SlidingDateRangeType.Next, SlidingDateRangeType.Upcoming };

            string helpHtml = @"
    
    <div class='slidingdaterange-help'>

        <p>A date range can either be a specific date range, or a sliding date range based on the current date and time.</p>
        <p>For a sliding date range, you can choose either <strong>current, previous, last, next, upcoming</strong> with a time period of <strong>hour, day, week, month, or year</strong>. Note that a week is Monday thru Sunday.</p>
        <br />
        <ul class=''>
            <li><strong>Current</strong> - the time period that the current date/time is in</li>
            <li><strong>Previous</strong> - the time period(s) prior to the current period (does not include the current time period). For example, to see the most recent weekend, select 'Previous 1 Week'</li>
            <li><strong>Last</strong> - the last X time period(s) including the current until today. For example, to see so far this current week and prior week, select 'Last 2 weeks'</li>
            <li><strong>Next</strong> - the next X time period(s) including the rest of the current period. For example, to see the rest of the current month and the next full month after, select 'Next 2 months'</li>
            <li><strong>Upcoming</strong> - the upcoming X time period(s) not including the current time period.</li>
        </ul>

        <h3>Preview of the sliding date ranges</h3>";

            foreach (var slidingDateRangeType in slidingDateRangeTypesForHelp)
            {
                helperPicker.SlidingDateRangeMode = slidingDateRangeType;
                helperPicker.NumberOfTimeUnits    = 2;
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(@"<h4>{0}</h4>", slidingDateRangeType.ConvertToString());
                sb.AppendLine("<ul>");
                foreach (var timeUnitType in Enum.GetValues(typeof(TimeUnitType)).OfType <TimeUnitType>())
                {
                    helperPicker.TimeUnit = timeUnitType;
                    sb.AppendFormat(@"
                    <li>
                        <span class='slidingdaterange-help-key'>{0} {1}</span>
                        <span class='slidingdaterange-help-value'> - {2}</span>
                    </li>",
                                    slidingDateRangeType != SlidingDateRangeType.Current ? helperPicker.NumberOfTimeUnits.ToString() : string.Empty,
                                    helperPicker.TimeUnit.ConvertToString().PluralizeIf(slidingDateRangeType != SlidingDateRangeType.Current && helperPicker.NumberOfTimeUnits > 1),
                                    SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues(helperPicker.DelimitedValues).ToStringAutomatic());
                }
                sb.AppendLine("</ul>");

                helpHtml += sb.ToString();
            }

            helpHtml += @"
    </div>
";

            return(helpHtml);
        }
示例#3
0
        /// <summary>
        /// Gets the help HTML that explains usage of the SlidingDateRange picker with examples
        /// </summary>
        /// <param name="currentDateTime">The current date time.</param>
        /// <returns></returns>
        public static string GetHelpHtml( DateTime currentDateTime )
        {
            SlidingDateRangePicker helperPicker = new SlidingDateRangePicker();
            SlidingDateRangeType[] slidingDateRangeTypesForHelp = new SlidingDateRangeType[] { SlidingDateRangeType.Current, SlidingDateRangeType.Previous, SlidingDateRangeType.Last, SlidingDateRangeType.Next, SlidingDateRangeType.Upcoming };

            string helpHtml = @"

            <div class='slidingdaterange-help'>

            <p>A date range can either be a specific date range, or a sliding date range based on the current date and time.</p>
            <p>For a sliding date range, you can choose either <strong>current, previous, last, next, upcoming</strong> with a time period of <strong>hour, day, week, month, or year</strong>. Note that a week is Monday thru Sunday.</p>
            <br />
            <ul class=''>
            <li><strong>Current</strong> - the time period that the current date/time is in</li>
            <li><strong>Previous</strong> - the time period(s) prior to the current period (does not include the current time period). For example, to see the most recent weekend, select 'Previous 1 Week'</li>
            <li><strong>Last</strong> - the last X time period(s) including the current until today. For example, to see so far this current week and prior week, select 'Last 2 weeks'</li>
            <li><strong>Next</strong> - the next X time period(s) including the rest of the current period. For example, to see the rest of the current month and the next full month after, select 'Next 2 months'</li>
            <li><strong>Upcoming</strong> - the upcoming X time period(s) not including the current time period.</li>
            </ul>

            <h3>Preview of the sliding date ranges</h3>";

            foreach ( var slidingDateRangeType in slidingDateRangeTypesForHelp )
            {
                helperPicker.SlidingDateRangeMode = slidingDateRangeType;
                helperPicker.NumberOfTimeUnits = 2;
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat( @"<h4>{0}</h4>", slidingDateRangeType.ConvertToString() );
                sb.AppendLine( "<ul>" );
                foreach ( var timeUnitType in Enum.GetValues( typeof( TimeUnitType ) ).OfType<TimeUnitType>() )
                {
                    helperPicker.TimeUnit = timeUnitType;
                    sb.AppendFormat( @"
                    <li>
                        <span class='slidingdaterange-help-key'>{0} {1}</span>
                        <span class='slidingdaterange-help-value'> - {2}</span>
                    </li>",
                          slidingDateRangeType != SlidingDateRangeType.Current ? helperPicker.NumberOfTimeUnits.ToString() : string.Empty,
                          helperPicker.TimeUnit.ConvertToString().PluralizeIf( slidingDateRangeType != SlidingDateRangeType.Current && helperPicker.NumberOfTimeUnits > 1 ),
                          SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues( helperPicker.DelimitedValues ).ToStringAutomatic() );
                }
                sb.AppendLine( "</ul>" );

                helpHtml += sb.ToString();
            }

            helpHtml += @"
            </div>
            ";

            return helpHtml;
        }
示例#4
0
        /// <summary>
        /// Populates the drop downs.
        /// </summary>
        private void PopulateDropDowns()
        {
            EnsureChildControls();
            _ddlLastCurrent.Items.Clear();
            _ddlLastCurrent.Items.Add( new ListItem( string.Empty, SlidingDateRangeType.All.ConvertToInt().ToString() ) );

            SlidingDateRangeType[] sortedTypes = new SlidingDateRangeType[]
                {
                    SlidingDateRangeType.Current,
                    SlidingDateRangeType.Previous,
                    SlidingDateRangeType.Last,
                    SlidingDateRangeType.Next,
                    SlidingDateRangeType.Upcoming,
                    SlidingDateRangeType.DateRange
                };

            foreach ( var slidingType in sortedTypes )
            {
                if ( this.EnabledSlidingDateRangeTypes.Contains( slidingType ) )
                {
                    _ddlLastCurrent.Items.Add( new ListItem( slidingType.ConvertToString(), slidingType.ConvertToInt().ToString() ) );
                }
            }

            _ddlTimeUnitTypeSingular.Items.Clear();
            _ddlTimeUnitTypePlural.Items.Clear();

            foreach ( var item in this.EnabledSlidingDateRangeUnits )
            {
                _ddlTimeUnitTypeSingular.Items.Add( new ListItem( item.ConvertToString(), item.ConvertToInt().ToString() ) );
                _ddlTimeUnitTypePlural.Items.Add( new ListItem( item.ConvertToString().Pluralize(), item.ConvertToInt().ToString() ) );
            }

            ddl_SelectedIndexChanged( null, null );
        }