public TimeLine() { InitializeComponent(); DataContext = this; Intervals = new List <Interval>(); FullTime = TimeSpan.FromSeconds(450); T1.T_full = FullTime; T1.T_el = TimeSpan.FromSeconds(60); T1.ChangeDashesHeight(12); T1.ChangeDashesWidth(1); T2.T_full = FullTime; T2.T_el = TimeSpan.FromSeconds(10); T2.ChangeDashesHeight(6); Cursor1.Container = this; Binding binding = new Binding(); binding.ElementName = "Cursor1"; // элемент-источник binding.Path = new PropertyPath("CRPosition"); // свойство элемента-источника binding.Mode = BindingMode.TwoWay; this.SetBinding(TimeLine.POSProperty, binding); // установка привязки для элемента-приемника OnPOSChanged += TimeLine_OnPOSChanged; Cursor1.OnCRPChanged += Cursor1_OnCRPChanged; Cursor1.OnStartDrag += Cursor1_OnStartDrag; Cursor1.OnEndDrag += Cursor1_OnEndDrag; OnSelectedItemChanged += TimeLine_OnSelectedItemChanged; }
void RefreshDashes() { T1.T_full = FullTime; T2.T_full = FullTime; T10.T_full = FullTime; T1.T_el = TimeSpan.FromSeconds(60); T2.T_el = TimeSpan.FromSeconds(10); T10.T_el = TimeSpan.FromSeconds(600); int N = (int)Math.Round((FullTime.TotalSeconds / T1.T_el.TotalSeconds)) + 1; T1.ClearDashes(); T1.FillDashes(N); N = (int)Math.Round((FullTime.TotalSeconds / T2.T_el.TotalSeconds)) + 1; T2.ClearDashes(); T2.FillDashes(N); N = (int)Math.Round((FullTime.TotalSeconds / T10.T_el.TotalSeconds)) + 1; T10.ClearDashes(); T10.FillDashes(N); T1.ChangeDashesHeight(12); T1.ChangeDashesWidth(1); T2.ChangeDashesHeight(6); T10.ChangeDashesHeight(18); T10.ChangeDashesWidth(2); T1.Visibility = Visibility.Visible; T2.Visibility = Visibility.Visible; T10.Visibility = Visibility.Visible; if (FullTime < TimeSpan.FromMinutes(1)) { T1.TimeLabelVisibility = Visibility.Hidden; T2.TimeLabelVisibility = Visibility.Visible; T10.TimeLabelVisibility = Visibility.Hidden; } else if (FullTime < TimeSpan.FromMinutes(20)) { T1.TimeLabelVisibility = Visibility.Visible; T2.TimeLabelVisibility = Visibility.Hidden; T10.TimeLabelVisibility = Visibility.Hidden; } else if (FullTime >= TimeSpan.FromMinutes(20)) { T1.TimeLabelVisibility = Visibility.Hidden; T2.TimeLabelVisibility = Visibility.Hidden; T10.TimeLabelVisibility = Visibility.Visible; T2.Visibility = Visibility.Hidden; } }
public TimeLine() { InitializeComponent(); Intervals = new ObservableCollection <Interval>(); FullTime = TimeSpan.FromSeconds(450); T1.T_full = FullTime; T1.T_el = TimeSpan.FromSeconds(60); T1.ChangeDashesHeight(12); T1.ChangeDashesWidth(1); T2.T_full = FullTime; T2.T_el = TimeSpan.FromSeconds(10); T2.ChangeDashesHeight(6); Cursor1.Container = this; }