Skip to content

Commit 49896e2

Browse files
authored
fix: missing sign on alignment graph offset axis (#20)
1 parent 766581d commit 49896e2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

AudioAlign/AlignmentGraphWindow.xaml.cs

+22
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,28 @@ double maxIntervalSize
152152
interval = nextInterval;
153153
}
154154
}
155+
156+
/// <summary>
157+
/// Adds missing negative signs to axis labels when a custom format is used.
158+
///
159+
/// The axis formatter converts the `double`-parameter to a `TimeSpan` and formats
160+
/// it with `string.Format`. By default, when no custom format is specified, it adds
161+
/// the negative sign to negative time spans.
162+
/// When specifying a custom format, the negative sign is no longer added (only to time
163+
/// spans; it is still added to other types), so it needs to be additionally added
164+
/// to the formatted string.
165+
/// </summary>
166+
protected override string FormatValueOverride(double x)
167+
{
168+
var format = base.FormatValueOverride(x);
169+
170+
if (StringFormat != null && x < 0)
171+
{
172+
format = "-" + format;
173+
}
174+
175+
return format;
176+
}
155177
}
156178
}
157179
}

0 commit comments

Comments
 (0)