mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
#56 Add Font setting
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using WindowsInput;
|
||||
using WindowsInput.Native;
|
||||
@@ -21,10 +22,12 @@ using Wox.Plugin;
|
||||
using Wox.PluginLoader;
|
||||
using Application = System.Windows.Application;
|
||||
using ContextMenu = System.Windows.Forms.ContextMenu;
|
||||
using Control = System.Windows.Controls.Control;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MenuItem = System.Windows.Forms.MenuItem;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using MouseButton = System.Windows.Input.MouseButton;
|
||||
using TextBox = System.Windows.Controls.TextBox;
|
||||
using ToolTip = System.Windows.Controls.ToolTip;
|
||||
|
||||
namespace Wox
|
||||
@@ -394,6 +397,27 @@ namespace Wox
|
||||
Source = new Uri(Path.Combine(Directory.GetCurrentDirectory(), "Themes\\" + themeName + ".xaml"), UriKind.Absolute)
|
||||
};
|
||||
|
||||
|
||||
Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
|
||||
if (queryBoxStyle != null)
|
||||
{
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontFamilyProperty, new FontFamily(CommonStorage.Instance.UserSetting.QueryBoxFont)));
|
||||
}
|
||||
Style resultItemStyle = dict["ItemTitleStyle"] as Style;
|
||||
Style resultSubItemStyle = dict["ItemSubTitleStyle"] as Style;
|
||||
Style resultItemSelectedStyle = dict["ItemTitleSelectedStyle"] as Style;
|
||||
Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style;
|
||||
if (resultItemStyle != null && resultSubItemStyle != null
|
||||
&& resultSubItemSelectedStyle != null && resultItemSelectedStyle != null)
|
||||
{
|
||||
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(CommonStorage.Instance.UserSetting.ResultItemFont));
|
||||
|
||||
resultItemStyle.Setters.Add(fontFamily);
|
||||
resultSubItemStyle.Setters.Add(fontFamily);
|
||||
resultItemSelectedStyle.Setters.Add(fontFamily);
|
||||
resultSubItemSelectedStyle.Setters.Add(fontFamily);
|
||||
}
|
||||
|
||||
Application.Current.Resources.MergedDictionaries.Clear();
|
||||
Application.Current.Resources.MergedDictionaries.Add(dict);
|
||||
}
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
<CheckBox x:Name="cbReplaceWinR" />
|
||||
<TextBlock Text="Replace Win+R" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="10">
|
||||
<TextBlock Text="Theme:" />
|
||||
<ComboBox x:Name="themeComboBox" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="Hotkey">
|
||||
@@ -115,5 +111,48 @@
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="Theme">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"></ColumnDefinition>
|
||||
<ColumnDefinition></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Orientation="Horizontal" Margin="10" Grid.Column="0">
|
||||
<TextBlock Text="Theme:" />
|
||||
<ComboBox x:Name="themeComboBox" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120"/>
|
||||
</StackPanel>
|
||||
<Grid Margin="10" Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition ></RowDefinition>
|
||||
<RowDefinition Height="40"></RowDefinition>
|
||||
<RowDefinition Height="40"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition></ColumnDefinition>
|
||||
<ColumnDefinition></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal" Grid.ColumnSpan="2" Grid.Row="0" Margin="10">
|
||||
<Border Width="500" Style="{DynamicResource WindowBorderStyle}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50" ></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Text="Hello Wox" IsReadOnly="True" Style="{DynamicResource QueryBoxStyle}" Grid.Row="0"/>
|
||||
<wox:ResultPanel Grid.Row="1" x:Name="resultPanelPreview"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="0" Margin="10">
|
||||
<TextBlock Text="Query Box Font:" />
|
||||
<ComboBox x:Name="cbQueryBoxFont" ItemsSource="{x:Static Fonts.SystemFontFamilies}" SelectionChanged="CbQueryBoxFont_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="0" Margin="10">
|
||||
<TextBlock Text="Result Item Font:" />
|
||||
<ComboBox x:Name="cbResultItemFont" ItemsSource="{x:Static Fonts.SystemFontFamilies}" SelectionChanged="CbResultItemFont_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Window>
|
||||
|
||||
@@ -5,9 +5,11 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using IWshRuntimeLibrary;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
using Wox.Plugin;
|
||||
using Application = System.Windows.Forms.Application;
|
||||
using File = System.IO.File;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
@@ -57,6 +59,58 @@ namespace Wox
|
||||
CommonStorage.Instance.Save();
|
||||
};
|
||||
|
||||
#region Load Theme Data
|
||||
|
||||
if (!string.IsNullOrEmpty(CommonStorage.Instance.UserSetting.QueryBoxFont) &&
|
||||
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(CommonStorage.Instance.UserSetting.QueryBoxFont)) > 0)
|
||||
{
|
||||
cbQueryBoxFont.Text = CommonStorage.Instance.UserSetting.QueryBoxFont;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(CommonStorage.Instance.UserSetting.ResultItemFont) &&
|
||||
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(CommonStorage.Instance.UserSetting.ResultItemFont)) > 0)
|
||||
{
|
||||
cbResultItemFont.Text = CommonStorage.Instance.UserSetting.ResultItemFont;
|
||||
}
|
||||
resultPanelPreview.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/work.png",
|
||||
PluginDirectory = AppDomain.CurrentDomain.BaseDirectory
|
||||
},
|
||||
new Result()
|
||||
{
|
||||
Title = "Search applications",
|
||||
SubTitle = "Search applications, files (via everything plugin) and chrome bookmarks",
|
||||
IcoPath = "Images/work.png",
|
||||
PluginDirectory = AppDomain.CurrentDomain.BaseDirectory
|
||||
},
|
||||
new Result()
|
||||
{
|
||||
Title = "Search web contents with shortcuts",
|
||||
SubTitle = "e.g. search google with g keyword or youtube keyword)",
|
||||
IcoPath = "Images/work.png",
|
||||
PluginDirectory = AppDomain.CurrentDomain.BaseDirectory
|
||||
},
|
||||
new Result()
|
||||
{
|
||||
Title = "clipboard history ",
|
||||
IcoPath = "Images/work.png",
|
||||
PluginDirectory = AppDomain.CurrentDomain.BaseDirectory
|
||||
},
|
||||
new Result()
|
||||
{
|
||||
Title = "Themes support",
|
||||
SubTitle = "get more themes from http://www.getwox.com/theme",
|
||||
IcoPath = "Images/work.png",
|
||||
PluginDirectory = AppDomain.CurrentDomain.BaseDirectory
|
||||
}
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
foreach (string theme in LoadAvailableThemes())
|
||||
{
|
||||
@@ -83,13 +137,7 @@ namespace Wox
|
||||
return Directory.GetFiles(themePath).Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Default.xaml")).ToList();
|
||||
}
|
||||
|
||||
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
string themeName = themeComboBox.SelectedItem.ToString();
|
||||
MainWindow.SetTheme(themeName);
|
||||
CommonStorage.Instance.UserSetting.Theme = themeName;
|
||||
CommonStorage.Instance.Save();
|
||||
}
|
||||
|
||||
|
||||
private void btnAddWebSearch_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -231,5 +279,32 @@ namespace Wox
|
||||
{
|
||||
Process.Start("Wox.UAC.exe", "AssociatePluginInstaller");
|
||||
}
|
||||
|
||||
#region Theme
|
||||
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
string themeName = themeComboBox.SelectedItem.ToString();
|
||||
MainWindow.SetTheme(themeName);
|
||||
CommonStorage.Instance.UserSetting.Theme = themeName;
|
||||
CommonStorage.Instance.Save();
|
||||
}
|
||||
|
||||
private void CbQueryBoxFont_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
string queryBoxFontName = cbQueryBoxFont.SelectedItem.ToString();
|
||||
CommonStorage.Instance.UserSetting.QueryBoxFont = queryBoxFontName;
|
||||
CommonStorage.Instance.Save();
|
||||
App.Window.SetTheme(CommonStorage.Instance.UserSetting.Theme);
|
||||
}
|
||||
|
||||
private void CbResultItemFont_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
string resultItemFont = cbResultItemFont.SelectedItem.ToString();
|
||||
CommonStorage.Instance.UserSetting.ResultItemFont = resultItemFont;
|
||||
CommonStorage.Instance.Save();
|
||||
App.Window.SetTheme(CommonStorage.Instance.UserSetting.Theme);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<Setter Property="Foreground" Value="#E3E0E3" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
||||
<Setter Property="FontFamily" Value="Arial, Serif" />
|
||||
</Style>
|
||||
<Style x:Key="BaseWindowBorderStyle" TargetType="{x:Type Border}">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
@@ -32,9 +33,11 @@
|
||||
<Setter Property="Foreground" Value="#FFFFF8" />
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
<Setter Property="FontWeight" Value="Medium" />
|
||||
<Setter Property="FontFamily" Value="Arial, Serif" />
|
||||
</Style>
|
||||
<Style x:Key="BaseItemSubTitleStyle" TargetType="{x:Type TextBlock}" >
|
||||
<Setter Property="Foreground" Value="#D9D9D4" />
|
||||
<Setter Property="FontFamily" Value="Arial, Serif" />
|
||||
</Style>
|
||||
<Style x:Key="BaseItemTitleSelectedStyle" TargetType="{x:Type TextBlock}" >
|
||||
<Setter Property="Foreground" Value="#FFFFF8" />
|
||||
|
||||
Reference in New Issue
Block a user