コード例 #1
0
        public static void MinuteChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            int         min;
            HourControl THIS = d as HourControl;

            try
            {
                string str   = (string)e.NewValue;
                string final = "";

                min = int.Parse(str);
                if (min < 0 || min > 60)
                {
                    throw new Exception();
                }
                if (min < 10)
                {
                    final = "0" + min.ToString();
                }
                else
                {
                    final = min.ToString();
                }
                THIS.mm = final;
            }
            catch
            {
                MessageBox.Show(
                    "Only numbers between 0 and 59.",
                    "WARNING",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
            THIS.CheckMinute();
        }
コード例 #2
0
        public static void TimeChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HourControl THIS = d as HourControl;

            THIS.tt = (DateTime)e.NewValue;

            THIS.hh             = THIS.tt.Hour.ToString();
            THIS.hour.Content   = THIS.hh;
            THIS.mm             = THIS.tt.Minute.ToString();
            THIS.minute.Content = THIS.mm;

            TimeEventArgs args = new TimeEventArgs(THIS.tt);

            THIS.OnTimeChanged(args);
        }
コード例 #3
0
        public static void HourChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            int         hr;
            HourControl THIS = d as HourControl;

            string str   = (string)e.NewValue;
            string final = "";

            hr = int.Parse(str);
            if (hr < 0 || hr > 23)
            {
                throw new Exception();
            }
            if (hr < 10)
            {
                final = "0" + hr.ToString();
            }
            else
            {
                final = hr.ToString();
            }
            THIS.hh = final;
            THIS.CheckHour();
        }