示例#1
0
        private static void DateTimeValueChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DateTime dtNew    = DateTime.Now;
            string   newValue = e.NewValue == null ? "" : e.NewValue.ToString();

            if (DateTime.TryParse(newValue.ToString(), out dtNew))
            {
            }
            UTimeControl thisDateTime = d as UTimeControl;
            string       hor          = dtNew.Hour.ToString().PadLeft(2, '0');
            string       minit        = dtNew.Minute.ToString().PadLeft(2, '0');

            thisDateTime.SetValue(DateValueProperty, dtNew);
            thisDateTime.SetValue(HourValueProperty, hor);
            thisDateTime.SetValue(MinitValueProperty, minit);

            if (thisDateTime.DataChanged != null)
            {
                thisDateTime.DataChanged(thisDateTime, (DateTime)thisDateTime.GetValue(DateValueProperty));
            }
        }
示例#2
0
        private static void UpdateNewValue(UTimeControl UIDateTimeCtrl)
        {
            if (UIDateTimeCtrl != null)
            {
                DateTime dValue = (DateTime)UIDateTimeCtrl.GetValue(DateValueProperty);
                string   hValue = (string)UIDateTimeCtrl.GetValue(HourValueProperty);
                string   mValue = (string)UIDateTimeCtrl.GetValue(MinitValueProperty);

                hValue = hValue == null ? "00" : hValue;
                mValue = mValue == null ? "00" : mValue;
                if (DateTime.TryParse(dValue.ToString("yyyy-MM-dd") + " " + hValue + ":" + mValue, out dValue))
                {
                }
                UIDateTimeCtrl.SetValue(TimeValueProperty, dValue);
            }
        }