mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 20:57:22 +02:00
Databinding for theme tab
This commit is contained in:
@@ -24,12 +24,7 @@
|
|||||||
Left="{Binding Left, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
Left="{Binding Left, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
Top="{Binding Top, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
Top="{Binding Top, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
d:DataContext="{d:DesignInstance vm:MainViewModel, IsDesignTimeCreatable=True}">
|
d:DataContext="{d:DesignInstance vm:MainViewModel}">
|
||||||
<Window.Resources>
|
|
||||||
<DataTemplate DataType="{x:Type vm:ResultsViewModel}">
|
|
||||||
<wox:ResultListBox PreviewMouseDown="OnPreviewMouseButtonDown" />
|
|
||||||
</DataTemplate>
|
|
||||||
</Window.Resources>
|
|
||||||
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="OnMouseDown">
|
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="OnMouseDown">
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<TextBox Style="{DynamicResource QueryBoxStyle}"
|
<TextBox Style="{DynamicResource QueryBoxStyle}"
|
||||||
@@ -51,8 +46,12 @@
|
|||||||
Style="{DynamicResource PendingLineStyle}" Visibility="{Binding ProgressBarVisibility, Mode=TwoWay}"
|
Style="{DynamicResource PendingLineStyle}" Visibility="{Binding ProgressBarVisibility, Mode=TwoWay}"
|
||||||
Y1="0" Y2="0" X2="100" Height="2" Width="752" StrokeThickness="1">
|
Y1="0" Y2="0" X2="100" Height="2" Width="752" StrokeThickness="1">
|
||||||
</Line>
|
</Line>
|
||||||
<ContentControl Name="Results" Content="{Binding Results}" Visibility="{Binding ResultListBoxVisibility}" />
|
<ContentControl Visibility="{Binding ResultListBoxVisibility}" >
|
||||||
<ContentControl Name ="ContextMenu" Content="{Binding ContextMenu}" Visibility="{Binding ContextMenuVisibility}" />
|
<wox:ResultListBox DataContext="{Binding Results}" PreviewMouseDown="OnPreviewMouseButtonDown" />
|
||||||
|
</ContentControl>
|
||||||
|
<ContentControl Visibility="{Binding ContextMenuVisibility}">
|
||||||
|
<wox:ResultListBox DataContext="{Binding ContextMenu}" PreviewMouseDown="OnPreviewMouseButtonDown" />
|
||||||
|
</ContentControl>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -101,8 +101,8 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
|
_settingsViewModel.SelectedTab = (Tab)tab;
|
||||||
SettingWindow sw = SingletonWindowOpener.Open<SettingWindow>(this, _settingsViewModel);
|
SettingWindow sw = SingletonWindowOpener.Open<SettingWindow>(this, _settingsViewModel);
|
||||||
_settingsViewModel.SelectedTab = (Tab) tab;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
MaxHeight="{Binding MaxHeight}"
|
MaxHeight="{Binding MaxHeight}"
|
||||||
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
|
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
|
||||||
SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"
|
SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"
|
||||||
HorizontalContentAlignment="Stretch" ItemsSource="{Binding Results}" Margin="{Binding Margin}"
|
HorizontalContentAlignment="Stretch" ItemsSource="{Binding Results}"
|
||||||
|
Margin="{Binding Margin}"
|
||||||
Style="{DynamicResource BaseListboxStyle}" Focusable="False"
|
Style="{DynamicResource BaseListboxStyle}" Focusable="False"
|
||||||
KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single"
|
KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single"
|
||||||
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard"
|
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard"
|
||||||
|
|||||||
@@ -12,15 +12,6 @@ namespace Wox
|
|||||||
[Synchronization]
|
[Synchronization]
|
||||||
public partial class ResultListBox
|
public partial class ResultListBox
|
||||||
{
|
{
|
||||||
public void AddResults(List<Result> newRawResults)
|
|
||||||
{
|
|
||||||
var vm = (ResultsViewModel) DataContext;
|
|
||||||
var newResults = newRawResults.Select(r => new ResultViewModel(r)).ToList();
|
|
||||||
vm.Results.Update(newResults);
|
|
||||||
vm.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ResultListBox()
|
public ResultListBox()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
Height="600" Width="800" PreviewKeyDown="Window_PreviewKeyDown"
|
Height="600" Width="800" PreviewKeyDown="Window_PreviewKeyDown"
|
||||||
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}">
|
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}">
|
||||||
<TabControl Height="auto" SelectedIndex="{Binding SelectedTab}">
|
<TabControl Height="auto" SelectedIndex="{Binding SelectedTab, FallbackValue=0}">
|
||||||
<TabItem Header="{DynamicResource general}" Height="24" VerticalAlignment="Top">
|
<TabItem Header="{DynamicResource general}" Height="24" VerticalAlignment="Top">
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<CheckBox IsChecked="{Binding Settings.StartWoxOnSystemStartup}" Margin="10">
|
<CheckBox IsChecked="{Binding Settings.StartWoxOnSystemStartup}" Margin="10">
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
MouseUp="OnMorePluginsClicked" Foreground="Blue"
|
MouseUp="OnMorePluginsClicked" Foreground="Blue"
|
||||||
Text="{DynamicResource browserMorePlugins}" />
|
Text="{DynamicResource browserMorePlugins}" />
|
||||||
<ListBox SelectedIndex="0" SelectedItem="{Binding SelectedPlugin}"
|
<ListBox SelectedIndex="0" SelectedItem="{Binding SelectedPlugin}"
|
||||||
ItemsSource="{Binding MetadataViewModels}"
|
ItemsSource="{Binding PluginViewModels}"
|
||||||
Margin="10, 0, 10, 10" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
Margin="10, 0, 10, 10" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
@@ -152,7 +152,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="{DynamicResource theme}" Selector.Selected="OnThemeTabSelected">
|
<TabItem Header="{DynamicResource theme}">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="200" />
|
<ColumnDefinition Width="200" />
|
||||||
@@ -160,18 +160,18 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<DockPanel Grid.Column="0">
|
<DockPanel Grid.Column="0">
|
||||||
<TextBlock DockPanel.Dock="Top" Margin="10" HorizontalAlignment="Left" Cursor="Hand"
|
<TextBlock DockPanel.Dock="Top" Margin="10" HorizontalAlignment="Left" Cursor="Hand"
|
||||||
MouseUp="tbMoreThemes_MouseUp" Foreground="Blue"
|
MouseUp="OnMoreThemesClick" Foreground="Blue"
|
||||||
Text="{DynamicResource browserMoreThemes}" />
|
Text="{DynamicResource browserMoreThemes}" />
|
||||||
<ListBox x:Name="Theme" Margin="10, 0, 10, 10"
|
<ListBox SelectedItem="{Binding SelectedTheme}" ItemsSource="{Binding Themes}"
|
||||||
SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Stretch"
|
Margin="10, 0, 10, 10" Width="180"
|
||||||
VerticalAlignment="Stretch" Width="180" />
|
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
<Grid Margin="0" Grid.Column="1">
|
<Grid Margin="0" Grid.Column="1">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition Height="100" />
|
<RowDefinition Height="100" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel x:Name="PreviewPanel" Grid.Row="0" Margin="0">
|
<StackPanel Background="{Binding PreviewBackground}" Grid.Row="0" Margin="0">
|
||||||
<StackPanel Orientation="Horizontal" Margin="10"
|
<StackPanel Orientation="Horizontal" Margin="10"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center">
|
HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
<Border Width="500" Style="{DynamicResource WindowBorderStyle}">
|
<Border Width="500" Style="{DynamicResource WindowBorderStyle}">
|
||||||
@@ -182,7 +182,9 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBox Text="{DynamicResource helloWox}" IsReadOnly="True"
|
<TextBox Text="{DynamicResource helloWox}" IsReadOnly="True"
|
||||||
Style="{DynamicResource QueryBoxStyle}" Grid.Row="0" />
|
Style="{DynamicResource QueryBoxStyle}" Grid.Row="0" />
|
||||||
<wox:ResultListBox Grid.Row="1" x:Name="ResultListBoxPreview" />
|
<ContentControl Visibility="Visible" Grid.Row="1">
|
||||||
|
<wox:ResultListBox DataContext="{Binding PreviewResults}" />
|
||||||
|
</ContentControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -191,15 +193,13 @@
|
|||||||
<StackPanel Grid.Row="1" Margin="0 10 0 10" Orientation="Vertical">
|
<StackPanel Grid.Row="1" Margin="0 10 0 10" Orientation="Vertical">
|
||||||
<StackPanel Orientation="Horizontal" Margin="2">
|
<StackPanel Orientation="Horizontal" Margin="2">
|
||||||
<TextBlock Text="{DynamicResource queryBoxFont}" />
|
<TextBlock Text="{DynamicResource queryBoxFont}" />
|
||||||
<ComboBox Margin="10 -2 5 0" x:Name="QueryBoxFont"
|
<ComboBox ItemsSource="{x:Static Fonts.SystemFontFamilies}"
|
||||||
ItemsSource="{x:Static Fonts.SystemFontFamilies}"
|
SelectedItem="{Binding SelectedQueryBoxFont}"
|
||||||
SelectionChanged="CbQueryBoxFont_OnSelectionChanged" HorizontalAlignment="Left"
|
HorizontalAlignment="Left" VerticalAlignment="Top" Width="160" Margin="10 -2 5 0"/>
|
||||||
VerticalAlignment="Top" Width="160" />
|
<ComboBox ItemsSource="{Binding SelectedQueryBoxFont.FamilyTypefaces}"
|
||||||
<ComboBox Margin="0 -2 0 0"
|
SelectedItem="{Binding SelectedQueryBoxFontFaces}"
|
||||||
x:Name="QueryBoxFontFaces"
|
HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||||
ItemsSource="{Binding SelectedValue.FamilyTypefaces, ElementName=QueryBoxFont}"
|
Width="120" Margin="0 -2 0 0">
|
||||||
SelectionChanged="CbQueryBoxFontFaces_OnSelectionChanged"
|
|
||||||
HorizontalAlignment="Left" VerticalAlignment="Top" Width="120">
|
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
|
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
|
||||||
@@ -215,15 +215,14 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" Margin="2">
|
<StackPanel Orientation="Horizontal" Margin="2">
|
||||||
<TextBlock Text="{DynamicResource resultItemFont}" />
|
<TextBlock Text="{DynamicResource resultItemFont}" />
|
||||||
<ComboBox Margin="5 -2 5 0" x:Name="ResultFontComboBox"
|
<ComboBox ItemsSource="{x:Static Fonts.SystemFontFamilies}"
|
||||||
ItemsSource="{x:Static Fonts.SystemFontFamilies}"
|
SelectedItem="{Binding SelectedResultFont}"
|
||||||
SelectionChanged="OnResultFontSelectionChanged" HorizontalAlignment="Left"
|
HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||||
VerticalAlignment="Top" Width="160" />
|
Width="160" Margin="5 -2 5 0" />
|
||||||
<ComboBox Margin="0 -2 0 0"
|
<ComboBox ItemsSource="{Binding SelectedResultFont.FamilyTypefaces}"
|
||||||
x:Name="ResultFontFacesComboBox"
|
SelectedItem="{Binding SelectedResultFontFaces}"
|
||||||
ItemsSource="{Binding SelectedValue.FamilyTypefaces, ElementName=ResultFontComboBox}"
|
HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||||
SelectionChanged="OnResultFontFacesSelectionChanged" HorizontalAlignment="Left"
|
Width="120" Margin="0 -2 0 0">
|
||||||
VerticalAlignment="Top" Width="120">
|
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
|
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
|
||||||
@@ -242,7 +241,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="{DynamicResource hotkey}" Selector.Selected="OnThemeTabSelected">
|
<TabItem Header="{DynamicResource hotkey}" Selector.Selected="OnHotkeyTabSelected">
|
||||||
<Grid Margin="10">
|
<Grid Margin="10">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="30" />
|
<RowDefinition Height="30" />
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ namespace Wox
|
|||||||
DataContext = viewModel;
|
DataContext = viewModel;
|
||||||
_viewModel = viewModel;
|
_viewModel = viewModel;
|
||||||
_api = api;
|
_api = api;
|
||||||
ResultListBoxPreview.DataContext = new ResultsViewModel(_settings);
|
|
||||||
Loaded += Setting_Loaded;
|
Loaded += Setting_Loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,189 +259,10 @@ namespace Wox
|
|||||||
|
|
||||||
#region Theme
|
#region Theme
|
||||||
|
|
||||||
private void tbMoreThemes_MouseUp(object sender, MouseButtonEventArgs e)
|
private void OnMoreThemesClick(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
Process.Start("http://www.getwox.com/theme");
|
Process.Start("http://www.getwox.com/theme");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnThemeTabSelected(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Stopwatch.Debug("theme load", () =>
|
|
||||||
{
|
|
||||||
var s = Fonts.SystemFontFamilies;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (themeTabLoaded) return;
|
|
||||||
|
|
||||||
themeTabLoaded = true;
|
|
||||||
if (!string.IsNullOrEmpty(_settings.QueryBoxFont) &&
|
|
||||||
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(_settings.QueryBoxFont)) > 0)
|
|
||||||
{
|
|
||||||
QueryBoxFont.Text = _settings.QueryBoxFont;
|
|
||||||
|
|
||||||
QueryBoxFontFaces.SelectedItem =
|
|
||||||
SyntaxSugars.CallOrRescueDefault(
|
|
||||||
() => ((FontFamily)QueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
|
||||||
_settings.QueryBoxFontStyle,
|
|
||||||
_settings.QueryBoxFontWeight,
|
|
||||||
_settings.QueryBoxFontStretch
|
|
||||||
));
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(_settings.ResultFont) &&
|
|
||||||
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(_settings.ResultFont)) > 0)
|
|
||||||
{
|
|
||||||
ResultFontComboBox.Text = _settings.ResultFont;
|
|
||||||
|
|
||||||
ResultFontFacesComboBox.SelectedItem =
|
|
||||||
SyntaxSugars.CallOrRescueDefault(
|
|
||||||
() => ((FontFamily)ResultFontComboBox.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
|
||||||
_settings.ResultFontStyle,
|
|
||||||
_settings.ResultFontWeight,
|
|
||||||
_settings.ResultFontStretch
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
ResultListBoxPreview.AddResults(new List<Result>
|
|
||||||
{
|
|
||||||
new Result
|
|
||||||
{
|
|
||||||
Title = "Wox is an effective launcher for windows",
|
|
||||||
SubTitle = "Wox provide bundles of features let you access infomations quickly.",
|
|
||||||
IcoPath = "Images/app.png",
|
|
||||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
|
|
||||||
},
|
|
||||||
new Result
|
|
||||||
{
|
|
||||||
Title = "Search applications",
|
|
||||||
SubTitle = "Search applications, files (via everything plugin) and browser bookmarks",
|
|
||||||
IcoPath = "Images/app.png",
|
|
||||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
|
|
||||||
},
|
|
||||||
new Result
|
|
||||||
{
|
|
||||||
Title = "Search web contents with shortcuts",
|
|
||||||
SubTitle = "e.g. search google with g keyword or youtube keyword)",
|
|
||||||
IcoPath = "Images/app.png",
|
|
||||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
|
|
||||||
},
|
|
||||||
new Result
|
|
||||||
{
|
|
||||||
Title = "clipboard history ",
|
|
||||||
IcoPath = "Images/app.png",
|
|
||||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
|
|
||||||
},
|
|
||||||
new Result
|
|
||||||
{
|
|
||||||
Title = "Themes support",
|
|
||||||
SubTitle = "get more themes from http://www.getwox.com/theme",
|
|
||||||
IcoPath = "Images/app.png",
|
|
||||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
|
|
||||||
},
|
|
||||||
new Result
|
|
||||||
{
|
|
||||||
Title = "Plugins support",
|
|
||||||
SubTitle = "get more plugins from http://www.getwox.com/plugin",
|
|
||||||
IcoPath = "Images/app.png",
|
|
||||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
|
|
||||||
},
|
|
||||||
new Result
|
|
||||||
{
|
|
||||||
Title = "Wox is an open-source software",
|
|
||||||
SubTitle = "Wox benefits from the open-source community a lot",
|
|
||||||
IcoPath = "Images/app.png",
|
|
||||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (string theme in ThemeManager.Instance.LoadAvailableThemes())
|
|
||||||
{
|
|
||||||
string themeName = Path.GetFileNameWithoutExtension(theme);
|
|
||||||
Theme.Items.Add(themeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
Theme.SelectedItem = _settings.Theme;
|
|
||||||
|
|
||||||
var wallpaper = WallpaperPathRetrieval.GetWallpaperPath();
|
|
||||||
if (wallpaper != null && File.Exists(wallpaper))
|
|
||||||
{
|
|
||||||
var memStream = new MemoryStream(File.ReadAllBytes(wallpaper));
|
|
||||||
var bitmap = new BitmapImage();
|
|
||||||
bitmap.BeginInit();
|
|
||||||
bitmap.StreamSource = memStream;
|
|
||||||
bitmap.EndInit();
|
|
||||||
var brush = new ImageBrush(bitmap);
|
|
||||||
brush.Stretch = Stretch.UniformToFill;
|
|
||||||
PreviewPanel.Background = brush;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor();
|
|
||||||
PreviewPanel.Background = new SolidColorBrush(wallpaperColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
string themeName = Theme.SelectedItem.ToString();
|
|
||||||
ThemeManager.Instance.ChangeTheme(themeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CbQueryBoxFont_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (!settingsLoaded) return;
|
|
||||||
string queryBoxFontName = QueryBoxFont.SelectedItem.ToString();
|
|
||||||
_settings.QueryBoxFont = queryBoxFontName;
|
|
||||||
QueryBoxFontFaces.SelectedItem = ((FontFamily)QueryBoxFont.SelectedItem).ChooseRegularFamilyTypeface();
|
|
||||||
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CbQueryBoxFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (!settingsLoaded) return;
|
|
||||||
FamilyTypeface typeface = (FamilyTypeface)QueryBoxFontFaces.SelectedItem;
|
|
||||||
if (typeface == null)
|
|
||||||
{
|
|
||||||
if (QueryBoxFontFaces.Items.Count > 0)
|
|
||||||
QueryBoxFontFaces.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_settings.QueryBoxFontStretch = typeface.Stretch.ToString();
|
|
||||||
_settings.QueryBoxFontWeight = typeface.Weight.ToString();
|
|
||||||
_settings.QueryBoxFontStyle = typeface.Style.ToString();
|
|
||||||
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnResultFontSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (!settingsLoaded) return;
|
|
||||||
string resultItemFont = ResultFontComboBox.SelectedItem.ToString();
|
|
||||||
_settings.ResultFont = resultItemFont;
|
|
||||||
ResultFontFacesComboBox.SelectedItem =
|
|
||||||
((FontFamily)ResultFontComboBox.SelectedItem).ChooseRegularFamilyTypeface();
|
|
||||||
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnResultFontFacesSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (!settingsLoaded) return;
|
|
||||||
FamilyTypeface typeface = (FamilyTypeface)ResultFontFacesComboBox.SelectedItem;
|
|
||||||
if (typeface == null)
|
|
||||||
{
|
|
||||||
if (ResultFontFacesComboBox.Items.Count > 0)
|
|
||||||
ResultFontFacesComboBox.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_settings.ResultFontStretch = typeface.Stretch.ToString();
|
|
||||||
_settings.ResultFontWeight = typeface.Weight.ToString();
|
|
||||||
_settings.ResultFontStyle = typeface.Style.ToString();
|
|
||||||
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Plugin
|
#region Plugin
|
||||||
|
|||||||
@@ -232,14 +232,14 @@ namespace Wox.ViewModel
|
|||||||
|
|
||||||
private void InitializeResultListBox()
|
private void InitializeResultListBox()
|
||||||
{
|
{
|
||||||
Results = new ResultsViewModel(_settings);
|
Results = new ResultsViewModel(_settings.MaxResultsToShow);
|
||||||
ResultListBoxVisibility = Visibility.Collapsed;
|
ResultListBoxVisibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void InitializeContextMenu()
|
private void InitializeContextMenu()
|
||||||
{
|
{
|
||||||
ContextMenu = new ResultsViewModel(_settings);
|
ContextMenu = new ResultsViewModel(_settings.MaxResultsToShow);
|
||||||
ContextMenuVisibility = Visibility.Collapsed;
|
ContextMenuVisibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,20 +19,23 @@ namespace Wox.ViewModel
|
|||||||
|
|
||||||
private readonly object _addResultsLock = new object();
|
private readonly object _addResultsLock = new object();
|
||||||
private readonly object _collectionLock = new object();
|
private readonly object _collectionLock = new object();
|
||||||
private readonly Settings _settings;
|
public int MaxResults = 6;
|
||||||
|
|
||||||
public ResultsViewModel(Settings settings)
|
public ResultsViewModel()
|
||||||
{
|
{
|
||||||
_settings = settings;
|
|
||||||
Results = new ResultCollection();
|
Results = new ResultCollection();
|
||||||
BindingOperations.EnableCollectionSynchronization(Results, _collectionLock);
|
BindingOperations.EnableCollectionSynchronization(Results, _collectionLock);
|
||||||
}
|
}
|
||||||
|
public ResultsViewModel(int maxResults) : this()
|
||||||
|
{
|
||||||
|
MaxResults = maxResults;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ViewModel Properties
|
#region ViewModel Properties
|
||||||
|
|
||||||
public int MaxHeight => _settings.MaxResultsToShow * 50;
|
public int MaxHeight => MaxResults * 50;
|
||||||
|
|
||||||
public int SelectedIndex
|
public int SelectedIndex
|
||||||
{
|
{
|
||||||
@@ -108,12 +111,12 @@ namespace Wox.ViewModel
|
|||||||
|
|
||||||
public void SelectNextPage()
|
public void SelectNextPage()
|
||||||
{
|
{
|
||||||
SelectedIndex = NewIndex(SelectedIndex + _settings.MaxResultsToShow);
|
SelectedIndex = NewIndex(SelectedIndex + MaxResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectPrevPage()
|
public void SelectPrevPage()
|
||||||
{
|
{
|
||||||
SelectedIndex = NewIndex(SelectedIndex - _settings.MaxResultsToShow);
|
SelectedIndex = NewIndex(SelectedIndex - MaxResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
using PropertyChanged;
|
using PropertyChanged;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
using Wox.Core.Resource;
|
using Wox.Core.Resource;
|
||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
|
using Wox.Helper;
|
||||||
using Wox.Infrastructure.Storage;
|
using Wox.Infrastructure.Storage;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using static System.String;
|
using static System.String;
|
||||||
@@ -22,8 +27,11 @@ namespace Wox.ViewModel
|
|||||||
private readonly Dictionary<ISettingProvider, Control> _featureControls = new Dictionary<ISettingProvider, Control>();
|
private readonly Dictionary<ISettingProvider, Control> _featureControls = new Dictionary<ISettingProvider, Control>();
|
||||||
|
|
||||||
public Tab SelectedTab { get; set; } = Tab.General;
|
public Tab SelectedTab { get; set; } = Tab.General;
|
||||||
|
#region general
|
||||||
public List<Language> Languages => InternationalizationManager.Instance.LoadAvailableLanguages();
|
public List<Language> Languages => InternationalizationManager.Instance.LoadAvailableLanguages();
|
||||||
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
|
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
|
||||||
|
#endregion
|
||||||
|
#region plugin
|
||||||
public PluginViewModel SelectedPlugin { get; set; }
|
public PluginViewModel SelectedPlugin { get; set; }
|
||||||
public IList<PluginViewModel> PluginViewModels
|
public IList<PluginViewModel> PluginViewModels
|
||||||
{
|
{
|
||||||
@@ -92,16 +100,198 @@ namespace Wox.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
#region theme
|
||||||
|
|
||||||
|
public string SelectedTheme
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Settings.Theme;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Settings.Theme = value;
|
||||||
|
ThemeManager.Instance.ChangeTheme(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<string> Themes => ThemeManager.Instance.LoadAvailableThemes().Select(Path.GetFileNameWithoutExtension).ToList();
|
||||||
|
|
||||||
|
public Brush PreviewBackground
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var wallpaper = WallpaperPathRetrieval.GetWallpaperPath();
|
||||||
|
if (wallpaper != null && File.Exists(wallpaper))
|
||||||
|
{
|
||||||
|
var memStream = new MemoryStream(File.ReadAllBytes(wallpaper));
|
||||||
|
var bitmap = new BitmapImage();
|
||||||
|
bitmap.BeginInit();
|
||||||
|
bitmap.StreamSource = memStream;
|
||||||
|
bitmap.EndInit();
|
||||||
|
var brush = new ImageBrush(bitmap) { Stretch = Stretch.UniformToFill };
|
||||||
|
return brush;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor();
|
||||||
|
var brush = new SolidColorBrush(wallpaperColor);
|
||||||
|
return brush;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultsViewModel PreviewResults
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
|
||||||
|
const string image = "app.png";
|
||||||
|
const string theme = "http://www.getwox.com/theme/builder";
|
||||||
|
const string plugin = "http://www.getwox.com/plugin";
|
||||||
|
List<Result> results = new List<Result>
|
||||||
|
{
|
||||||
|
new Result
|
||||||
|
{
|
||||||
|
Title = "WoX is a launcher for Windows that simply works.",
|
||||||
|
SubTitle = "You can call it Windows omni-eXecutor if you want a long name.",
|
||||||
|
IcoPath = image,
|
||||||
|
},
|
||||||
|
new Result
|
||||||
|
{
|
||||||
|
Title = "Search for everything—applications, folders, files and more.",
|
||||||
|
SubTitle = "Use pinyin to search for programs. (yyy / wangyiyun → 网易云音乐)",
|
||||||
|
IcoPath = image,
|
||||||
|
},
|
||||||
|
new Result
|
||||||
|
{
|
||||||
|
Title = "Keyword plugin search.",
|
||||||
|
SubTitle = "search google with g search_term.",
|
||||||
|
IcoPath = image,
|
||||||
|
},
|
||||||
|
new Result
|
||||||
|
{
|
||||||
|
Title = "Build custom themes at: ",
|
||||||
|
SubTitle = theme,
|
||||||
|
},
|
||||||
|
new Result
|
||||||
|
{
|
||||||
|
Title = "Install plugins from: ",
|
||||||
|
SubTitle = plugin,
|
||||||
|
IcoPath = image,
|
||||||
|
},
|
||||||
|
new Result
|
||||||
|
{
|
||||||
|
Title = $"Open Source: {Infrastructure.Constant.Github}",
|
||||||
|
SubTitle = "Please star it!",
|
||||||
|
IcoPath = image,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var vm = new ResultsViewModel(6);
|
||||||
|
vm.AddResults(results, "PREVIEW");
|
||||||
|
return vm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FontFamily SelectedQueryBoxFont
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Fonts.SystemFontFamilies.Count(o =>
|
||||||
|
o.FamilyNames.Values != null &&
|
||||||
|
o.FamilyNames.Values.Contains(Settings.QueryBoxFont)) > 0)
|
||||||
|
{
|
||||||
|
var font = new FontFamily(Settings.QueryBoxFont);
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var font = new FontFamily("Segoe UI");
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Settings.QueryBoxFont = value.ToString();
|
||||||
|
ThemeManager.Instance.ChangeTheme(Settings.Theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FamilyTypeface SelectedQueryBoxFontFaces
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var typeface = SyntaxSugars.CallOrRescueDefault(
|
||||||
|
() => SelectedQueryBoxFont.ConvertFromInvariantStringsOrNormal(
|
||||||
|
Settings.QueryBoxFontStyle,
|
||||||
|
Settings.QueryBoxFontWeight,
|
||||||
|
Settings.QueryBoxFontStretch
|
||||||
|
));
|
||||||
|
return typeface;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Settings.QueryBoxFontStretch = value.Stretch.ToString();
|
||||||
|
Settings.QueryBoxFontWeight = value.Weight.ToString();
|
||||||
|
Settings.QueryBoxFontStyle = value.Style.ToString();
|
||||||
|
ThemeManager.Instance.ChangeTheme(Settings.Theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FontFamily SelectedResultFont
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Fonts.SystemFontFamilies.Count(o =>
|
||||||
|
o.FamilyNames.Values != null &&
|
||||||
|
o.FamilyNames.Values.Contains(Settings.ResultFont)) > 0)
|
||||||
|
{
|
||||||
|
var font = new FontFamily(Settings.ResultFont);
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var font = new FontFamily("Segoe UI");
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Settings.ResultFont = value.ToString();
|
||||||
|
ThemeManager.Instance.ChangeTheme(Settings.Theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FamilyTypeface SelectedResultFontFaces
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var typeface = SyntaxSugars.CallOrRescueDefault(
|
||||||
|
() => SelectedQueryBoxFont.ConvertFromInvariantStringsOrNormal(
|
||||||
|
Settings.ResultFontStyle,
|
||||||
|
Settings.ResultFontWeight,
|
||||||
|
Settings.ResultFontStretch
|
||||||
|
));
|
||||||
|
return typeface;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Settings.ResultFontStretch = value.Stretch.ToString();
|
||||||
|
Settings.ResultFontWeight = value.Weight.ToString();
|
||||||
|
Settings.ResultFontStyle = value.Style.ToString();
|
||||||
|
ThemeManager.Instance.ChangeTheme(Settings.Theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
public SettingWindowViewModel()
|
public SettingWindowViewModel()
|
||||||
{
|
{
|
||||||
_storage = new JsonStrorage<Settings>();
|
_storage = new JsonStrorage<Settings>();
|
||||||
Settings = _storage.Load();
|
Settings = _storage.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo happlebao save
|
||||||
|
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
_storage.Save();
|
_storage.Save();
|
||||||
|
|||||||
Reference in New Issue
Block a user