Beispiel #1
0
        private void CmdBindPasteTimeExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            int Hour, Minute, Second;

            if (TimeCtrlExtensions.IsValidTime((string)System.Windows.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);
            }
        }
Beispiel #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 == SystemDateInfo.AMDesignator[Idx].ToString()) ?
                   SystemDateInfo.PMDesignator[Idx].ToString() : SystemDateInfo.AMDesignator[Idx].ToString();
     }
     AM_PM_Handle(tb);
 }
Beispiel #3
0
        private string GetFormatedStr(TimeEntry te)
        {
            string strFormat = "";
            string strAMPM   = (te.Hour >= 12) ? SystemDateInfo.PMDesignator : SystemDateInfo.AMDesignator;
            char   AMPMShort = (te.Hour >= 12) ? SystemDateInfo.PMDesignator[TimeCtrlExtensions.Get_t_Idx()] :
                               SystemDateInfo.AMDesignator[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));
        }
Beispiel #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 == SystemDateInfo.AMDesignator[TimeCtrlExtensions.Get_t_Idx()].ToString());
            }

            Value = Value.Reset_AM_PM_Time(IsAm);

            tb.SelectAll();
        }
Beispiel #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;
                }
            }
        }
Beispiel #6
0
        void CmdBindPasteTimeCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            int Hour, Minute, Second;

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