From 5c92fbdb37f3074758fa826970968efecd01495a Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 29 Oct 2024 19:59:22 +0800 Subject: [PATCH] fix: MinWidth not work while manually resizing window (#619) Signed-off-by: leo --- src/Views/StashesPage.axaml | 2 +- src/Views/StashesPage.axaml.cs | 14 ++++++++++++++ src/Views/WorkingCopy.axaml | 2 +- src/Views/WorkingCopy.axaml.cs | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Views/StashesPage.axaml b/src/Views/StashesPage.axaml index 0b747179..87847c06 100644 --- a/src/Views/StashesPage.axaml +++ b/src/Views/StashesPage.axaml @@ -9,7 +9,7 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SourceGit.Views.StashesPage" x:DataType="vm:StashesPage"> - + diff --git a/src/Views/StashesPage.axaml.cs b/src/Views/StashesPage.axaml.cs index 60e8f0c1..f3048889 100644 --- a/src/Views/StashesPage.axaml.cs +++ b/src/Views/StashesPage.axaml.cs @@ -9,6 +9,20 @@ namespace SourceGit.Views InitializeComponent(); } + private void OnMainLayoutSizeChanged(object sender, SizeChangedEventArgs e) + { + var grid = sender as Grid; + if (grid == null) + return; + + var layout = ViewModels.Preference.Instance.Layout; + var width = grid.Bounds.Width; + var maxLeft = width - 304; + + if (layout.StashesLeftWidth.Value - maxLeft > 1.0) + layout.StashesLeftWidth = new GridLength(maxLeft, GridUnitType.Pixel); + } + private void OnStashContextRequested(object sender, ContextRequestedEventArgs e) { if (DataContext is ViewModels.StashesPage vm && sender is Border border) diff --git a/src/Views/WorkingCopy.axaml b/src/Views/WorkingCopy.axaml index 158268cd..dae1f886 100644 --- a/src/Views/WorkingCopy.axaml +++ b/src/Views/WorkingCopy.axaml @@ -8,7 +8,7 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600" x:Class="SourceGit.Views.WorkingCopy" x:DataType="vm:WorkingCopy"> - + diff --git a/src/Views/WorkingCopy.axaml.cs b/src/Views/WorkingCopy.axaml.cs index 3d615692..f64e1a30 100644 --- a/src/Views/WorkingCopy.axaml.cs +++ b/src/Views/WorkingCopy.axaml.cs @@ -11,6 +11,20 @@ namespace SourceGit.Views InitializeComponent(); } + private void OnMainLayoutSizeChanged(object sender, SizeChangedEventArgs e) + { + var grid = sender as Grid; + if (grid == null) + return; + + var layout = ViewModels.Preference.Instance.Layout; + var width = grid.Bounds.Width; + var maxLeft = width - 304; + + if (layout.WorkingCopyLeftWidth.Value - maxLeft > 1.0) + layout.WorkingCopyLeftWidth = new GridLength(maxLeft, GridUnitType.Pixel); + } + private void OnOpenCommitMessagePicker(object sender, RoutedEventArgs e) { if (sender is Button button && DataContext is ViewModels.WorkingCopy vm)