Skip to content

Commit

Permalink
fix: 修复当窗口宽度为 0 时回弹动画产生负值宽度导致崩溃的问题 ClassIsland#386
Browse files Browse the repository at this point in the history
  • Loading branch information
HelloWRC committed Sep 30, 2024
1 parent 295a60c commit af961e0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ClassIsland.Core/Converters/WidthDoubleToRectConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Globalization;
using System.Diagnostics;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
Expand All @@ -20,9 +21,9 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
var w = (double)values[0];
var gw = (double)values[1];
var gh = (double)values[2];
var w = Math.Max(0, (double)values[0]);
var gw = Math.Max(0, (double)values[1]);
var gh = Math.Max(0, (double)values[2]);
var l = (int)values[3];
var rX = (double)values[4];
var rY = (double)values[5];
Expand All @@ -44,7 +45,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
break;
}

//Debug.WriteLine(gw);
Debug.WriteLine(w);
return new RectangleGeometry(new Rect(new Point(px, 0), new Size(w, gh)), rX, rY);
}

Expand Down

0 comments on commit af961e0

Please sign in to comment.