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 @@ - +