Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Windows;
|
---|
6 | using Microsoft.Research.DynamicDataDisplay.Charts.Axes;
|
---|
7 | using System.Globalization;
|
---|
8 |
|
---|
9 | namespace Microsoft.Research.DynamicDataDisplay.Charts
|
---|
10 | {
|
---|
11 | public abstract class DateTimeLabelProviderBase : LabelProviderBase<DateTime>
|
---|
12 | {
|
---|
13 | private string dateFormat;
|
---|
14 | protected string DateFormat
|
---|
15 | {
|
---|
16 | get { return dateFormat; }
|
---|
17 | set { dateFormat = value; }
|
---|
18 | }
|
---|
19 |
|
---|
20 | protected override string GetStringCore(LabelTickInfo<DateTime> tickInfo)
|
---|
21 | {
|
---|
22 | return tickInfo.Tick.ToString(dateFormat);
|
---|
23 | }
|
---|
24 |
|
---|
25 | protected virtual string GetDateFormat(DifferenceIn diff)
|
---|
26 | {
|
---|
27 | string format = null;
|
---|
28 |
|
---|
29 | switch (diff)
|
---|
30 | {
|
---|
31 | case DifferenceIn.Year:
|
---|
32 | format = "yyyy";
|
---|
33 | break;
|
---|
34 | case DifferenceIn.Month:
|
---|
35 | format = "MMM";
|
---|
36 | break;
|
---|
37 | case DifferenceIn.Day:
|
---|
38 | format = "%d";
|
---|
39 | break;
|
---|
40 | case DifferenceIn.Hour:
|
---|
41 | format = "HH:mm";
|
---|
42 | break;
|
---|
43 | case DifferenceIn.Minute:
|
---|
44 | format = "%m";
|
---|
45 | break;
|
---|
46 | case DifferenceIn.Second:
|
---|
47 | format = "ss";
|
---|
48 | break;
|
---|
49 | case DifferenceIn.Millisecond:
|
---|
50 | format = "fff";
|
---|
51 | break;
|
---|
52 | default:
|
---|
53 | break;
|
---|
54 | }
|
---|
55 |
|
---|
56 | return format;
|
---|
57 | }
|
---|
58 | }
|
---|
59 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.