コード例 #1
0
        private void CmdBindPasteTimeExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            int Hour, Minute, Second;

            if (TimeCtrlExtensions.IsValidTime((string)Clipboard.GetData("Text"), TimePattern, out Hour, out Minute, out Second))
            {
                Value = new DateTime(Value.Year, Value.Month, Value.Day, Hour, Minute, Second, Value.Millisecond, Value.Kind);
            }
        }
コード例 #2
0
 void AM_PM_Change(TextBox tb)
 {
     if (tb.get_HMSType() == HMSType.tt)
     {
         tb.Text = (tb.Text == SystemDateInfo.AMDesignator) ? SystemDateInfo.PMDesignator : SystemDateInfo.AMDesignator;
     }
     else // tb.get_HMSType() == HMSType.t
     {
         int Idx = TimeCtrlExtensions.Get_t_Idx();
         tb.Text = (tb.Text == TimeCtrlExtensions.GetAMDesignatorChar(Idx)) ?
                   TimeCtrlExtensions.GetPMDesignatorChar(Idx) : TimeCtrlExtensions.GetAMDesignatorChar(Idx);
     }
     AM_PM_Handle(tb);
 }
コード例 #3
0
        private string GetFormatedStr(TimeEntry te)
        {
            string strFormat = "";
            string strAMPM   = (te.Hour >= 12) ? SystemDateInfo.PMDesignator : SystemDateInfo.AMDesignator;
            string AMPMShort = (te.Hour >= 12) ? TimeCtrlExtensions.GetPMDesignatorChar(TimeCtrlExtensions.Get_t_Idx()) :
                               TimeCtrlExtensions.GetAMDesignatorChar(TimeCtrlExtensions.Get_t_Idx());

            foreach (FrameworkElement fe in TimeCtrls.Children)
            {
                strFormat += fe.get_TextFormat();
            }

            return(string.Format(strFormat, te.Hour, te.Hour.Get12Hour(), te.Minute, te.Second, strAMPM, AMPMShort));
        }
コード例 #4
0
        void AM_PM_Handle(TextBox tb)
        {
            bool IsAm;

            if (tb.get_HMSType() == HMSType.tt)
            {
                IsAm = (tb.Text == SystemDateInfo.AMDesignator);
            }
            else // tb.get_HMSType() == HMSType.t
            {
                IsAm = (tb.Text == TimeCtrlExtensions.GetAMDesignatorChar(TimeCtrlExtensions.Get_t_Idx()));
            }

            Value = Value.Reset_AM_PM_Time(IsAm);

            tb.SelectAll();
        }
コード例 #5
0
        void tb_tt_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            TextBox tb = sender as TextBox;

            if (tb != null)
            {
                int Idx = TimeCtrlExtensions.Get_t_Idx();

                if (!AM_PM_HandleInput(tb, e.Text, SystemDateInfo.AMDesignator, Idx))
                {
                    e.Handled = AM_PM_HandleInput(tb, e.Text, SystemDateInfo.PMDesignator, Idx);
                }
                else
                {
                    e.Handled = true;
                }
            }
        }
コード例 #6
0
        void CmdBindPasteTimeCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            int Hour, Minute, Second;

            e.CanExecute = TimeCtrlExtensions.IsValidTime((string)Clipboard.GetData("Text"), TimePattern, out Hour, out Minute, out Second);
        }