Skip to content

Commit

Permalink
四舍五入
Browse files Browse the repository at this point in the history
  • Loading branch information
clover-yan committed Jun 4, 2023
1 parent 3e24a4c commit 57f7a94
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions DateCountdown/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,21 @@ private void DispatcherTimer_Tick(object sender, EventArgs e)
reded = true;
TextBlockDays.Foreground = new SolidColorBrush(Colors.Red) { Opacity = alpha ? 0.5 : 1 };
}
string detailStr = StringFormat == "." ? "" : Math.Abs(detailNum).ToString(StringFormat);
if (detailStr.StartsWith("1"))
{
TextBlockDays.Text = ((timeSpan.Days < 0 || detailNum < 0.0) && neg ? "-" + (Math.Abs(timeSpan.Days)+1).ToString() : (Math.Abs(timeSpan.Days)+1).ToString());
detailStr = StringFormat;
string detailStr;
if (StringFormat == ".") {
detailStr = "";
if (detailNum >= 0.5) {
TextBlockDays.Text = ((timeSpan.Days < 0 || detailNum < 0.0) && neg ? "-" + (Math.Abs(timeSpan.Days)+1).ToString() : (Math.Abs(timeSpan.Days)+1).ToString());
}
} else {
detailStr = Math.Abs(detailNum).ToString(StringFormat);
if (detailStr.StartsWith("1"))
{
TextBlockDays.Text = ((timeSpan.Days < 0 || detailNum < 0.0) && neg ? "-" + (Math.Abs(timeSpan.Days)+1).ToString() : (Math.Abs(timeSpan.Days)+1).ToString());
detailStr = StringFormat;
}
}

TextBlockDaysDetails.Text = detailStr;

if (Topmost) {
Expand Down

0 comments on commit 57f7a94

Please sign in to comment.