11using System ;
22using System . Linq ;
33using System . Windows ;
4+ using Whathecode . System ;
45using Whathecode . System . Linq ;
56using Whathecode . System . Windows . Controls ;
67using Whathecode . System . Windows . DependencyPropertyFactory ;
@@ -36,21 +37,21 @@ public TimeLineLabelFactories LabelFactories
3637 set { Factory . SetValue ( this , TimeLineProperties . LabelFactories , value ) ; }
3738 }
3839
39- [ DependencyProperty ( TimeLineProperties . DominantTickFactory ) ]
40+ [ DependencyProperty ( TimeLineProperties . DominantTickFactory , DefaultValue = "" ) ]
4041 public string DominantTickFactory
4142 {
4243 get { return ( string ) Factory . GetValue ( this , TimeLineProperties . DominantTickFactory ) ; }
4344 private set { Factory . SetValue ( this , TimeLineProperties . DominantTickFactory , value ) ; }
4445 }
4546
46- [ DependencyProperty ( TimeLineProperties . DominantHeaderFactory ) ]
47+ [ DependencyProperty ( TimeLineProperties . DominantHeaderFactory , DefaultValue = "" ) ]
4748 public string DominantHeaderFactory
4849 {
4950 get { return ( string ) Factory . GetValue ( this , TimeLineProperties . DominantHeaderFactory ) ; }
5051 private set { Factory . SetValue ( this , TimeLineProperties . DominantHeaderFactory , value ) ; }
5152 }
5253
53- [ DependencyProperty ( TimeLineProperties . DominantBreadcrumbFactory ) ]
54+ [ DependencyProperty ( TimeLineProperties . DominantBreadcrumbFactory , DefaultValue = "" ) ]
5455 public string DominantBreadcrumbFactory
5556 {
5657 get { return ( string ) Factory . GetValue ( this , TimeLineProperties . DominantBreadcrumbFactory ) ; }
@@ -61,8 +62,47 @@ public string DominantBreadcrumbFactory
6162 static TimeLine ( )
6263 {
6364 DefaultStyleKeyProperty . OverrideMetadata ( Type , new FrameworkPropertyMetadata ( Type ) ) ;
65+ VisibleIntervalProperty . AddOwner ( typeof ( TimeLine ) ) ;
6466 }
6567
68+ public TimeLine ( )
69+ {
70+ LabelFactories = new TimeLineLabelFactories
71+ {
72+ // Ticks, from quarters to years.
73+ new TimeLineTickFactory { Name = "Quarters" , StepSize = TimeSpan . FromMinutes ( 15 ) , MinimumPixelsBetweenLabels = 60 , OverrideGroup = "Ticks" } ,
74+ new TimeLineTickFactory { Name = "Hours" , TimeStepSize = DateTimePart . Hour , MinimumPixelsBetweenLabels = 60 , OverrideGroup = "Ticks" } ,
75+ new TimeLineTickFactory { Name = "DayQuarters" , StepSize = TimeSpan . FromHours ( 6 ) , MinimumPixelsBetweenLabels = 60 , OverrideGroup = "Ticks" } ,
76+ new TimeLineTickFactory { Name = "Days" , TimeStepSize = DateTimePart . Day , MinimumPixelsBetweenLabels = 50 , OverrideGroup = "Ticks" } ,
77+ new TimeLineTickFactory { Name = "Weeks" , StepSize = TimeSpan . FromDays ( 7 ) , MinimumPixelsBetweenLabels = 60 , OverrideGroup = "Ticks" } ,
78+ new TimeLineTickFactory { Name = "Months" , TimeStepSize = DateTimePart . Month , MinimumPixelsBetweenLabels = 50 , OverrideGroup = "Ticks" } ,
79+ new TimeLineTickFactory { Name = "Years" , TimeStepSize = DateTimePart . Year , MinimumPixelsBetweenLabels = 60 , OverrideGroup = "Ticks" } ,
80+ // Additional context labels at bottom.
81+ new TimeLineContextLabelFactory { Name = "DayContext" , TimeStepSize = DateTimePart . Day , MinimumPixelsBetweenLabels = 50 , FixedY = 100 } ,
82+ new TimeLineContextLabelFactory { Name = "MonthContext" , TimeStepSize = DateTimePart . Month , MinimumPixelsBetweenLabels = 100 , FixedY = 100 } ,
83+ new TimeLineContextLabelFactory { Name = "YearContext" , TimeStepSize = DateTimePart . Year , MinimumPixelsBetweenLabels = 100 , FixedY = 100 } ,
84+ // Header labels.
85+ new TimeLineHeaderFactory { Name = "YearHeader" , TimeStepSize = DateTimePart . Year , MinimumPixelsBetweenLabels = 200 } ,
86+ new TimeLineHeaderFactory { Name = "MonthHeader" , TimeStepSize = DateTimePart . Month , MinimumPixelsBetweenLabels = 200 } ,
87+ new TimeLineHeaderFactory { Name = "WeekHeader" , StepSize = TimeSpan . FromDays ( 7 ) , MinimumPixelsBetweenLabels = 200 } ,
88+ new TimeLineHeaderFactory { Name = "DayHeader" , TimeStepSize = DateTimePart . Day , MinimumPixelsBetweenLabels = 200 } ,
89+ new TimeLineHeaderFactory { Name = "DayQuarterHeader" , StepSize = TimeSpan . FromHours ( 6 ) , MinimumPixelsBetweenLabels = 200 } ,
90+ new TimeLineHeaderFactory { Name = "HourHeader" , TimeStepSize = DateTimePart . Hour , MinimumPixelsBetweenLabels = 200 } ,
91+ new TimeLineHeaderFactory { Name = "QuarterHeader" , StepSize = TimeSpan . FromMinutes ( 15 ) , MinimumPixelsBetweenLabels = 200 } ,
92+ // Breadcrumb labels underneath headers.
93+ new TimeLineBreadcrumbFactory { Name = "YearBreadcrumbs" , TimeStepSize = DateTimePart . Year , MinimumPixelsBetweenLabels = 200 } ,
94+ new TimeLineBreadcrumbFactory { Name = "MonthBreadcrumbs" , TimeStepSize = DateTimePart . Month , MinimumPixelsBetweenLabels = 200 } ,
95+ new TimeLineBreadcrumbFactory { Name = "WeekBreadcrumbs" , StepSize = TimeSpan . FromDays ( 7 ) , MinimumPixelsBetweenLabels = 200 } ,
96+ new TimeLineBreadcrumbFactory { Name = "DayBreadcrumbs" , TimeStepSize = DateTimePart . Day , MinimumPixelsBetweenLabels = 200 } ,
97+ new TimeLineBreadcrumbFactory { Name = "DayQuarterBreadcrumbs" , StepSize = TimeSpan . FromHours ( 6 ) , MinimumPixelsBetweenLabels = 200 } ,
98+ new TimeLineBreadcrumbFactory { Name = "HourBreadcrumbs" , TimeStepSize = DateTimePart . Hour , MinimumPixelsBetweenLabels = 200 } ,
99+ new TimeLineBreadcrumbFactory { Name = "QuarterBreadcrumbs" , StepSize = TimeSpan . FromMinutes ( 15 ) , MinimumPixelsBetweenLabels = 200 } ,
100+ // Fixed elements.
101+ new TimeLineLabelCollection { new TimeIndicator ( ) }
102+ } ;
103+ }
104+
105+
66106 public override void OnApplyTemplate ( )
67107 {
68108 base . OnApplyTemplate ( ) ;
@@ -84,10 +124,10 @@ public override void OnApplyTemplate()
84124
85125 // Get dominant header and breadcrumb factories.
86126 var dontFit = LabelFactories
87- . OfType < AbstractTimeLineHeaderFactory > ( ) // Get the smallest interval which is too large to fit the screen vertically.
127+ . OfType < TimeLineHeaderFactory > ( ) // Get the smallest interval which is too large to fit the screen vertically.
88128 . Where ( f => ( ( double ) f . MaximumLabelSize . Ticks / VisibleInterval . Size . Ticks ) * ActualWidth > ActualHeight )
89129 . ToList ( ) ;
90- AbstractTimeLineHeaderFactory currentHeaderFactory = dontFit . Count == 0 ? null : dontFit . MinBy ( f => f . MaximumLabelSize ) ;
130+ TimeLineHeaderFactory currentHeaderFactory = dontFit . Count == 0 ? null : dontFit . MinBy ( f => f . MaximumLabelSize ) ;
91131 if ( currentHeaderFactory != null )
92132 {
93133 DominantHeaderFactory = currentHeaderFactory . Name ;
0 commit comments