mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Move ProgramSetting into Feature
This commit is contained in:
parent
4512854c2a
commit
479945455b
11 changed files with 219 additions and 106 deletions
29
Wox.Infrastructure/StringEmptyConverter.cs
Normal file
29
Wox.Infrastructure/StringEmptyConverter.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
public class StringEmptyConverter : MarkupExtension, IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return string.IsNullOrEmpty((string)value) ? parameter : value;
|
||||
}
|
||||
|
||||
public object ConvertBack(
|
||||
object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Wox.Infrastructure/StringNullOrEmptyToVisibilityConverter.cs
Normal file
26
Wox.Infrastructure/StringNullOrEmptyToVisibilityConverter.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
public class StringNullOrEmptyToVisibilityConverter : MarkupExtension, IValueConverter
|
||||
{
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -37,6 +37,7 @@
|
|||
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
|
|
@ -60,6 +61,8 @@
|
|||
<Compile Include="Storage\UserSettings\PluginHotkey.cs" />
|
||||
<Compile Include="Storage\UserSettings\ProgramSource.cs" />
|
||||
<Compile Include="Storage\UserSettings\WebSearch.cs" />
|
||||
<Compile Include="StringEmptyConverter.cs" />
|
||||
<Compile Include="StringNullOrEmptyToVisibilityConverter.cs" />
|
||||
<Compile Include="WindowsShellRun.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
56
Wox.Plugin.System/ProgramSetting.xaml
Normal file
56
Wox.Plugin.System/ProgramSetting.xaml
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<UserControl x:Class="Wox.Plugin.System.ProgramSetting"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:infrastructure="clr-namespace:Wox.Infrastructure;assembly=Wox.Infrastructure"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ListView x:Name="programSourceView" Grid.Row="0">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="Location" Width="400">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={infrastructure:StringEmptyConverter}}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Header="Type" Width="150">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Type}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Header="Bonus Points" Width="100">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding BonusPoints}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Header="Enabled" Width="100">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Enabled}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
<StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Button x:Name="btnDeleteProgramSource" Click="btnDeleteProgramSource_OnClick" Width="100" Margin="10" Content="Delete"/>
|
||||
<Button x:Name="btnEditProgramSource" Click="btnEditProgramSource_OnClick" Width="100" Margin="10" Content="Edit"/>
|
||||
<Button x:Name="btnAddProgramSource" Click="btnAddProgramSource_OnClick" Width="100" Margin="10" Content="Add"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="1" Margin="10" HorizontalAlignment="Left" Text="* Restarting required" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
78
Wox.Plugin.System/ProgramSetting.xaml.cs
Normal file
78
Wox.Plugin.System/ProgramSetting.xaml.cs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
namespace Wox.Plugin.System
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ProgramSetting.xaml
|
||||
/// </summary>
|
||||
public partial class ProgramSetting : UserControl
|
||||
{
|
||||
public ProgramSetting()
|
||||
{
|
||||
InitializeComponent();
|
||||
Loaded += Setting_Loaded;
|
||||
}
|
||||
|
||||
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
programSourceView.ItemsSource = UserSettingStorage.Instance.ProgramSources;
|
||||
}
|
||||
|
||||
public void ReloadProgramSourceView()
|
||||
{
|
||||
programSourceView.Items.Refresh();
|
||||
}
|
||||
|
||||
|
||||
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProgramSourceSetting programSource = new ProgramSourceSetting(this);
|
||||
programSource.ShowDialog();
|
||||
}
|
||||
|
||||
private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProgramSource seletedProgramSource = programSourceView.SelectedItem as ProgramSource;
|
||||
if (seletedProgramSource != null &&
|
||||
MessageBox.Show("Are your sure to delete " + seletedProgramSource.ToString(), "Delete ProgramSource",
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
UserSettingStorage.Instance.ProgramSources.Remove(seletedProgramSource);
|
||||
programSourceView.Items.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please select a program source");
|
||||
}
|
||||
}
|
||||
|
||||
private void btnEditProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProgramSource seletedProgramSource = programSourceView.SelectedItem as ProgramSource;
|
||||
if (seletedProgramSource != null)
|
||||
{
|
||||
ProgramSourceSetting programSource = new ProgramSourceSetting(this);
|
||||
programSource.UpdateItem(seletedProgramSource);
|
||||
programSource.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please select a program source");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<Window x:Class="Wox.ProgramSourceSetting"
|
||||
<Window x:Class="Wox.Plugin.System.ProgramSourceSetting"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Icon="Images\app.png"
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
|
@ -11,21 +12,20 @@ using System.Windows.Input;
|
|||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
namespace Wox
|
||||
namespace Wox.Plugin.System
|
||||
{
|
||||
public partial class ProgramSourceSetting : Window
|
||||
{
|
||||
private SettingWindow settingWindow;
|
||||
private ProgramSetting settingWindow;
|
||||
private bool update;
|
||||
private ProgramSource updateProgramSource;
|
||||
|
||||
public ProgramSourceSetting(SettingWindow settingWidow)
|
||||
public ProgramSourceSetting(ProgramSetting settingWidow)
|
||||
{
|
||||
this.settingWindow = settingWidow;
|
||||
InitializeComponent();
|
||||
|
|
@ -117,8 +117,8 @@ namespace Wox
|
|||
Type type;
|
||||
if (item != null && Wox.Plugin.System.Programs.SourceTypes.TryGetValue(item, out type))
|
||||
{
|
||||
var attrs = type.GetCustomAttributes(typeof(System.ComponentModel.BrowsableAttribute), false);
|
||||
if (attrs.Length > 0 && (attrs[0] as System.ComponentModel.BrowsableAttribute).Browsable == false)
|
||||
var attrs = type.GetCustomAttributes(typeof(BrowsableAttribute), false);
|
||||
if (attrs.Length > 0 && (attrs[0] as BrowsableAttribute).Browsable == false)
|
||||
{
|
||||
this.tbLocation.IsEnabled = false;
|
||||
return;
|
||||
|
|
@ -38,6 +38,9 @@
|
|||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="YAMP">
|
||||
<HintPath>..\packages\YAMP.1.3.0\lib\net35\YAMP.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -52,6 +55,12 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CMD\CMDStorage.cs" />
|
||||
<Compile Include="ProgramSetting.xaml.cs">
|
||||
<DependentUpon>ProgramSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProgramSourceSetting.xaml.cs">
|
||||
<DependentUpon>ProgramSourceSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProgramSources\AppPathsProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\CommonStartMenuProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\PortableAppsProgramSource.cs" />
|
||||
|
|
@ -85,6 +94,16 @@
|
|||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="ProgramSetting.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ProgramSourceSetting.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
|
|
|
|||
|
|
@ -76,56 +76,7 @@
|
|||
<Button x:Name="btnAddCustomeHotkey" Click="BtnAddCustomeHotkey_OnClick" Width="100" Margin="10" Content="Add"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Programs">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ListView x:Name="programSourceView" Grid.Row="0">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="Location" Width="400">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={wox:StringEmptyConverter}}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Header="Type" Width="150">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Type}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Header="Bonus Points" Width="100">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding BonusPoints}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Header="Enabled" Width="100">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Enabled}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
<StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Button x:Name="btnDeleteProgramSource" Click="btnDeleteProgramSource_OnClick" Width="100" Margin="10" Content="Delete"/>
|
||||
<Button x:Name="btnEditProgramSource" Click="btnEditProgramSource_OnClick" Width="100" Margin="10" Content="Edit"/>
|
||||
<Button x:Name="btnAddProgramSource" Click="btnAddProgramSource_OnClick" Width="100" Margin="10" Content="Add"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="1" Margin="10" HorizontalAlignment="Left" Text="* Restarting required" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabItem>
|
||||
<TabItem Header="Web Search">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
|
|
|
|||
|
|
@ -153,7 +153,6 @@ namespace Wox
|
|||
themeComboBox.SelectedItem = UserSettingStorage.Instance.Theme;
|
||||
cbReplaceWinR.IsChecked = UserSettingStorage.Instance.ReplaceWinR;
|
||||
webSearchView.ItemsSource = UserSettingStorage.Instance.WebSearches;
|
||||
programSourceView.ItemsSource = UserSettingStorage.Instance.ProgramSources;
|
||||
lvCustomHotkey.ItemsSource = UserSettingStorage.Instance.CustomPluginHotkeys;
|
||||
cbEnablePythonPlugins.IsChecked = UserSettingStorage.Instance.EnablePythonPlugins;
|
||||
cbStartWithWindows.IsChecked = File.Exists(woxLinkPath);
|
||||
|
|
@ -202,10 +201,6 @@ namespace Wox
|
|||
webSearchView.Items.Refresh();
|
||||
}
|
||||
|
||||
public void ReloadProgramSourceView()
|
||||
{
|
||||
programSourceView.Items.Refresh();
|
||||
}
|
||||
|
||||
private List<string> LoadAvailableThemes()
|
||||
{
|
||||
|
|
@ -252,43 +247,6 @@ namespace Wox
|
|||
}
|
||||
}
|
||||
|
||||
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProgramSourceSetting programSource = new ProgramSourceSetting(this);
|
||||
programSource.ShowDialog();
|
||||
}
|
||||
|
||||
private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProgramSource seletedProgramSource = programSourceView.SelectedItem as ProgramSource;
|
||||
if (seletedProgramSource != null &&
|
||||
MessageBox.Show("Are your sure to delete " + seletedProgramSource.ToString(), "Delete ProgramSource",
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
UserSettingStorage.Instance.ProgramSources.Remove(seletedProgramSource);
|
||||
programSourceView.Items.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please select a program source");
|
||||
}
|
||||
}
|
||||
|
||||
private void btnEditProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProgramSource seletedProgramSource = programSourceView.SelectedItem as ProgramSource;
|
||||
if (seletedProgramSource != null)
|
||||
{
|
||||
ProgramSourceSetting programSource = new ProgramSourceSetting(this);
|
||||
programSource.UpdateItem(seletedProgramSource);
|
||||
programSource.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please select a program source");
|
||||
}
|
||||
}
|
||||
|
||||
private void CbStartWithWindows_OnChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CreateStartupFolderShortcut();
|
||||
|
|
|
|||
|
|
@ -120,9 +120,6 @@
|
|||
<Compile Include="Helper\WallpaperPathRetrieval.cs" />
|
||||
<Compile Include="Helper\WindowIntelopHelper.cs" />
|
||||
<Compile Include="OpacityModeConverter.cs" />
|
||||
<Compile Include="ProgramSourceSetting.xaml.cs">
|
||||
<DependentUpon>ProgramSourceSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CustomPluginHotkeySetting.xaml.cs">
|
||||
<DependentUpon>CustomPluginHotkeySetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
@ -160,10 +157,6 @@
|
|||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ProgramSourceSetting.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="CustomPluginHotkeySetting.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
|
|
|||
Loading…
Reference in a new issue