Ejemplo n.º 1
0
        private static void UpdateNewValue_all(UIDateTime UIDateTimeCtrl)
        {
            if (UIDateTimeCtrl != null)
            {
                DateTime dValue_begin = (DateTime)UIDateTimeCtrl.GetValue(BeginDateValue_allProperty);
                DateTime dValue_stop  = (DateTime)UIDateTimeCtrl.GetValue(StopDateValue_allProperty);
                string   hValue       = (string)UIDateTimeCtrl.GetValue(HourValue_allProperty);
                string   mValue       = (string)UIDateTimeCtrl.GetValue(MinitValue_allProperty);

                hValue = hValue == null ? "00" : hValue;
                mValue = mValue == null ? "00" : mValue;
                if (DateTime.TryParse(dValue_begin.ToString("yyyy-MM-dd") + " " + hValue + ":" + mValue, out dValue_begin))
                {
                }
                if (DateTime.TryParse(dValue_stop.ToString("yyyy-MM-dd") + " " + hValue + ":" + mValue, out dValue_stop))
                {
                }
                UIDateTimeCtrl.SetValue(StartDateTimeValueProperty, dValue_begin);
                UIDateTimeCtrl.SetValue(StopDateTimeValueProperty, dValue_stop);
                if (UIDateTimeCtrl.BeginDateTimeChanged != null)
                {
                    UIDateTimeCtrl.BeginDateTimeChanged(dValue_begin);
                }
                if (UIDateTimeCtrl.StopDateTimeChanged != null)
                {
                    UIDateTimeCtrl.StopDateTimeChanged(dValue_stop);
                }
            }
        }
Ejemplo n.º 2
0
        private static void UpdateNewValue_custom(UIDateTime UIDateTimeCtrl)
        {
            if (UIDateTimeCtrl != null)
            {
                DateTime dValue       = (DateTime)UIDateTimeCtrl.GetValue(DateValue_customProperty);
                string   hValue_begin = (string)UIDateTimeCtrl.GetValue(BeginHourValue_customProperty);
                string   mValue_begin = (string)UIDateTimeCtrl.GetValue(BeginMinitValue_customProperty);
                string   hValue_stop  = (string)UIDateTimeCtrl.GetValue(StopHourValue_customProperty);
                string   mValue_stop  = (string)UIDateTimeCtrl.GetValue(StopMinitValue_customProperty);

                hValue_begin = hValue_begin == null ? "00" : hValue_begin;
                mValue_begin = mValue_begin == null ? "00" : mValue_begin;
                hValue_stop  = hValue_stop == null ? "00" : hValue_stop;
                mValue_stop  = mValue_stop == null ? "00" : mValue_stop;

                DateTime BeginTime = DateTime.Now;
                DateTime StopTime  = DateTime.Now;
                if (DateTime.TryParse(dValue.ToString("yyyy-MM-dd") + " " + hValue_begin + ":" + mValue_begin, out BeginTime))
                {
                }
                if (DateTime.TryParse(dValue.ToString("yyyy-MM-dd") + " " + hValue_stop + ":" + mValue_stop, out StopTime))
                {
                }
                UIDateTimeCtrl.SetValue(StartDateTimeValueProperty, BeginTime);
                UIDateTimeCtrl.SetValue(StopDateTimeValueProperty, StopTime);
                if (UIDateTimeCtrl.BeginDateTimeChanged != null)
                {
                    UIDateTimeCtrl.BeginDateTimeChanged(BeginTime);
                }
                if (UIDateTimeCtrl.StopDateTimeChanged != null)
                {
                    UIDateTimeCtrl.StopDateTimeChanged(StopTime);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 结束时间
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void StopDateTimeValueChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DateTime dtNew    = DateTime.Now;
            string   newValue = e.NewValue == null ? "" : e.NewValue.ToString();

            if (DateTime.TryParse(newValue.ToString(), out dtNew))
            {
            }
            UIDateTime thisDateTime = d as UIDateTime;

            if (dtNew < thisDateTime.baseTime)
            {
                return;
            }
            string hor   = dtNew.Hour.ToString().PadLeft(2, '0');
            string minit = dtNew.Minute.ToString().PadLeft(2, '0');


            int type = (int)thisDateTime.GetValue(DateTimeTypeProperty);

            //if (type == -1)
            //{
            //    thisDateTime.SetValue(BeginDateValue_allProperty, dtNew);
            //    thisDateTime.SetValue(HourValue_allProperty, hor);
            //    thisDateTime.SetValue(MinitValue_allProperty, minit);
            //    //thisDateTime.SetValue(DateValue_customProperty, dtNew);
            //    thisDateTime.SetValue(BeginHourValue_customProperty, hor);
            //    thisDateTime.SetValue(BeginMinitValue_customProperty, minit);
            //}


            if (type == 0)
            {
                thisDateTime.SetValue(StopDateValue_allProperty, dtNew);
                thisDateTime.SetValue(HourValue_allProperty, hor);
                thisDateTime.SetValue(MinitValue_allProperty, minit);
            }
            else
            {
                thisDateTime.SetValue(DateValue_customProperty, dtNew);
                thisDateTime.SetValue(StopHourValue_customProperty, hor);
                thisDateTime.SetValue(StopMinitValue_customProperty, minit);
            }
            //UIDateTime thisDateTime = d as UIDateTime;
            //string newValue = e.NewValue == null ? "" : e.NewValue.ToString();
            //string[] t = newValue.Split(' ');
            //if (t.Length == 2)
            //{
            //    thisDateTime.SetValue(DateValueProperty, t[0]);
            //    string[] t2 = t[1].Split(':');
            //    if (t2.Length == 2)
            //    {
            //        thisDateTime.SetValue(HourValueProperty, t2[0]);
            //        thisDateTime.SetValue(MinitValueProperty, t2[1]);
            //    }
            //}
        }