From 4120407ac3b0815a952d4b8ed16bca915b4eeb07 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Wed, 14 Jan 2026 23:01:35 -0800 Subject: [PATCH] Add initial Avalonia UI project for migration Create Flow.Launcher.Avalonia project as foundation for migrating from WPF to Avalonia UI framework. Key components: - MainWindow with query box and results list (matching WPF layout) - ViewModels: MainViewModel, ResultsViewModel, ResultViewModel - Themes/Base.axaml with converted styles from WPF - FluentAvaloniaUI for Windows 11 styling - References existing Core/Infrastructure/Plugin projects The project builds and runs alongside the existing WPF application. This is Phase 1 of the incremental migration approach. --- Flow.Launcher.Avalonia/App.axaml | 21 ++ Flow.Launcher.Avalonia/App.axaml.cs | 52 +++++ .../Converters/BoolToIsVisibleConverter.cs | 34 +++ .../Converters/CommonConverters.cs | 109 +++++++++ .../Flow.Launcher.Avalonia.csproj | 65 ++++++ Flow.Launcher.Avalonia/MainWindow.axaml | 131 +++++++++++ Flow.Launcher.Avalonia/MainWindow.axaml.cs | 118 ++++++++++ Flow.Launcher.Avalonia/Program.cs | 21 ++ Flow.Launcher.Avalonia/Themes/Base.axaml | 211 ++++++++++++++++++ Flow.Launcher.Avalonia/Themes/Resources.axaml | 23 ++ .../ViewModel/MainViewModel.cs | 151 +++++++++++++ .../ViewModel/ResultViewModel.cs | 30 +++ .../ViewModel/ResultsViewModel.cs | 91 ++++++++ .../Views/ResultListBox.axaml | 93 ++++++++ .../Views/ResultListBox.axaml.cs | 34 +++ Flow.Launcher.Avalonia/app.manifest | 19 ++ Flow.Launcher.sln | 41 ++-- 17 files changed, 1231 insertions(+), 13 deletions(-) create mode 100644 Flow.Launcher.Avalonia/App.axaml create mode 100644 Flow.Launcher.Avalonia/App.axaml.cs create mode 100644 Flow.Launcher.Avalonia/Converters/BoolToIsVisibleConverter.cs create mode 100644 Flow.Launcher.Avalonia/Converters/CommonConverters.cs create mode 100644 Flow.Launcher.Avalonia/Flow.Launcher.Avalonia.csproj create mode 100644 Flow.Launcher.Avalonia/MainWindow.axaml create mode 100644 Flow.Launcher.Avalonia/MainWindow.axaml.cs create mode 100644 Flow.Launcher.Avalonia/Program.cs create mode 100644 Flow.Launcher.Avalonia/Themes/Base.axaml create mode 100644 Flow.Launcher.Avalonia/Themes/Resources.axaml create mode 100644 Flow.Launcher.Avalonia/ViewModel/MainViewModel.cs create mode 100644 Flow.Launcher.Avalonia/ViewModel/ResultViewModel.cs create mode 100644 Flow.Launcher.Avalonia/ViewModel/ResultsViewModel.cs create mode 100644 Flow.Launcher.Avalonia/Views/ResultListBox.axaml create mode 100644 Flow.Launcher.Avalonia/Views/ResultListBox.axaml.cs create mode 100644 Flow.Launcher.Avalonia/app.manifest diff --git a/Flow.Launcher.Avalonia/App.axaml b/Flow.Launcher.Avalonia/App.axaml new file mode 100644 index 000000000..7a48015b4 --- /dev/null +++ b/Flow.Launcher.Avalonia/App.axaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + diff --git a/Flow.Launcher.Avalonia/App.axaml.cs b/Flow.Launcher.Avalonia/App.axaml.cs new file mode 100644 index 000000000..0b8d0c827 --- /dev/null +++ b/Flow.Launcher.Avalonia/App.axaml.cs @@ -0,0 +1,52 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using CommunityToolkit.Mvvm.DependencyInjection; +using Flow.Launcher.Infrastructure.UserSettings; +using Microsoft.Extensions.DependencyInjection; +using System; + +namespace Flow.Launcher.Avalonia; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + // Set up dependency injection + var services = new ServiceCollection(); + ConfigureServices(services); + var serviceProvider = services.BuildServiceProvider(); + Ioc.Default.ConfigureServices(serviceProvider); + + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow(); + } + + base.OnFrameworkInitializationCompleted(); + } + + private void ConfigureServices(IServiceCollection services) + { + // Register settings - for now create a default instance + // In production, this would load from the existing settings file + services.AddSingleton(_ => + { + var settings = new Settings(); + // Set some defaults for the Avalonia version + settings.WindowSize = 580; + settings.WindowHeightSize = 42; + settings.QueryBoxFontSize = 24; + settings.ItemHeightSize = 50; + settings.ResultItemFontSize = 14; + settings.ResultSubItemFontSize = 12; + settings.MaxResultsToShow = 6; + return settings; + }); + } +} diff --git a/Flow.Launcher.Avalonia/Converters/BoolToIsVisibleConverter.cs b/Flow.Launcher.Avalonia/Converters/BoolToIsVisibleConverter.cs new file mode 100644 index 000000000..e8d0211a4 --- /dev/null +++ b/Flow.Launcher.Avalonia/Converters/BoolToIsVisibleConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Globalization; +using Avalonia.Data.Converters; + +namespace Flow.Launcher.Avalonia.Converters; + +/// +/// Converts a boolean value to IsVisible (Avalonia uses bool for visibility, not Visibility enum) +/// +public class BoolToIsVisibleConverter : IValueConverter +{ + /// + /// If true, inverts the boolean value (true becomes false, false becomes true) + /// + public bool Invert { get; set; } + + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is bool boolValue) + { + return Invert ? !boolValue : boolValue; + } + return false; + } + + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is bool boolValue) + { + return Invert ? !boolValue : boolValue; + } + return false; + } +} diff --git a/Flow.Launcher.Avalonia/Converters/CommonConverters.cs b/Flow.Launcher.Avalonia/Converters/CommonConverters.cs new file mode 100644 index 000000000..22b6349f3 --- /dev/null +++ b/Flow.Launcher.Avalonia/Converters/CommonConverters.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using Avalonia.Data.Converters; +using Avalonia.Media; + +namespace Flow.Launcher.Avalonia.Converters; + +/// +/// Converts text with highlight ranges to formatted text with bold highlights. +/// This is a simplified version - full implementation would use Avalonia's TextDecorations. +/// +public class HighlightTextConverter : IMultiValueConverter +{ + public object? Convert(IList values, Type targetType, object? parameter, CultureInfo culture) + { + // For now, just return the plain text + // Full implementation would create formatted inline text with highlights + if (values.Count >= 1 && values[0] is string text) + { + return text; + } + return string.Empty; + } +} + +/// +/// Converts query text and selected item to suggestion text. +/// +public class QuerySuggestionBoxConverter : IMultiValueConverter +{ + public object? Convert(IList values, Type targetType, object? parameter, CultureInfo culture) + { + // values[0]: QueryTextBox (element) + // values[1]: SelectedItem + // values[2]: QueryText + + if (values.Count < 3) + return string.Empty; + + var queryText = values[2] as string ?? string.Empty; + + // For now, return empty - full implementation would show autocomplete suggestion + // based on the selected result's title + return string.Empty; + } +} + +/// +/// Converts integer index to ordinal number for hotkey display (1, 2, 3...). +/// +public class OrdinalConverter : IValueConverter +{ + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is int index) + { + // Convert 0-based index to 1-based display, wrapping 9 to 0 + var displayNumber = (index + 1) % 10; + return displayNumber.ToString(); + } + return "0"; + } + + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } +} + +/// +/// Converts a size to a ratio of itself. +/// +public class SizeRatioConverter : IValueConverter +{ + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is double size && parameter is string ratioStr && double.TryParse(ratioStr, out var ratio)) + { + return size * ratio; + } + return value; + } + + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } +} + +/// +/// Converts string to null if empty (for image sources). +/// +public class StringToNullConverter : IValueConverter +{ + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is string str && string.IsNullOrWhiteSpace(str)) + { + return null; + } + return value; + } + + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + return value?.ToString() ?? string.Empty; + } +} diff --git a/Flow.Launcher.Avalonia/Flow.Launcher.Avalonia.csproj b/Flow.Launcher.Avalonia/Flow.Launcher.Avalonia.csproj new file mode 100644 index 000000000..99b50426f --- /dev/null +++ b/Flow.Launcher.Avalonia/Flow.Launcher.Avalonia.csproj @@ -0,0 +1,65 @@ + + + + WinExe + net9.0-windows10.0.19041.0 + enable + true + app.manifest + true + ..\Flow.Launcher\Resources\app.ico + Flow.Launcher.Avalonia.Program + false + false + false + Flow.Launcher.Avalonia + Flow.Launcher.Avalonia + + + + ..\Output\Debug\Avalonia\ + DEBUG;TRACE;AVALONIA + + + + ..\Output\Release\Avalonia\ + TRACE;RELEASE;AVALONIA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + diff --git a/Flow.Launcher.Avalonia/MainWindow.axaml b/Flow.Launcher.Avalonia/MainWindow.axaml new file mode 100644 index 000000000..8904a0238 --- /dev/null +++ b/Flow.Launcher.Avalonia/MainWindow.axaml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Flow.Launcher.Avalonia/MainWindow.axaml.cs b/Flow.Launcher.Avalonia/MainWindow.axaml.cs new file mode 100644 index 000000000..8723174c3 --- /dev/null +++ b/Flow.Launcher.Avalonia/MainWindow.axaml.cs @@ -0,0 +1,118 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Input; +using Avalonia.Interactivity; +using Avalonia.Markup.Xaml; +using CommunityToolkit.Mvvm.DependencyInjection; +using Flow.Launcher.Avalonia.ViewModel; +using Flow.Launcher.Infrastructure.UserSettings; +using System; + +namespace Flow.Launcher.Avalonia; + +public partial class MainWindow : Window +{ + private MainViewModel? _viewModel; + private TextBox? _queryTextBox; + + public MainWindow() + { + InitializeComponent(); + + // Create and set the ViewModel + var settings = Ioc.Default.GetRequiredService(); + _viewModel = new MainViewModel(settings); + DataContext = _viewModel; + + // Get reference to the query text box + _queryTextBox = this.FindControl("QueryTextBox"); + + // Subscribe to window events + this.Deactivated += OnWindowDeactivated; + +#if DEBUG + this.AttachDevTools(); +#endif + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + + protected override void OnLoaded(RoutedEventArgs e) + { + base.OnLoaded(e); + + // Focus the query text box when window loads + _queryTextBox?.Focus(); + } + + protected override void OnOpened(EventArgs e) + { + base.OnOpened(e); + + // Center the window on screen + CenterOnScreen(); + + // Focus and select all text + if (_queryTextBox != null) + { + _queryTextBox.Focus(); + _queryTextBox.SelectAll(); + } + } + + private void CenterOnScreen() + { + var screen = Screens.Primary; + if (screen != null) + { + var workingArea = screen.WorkingArea; + var x = (workingArea.Width - Width) / 2 + workingArea.X; + var y = workingArea.Height * 0.25 + workingArea.Y; // Position at 25% from top (like Flow Launcher) + Position = new PixelPoint((int)x, (int)y); + } + } + + protected override void OnKeyDown(KeyEventArgs e) + { + base.OnKeyDown(e); + + // Handle Escape to hide window + if (e.Key == Key.Escape) + { + Hide(); + e.Handled = true; + } + } + + private void OnWindowBorderPointerPressed(object? sender, PointerPressedEventArgs e) + { + // Allow dragging the window + if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) + { + BeginMoveDrag(e); + } + } + + // Note: In Avalonia, use the Deactivated event instead of override + // Subscribe in constructor: this.Deactivated += OnWindowDeactivated; + private void OnWindowDeactivated(object? sender, EventArgs e) + { + // Optionally hide window when it loses focus (like original Flow Launcher) + // Uncomment if desired: + // Hide(); + } + + /// + /// Shows the window and focuses the query text box + /// + public void ShowAndFocus() + { + Show(); + Activate(); + _queryTextBox?.Focus(); + _queryTextBox?.SelectAll(); + } +} diff --git a/Flow.Launcher.Avalonia/Program.cs b/Flow.Launcher.Avalonia/Program.cs new file mode 100644 index 000000000..1c4a9c330 --- /dev/null +++ b/Flow.Launcher.Avalonia/Program.cs @@ -0,0 +1,21 @@ +using System; +using Avalonia; + +namespace Flow.Launcher.Avalonia; + +internal sealed class Program +{ + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .WithInterFont() + .LogToTrace(); +} diff --git a/Flow.Launcher.Avalonia/Themes/Base.axaml b/Flow.Launcher.Avalonia/Themes/Base.axaml new file mode 100644 index 000000000..5f1845f96 --- /dev/null +++ b/Flow.Launcher.Avalonia/Themes/Base.axaml @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Flow.Launcher.Avalonia/Themes/Resources.axaml b/Flow.Launcher.Avalonia/Themes/Resources.axaml new file mode 100644 index 000000000..29afcff9e --- /dev/null +++ b/Flow.Launcher.Avalonia/Themes/Resources.axaml @@ -0,0 +1,23 @@ + + + + F1 M12000,12000z M0,0z M10354,10962C10326,10951 10279,10927 10249,10907 10216,10886 9476,10153 8370,9046 7366,8042 6541,7220 6536,7220 6532,7220 6498,7242 6461,7268 6213,7447 5883,7619 5592,7721 5194,7860 4802,7919 4360,7906 3612,7886 2953,7647 2340,7174 2131,7013 1832,6699 1664,6465 1394,6088 1188,5618 1097,5170 1044,4909 1030,4764 1030,4470 1030,4130 1056,3914 1135,3609 1263,3110 1511,2633 1850,2235 1936,2134 2162,1911 2260,1829 2781,1395 3422,1120 4090,1045 4271,1025 4667,1025 4848,1045 5505,1120 6100,1368 6630,1789 6774,1903 7081,2215 7186,2355 7362,2588 7467,2759 7579,2990 7802,3455 7911,3937 7911,4460 7911,4854 7861,5165 7737,5542 7684,5702 7675,5724 7602,5885 7517,6071 7390,6292 7270,6460 7242,6499 7220,6533 7220,6538 7220,6542 8046,7371 9055,8380 10441,9766 10898,10229 10924,10274 10945,10308 10966,10364 10976,10408 10990,10472 10991,10493 10980,10554 10952,10717 10840,10865 10690,10937 10621,10971 10607,10974 10510,10977 10425,10980 10395,10977 10354,10962z M4685,7050C5214,7001 5694,6809 6100,6484 6209,6396 6396,6209 6484,6100 7151,5267 7246,4110 6721,3190 6369,2571 5798,2137 5100,1956 4706,1855 4222,1855 3830,1957 3448,2056 3140,2210 2838,2453 2337,2855 2010,3427 1908,4080 1877,4274 1877,4656 1908,4850 1948,5105 2028,5370 2133,5590 2459,6272 3077,6782 3810,6973 3967,7014 4085,7034 4290,7053 4371,7061 4583,7059 4685,7050z + + + #E6202020 + #E3E0E3 + #FFFFF8 + #999999 + #333333 + #30FFFFFF + + + + + + + + + + diff --git a/Flow.Launcher.Avalonia/ViewModel/MainViewModel.cs b/Flow.Launcher.Avalonia/ViewModel/MainViewModel.cs new file mode 100644 index 000000000..94c52cc4b --- /dev/null +++ b/Flow.Launcher.Avalonia/ViewModel/MainViewModel.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using System.Windows.Input; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Flow.Launcher.Infrastructure.UserSettings; + +namespace Flow.Launcher.Avalonia.ViewModel; + +/// +/// Simplified MainViewModel for the Avalonia version. +/// This will eventually be unified with the WPF MainViewModel. +/// +public partial class MainViewModel : ObservableObject +{ + private readonly Settings _settings; + + [ObservableProperty] + private string _queryText = string.Empty; + + [ObservableProperty] + private string _querySuggestionText = string.Empty; + + [ObservableProperty] + private bool _isQueryRunning; + + [ObservableProperty] + private bool _hasResults; + + [ObservableProperty] + private ResultsViewModel _results; + + public Settings Settings => _settings; + + public MainViewModel(Settings settings) + { + _settings = settings; + _results = new ResultsViewModel(settings); + + // Add some demo results for testing + AddDemoResults(); + } + + partial void OnQueryTextChanged(string value) + { + // Simulate query execution + if (!string.IsNullOrWhiteSpace(value)) + { + IsQueryRunning = true; + HasResults = true; + + // Simulate search + Task.Delay(100).ContinueWith(_ => + { + IsQueryRunning = false; + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + else + { + HasResults = false; + IsQueryRunning = false; + } + } + + private void AddDemoResults() + { + // Add demo results for UI testing + Results.AddResult(new ResultViewModel + { + Title = "Welcome to Flow Launcher (Avalonia)", + SubTitle = "This is a demo result - Avalonia migration in progress", + IconPath = "Images/app.png" + }); + + Results.AddResult(new ResultViewModel + { + Title = "Settings", + SubTitle = "Open Flow Launcher settings", + IconPath = "Images/app.png" + }); + + Results.AddResult(new ResultViewModel + { + Title = "Notepad", + SubTitle = "C:\\Windows\\System32\\notepad.exe", + IconPath = "Images/app.png" + }); + + Results.AddResult(new ResultViewModel + { + Title = "Calculator", + SubTitle = "Microsoft Calculator", + IconPath = "Images/app.png" + }); + + HasResults = true; + } + + [RelayCommand] + private void Esc() + { + QueryText = string.Empty; + } + + [RelayCommand] + private void OpenResult(object? parameter) + { + var selectedResult = Results.SelectedItem; + if (selectedResult != null) + { + // Execute the result action + System.Diagnostics.Debug.WriteLine($"Opening result: {selectedResult.Title}"); + } + } + + [RelayCommand] + private void SelectNextItem() + { + Results.SelectNextItem(); + } + + [RelayCommand] + private void SelectPrevItem() + { + Results.SelectPrevItem(); + } + + [RelayCommand] + private void AutocompleteQuery() + { + if (Results.SelectedItem != null) + { + QueryText = Results.SelectedItem.Title; + } + } + + [RelayCommand] + private void ReloadPluginData() + { + // Placeholder for plugin data reload + System.Diagnostics.Debug.WriteLine("Reloading plugin data..."); + } + + [RelayCommand] + private void ReQuery() + { + // Placeholder for re-query + System.Diagnostics.Debug.WriteLine("Re-querying..."); + } +} diff --git a/Flow.Launcher.Avalonia/ViewModel/ResultViewModel.cs b/Flow.Launcher.Avalonia/ViewModel/ResultViewModel.cs new file mode 100644 index 000000000..a34368308 --- /dev/null +++ b/Flow.Launcher.Avalonia/ViewModel/ResultViewModel.cs @@ -0,0 +1,30 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using Flow.Launcher.Infrastructure.UserSettings; + +namespace Flow.Launcher.Avalonia.ViewModel; + +/// +/// ViewModel for a single result item. +/// +public partial class ResultViewModel : ObservableObject +{ + [ObservableProperty] + private string _title = string.Empty; + + [ObservableProperty] + private string _subTitle = string.Empty; + + [ObservableProperty] + private string _iconPath = string.Empty; + + [ObservableProperty] + private bool _isSelected; + + [ObservableProperty] + private Settings? _settings; + + // Computed properties for display + public bool ShowIcon => !string.IsNullOrEmpty(IconPath); + + public bool ShowSubTitle => !string.IsNullOrEmpty(SubTitle); +} diff --git a/Flow.Launcher.Avalonia/ViewModel/ResultsViewModel.cs b/Flow.Launcher.Avalonia/ViewModel/ResultsViewModel.cs new file mode 100644 index 000000000..1a006f363 --- /dev/null +++ b/Flow.Launcher.Avalonia/ViewModel/ResultsViewModel.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.ObjectModel; +using CommunityToolkit.Mvvm.ComponentModel; +using Flow.Launcher.Infrastructure.UserSettings; + +namespace Flow.Launcher.Avalonia.ViewModel; + +/// +/// ViewModel for the results list. +/// +public partial class ResultsViewModel : ObservableObject +{ + private readonly Settings _settings; + + [ObservableProperty] + private ObservableCollection _results = new(); + + [ObservableProperty] + private ResultViewModel? _selectedItem; + + [ObservableProperty] + private int _selectedIndex; + + [ObservableProperty] + private bool _isVisible = true; + + public Settings Settings => _settings; + + public int MaxHeight => (int)(_settings.MaxResultsToShow * _settings.ItemHeightSize); + + public ResultsViewModel(Settings settings) + { + _settings = settings; + } + + public void AddResult(ResultViewModel result) + { + result.Settings = _settings; + Results.Add(result); + + // Select first item if nothing selected + if (SelectedItem == null && Results.Count > 0) + { + SelectedIndex = 0; + SelectedItem = Results[0]; + } + } + + public void Clear() + { + Results.Clear(); + SelectedItem = null; + SelectedIndex = -1; + } + + public void SelectNextItem() + { + if (Results.Count == 0) return; + + var newIndex = SelectedIndex + 1; + if (newIndex >= Results.Count) + { + newIndex = 0; // Wrap to beginning + } + + SelectedIndex = newIndex; + SelectedItem = Results[newIndex]; + } + + public void SelectPrevItem() + { + if (Results.Count == 0) return; + + var newIndex = SelectedIndex - 1; + if (newIndex < 0) + { + newIndex = Results.Count - 1; // Wrap to end + } + + SelectedIndex = newIndex; + SelectedItem = Results[newIndex]; + } + + partial void OnSelectedIndexChanged(int value) + { + if (value >= 0 && value < Results.Count) + { + SelectedItem = Results[value]; + } + } +} diff --git a/Flow.Launcher.Avalonia/Views/ResultListBox.axaml b/Flow.Launcher.Avalonia/Views/ResultListBox.axaml new file mode 100644 index 000000000..144fc8e18 --- /dev/null +++ b/Flow.Launcher.Avalonia/Views/ResultListBox.axaml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Flow.Launcher.Avalonia/Views/ResultListBox.axaml.cs b/Flow.Launcher.Avalonia/Views/ResultListBox.axaml.cs new file mode 100644 index 000000000..797f123e9 --- /dev/null +++ b/Flow.Launcher.Avalonia/Views/ResultListBox.axaml.cs @@ -0,0 +1,34 @@ +using Avalonia.Controls; +using Avalonia.Input; +using Avalonia.Markup.Xaml; + +namespace Flow.Launcher.Avalonia.Views; + +public partial class ResultListBox : UserControl +{ + private ListBox? _listBox; + + public ResultListBox() + { + InitializeComponent(); + _listBox = this.FindControl("ResultsList"); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + + protected override void OnPointerPressed(PointerPressedEventArgs e) + { + base.OnPointerPressed(e); + + // Handle left click on result item + var point = e.GetCurrentPoint(this); + if (point.Properties.IsLeftButtonPressed) + { + // The ListBox handles selection automatically + // Additional click handling can be added here + } + } +} diff --git a/Flow.Launcher.Avalonia/app.manifest b/Flow.Launcher.Avalonia/app.manifest new file mode 100644 index 000000000..e07605041 --- /dev/null +++ b/Flow.Launcher.Avalonia/app.manifest @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + true/pm + PerMonitorV2 + + + + diff --git a/Flow.Launcher.sln b/Flow.Launcher.sln index e44b23232..d830065cd 100644 --- a/Flow.Launcher.sln +++ b/Flow.Launcher.sln @@ -1,3 +1,4 @@ + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32901.215 @@ -71,6 +72,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Plugin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.WindowsSettings", "Plugins\Flow.Launcher.Plugin.WindowsSettings\Flow.Launcher.Plugin.WindowsSettings.csproj", "{5043CECE-E6A7-4867-9CBE-02D27D83747A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flow.Launcher.Avalonia", "Flow.Launcher.Avalonia\Flow.Launcher.Avalonia.csproj", "{6B30B56B-7CEA-4868-828D-1460A57ACF47}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -81,8 +84,20 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x64.ActiveCfg = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x64.Build.0 = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.ActiveCfg = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.Build.0 = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.Build.0 = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x64.ActiveCfg = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x64.Build.0 = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.ActiveCfg = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.Build.0 = Release|Any CPU {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Any CPU.Build.0 = Debug|Any CPU {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|x64.ActiveCfg = Debug|Any CPU {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|x64.Build.0 = Debug|Any CPU {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|x86.ActiveCfg = Debug|Any CPU @@ -105,18 +120,6 @@ Global {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|x64.Build.0 = Release|Any CPU {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|x86.ActiveCfg = Release|Any CPU {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|x86.Build.0 = Release|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x64.ActiveCfg = Debug|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x64.Build.0 = Debug|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.ActiveCfg = Debug|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.Build.0 = Debug|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.Build.0 = Release|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x64.ActiveCfg = Release|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x64.Build.0 = Release|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.ActiveCfg = Release|Any CPU - {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.Build.0 = Release|Any CPU {4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|Any CPU.Build.0 = Debug|Any CPU {4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -286,6 +289,18 @@ Global {5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x64.Build.0 = Release|Any CPU {5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x86.ActiveCfg = Release|Any CPU {5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x86.Build.0 = Release|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Debug|x64.ActiveCfg = Debug|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Debug|x64.Build.0 = Debug|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Debug|x86.ActiveCfg = Debug|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Debug|x86.Build.0 = Debug|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Release|Any CPU.Build.0 = Release|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Release|x64.ActiveCfg = Release|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Release|x64.Build.0 = Release|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Release|x86.ActiveCfg = Release|Any CPU + {6B30B56B-7CEA-4868-828D-1460A57ACF47}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE