Ejemplo n.º 1
0
        /// <summary>
        /// For WPF calendar with SelectionMode="MultipleRange" this method deselects other selected dates and selects the specified range.
        /// For any other type of SelectionMode it deselects other selected dates and selects only the last date in the range.
        /// For Win32 multiple selection calendar the "dates" parameter should contain two dates, the first and the last date of the range to be selected.
        /// For Win32 single selection calendar this method selects only the second date from the "dates" array.
        /// For WPF calendar all dates should be specified in the "dates" parameter, not only the first and the last date of the range.
        /// </summary>
        public void SelectRange(DateTime[] dates)
        {
            if (dates.Length == 0)
            {
                return;
            }

            if (FrameworkType == FrameworkType.Wpf)
            {
                SetSelectedDate(dates[0], false);
                for (int i = 1; i < dates.Length; i++)
                {
                    SetSelectedDate(dates[i], true);
                }
                return;
            }
            else if (FrameworkType == FrameworkType.Win32)
            {
                if (Properties.NativeWindowHandle.IsSupported)
                {
                    var windowHandle = Properties.NativeWindowHandle.ValueOrDefault;
                    if (windowHandle != IntPtr.Zero)
                    {
                        Win32Fallback.SetSelectedRange(windowHandle, dates);
                        return;
                    }
                }
            }

            throw new NotSupportedException("Not supported");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deselects other selected dates and selects the specified date.
        /// </summary>
        public void SelectDate(DateTime date)
        {
            if (FrameworkType == FrameworkType.Wpf)
            {
                SetSelectedDate(date, false);
                return;
            }
            else if (FrameworkType == FrameworkType.Win32)
            {
                if (Properties.NativeWindowHandle.IsSupported)
                {
                    var windowHandle = Properties.NativeWindowHandle.ValueOrDefault;
                    if (windowHandle != IntPtr.Zero)
                    {
                        Win32Fallback.SetSelectedDate(windowHandle, date);
                        return;
                    }
                }
            }

            throw new NotSupportedException("Not supported");
        }