Implement Install & Refresh Button

- Add ShowMainWindow API for IPublicAPI
This commit is contained in:
Kevin Zhang 2021-10-16 21:28:55 -05:00
parent 1ce31505a6
commit 52b3579525
5 changed files with 53 additions and 18 deletions

View file

@ -59,6 +59,11 @@ namespace Flow.Launcher.Plugin
/// <param name="subTitle">Optional message subtitle</param>
void ShowMsgError(string title, string subTitle = "");
/// <summary>
/// Show the MainWindow when hiding
/// </summary>
void ShowMainWindow();
/// <summary>
/// Show message box
/// </summary>

View file

@ -68,6 +68,8 @@ namespace Flow.Launcher
public void RestarApp() => RestartApp();
public void ShowMainWindow() => _mainVM.MainWindowVisibility = Visibility.Visible;
public void CheckForNewUpdate() => _settingsVM.UpdateApp();
public void SaveAppAllSettings()

View file

@ -37,7 +37,7 @@
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
<Style x:Key="SettingGrid" TargetType="ItemsControl">
<Setter Property="Focusable" Value="False" />
<Setter Property="Margin" Value="0" />
@ -63,7 +63,7 @@
<Setter Property="Margin" Value="0 5 0 0" />
<Setter Property="Padding" Value="0 15 0 15" />
<Setter Property="SnapsToDevicePixels" Value="True" />
</Style>
<Style x:Key="SettingTitleLabel" TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="0 0 0 0" />
@ -362,7 +362,7 @@
</Window.Resources>
<TabControl Height="auto" SelectedIndex="1" TabStripPlacement="Left" Background="#f3f3f3">
<TabControl Height="auto" SelectedIndex="1" TabStripPlacement="Left" Background="#f3f3f3">
<TabItem Style="{DynamicResource logo}">
<TabItem.Header>
<Grid Margin="0 18 0 0">
@ -378,7 +378,8 @@
</Grid>
</TabItem.Header>
</TabItem>
<TabItem> <!-- LEFT TAB WIDTH -->
<TabItem>
<!-- LEFT TAB WIDTH -->
<TabItem.Header>
<Grid>
<Grid.ColumnDefinitions>
@ -881,7 +882,16 @@
<TextBlock Text="Plugin Store" TextAlignment="left" FontSize="30" Margin="0 5 0 5"/>
</Border>
<Border Grid.Row="0" Grid.Column="1" Background="#f3f3f3" Padding="5 18 32 0">
<Button Content="Refresh" FontSize="13" Margin="0 5 0 5" HorizontalAlignment="Right" Background="#ffffff" Padding="12 4 12 4" Height="34" BorderBrush="#cecece" BorderThickness="1 1 1 2"/>
<Button Content="Refresh"
FontSize="13"
Margin="0 5 0 5"
HorizontalAlignment="Right"
Background="#ffffff"
Padding="12 4 12 4"
Height="34"
BorderBrush="#cecece"
Click="OnPluginStoreRefreshClick"
BorderThickness="1 1 1 2"/>
</Border>
<Border Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Background="#f3f3f3" Padding="0 0 0 0">
<ListBox x:Name="StoreListBox"
@ -905,18 +915,9 @@
<ToggleButton.Template>
<ControlTemplate TargetType="{x:Type ButtonBase}">
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
<ControlTemplate.Triggers>
</ControlTemplate.Triggers>
<ControlTemplate.Triggers/>
</ControlTemplate>
</ToggleButton.Template>
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
<Grid HorizontalAlignment="Left" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
@ -998,7 +999,10 @@
</StackPanel>
</StackPanel>
<Border Padding="0 0 20 0">
<Button Foreground="Black" Name="ShortCutButtonPrev" Content="Install" Width="90" MinHeight="40" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="1" Margin="0 0 0 0">
<Button Foreground="Black" Name="ShortCutButtonPrev" Content="Install"
Click="OnExternalPluginInstallClick"
Width="90" MinHeight="40" HorizontalAlignment="Right"
VerticalAlignment="Center" Grid.Column="1" Margin="0 0 0 0">
</Button>
</Border>
</Grid>
@ -1079,7 +1083,7 @@
<Border Margin="0 0 0 0" Grid.Row="1">
<Rectangle Width="Auto" HorizontalAlignment="Stretch"
Style="{DynamicResource SeparatorStyle}"
Visibility="visible" />
Visibility="Visible" />
</Border>
<ContentControl Grid.Row="2">
@ -1112,7 +1116,7 @@
</ItemsControl>
</Border>
</StackPanel>
<StackPanel Grid.Row="3">
<Border Style="{DynamicResource SettingGroupBox}" Margin="0 8 0 0" Padding="0"
HorizontalAlignment="Stretch">

View file

@ -14,6 +14,7 @@ using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.ViewModel;
using Flow.Launcher.Helper;
using System.Windows.Controls;
using Flow.Launcher.Core.ExternalPlugins;
namespace Flow.Launcher
{
@ -264,6 +265,22 @@ namespace Flow.Launcher
FilesFolders.OpenPath(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
}
private void OnPluginStoreRefreshClick(object sender, RoutedEventArgs e)
{
_ = viewModel.RefreshExternalPluginsAsync();
}
private void OnExternalPluginInstallClick(object sender, RoutedEventArgs e)
{
if(sender is Button { DataContext: UserPlugin plugin })
{
var pluginsManagerPlugin = PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7");
var actionKeywrod = pluginsManagerPlugin.Metadata.ActionKeywords.Count == 0 ? "" : pluginsManagerPlugin.Metadata.ActionKeywords[0];
API.ChangeQuery($"{actionKeywrod} install {plugin.Name}");
API.ShowMainWindow();
}
}
/*
private void OnPluginActionKeywordsClick(object sender, RoutedEventArgs e)
{

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
@ -265,6 +266,12 @@ namespace Flow.Launcher.ViewModel
}
}
public async Task RefreshExternalPluginsAsync()
{
await PluginsManifest.UpdateManifestAsync();
OnPropertyChanged(nameof(ExternalPlugins));
}
#endregion