Skip to content

Commit ad77ecd

Browse files
committed
Set VirtualizingPanel.ScrollUnit and ScrollViewer.CanContentScroll for other tab.
Close Flyout when clicking install
1 parent 6e76d87 commit ad77ecd

File tree

3 files changed

+58
-14
lines changed

3 files changed

+58
-14
lines changed

Flow.Launcher/SettingWindow.xaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,8 @@
607607
<ScrollViewer
608608
Margin="0,0,0,0"
609609
Background="{DynamicResource Color01B}"
610-
ScrollViewer.CanContentScroll="False"
610+
CanContentScroll="True"
611+
VirtualizingPanel.ScrollUnit="Pixel"
611612
VirtualizingStackPanel.IsVirtualizing="True">
612613
<StackPanel Margin="5,18,25,30" Orientation="Vertical">
613614
<TextBlock
@@ -1395,6 +1396,7 @@
13951396
FontSize="14"
13961397
KeyDown="PluginStoreFilterTxb_OnKeyDown"
13971398
LostFocus="RefreshPluginStoreEventHandler"
1399+
13981400
Text=""
13991401
TextAlignment="Left"
14001402
ToolTip="{DynamicResource searchpluginToolTip}"
@@ -1436,7 +1438,7 @@
14361438
Padding="12,4,12,4"
14371439
HorizontalAlignment="Right"
14381440
VerticalAlignment="Center"
1439-
Click="OnPluginStoreRefreshClick"
1441+
Command="{Binding RefreshExternalPluginsCommand}"
14401442
Content="{DynamicResource refresh}"
14411443
DockPanel.Dock="Right"
14421444
FontSize="13" />
@@ -1515,7 +1517,8 @@
15151517
HorizontalContentAlignment="Stretch"
15161518
VerticalContentAlignment="Stretch"
15171519
BorderThickness="0"
1518-
FocusVisualStyle="{StaticResource StoreItemFocusVisualStyleKey}">
1520+
FocusVisualStyle="{StaticResource StoreItemFocusVisualStyleKey}"
1521+
Click="StoreListItem_Click">
15191522
<ui:FlyoutService.Flyout>
15201523
<ui:Flyout x:Name="InstallFlyout" Placement="Bottom">
15211524
<Grid MinWidth="200">
@@ -1675,7 +1678,8 @@
16751678
<ScrollViewer
16761679
Margin="0,0,0,0"
16771680
Padding="6,0,24,0"
1678-
ScrollViewer.CanContentScroll="False"
1681+
ScrollViewer.CanContentScroll="True"
1682+
VirtualizingStackPanel.ScrollUnit="Pixel"
16791683
VirtualizingStackPanel.IsVirtualizing="True">
16801684
<Grid Margin="0,0,0,0">
16811685
<Grid.RowDefinitions>
@@ -2252,7 +2256,8 @@
22522256
<ScrollViewer
22532257
Margin="0,0,0,0"
22542258
Padding="0,0,6,0"
2255-
ScrollViewer.CanContentScroll="False"
2259+
ScrollViewer.CanContentScroll="True"
2260+
VirtualizingStackPanel.ScrollUnit="Pixel"
22562261
VirtualizingStackPanel.IsVirtualizing="True">
22572262
<Border>
22582263
<Grid Margin="5,18,18,10">
@@ -2547,7 +2552,8 @@
25472552
<ScrollViewer
25482553
Margin="0,0,0,0"
25492554
Padding="5,0,24,0"
2550-
ScrollViewer.CanContentScroll="False"
2555+
ScrollViewer.CanContentScroll="True"
2556+
VirtualizingStackPanel.ScrollUnit="Pixel"
25512557
VirtualizingStackPanel.IsVirtualizing="True">
25522558
<Border>
25532559

@@ -2720,7 +2726,8 @@
27202726
<ScrollViewer
27212727
Margin="0,0,0,0"
27222728
Background="{DynamicResource Color01B}"
2723-
ScrollViewer.CanContentScroll="False"
2729+
ScrollViewer.CanContentScroll="True"
2730+
VirtualizingStackPanel.ScrollUnit="Pixel"
27242731
VirtualizingStackPanel.IsVirtualizing="True">
27252732
<StackPanel Margin="5,14,25,30" Orientation="Vertical">
27262733
<TextBlock

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Windows.Forms;
1919
using System.Windows.Input;
2020
using System.Windows.Interop;
21+
using System.Windows.Media;
2122
using System.Windows.Navigation;
2223
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
2324
using Button = System.Windows.Controls.Button;
@@ -300,17 +301,35 @@ private void ClearLogFolder(object sender, RoutedEventArgs e)
300301
}
301302
}
302303

303-
private void OnPluginStoreRefreshClick(object sender, RoutedEventArgs e)
304+
private static T FindParent<T>(DependencyObject child) where T : DependencyObject
304305
{
305-
_ = viewModel.RefreshExternalPluginsAsync();
306-
}
306+
//get parent item
307+
DependencyObject parentObject = VisualTreeHelper.GetParent(child);
308+
309+
//we've reached the end of the tree
310+
if (parentObject == null) return null;
307311

312+
//check if the parent matches the type we're looking for
313+
T parent = parentObject as T;
314+
if (parent != null)
315+
return parent;
316+
else
317+
return FindParent<T>(parentObject);
318+
}
319+
308320
private void OnExternalPluginInstallClick(object sender, RoutedEventArgs e)
309321
{
310-
if (sender is Button { DataContext: PluginStoreItemViewModel plugin })
322+
if (sender is not Button { DataContext: PluginStoreItemViewModel plugin } button)
323+
{
324+
return;
325+
}
326+
327+
if (storeClickedButton != null)
311328
{
312-
viewModel.DisplayPluginQuery($"install {plugin.Name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7"));
329+
FlyoutService.GetFlyout(storeClickedButton).Hide();
313330
}
331+
332+
viewModel.DisplayPluginQuery($"install {plugin.Name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7"));
314333
}
315334

316335
private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs e)
@@ -545,5 +564,21 @@ public double WindowTop()
545564
return top;
546565
}
547566

567+
private Button storeClickedButton;
568+
569+
private void StoreListItem_Click(object sender, RoutedEventArgs e)
570+
{
571+
if (sender is not Button button)
572+
return;
573+
574+
storeClickedButton = button;
575+
576+
var flyout = FlyoutService.GetFlyout(button);
577+
flyout.Closed += (_, _) =>
578+
{
579+
storeClickedButton = null;
580+
};
581+
582+
}
548583
}
549584
}

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
using Flow.Launcher.Plugin;
2121
using Flow.Launcher.Plugin.SharedModels;
2222
using System.Collections.ObjectModel;
23+
using CommunityToolkit.Mvvm.Input;
2324

2425
namespace Flow.Launcher.ViewModel
2526
{
26-
public class SettingWindowViewModel : BaseModel
27+
public partial class SettingWindowViewModel : BaseModel
2728
{
2829
private readonly Updater _updater;
2930
private readonly IPortable _portable;
@@ -330,7 +331,8 @@ public Control SettingProvider
330331
}
331332
}
332333

333-
public async Task RefreshExternalPluginsAsync()
334+
[RelayCommand]
335+
private async Task RefreshExternalPluginsAsync()
334336
{
335337
await PluginsManifest.UpdateManifestAsync();
336338
OnPropertyChanged(nameof(ExternalPlugins));

0 commit comments

Comments
 (0)