From a92ebf5756ba6f937189f3c30becbd88e3104040 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sun, 8 Jan 2023 16:31:37 -0600 Subject: [PATCH 1/6] Dynamic Height and Dynamic Icon Size --- .../DiameterToCenterPointConverter.cs | 25 +++ .../Converters/IconRadiusConverter.cs | 27 +++ Flow.Launcher/ResultListBox.xaml | 155 +++++++++++------- Flow.Launcher/Themes/Base.xaml | 8 + Flow.Launcher/ViewModel/ResultsViewModel.cs | 2 +- 5 files changed, 156 insertions(+), 61 deletions(-) create mode 100644 Flow.Launcher/Converters/DiameterToCenterPointConverter.cs create mode 100644 Flow.Launcher/Converters/IconRadiusConverter.cs diff --git a/Flow.Launcher/Converters/DiameterToCenterPointConverter.cs b/Flow.Launcher/Converters/DiameterToCenterPointConverter.cs new file mode 100644 index 00000000000..e81bb250790 --- /dev/null +++ b/Flow.Launcher/Converters/DiameterToCenterPointConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace Flow.Launcher.Converters +{ + public class DiameterToCenterPointConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is double d) + { + return new Point(d / 2, d / 2); + } + + return new Point(0, 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotSupportedException(); + } + } +} diff --git a/Flow.Launcher/Converters/IconRadiusConverter.cs b/Flow.Launcher/Converters/IconRadiusConverter.cs new file mode 100644 index 00000000000..51129cfb873 --- /dev/null +++ b/Flow.Launcher/Converters/IconRadiusConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using Windows.Devices.PointOfService; + +namespace Flow.Launcher.Converters +{ + public class IconRadiusConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values.Length != 2) + throw new ArgumentException("IconRadiusConverter must have 2 parameters"); + + return values[1] switch + { + true => (double)values[0] / 2, + false => (double)values[0], + _ => throw new ArgumentException("The second argument should be boolean", nameof(values)) + }; + } + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotSupportedException(); + } + } +} diff --git a/Flow.Launcher/ResultListBox.xaml b/Flow.Launcher/ResultListBox.xaml index 8f3238303f3..b2ab4a28770 100644 --- a/Flow.Launcher/ResultListBox.xaml +++ b/Flow.Launcher/ResultListBox.xaml @@ -1,5 +1,4 @@ - + + + +