Example #1
0
        static PersianCalendar()
        {
            PropertyMetadata displayModeMetaData = new PropertyMetadata(modeChanged);

            DisplayModeProperty =
                DependencyProperty.Register("DisplayMode", typeof(CalendarMode), typeof(PersianCalendar), displayModeMetaData);

            PropertyMetadata displayDateMetaData = new PropertyMetadata(PersianDate.Today, modeChanged);

            displayDateMetaData.CoerceValueCallback = coerceDateToBeInRange;
            DisplayDateProperty =
                DependencyProperty.Register("DisplayDate", typeof(PersianDate), typeof(PersianCalendar), displayDateMetaData);


            PropertyMetadata selectedDateMetaData = new PropertyMetadata(PersianDate.Today,
                                                                         (DependencyObject d, DependencyPropertyChangedEventArgs e) =>
            {
                PersianCalendar pc = d as PersianCalendar;
                pc.selectedDateCheck((PersianDate)e.OldValue);
                pc.RaiseEvent(new RoutedEventArgs(SelectedDateChangedEvent, pc));
            }
                                                                         );

            selectedDateMetaData.CoerceValueCallback = coerceDateToBeInRange;
            SelectedDateProperty =
                DependencyProperty.Register("SelectedDate", typeof(PersianDate), typeof(PersianCalendar), selectedDateMetaData);

            PropertyMetadata displayDateStartMetaData = new PropertyMetadata
            {
                DefaultValue            = new PersianDate(),
                CoerceValueCallback     = new CoerceValueCallback(coerceDisplayDateStart),
                PropertyChangedCallback = new PropertyChangedCallback(DisplayDateStartChanged),
            };

            DisplayDateStartProperty =
                DependencyProperty.Register("DisplayDateStart", typeof(PersianDate), typeof(PersianCalendar), displayDateStartMetaData);

            PropertyMetadata displayDateEndMetaData = new PropertyMetadata
            {
                DefaultValue            = new PersianDate(10000, 1, 1),
                CoerceValueCallback     = new CoerceValueCallback(coerceDisplayDateEnd),
                PropertyChangedCallback = new PropertyChangedCallback(DisplayDateEndChanged),
            };

            DisplayDateEndProperty =
                DependencyProperty.Register("DisplayDateEnd", typeof(PersianDate), typeof(PersianCalendar), displayDateEndMetaData);


            PropertyMetadata todayBackgroundMetaData = new PropertyMetadata(Brushes.AliceBlue,
                                                                            (DependencyObject d, DependencyPropertyChangedEventArgs e) =>
            {
                PersianCalendar pc = d as PersianCalendar;
                pc.todayCheck();
            }
                                                                            );

            TodayBackGroundProperty =
                DependencyProperty.Register("TodayBackGround", typeof(Brush), typeof(PersianCalendar), todayBackgroundMetaData);

            SelectedDateChangedEvent = EventManager.RegisterRoutedEvent("SelectedDateChanged",
                                                                        RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PersianCalendar));
        }
Example #2
0
        static void modeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            PersianCalendar pc = d as PersianCalendar;

            pc.setCalendar();
        }