Skip to content

Commit

Permalink
fix: missing sign on alignment graph offset axis (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
protyposis authored Jan 29, 2024
1 parent 766581d commit 49896e2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions AudioAlign/AlignmentGraphWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,28 @@ double maxIntervalSize
interval = nextInterval;
}
}

/// <summary>
/// Adds missing negative signs to axis labels when a custom format is used.
///
/// The axis formatter converts the `double`-parameter to a `TimeSpan` and formats
/// it with `string.Format`. By default, when no custom format is specified, it adds
/// the negative sign to negative time spans.
/// When specifying a custom format, the negative sign is no longer added (only to time
/// spans; it is still added to other types), so it needs to be additionally added
/// to the formatted string.
/// </summary>
protected override string FormatValueOverride(double x)
{
var format = base.FormatValueOverride(x);

if (StringFormat != null && x < 0)
{
format = "-" + format;
}

return format;
}
}
}
}

0 comments on commit 49896e2

Please sign in to comment.