From c125342fbfaadee5ea6fd66bb3436a06442d34f2 Mon Sep 17 00:00:00 2001 From: routersys Date: Sun, 1 Nov 2026 13:11:47 +0900 Subject: [PATCH] =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=AE=E5=AF=B8=E6=B3=95?= =?UTF-8?q?=E3=81=A8=E4=B8=8D=E9=80=8F=E6=98=8E=E5=BA=A6=E3=81=AE=E6=95=B0?= =?UTF-8?q?=E5=80=A4=E3=82=921=E3=81=8B=E6=89=80=E3=81=AB=E3=81=BE?= =?UTF-8?q?=E3=81=A8=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UndoTree/DoubleToGridLengthConverter.cs | 6 +++--- UndoTree/UndoTreeDetailItemViewModel.cs | 2 +- UndoTree/UndoTreeLayout.cs | 14 ++++++++++++++ UndoTree/UndoTreeNodeViewModel.cs | 4 ++-- UndoTree/UndoTreeState.cs | 2 +- UndoTree/UndoTreeView.xaml | 10 +++++----- UndoTree/UndoTreeViewModel.cs | 5 +---- 7 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 UndoTree/UndoTreeLayout.cs diff --git a/UndoTree/DoubleToGridLengthConverter.cs b/UndoTree/DoubleToGridLengthConverter.cs index 4a35e71..182847c 100644 --- a/UndoTree/DoubleToGridLengthConverter.cs +++ b/UndoTree/DoubleToGridLengthConverter.cs @@ -4,15 +4,15 @@ using System.Windows.Data; namespace UndoTree; -public sealed class DoubleToGridLengthConverter : IValueConverter +internal sealed class DoubleToGridLengthConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value is double height && !double.IsNaN(height) && !double.IsInfinity(height) ? new GridLength(height) - : new GridLength(160); + : new GridLength(UndoTreeLayout.DefaultDetailsHeight); public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => value is GridLength gridLength && gridLength.IsAbsolute ? gridLength.Value - : 160d; + : UndoTreeLayout.DefaultDetailsHeight; } diff --git a/UndoTree/UndoTreeDetailItemViewModel.cs b/UndoTree/UndoTreeDetailItemViewModel.cs index acf9bce..1b46e21 100644 --- a/UndoTree/UndoTreeDetailItemViewModel.cs +++ b/UndoTree/UndoTreeDetailItemViewModel.cs @@ -15,5 +15,5 @@ internal class UndoTreeDetailItemViewModel(string text, string detail, int level public string Display => UndoTreeText.WithDetail(Text, Detail); - public Thickness Margin => new(Level * 16, 0, 0, 0); + public Thickness Margin => new(Level * UndoTreeLayout.IndentWidth, 0, 0, 0); } diff --git a/UndoTree/UndoTreeLayout.cs b/UndoTree/UndoTreeLayout.cs new file mode 100644 index 0000000..4bc04a3 --- /dev/null +++ b/UndoTree/UndoTreeLayout.cs @@ -0,0 +1,14 @@ +namespace UndoTree; + +internal static class UndoTreeLayout +{ + public const double DefaultDetailsHeight = 160; + public const double MinDetailsHeight = 60; + public const double MaxDetailsHeight = 600; + public const double MinTreeHeight = 60; + public const double IndentWidth = 16; + public const int FilterDelayMilliseconds = 150; + public const double PathOpacity = 1; + public const double RedoOpacity = 0.75; + public const double OtherBranchOpacity = 0.55; +} diff --git a/UndoTree/UndoTreeNodeViewModel.cs b/UndoTree/UndoTreeNodeViewModel.cs index 166d182..9b3ab9a 100644 --- a/UndoTree/UndoTreeNodeViewModel.cs +++ b/UndoTree/UndoTreeNodeViewModel.cs @@ -146,7 +146,7 @@ internal class UndoTreeNodeViewModel : Bindable public int Level { get; set => Set(ref field, value, nameof(Level), nameof(Margin)); } - public Thickness Margin => new(Level * 16, 0, 0, 0); + public Thickness Margin => new(Level * UndoTreeLayout.IndentWidth, 0, 0, 0); public bool IsExpanded { @@ -175,7 +175,7 @@ internal class UndoTreeNodeViewModel : Bindable public bool IsRedoable { get; set => Set(ref field, value, nameof(IsRedoable), nameof(Opacity)); } - public double Opacity => IsCurrent || IsOnPath ? 1 : IsRedoable ? 0.75 : 0.55; + public double Opacity => IsCurrent || IsOnPath ? UndoTreeLayout.PathOpacity : IsRedoable ? UndoTreeLayout.RedoOpacity : UndoTreeLayout.OtherBranchOpacity; public event EventHandler? ExpandRequested; diff --git a/UndoTree/UndoTreeState.cs b/UndoTree/UndoTreeState.cs index 9930666..f635dd4 100644 --- a/UndoTree/UndoTreeState.cs +++ b/UndoTree/UndoTreeState.cs @@ -4,5 +4,5 @@ internal record UndoTreeState { public bool IsDetailsVisible { get; init; } = true; - public double DetailsHeight { get; init; } = 160; + public double DetailsHeight { get; init; } = UndoTreeLayout.DefaultDetailsHeight; } diff --git a/UndoTree/UndoTreeView.xaml b/UndoTree/UndoTreeView.xaml index b590538..ff4614d 100644 --- a/UndoTree/UndoTreeView.xaml +++ b/UndoTree/UndoTreeView.xaml @@ -40,13 +40,13 @@ - +