|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
using System.Collections; |
|
|
using System.Text; |
|
|
using System.Drawing; |
|
|
using System.Runtime.Serialization; |
|
|
using System.Security.Permissions; |
|
|
|
|
|
namespace ZedGraph |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Serializable] |
|
|
class DateScale : Scale, ISerializable |
|
|
{ |
|
|
|
|
|
#region constructors |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DateScale( Axis owner ) |
|
|
: base( owner ) |
|
|
{ |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DateScale( Scale rhs, Axis owner ) |
|
|
: base( rhs, owner ) |
|
|
{ |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override Scale Clone( Axis owner ) |
|
|
{ |
|
|
return new DateScale( this, owner ); |
|
|
} |
|
|
|
|
|
#endregion |
|
|
|
|
|
#region properties |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override AxisType Type |
|
|
{ |
|
|
get { return AxisType.Date; } |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override double Min |
|
|
{ |
|
|
get { return _min; } |
|
|
set { _min = XDate.MakeValidDate( value ); _minAuto = false; } |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override double Max |
|
|
{ |
|
|
get { return _max; } |
|
|
set { _max = XDate.MakeValidDate( value ); _maxAuto = false; } |
|
|
} |
|
|
#endregion |
|
|
|
|
|
#region methods |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override internal double CalcMajorTicValue( double baseVal, double tic ) |
|
|
{ |
|
|
XDate xDate = new XDate( baseVal ); |
|
|
|
|
|
switch ( _majorUnit ) |
|
|
{ |
|
|
case DateUnit.Year: |
|
|
default: |
|
|
xDate.AddYears( tic * _majorStep ); |
|
|
break; |
|
|
case DateUnit.Month: |
|
|
xDate.AddMonths( tic * _majorStep ); |
|
|
break; |
|
|
case DateUnit.Day: |
|
|
xDate.AddDays( tic * _majorStep ); |
|
|
break; |
|
|
case DateUnit.Hour: |
|
|
xDate.AddHours( tic * _majorStep ); |
|
|
break; |
|
|
case DateUnit.Minute: |
|
|
xDate.AddMinutes( tic * _majorStep ); |
|
|
break; |
|
|
case DateUnit.Second: |
|
|
xDate.AddSeconds( tic * _majorStep ); |
|
|
break; |
|
|
case DateUnit.Millisecond: |
|
|
xDate.AddMilliseconds( tic * _majorStep ); |
|
|
break; |
|
|
} |
|
|
|
|
|
return xDate.XLDate; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override internal double CalcMinorTicValue( double baseVal, int iTic ) |
|
|
{ |
|
|
XDate xDate = new XDate( baseVal ); |
|
|
|
|
|
switch ( _minorUnit ) |
|
|
{ |
|
|
case DateUnit.Year: |
|
|
default: |
|
|
xDate.AddYears( (double) iTic * _minorStep ); |
|
|
break; |
|
|
case DateUnit.Month: |
|
|
xDate.AddMonths( (double) iTic * _minorStep ); |
|
|
break; |
|
|
case DateUnit.Day: |
|
|
xDate.AddDays( (double) iTic * _minorStep ); |
|
|
break; |
|
|
case DateUnit.Hour: |
|
|
xDate.AddHours( (double) iTic * _minorStep ); |
|
|
break; |
|
|
case DateUnit.Minute: |
|
|
xDate.AddMinutes( (double) iTic * _minorStep ); |
|
|
break; |
|
|
case DateUnit.Second: |
|
|
xDate.AddSeconds( (double) iTic * _minorStep ); |
|
|
break; |
|
|
} |
|
|
|
|
|
return xDate.XLDate; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override internal int CalcMinorStart( double baseVal ) |
|
|
{ |
|
|
switch ( _minorUnit ) |
|
|
{ |
|
|
case DateUnit.Year: |
|
|
default: |
|
|
return (int) ( ( _min - baseVal ) / ( 365.0 * _minorStep ) ); |
|
|
case DateUnit.Month: |
|
|
return (int) ( ( _min - baseVal ) / ( 28.0 * _minorStep ) ); |
|
|
case DateUnit.Day: |
|
|
return (int) ( ( _min - baseVal ) / _minorStep ); |
|
|
case DateUnit.Hour: |
|
|
return (int) ( ( _min - baseVal ) * XDate.HoursPerDay / _minorStep ); |
|
|
case DateUnit.Minute: |
|
|
return (int) ( ( _min - baseVal ) * XDate.MinutesPerDay / _minorStep ); |
|
|
case DateUnit.Second: |
|
|
return (int) ( ( _min - baseVal ) * XDate.SecondsPerDay / _minorStep ); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override internal double CalcBaseTic() |
|
|
{ |
|
|
if ( _baseTic != PointPair.Missing ) |
|
|
return _baseTic; |
|
|
else |
|
|
{ |
|
|
int year, month, day, hour, minute, second, millisecond; |
|
|
XDate.XLDateToCalendarDate( _min, out year, out month, out day, out hour, out minute, |
|
|
out second, out millisecond ); |
|
|
switch ( _majorUnit ) |
|
|
{ |
|
|
case DateUnit.Year: |
|
|
default: |
|
|
month = 1; day = 1; hour = 0; minute = 0; second = 0; millisecond = 0; |
|
|
break; |
|
|
case DateUnit.Month: |
|
|
day = 1; hour = 0; minute = 0; second = 0; millisecond = 0; |
|
|
break; |
|
|
case DateUnit.Day: |
|
|
hour = 0; minute = 0; second = 0; millisecond = 0; |
|
|
break; |
|
|
case DateUnit.Hour: |
|
|
minute = 0; second = 0; millisecond = 0; |
|
|
break; |
|
|
case DateUnit.Minute: |
|
|
second = 0; millisecond = 0; |
|
|
break; |
|
|
case DateUnit.Second: |
|
|
millisecond = 0; |
|
|
break; |
|
|
case DateUnit.Millisecond: |
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
double xlDate = XDate.CalendarDateToXLDate( year, month, day, hour, minute, second, millisecond ); |
|
|
if ( xlDate < _min ) |
|
|
{ |
|
|
switch ( _majorUnit ) |
|
|
{ |
|
|
case DateUnit.Year: |
|
|
default: |
|
|
year++; |
|
|
break; |
|
|
case DateUnit.Month: |
|
|
month++; |
|
|
break; |
|
|
case DateUnit.Day: |
|
|
day++; |
|
|
break; |
|
|
case DateUnit.Hour: |
|
|
hour++; |
|
|
break; |
|
|
case DateUnit.Minute: |
|
|
minute++; |
|
|
break; |
|
|
case DateUnit.Second: |
|
|
second++; |
|
|
break; |
|
|
case DateUnit.Millisecond: |
|
|
millisecond++; |
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
xlDate = XDate.CalendarDateToXLDate( year, month, day, hour, minute, second, millisecond ); |
|
|
} |
|
|
|
|
|
return xlDate; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override internal int CalcNumTics() |
|
|
{ |
|
|
int nTics = 1; |
|
|
|
|
|
int year1, year2, month1, month2, day1, day2, hour1, hour2, minute1, minute2; |
|
|
int second1, second2, millisecond1, millisecond2; |
|
|
|
|
|
XDate.XLDateToCalendarDate( _min, out year1, out month1, out day1, |
|
|
out hour1, out minute1, out second1, out millisecond1 ); |
|
|
XDate.XLDateToCalendarDate( _max, out year2, out month2, out day2, |
|
|
out hour2, out minute2, out second2, out millisecond2 ); |
|
|
|
|
|
switch ( _majorUnit ) |
|
|
{ |
|
|
case DateUnit.Year: |
|
|
default: |
|
|
nTics = (int) ( ( year2 - year1 ) / _majorStep + 1.001 ); |
|
|
break; |
|
|
case DateUnit.Month: |
|
|
nTics = (int) ( ( month2 - month1 + 12.0 * ( year2 - year1 ) ) / _majorStep + 1.001 ); |
|
|
break; |
|
|
case DateUnit.Day: |
|
|
nTics = (int) ( ( _max - _min ) / _majorStep + 1.001 ); |
|
|
break; |
|
|
case DateUnit.Hour: |
|
|
nTics = (int) ( ( _max - _min ) / ( _majorStep / XDate.HoursPerDay ) + 1.001 ); |
|
|
break; |
|
|
case DateUnit.Minute: |
|
|
nTics = (int) ( ( _max - _min ) / ( _majorStep / XDate.MinutesPerDay ) + 1.001 ); |
|
|
break; |
|
|
case DateUnit.Second: |
|
|
nTics = (int)( ( _max - _min ) / ( _majorStep / XDate.SecondsPerDay ) + 1.001 ); |
|
|
break; |
|
|
case DateUnit.Millisecond: |
|
|
nTics = (int)( ( _max - _min ) / ( _majorStep / XDate.MillisecondsPerDay ) + 1.001 ); |
|
|
break; |
|
|
} |
|
|
|
|
|
if ( nTics < 1 ) |
|
|
nTics = 1; |
|
|
else if ( nTics > 1000 ) |
|
|
nTics = 1000; |
|
|
|
|
|
return nTics; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override public void PickScale( GraphPane pane, Graphics g, float scaleFactor ) |
|
|
{ |
|
|
|
|
|
base.PickScale( pane, g, scaleFactor ); |
|
|
|
|
|
|
|
|
if ( _max - _min < 1.0e-20 ) |
|
|
{ |
|
|
if ( _maxAuto ) |
|
|
_max = _max + 0.2 * ( _max == 0 ? 1.0 : Math.Abs( _max ) ); |
|
|
if ( _minAuto ) |
|
|
_min = _min - 0.2 * ( _min == 0 ? 1.0 : Math.Abs( _min ) ); |
|
|
} |
|
|
|
|
|
double targetSteps = ( _ownerAxis is XAxis || _ownerAxis is X2Axis ) ? |
|
|
Default.TargetXSteps : Default.TargetYSteps; |
|
|
|
|
|
|
|
|
double tempStep = CalcDateStepSize( _max - _min, targetSteps ); |
|
|
|
|
|
|
|
|
if ( _majorStepAuto ) |
|
|
{ |
|
|
_majorStep = tempStep; |
|
|
|
|
|
if ( _isPreventLabelOverlap ) |
|
|
{ |
|
|
|
|
|
double maxLabels = (double) this.CalcMaxLabels( g, pane, scaleFactor ); |
|
|
|
|
|
if ( maxLabels < this.CalcNumTics() ) |
|
|
_majorStep = CalcDateStepSize( _max - _min, maxLabels ); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ( _minAuto ) |
|
|
_min = CalcEvenStepDate( _min, -1 ); |
|
|
|
|
|
|
|
|
if ( _maxAuto ) |
|
|
_max = CalcEvenStepDate( _max, 1 ); |
|
|
|
|
|
_mag = 0; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected double CalcDateStepSize( double range, double targetSteps ) |
|
|
{ |
|
|
return CalcDateStepSize( range, targetSteps, this ); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal static double CalcDateStepSize( double range, double targetSteps, Scale scale ) |
|
|
{ |
|
|
|
|
|
double tempStep = range / targetSteps; |
|
|
|
|
|
if ( range > Default.RangeYearYear ) |
|
|
{ |
|
|
scale._majorUnit = DateUnit.Year; |
|
|
if ( scale._formatAuto ) |
|
|
scale._format = Default.FormatYearYear; |
|
|
|
|
|
tempStep = Math.Ceiling( tempStep / 365.0 ); |
|
|
|
|
|
if ( scale._minorStepAuto ) |
|
|
{ |
|
|
scale._minorUnit = DateUnit.Year; |
|
|
if ( tempStep == 1.0 ) |
|
|
scale._minorStep = 0.25; |
|
|
else |
|
|
scale._minorStep = Scale.CalcStepSize( tempStep, targetSteps ); |
|
|
} |
|
|
} |
|
|
else if ( range > Default.RangeYearMonth ) |
|
|
{ |
|
|
scale._majorUnit = DateUnit.Year; |
|
|
if ( scale._formatAuto ) |
|
|
scale._format = Default.FormatYearMonth; |
|
|
tempStep = Math.Ceiling( tempStep / 365.0 ); |
|
|
|
|
|
if ( scale._minorStepAuto ) |
|
|
{ |
|
|
scale._minorUnit = DateUnit.Month; |
|
|
|
|
|
|
|
|
scale._minorStep = Math.Ceiling( range / ( targetSteps * 3 ) / 30.0 ); |
|
|
|
|
|
if ( scale._minorStep > 6 ) |
|
|
scale._minorStep = 12; |
|
|
else if ( scale._minorStep > 3 ) |
|
|
scale._minorStep = 6; |
|
|
} |
|
|
} |
|
|
else if ( range > Default.RangeMonthMonth ) |
|
|
{ |
|
|
scale._majorUnit = DateUnit.Month; |
|
|
if ( scale._formatAuto ) |
|
|
scale._format = Default.FormatMonthMonth; |
|
|
tempStep = Math.Ceiling( tempStep / 30.0 ); |
|
|
|
|
|
if ( scale._minorStepAuto ) |
|
|
{ |
|
|
scale._minorUnit = DateUnit.Month; |
|
|
scale._minorStep = tempStep * 0.25; |
|
|
} |
|
|
} |
|
|
else if ( range > Default.RangeDayDay ) |
|
|
{ |
|
|
scale._majorUnit = DateUnit.Day; |
|
|
if ( scale._formatAuto ) |
|
|
scale._format = Default.FormatDayDay; |
|
|
tempStep = Math.Ceiling( tempStep ); |
|
|
|
|
|
if ( scale._minorStepAuto ) |
|
|
{ |
|
|
scale._minorUnit = DateUnit.Day; |
|
|
scale._minorStep = tempStep * 0.25; |
|
|
|
|
|
} |
|
|
} |
|
|
else if ( range > Default.RangeDayHour ) |
|
|
{ |
|
|
scale._majorUnit = DateUnit.Day; |
|
|
if ( scale._formatAuto ) |
|
|
scale._format = Default.FormatDayHour; |
|
|
tempStep = Math.Ceiling( tempStep ); |
|
|
|
|
|
if ( scale._minorStepAuto ) |
|
|
{ |
|
|
scale._minorUnit = DateUnit.Hour; |
|
|
|
|
|
|
|
|
scale._minorStep = Math.Ceiling( range / ( targetSteps * 3 ) * XDate.HoursPerDay ); |
|
|
|
|
|
if ( scale._minorStep > 6 ) |
|
|
scale._minorStep = 12; |
|
|
else if ( scale._minorStep > 3 ) |
|
|
scale._minorStep = 6; |
|
|
else |
|
|
scale._minorStep = 1; |
|
|
} |
|
|
} |
|
|
else if ( range > Default.RangeHourHour ) |
|
|
{ |
|
|
scale._majorUnit = DateUnit.Hour; |
|
|
tempStep = Math.Ceiling( tempStep * XDate.HoursPerDay ); |
|
|
if ( scale._formatAuto ) |
|
|
scale._format = Default.FormatHourHour; |
|
|
|
|
|
if ( tempStep > 12.0 ) |
|
|
tempStep = 24.0; |
|
|
else if ( tempStep > 6.0 ) |
|
|
tempStep = 12.0; |
|
|
else if ( tempStep > 2.0 ) |
|
|
tempStep = 6.0; |
|
|
else if ( tempStep > 1.0 ) |
|
|
tempStep = 2.0; |
|
|
else |
|
|
tempStep = 1.0; |
|
|
|
|
|
if ( scale._minorStepAuto ) |
|
|
{ |
|
|
scale._minorUnit = DateUnit.Hour; |
|
|
if ( tempStep <= 1.0 ) |
|
|
scale._minorStep = 0.25; |
|
|
else if ( tempStep <= 6.0 ) |
|
|
scale._minorStep = 1.0; |
|
|
else if ( tempStep <= 12.0 ) |
|
|
scale._minorStep = 2.0; |
|
|
else |
|
|
scale._minorStep = 4.0; |
|
|
} |
|
|
} |
|
|
else if ( range > Default.RangeHourMinute ) |
|
|
{ |
|
|
scale._majorUnit = DateUnit.Hour; |
|
|
tempStep = Math.Ceiling( tempStep * XDate.HoursPerDay ); |
|
|
|
|
|
if ( scale._formatAuto ) |
|
|
scale._format = Default.FormatHourMinute; |
|
|
|
|
|
if ( scale._minorStepAuto ) |
|
|
{ |
|
|
scale._minorUnit = DateUnit.Minute; |
|
|
|
|
|
|
|
|
scale._minorStep = Math.Ceiling( range / ( targetSteps * 3 ) * XDate.MinutesPerDay ); |
|
|
|
|
|
if ( scale._minorStep > 15.0 ) |
|
|
scale._minorStep = 30.0; |
|
|
else if ( scale._minorStep > 5.0 ) |
|
|
scale._minorStep = 15.0; |
|
|
else if ( scale._minorStep > 1.0 ) |
|
|
scale._minorStep = 5.0; |
|
|
else |
|
|
scale._minorStep = 1.0; |
|
|
} |
|
|
} |
|
|
else if ( range > Default.RangeMinuteMinute ) |
|
|
{ |
|
|
scale._majorUnit = DateUnit.Minute; |
|
|
if ( scale._formatAuto ) |
|
|
scale._format = Default.FormatMinuteMinute; |
|
|
|
|
|
tempStep = Math.Ceiling( tempStep * XDate.MinutesPerDay ); |
|
|
|
|
|
if ( tempStep > 15.0 ) |
|
|
tempStep = 30.0; |
|
|
else if ( tempStep > 5.0 ) |
|
|
tempStep = 15.0; |
|
|
else if ( tempStep > 1.0 ) |
|
|
tempStep = 5.0; |
|
|
else |
|
|
tempStep = 1.0; |
|
|
|
|
|
if ( scale._minorStepAuto ) |
|
|
{ |
|
|
scale._minorUnit = DateUnit.Minute; |
|
|
if ( tempStep <= 1.0 ) |
|
|
scale._minorStep = 0.25; |
|
|
else if ( tempStep <= 5.0 ) |
|
|
scale._minorStep = 1.0; |
|
|
else |
|
|
scale._minorStep = 5.0; |
|
|
} |
|
|
} |
|
|
else if ( range > Default.RangeMinuteSecond ) |
|
|
{ |
|
|
scale._majorUnit = DateUnit.Minute; |
|
|
tempStep = Math.Ceiling( tempStep * XDate.MinutesPerDay ); |
|
|
|
|
|
if ( scale._formatAuto ) |
|
|
scale._format = Default.FormatMinuteSecond; |
|
|
|
|
|
if ( scale._minorStepAuto ) |
|
|
{ |
|
|
scale._minorUnit = DateUnit.Second; |
|
|
|
|
|
|
|
|
scale._minorStep = Math.Ceiling( range / ( targetSteps * 3 ) * XDate.SecondsPerDay ); |
|
|
|
|
|
if ( scale._minorStep > 15.0 ) |
|
|
scale._minorStep = 30.0; |
|
|
else if ( scale._minorStep > 5.0 ) |
|
|
scale._minorStep = 15.0; |
|
|
else if ( scale._minorStep > 1.0 ) |
|
|
scale._minorStep = 5.0; |
|
|
else |
|
|
scale._minorStep = 1.0; |
|
|
} |
|
|
} |
|
|
else if ( range > Default.RangeSecondSecond ) |
|
|
{ |
|
|
scale._majorUnit = DateUnit.Second; |
|
|
if ( scale._formatAuto ) |
|
|
scale._format = Default.FormatSecondSecond; |
|
|
|
|
|
tempStep = Math.Ceiling( tempStep * XDate.SecondsPerDay ); |
|
|
|
|
|
if ( tempStep > 15.0 ) |
|
|
tempStep = 30.0; |
|
|
else if ( tempStep > 5.0 ) |
|
|
tempStep = 15.0; |
|
|
else if ( tempStep > 1.0 ) |
|
|
tempStep = 5.0; |
|
|
else |
|
|
tempStep = 1.0; |
|
|
|
|
|
if ( scale._minorStepAuto ) |
|
|
{ |
|
|
scale._minorUnit = DateUnit.Second; |
|
|
if ( tempStep <= 1.0 ) |
|
|
scale._minorStep = 0.25; |
|
|
else if ( tempStep <= 5.0 ) |
|
|
scale._minorStep = 1.0; |
|
|
else |
|
|
scale._minorStep = 5.0; |
|
|
} |
|
|
} |
|
|
else |
|
|
{ |
|
|
scale._majorUnit = DateUnit.Millisecond; |
|
|
if ( scale._formatAuto ) |
|
|
scale._format = Default.FormatMillisecond; |
|
|
|
|
|
tempStep = CalcStepSize( range * XDate.MillisecondsPerDay, Default.TargetXSteps ); |
|
|
|
|
|
if ( scale._minorStepAuto ) |
|
|
{ |
|
|
scale._minorStep = CalcStepSize( tempStep, |
|
|
( scale._ownerAxis is XAxis || scale._ownerAxis is X2Axis ) ? |
|
|
Default.TargetMinorXSteps : Default.TargetMinorYSteps ); |
|
|
scale._minorUnit = DateUnit.Millisecond; |
|
|
} |
|
|
} |
|
|
|
|
|
return tempStep; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected double CalcEvenStepDate( double date, int direction ) |
|
|
{ |
|
|
int year, month, day, hour, minute, second, millisecond; |
|
|
|
|
|
XDate.XLDateToCalendarDate( date, out year, out month, out day, |
|
|
out hour, out minute, out second, out millisecond ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( direction < 0 ) |
|
|
direction = 0; |
|
|
|
|
|
switch ( _majorUnit ) |
|
|
{ |
|
|
case DateUnit.Year: |
|
|
default: |
|
|
|
|
|
if ( direction == 1 && month == 1 && day == 1 && hour == 0 |
|
|
&& minute == 0 && second == 0 ) |
|
|
return date; |
|
|
else |
|
|
return XDate.CalendarDateToXLDate( year + direction, 1, 1, |
|
|
0, 0, 0 ); |
|
|
case DateUnit.Month: |
|
|
|
|
|
if ( direction == 1 && day == 1 && hour == 0 |
|
|
&& minute == 0 && second == 0 ) |
|
|
return date; |
|
|
else |
|
|
return XDate.CalendarDateToXLDate( year, month + direction, 1, |
|
|
0, 0, 0 ); |
|
|
case DateUnit.Day: |
|
|
|
|
|
if ( direction == 1 && hour == 0 && minute == 0 && second == 0 ) |
|
|
return date; |
|
|
else |
|
|
return XDate.CalendarDateToXLDate( year, month, |
|
|
day + direction, 0, 0, 0 ); |
|
|
case DateUnit.Hour: |
|
|
|
|
|
if ( direction == 1 && minute == 0 && second == 0 ) |
|
|
return date; |
|
|
else |
|
|
return XDate.CalendarDateToXLDate( year, month, day, |
|
|
hour + direction, 0, 0 ); |
|
|
case DateUnit.Minute: |
|
|
|
|
|
if ( direction == 1 && second == 0 ) |
|
|
return date; |
|
|
else |
|
|
return XDate.CalendarDateToXLDate( year, month, day, hour, |
|
|
minute + direction, 0 ); |
|
|
case DateUnit.Second: |
|
|
return XDate.CalendarDateToXLDate( year, month, day, hour, |
|
|
minute, second + direction ); |
|
|
|
|
|
case DateUnit.Millisecond: |
|
|
return XDate.CalendarDateToXLDate( year, month, day, hour, |
|
|
minute, second, millisecond + direction ); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override internal string MakeLabel( GraphPane pane, int index, double dVal ) |
|
|
{ |
|
|
if ( _format == null ) |
|
|
_format = Scale.Default.Format; |
|
|
|
|
|
return XDate.ToString( dVal, _format ); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override internal double MajorUnitMultiplier |
|
|
{ |
|
|
get { return GetUnitMultiple( _majorUnit ); } |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override internal double MinorUnitMultiplier |
|
|
{ |
|
|
get { return GetUnitMultiple( _minorUnit ); } |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private double GetUnitMultiple( DateUnit unit ) |
|
|
{ |
|
|
switch ( unit ) |
|
|
{ |
|
|
case DateUnit.Year: |
|
|
default: |
|
|
return 365.0; |
|
|
case DateUnit.Month: |
|
|
return 30.0; |
|
|
case DateUnit.Day: |
|
|
return 1.0; |
|
|
case DateUnit.Hour: |
|
|
return 1.0 / XDate.HoursPerDay; |
|
|
case DateUnit.Minute: |
|
|
return 1.0 / XDate.MinutesPerDay; |
|
|
case DateUnit.Second: |
|
|
return 1.0 / XDate.SecondsPerDay; |
|
|
case DateUnit.Millisecond: |
|
|
return 1.0 / XDate.MillisecondsPerDay; |
|
|
} |
|
|
} |
|
|
|
|
|
#endregion |
|
|
|
|
|
#region Serialization |
|
|
|
|
|
|
|
|
|
|
|
public const int schema2 = 10; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected DateScale( SerializationInfo info, StreamingContext context ) : base( info, context ) |
|
|
{ |
|
|
|
|
|
|
|
|
int sch = info.GetInt32( "schema2" ); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[SecurityPermissionAttribute(SecurityAction.Demand,SerializationFormatter=true)] |
|
|
public override void GetObjectData( SerializationInfo info, StreamingContext context ) |
|
|
{ |
|
|
base.GetObjectData( info, context ); |
|
|
info.AddValue( "schema2", schema2 ); |
|
|
} |
|
|
#endregion |
|
|
|
|
|
} |
|
|
} |
|
|
|