Exemple #1
0
        GroupByVertexAttributeTime
        (
            Microsoft.Office.Interop.Excel.Workbook workbook,
            String attributeColumnName,
            IEnumerable <DateTime> minimumValues
        )
        {
            Debug.Assert(workbook != null);
            Debug.Assert(!String.IsNullOrEmpty(attributeColumnName));
            Debug.Assert(minimumValues != null);

            StringToTypeConverter <DateTime> oStringToTypeConverter =
                (String stringValue, out DateTime dateTime) =>
            {
                // When an Excel cell is formatted as Time, the string read from
                // the cell is a Decimal.  Sample: 39448.625.

                dateTime = DateTime.MinValue;
                Decimal decDateTime;

                if (!Decimal.TryParse(stringValue, out decDateTime))
                {
                    return(false);
                }

                dateTime = ExcelDateTimeUtil.ExcelDecimalToDateTime(decDateTime);
                return(true);
            };

            TypeAdjuster <DateTime> oTypeAdjuster =
                (DateTime dateTime) =>
            {
                // Set the date component to some arbitrary, constant value and set
                // the seconds to 0.  The DateTimePicker control doesn't show
                // seconds by default, but its value includes the seconds and that
                // can lead to confusing comparison results.

                return(new DateTime(
                           2000,
                           1,
                           1,
                           dateTime.Hour,
                           dateTime.Minute,
                           0,
                           dateTime.Kind
                           ));
            };

            GroupByVertexAttributeGeneric <DateTime>(workbook, attributeColumnName,
                                                     minimumValues, DateTime.MinValue, oStringToTypeConverter,
                                                     oTypeAdjuster);
        }
        SetSelectedRange
        (
            Decimal selectedMinimum,
            Decimal selectedMaximum
        )
        {
            AssertValid();

            base.SetSelectedRange(
                ExcelDateTimeUtil.ExcelDecimalToDateTime(selectedMinimum),
                ExcelDateTimeUtil.ExcelDecimalToDateTime(selectedMaximum)
                );
        }
        SetAvailableRange
        (
            Decimal availableMinimum,
            Decimal availableMaximum
        )
        {
            AssertValid();

            base.SetAvailableRange(
                ExcelDateTimeUtil.ExcelDecimalToDateTime(availableMinimum),
                ExcelDateTimeUtil.ExcelDecimalToDateTime(availableMaximum)
                );
        }
        ValueToString
        (
            Decimal value
        )
        {
            AssertValid();

            ExcelColumnFormat eExcelColumnFormat;

            switch (this.Format)
            {
            case SimpleDateTimeFormat.Date:

                eExcelColumnFormat = ExcelColumnFormat.Date;
                break;

            case SimpleDateTimeFormat.Time:

                eExcelColumnFormat = ExcelColumnFormat.Time;
                break;

            case SimpleDateTimeFormat.DateAndTime:

                eExcelColumnFormat = ExcelColumnFormat.DateAndTime;
                break;

            default:

                Debug.Assert(false);
                return(null);
            }

            return(ExcelDateTimeUtil.DateTimeToString(
                       ExcelDateTimeUtil.ExcelDecimalToDateTime(value),
                       eExcelColumnFormat));
        }