Пример #1
0
        /// <summary>
        /// Called when property changes.
        /// </summary>
        /// <param name="d">The dependency object.</param>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.OldValue != e.NewValue)
            {
                DateLabel dateLabel = d as DateLabel;
                if (dateLabel != null)
                {
                    if (dateLabel.Value != null)
                    {
                        if (e.Property == DateTypeProperty)
                        {
                            if (Enum.IsDefined(typeof(DateType), e.NewValue))
                            {
                                dateLabel.Value.DateType = (DateType)e.NewValue;
                            }
                            else
                            {
                                dateLabel.Value.DateType = DateType.Exact;
                            }
                        }
                        else if (e.Property == DateValueProperty)
                        {
                            dateLabel.Value.DateValue = (DateTime)e.NewValue;
                        }
                        else if (e.Property == MonthProperty)
                        {
                            dateLabel.Value.Month = (int)e.NewValue;
                        }
                        else if (e.Property == NullIndexProperty)
                        {
                            dateLabel.Value.NullIndex = (int)e.NewValue;
                        }
                        else if (e.Property == YearProperty)
                        {
                            dateLabel.Value.Year = (int)e.NewValue;
                        }
                        else if (e.Property == ValueProperty)
                        {
                            CuiDate cd = e.NewValue as CuiDate;
                            if (cd != null)
                            {
                                dateLabel.DateType  = cd.DateType;
                                dateLabel.DateValue = cd.DateValue;
                                dateLabel.Month     = cd.Month;
                                dateLabel.NullIndex = cd.NullIndex;
                                dateLabel.Year      = cd.Year;
                            }
                        }
                    }

                    dateLabel.UpdateDisplayValue();
                    AutomationPeerValueChanged(e, dateLabel);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DateLabelAutomationPeer"/> class.
 /// </summary>
 /// <param name="control">The date label control.</param>
 public DateLabelAutomationPeer(DateLabel control) : base(control)
 {
 }
Пример #3
0
        /// <summary>
        /// Raises the value changed event for the DateLabel automation peer.
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        /// <param name="dateLabel">The date label.</param>
        private static void AutomationPeerValueChanged(DependencyPropertyChangedEventArgs e, DateLabel dateLabel)
        {
            DateLabelAutomationPeer peer;

#if SILVERLIGHT
            peer = FrameworkElementAutomationPeer.FromElement(dateLabel) as DateLabelAutomationPeer;
#else
            peer = UIElementAutomationPeer.FromElement(dateLabel) as DateLabelAutomationPeer;
#endif

            if (peer != null)
            {
                peer.RaiseValueChangedEvent(e.OldValue.ToString(), e.NewValue.ToString());
            }
        }