private static void GetValue(DependencyObject sender , DependencyPropertyChangedEventArgs args) { TimeControl timeControl = sender as TimeControl; if(timeControl != null) { var time = (TimeSpan)args.NewValue; timeControl.txthours.Text = string.Format("{0:00}" , time.Hours); timeControl.txtminuts.Text = string.Format("{0:00}", time.Minutes); timeControl.txtseconds.Text = string.Format("{0:00}", time.Seconds); timeControl.txtmilliseconds.Text = string.Format("{0:00}", time.Milliseconds /10); if(time.Hours == 0) timeControl.txthours.Style = timeControl.Resources["inativefont"] as Style; else timeControl.txthours.Style = timeControl.Resources["normalfont"] as Style; if (time.Minutes == 0) timeControl.txtminuts.Style = timeControl.Resources["inativefont"] as Style; else timeControl.txtminuts.Style = timeControl.Resources["normalfont"] as Style; if (time.Seconds == 0) timeControl.txtseconds.Style = timeControl.Resources["inativefont"] as Style; else timeControl.txtseconds.Style = timeControl.Resources["normalfont"] as Style; } }
private static void GetDouble(DependencyObject sender , DependencyPropertyChangedEventArgs args) { TimeControl timeControl = sender as TimeControl; if(timeControl != null) { int width = (int)(200 * (double)args.NewValue); timeControl.MainContainer.Width = width; int heght = (int)(43 * (double)args.NewValue); timeControl.MainContainer.Height = heght; int fontsize = (int)(40 * (double)args.NewValue); timeControl.txthours.FontSize = fontsize; timeControl.txtminuts.FontSize = fontsize; timeControl.txtseconds.FontSize = fontsize; timeControl.txt1.FontSize = timeControl.txt2.FontSize = timeControl.txt3.FontSize = fontsize; timeControl.txtmilliseconds.FontSize = fontsize / 2; } }