Skip to content

Commit

Permalink
fix: 配置页面保存按钮圆角的设置
Browse files Browse the repository at this point in the history
  • Loading branch information
SlimeNull committed May 15, 2023
1 parent 79df349 commit a94cdaa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion OpenGptChat/OpenGptChat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>1.1.6.3</Version>
<Version>1.1.6.4</Version>
<ImplicitUsings>disable</ImplicitUsings>
<ApplicationManifest>app.manifest</ApplicationManifest>
<StartupObject>OpenGptChat.EntryPoint</StartupObject>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net6.0-windows\publish\win-x64\</PublishDir>
<PublishDir>bin\Release\net6.0-windows\publish\win-x86\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
Expand Down
26 changes: 23 additions & 3 deletions OpenGptChat/Utilities/UiUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,24 @@ private static void CornerRadiusChanged(DependencyObject d, DependencyPropertyCh
if (d is not FrameworkElement ele)
return;

if (GetBorderFromControl(ele) is not Border border)
return;
void ApplyBorder(FrameworkElement ele)
{
if (GetBorderFromControl(ele) is not Border border)
return;

border.CornerRadius = (CornerRadius)e.NewValue;
border.CornerRadius = (CornerRadius)e.NewValue;
}

void LoadedOnce(object? sender, RoutedEventArgs _e)
{
ApplyBorder(ele);
ele.Loaded -= LoadedOnce;
}

if (ele.IsLoaded)
ApplyBorder(ele);
else
ele.Loaded += LoadedOnce;
}

private static Border? GetBorderFromControl(FrameworkElement control)
Expand All @@ -46,8 +60,14 @@ private static void CornerRadiusChanged(DependencyObject d, DependencyPropertyCh
for (int i = 0; i < childrenCount; i++)
{
DependencyObject child = VisualTreeHelper.GetChild(control, i);
if (child is not FrameworkElement childElement)
continue;

if (child is Border borderChild)
return borderChild;

if (GetBorderFromControl(childElement) is Border childBorderChild)
return childBorderChild;
}

return null;
Expand Down

0 comments on commit a94cdaa

Please sign in to comment.