Add opacity mode settings

This commit is contained in:
Yeechan Lu 2014-03-26 17:34:19 +08:00
parent 45f32ba62c
commit 343da4878d
6 changed files with 248 additions and 127 deletions

View File

@ -56,6 +56,12 @@ namespace Wox.Infrastructure.Storage.UserSettings
[JsonProperty] [JsonProperty]
public bool EnablePythonPlugins { get; set; } public bool EnablePythonPlugins { get; set; }
[JsonProperty]
public double Opacity { get; set; }
[JsonProperty]
public OpacityMode OpacityMode { get; set; }
public List<WebSearch> LoadDefaultWebSearches() public List<WebSearch> LoadDefaultWebSearches()
{ {
List<WebSearch> webSearches = new List<WebSearch>(); List<WebSearch> webSearches = new List<WebSearch>();
@ -123,6 +129,16 @@ namespace Wox.Infrastructure.Storage.UserSettings
Hotkey = "Alt + Space"; Hotkey = "Alt + Space";
QueryBoxFont = FontFamily.GenericSansSerif.Name; QueryBoxFont = FontFamily.GenericSansSerif.Name;
ResultItemFont = FontFamily.GenericSansSerif.Name; ResultItemFont = FontFamily.GenericSansSerif.Name;
} Opacity = 1;
OpacityMode = OpacityMode.Normal;
}
}
public enum OpacityMode
{
Normal = 0,
LayeredWindow = 1,
DWM = 2
} }
} }

View File

@ -51,6 +51,9 @@ namespace Wox
InitializeComponent(); InitializeComponent();
initialized = true; initialized = true;
if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow)
this.AllowsTransparency = true;
System.Net.WebRequest.RegisterPrefix("data", new DataWebRequestFactory()); System.Net.WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
@ -89,7 +92,9 @@ namespace Wox
Plugins.Init(); Plugins.Init();
InitProgressbarAnimation(); InitProgressbarAnimation();
//only works for win7+ //only works for win7+
if (UserSettingStorage.Instance.OpacityMode == OpacityMode.DWM)
DwmDropShadow.DropShadowToWindow(this); DwmDropShadow.DropShadowToWindow(this);
WindowIntelopHelper.DisableControlBox(this); WindowIntelopHelper.DisableControlBox(this);
@ -461,6 +466,11 @@ namespace Wox
Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.MergedDictionaries.Clear();
Application.Current.Resources.MergedDictionaries.Add(dict); Application.Current.Resources.MergedDictionaries.Add(dict);
if (this.AllowsTransparency)
this.Opacity = UserSettingStorage.Instance.Opacity;
else
this.Opacity = 1;
} }
#region Public API #region Public API

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Markup;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox
{
public class OpacityModeConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (!(value is OpacityMode)) return value.ToString();
var mode = (OpacityMode) value;
switch (mode)
{
case OpacityMode.Normal:
return "Normal Window";
case OpacityMode.LayeredWindow:
{
if (Environment.OSVersion.Version.Major < 5)
return "Layered Window (not supported by your Windows)";
if (Environment.OSVersion.Version.Major == 5)
return "Layered Window (not recommended on your Windows)";
return "Layered Window";
}
case OpacityMode.DWM:
{
if (Environment.OSVersion.Version.Major < 6)
return "DWM-Enabled Window (not supported by your Windows)";
return "DWM-Enabled Window";
}
}
return value.ToString();
}
public object ConvertBack(
object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}

View File

@ -1,7 +1,8 @@
<Window x:Class="Wox.SettingWindow" <Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wox="clr-namespace:Wox" xmlns:wox="clr-namespace:Wox"
xmlns:UserSettings="clr-namespace:Wox.Infrastructure.Storage.UserSettings;assembly=Wox.Infrastructure" x:Class="Wox.SettingWindow"
Icon="Images\app.png" Icon="Images\app.png"
Title="Wox Setting" Title="Wox Setting"
ResizeMode="NoResize" ResizeMode="NoResize"
@ -24,48 +25,46 @@
<TabItem Header="Hotkey"> <TabItem Header="Hotkey">
<Grid Margin="10"> <Grid Margin="10">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition> <RowDefinition Height="30"/>
<RowDefinition></RowDefinition> <RowDefinition/>
<RowDefinition Height="50"></RowDefinition> <RowDefinition Height="50"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock VerticalAlignment="Center" Margin="0 0 10 0">Wox Hotkey:</TextBlock> <TextBlock VerticalAlignment="Center" Margin="0 0 10 0"><Run Text="Wox Hotkey:"/></TextBlock>
<wox:HotkeyControl x:Name="ctlHotkey"/> <wox:HotkeyControl x:Name="ctlHotkey"/>
</StackPanel> </StackPanel>
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="20"></RowDefinition> <RowDefinition Height="20"/>
<RowDefinition></RowDefinition> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" Grid.Row="0" Margin="0 0 10 0">Custom Plugin Hotkey:</TextBlock> <TextBlock VerticalAlignment="Center" Grid.Row="0" Margin="0 0 10 0"><Run Text="Custom Plugin Hotkey:"/></TextBlock>
<ListView x:Name="lvCustomHotkey" Margin="0 5 0 0" Grid.Row="1"> <ListView x:Name="lvCustomHotkey" Margin="0 5 0 0" Grid.Row="1">
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridView.Columns>
<GridViewColumn Header="Hotkey" Width="180"> <GridViewColumn Header="Hotkey" Width="180">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Path= Hotkey}"></TextBlock> <TextBlock Text="{Binding Hotkey}"/>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Header="Action Keyword" Width="500"> <GridViewColumn Header="Action Keyword" Width="500">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Path= ActionKeyword}"></TextBlock> <TextBlock Text="{Binding ActionKeyword}"/>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
</GridView.Columns>
</GridView> </GridView>
</ListView.View> </ListView.View>
</ListView> </ListView>
</Grid> </Grid>
<StackPanel Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal"> <StackPanel Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal">
<Button x:Name="btnDeleteCustomHotkey" Click="BtnDeleteCustomHotkey_OnClick" Width="100" Margin="10">Delete</Button> <Button x:Name="btnDeleteCustomHotkey" Click="BtnDeleteCustomHotkey_OnClick" Width="100" Margin="10" Content="Delete"/>
<Button x:Name="btnEditCustomHotkey" Click="BtnEditCustomHotkey_OnClick" Width="100" Margin="10">Edit</Button> <Button x:Name="btnEditCustomHotkey" Click="BtnEditCustomHotkey_OnClick" Width="100" Margin="10" Content="Edit"/>
<Button x:Name="btnAddCustomeHotkey" Click="BtnAddCustomeHotkey_OnClick" Width="100" Margin="10">Add</Button> <Button x:Name="btnAddCustomeHotkey" Click="BtnAddCustomeHotkey_OnClick" Width="100" Margin="10" Content="Add"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</TabItem> </TabItem>
@ -73,49 +72,47 @@
<TabItem Header="Programs"> <TabItem Header="Programs">
<Grid Margin="10"> <Grid Margin="10">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition> <RowDefinition Height="*"/>
<RowDefinition Height="50"></RowDefinition> <RowDefinition Height="50"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ListView x:Name="programSourceView" Grid.Row="0"> <ListView x:Name="programSourceView" Grid.Row="0">
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridView.Columns>
<GridViewColumn Header="Location" Width="400"> <GridViewColumn Header="Location" Width="400">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Path=Location, Converter={wox:StringEmptyConverter}, ConverterParameter='(null)'}"></TextBlock> <TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={wox:StringEmptyConverter}}"/>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Header="Type" Width="150"> <GridViewColumn Header="Type" Width="150">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Path=Type}"></TextBlock> <TextBlock Text="{Binding Type}"/>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Header="Bonus Points" Width="100"> <GridViewColumn Header="Bonus Points" Width="100">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Path=BonusPoints}"></TextBlock> <TextBlock Text="{Binding BonusPoints}"/>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Header="Enabled" Width="100"> <GridViewColumn Header="Enabled" Width="100">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Path=Enabled}"></TextBlock> <TextBlock Text="{Binding Enabled}"/>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
</GridView.Columns>
</GridView> </GridView>
</ListView.View> </ListView.View>
</ListView> </ListView>
<StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal"> <StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
<Button x:Name="btnDeleteProgramSource" Click="btnDeleteProgramSource_OnClick" Width="100" Margin="10">Delete</Button> <Button x:Name="btnDeleteProgramSource" Click="btnDeleteProgramSource_OnClick" Width="100" Margin="10" Content="Delete"/>
<Button x:Name="btnEditProgramSource" Click="btnEditProgramSource_OnClick" Width="100" Margin="10">Edit</Button> <Button x:Name="btnEditProgramSource" Click="btnEditProgramSource_OnClick" Width="100" Margin="10" Content="Edit"/>
<Button x:Name="btnAddProgramSource" Click="btnAddProgramSource_OnClick" Width="100" Margin="10">Add</Button> <Button x:Name="btnAddProgramSource" Click="btnAddProgramSource_OnClick" Width="100" Margin="10" Content="Add"/>
</StackPanel> </StackPanel>
<TextBlock Grid.Row="1" Margin="10" HorizontalAlignment="Left" Text="* Restarting required" VerticalAlignment="Center" /> <TextBlock Grid.Row="1" Margin="10" HorizontalAlignment="Left" Text="* Restarting required" VerticalAlignment="Center" />
</Grid> </Grid>
@ -123,35 +120,33 @@
<TabItem Header="Web Search"> <TabItem Header="Web Search">
<Grid Margin="10"> <Grid Margin="10">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition> <RowDefinition Height="*"/>
<RowDefinition Height="50"></RowDefinition> <RowDefinition Height="50"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ListView x:Name="webSearchView" Grid.Row="0"> <ListView x:Name="webSearchView" Grid.Row="0">
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridView.Columns>
<GridViewColumn Header="ActionWord" Width="180"> <GridViewColumn Header="ActionWord" Width="180">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Path=ActionWord}"></TextBlock> <TextBlock Text="{Binding ActionWord}"/>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Header="Url" Width="500"> <GridViewColumn Header="Url" Width="500">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Path=Url}"></TextBlock> <TextBlock Text="{Binding Url}"/>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
</GridView.Columns>
</GridView> </GridView>
</ListView.View> </ListView.View>
</ListView> </ListView>
<StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal"> <StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
<Button x:Name="btnDeleteWebSearch" Click="btnDeleteWebSearch_OnClick" Width="100" Margin="10">Delete</Button> <Button x:Name="btnDeleteWebSearch" Click="btnDeleteWebSearch_OnClick" Width="100" Margin="10" Content="Delete"/>
<Button x:Name="btnEditWebSearch" Click="btnEditWebSearch_OnClick" Width="100" Margin="10">Edit</Button> <Button x:Name="btnEditWebSearch" Click="btnEditWebSearch_OnClick" Width="100" Margin="10" Content="Edit"/>
<Button x:Name="btnAddWebSearch" Click="btnAddWebSearch_OnClick" Width="100" Margin="10">Add</Button> <Button x:Name="btnAddWebSearch" Click="btnAddWebSearch_OnClick" Width="100" Margin="10" Content="Add"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</TabItem> </TabItem>
@ -162,37 +157,36 @@
<TextBlock Text="Enable Python Plugins" /> <TextBlock Text="Enable Python Plugins" />
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="10"> <StackPanel Orientation="Horizontal" Margin="10">
<Button x:Name="btnEnableInstaller" Click="BtnEnableInstaller_OnClick">enable plugin installer</Button> <Button x:Name="btnEnableInstaller" Click="BtnEnableInstaller_OnClick" Content="enable plugin installer"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</TabItem> </TabItem>
<TabItem Header="Theme"> <TabItem Header="Theme">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="200"></ColumnDefinition> <ColumnDefinition Width="200"/>
<ColumnDefinition></ColumnDefinition> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ListBox x:Name="themeComboBox" Grid.Column="0" Margin="10" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="180"/> <ListBox x:Name="themeComboBox" Grid.Column="0" Margin="10" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="180"/>
<Grid Margin="0" Grid.Column="1"> <Grid Margin="0" Grid.Column="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition ></RowDefinition> <RowDefinition />
<RowDefinition Height="40"></RowDefinition> <RowDefinition Height="80"/>
<RowDefinition Height="40"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition> <ColumnDefinition/>
<ColumnDefinition></ColumnDefinition> <ColumnDefinition Width="170" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel x:Name="PreviewPanel" Grid.ColumnSpan="2" Grid.Row="0" Margin="0"> <StackPanel x:Name="PreviewPanel" Grid.ColumnSpan="2" Grid.Row="0" Margin="0">
<StackPanel Orientation="Horizontal" Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel x:Name="PreviewMainPanel" Orientation="Horizontal" Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel.Resources> <StackPanel.Resources>
<ResourceDictionary Source="/PresentationFramework.Classic,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Classic.xaml"/> <ResourceDictionary Source="/PresentationFramework.Classic,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Classic.xaml"/>
</StackPanel.Resources> </StackPanel.Resources>
<Border Width="500" Style="{DynamicResource WindowBorderStyle}"> <Border Width="500" Style="{DynamicResource WindowBorderStyle}">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="50" ></RowDefinition> <RowDefinition Height="50" />
<RowDefinition></RowDefinition> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBox Text="Hello Wox" IsReadOnly="True" Style="{DynamicResource QueryBoxStyle}" Grid.Row="0"/> <TextBox Text="Hello Wox" IsReadOnly="True" Style="{DynamicResource QueryBoxStyle}" Grid.Row="0"/>
<wox:ResultPanel Grid.Row="1" x:Name="resultPanelPreview"/> <wox:ResultPanel Grid.Row="1" x:Name="resultPanelPreview"/>
@ -201,12 +195,13 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="10"> <StackPanel Grid.Row="1" Grid.Column="0" Margin="10" Orientation="Vertical">
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Text="Query Box Font:" /> <TextBlock Text="Query Box Font:" />
<ComboBox x:Name="cbQueryBoxFont" ItemsSource="{x:Static Fonts.SystemFontFamilies}" SelectionChanged="CbQueryBoxFont_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="180"/> <ComboBox x:Name="cbQueryBoxFont" ItemsSource="{x:Static Fonts.SystemFontFamilies}" SelectionChanged="CbQueryBoxFont_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="160"/>
<ComboBox <ComboBox
x:Name="cbQueryBoxFontFaces" x:Name="cbQueryBoxFontFaces"
ItemsSource="{Binding ElementName=cbQueryBoxFont,Path=SelectedValue.FamilyTypefaces}" SelectionChanged="CbQueryBoxFontFaces_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120"> ItemsSource="{Binding SelectedValue.FamilyTypefaces, ElementName=cbQueryBoxFont}" SelectionChanged="CbQueryBoxFontFaces_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}"> <ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
@ -220,12 +215,12 @@
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>
</ComboBox> </ComboBox>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="10"> <StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Text="Result Item Font:" /> <TextBlock Text="Result Item Font:" />
<ComboBox x:Name="cbResultItemFont" ItemsSource="{x:Static Fonts.SystemFontFamilies}" SelectionChanged="CbResultItemFont_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="180"/> <ComboBox x:Name="cbResultItemFont" ItemsSource="{x:Static Fonts.SystemFontFamilies}" SelectionChanged="CbResultItemFont_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="160"/>
<ComboBox <ComboBox
x:Name="cbResultItemFontFaces" x:Name="cbResultItemFontFaces"
ItemsSource="{Binding ElementName=cbResultItemFont,Path=SelectedValue.FamilyTypefaces}" SelectionChanged="CbResultItemFontFaces_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120"> ItemsSource="{Binding SelectedValue.FamilyTypefaces, ElementName=cbResultItemFont}" SelectionChanged="CbResultItemFontFaces_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}"> <ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
@ -239,6 +234,24 @@
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>
</ComboBox> </ComboBox>
</StackPanel> </StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1" Margin="10">
<TextBlock Text="Window Mode:" />
<ComboBox Name="CbOpacityMode" SelectionChanged="CbOpacityMode_OnSelectionChanged">
<UserSettings:OpacityMode>Normal</UserSettings:OpacityMode>
<UserSettings:OpacityMode>LayeredWindow</UserSettings:OpacityMode>
<UserSettings:OpacityMode>DWM</UserSettings:OpacityMode>
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={wox:OpacityModeConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Opacity:" />
<Slider x:Name="slOpacity" Maximum="1" Minimum="0" SmallChange="1" LargeChange="0.1" TickPlacement="BottomRight" TickFrequency="0.1" ValueChanged="slOpacity_ValueChanged" Width="100"/>
</StackPanel>
</StackPanel>
</Grid> </Grid>
</Grid> </Grid>
</TabItem> </TabItem>

View File

@ -157,6 +157,9 @@ namespace Wox
cbEnablePythonPlugins.IsChecked = UserSettingStorage.Instance.EnablePythonPlugins; cbEnablePythonPlugins.IsChecked = UserSettingStorage.Instance.EnablePythonPlugins;
cbStartWithWindows.IsChecked = File.Exists(woxLinkPath); cbStartWithWindows.IsChecked = File.Exists(woxLinkPath);
slOpacity.Value = UserSettingStorage.Instance.Opacity;
CbOpacityMode.SelectedItem = UserSettingStorage.Instance.OpacityMode;
var wallpaper = WallpaperPathRetrieval.GetWallpaperPath(); var wallpaper = WallpaperPathRetrieval.GetWallpaperPath();
if (wallpaper != null && File.Exists(wallpaper)) if (wallpaper != null && File.Exists(wallpaper))
{ {
@ -443,6 +446,32 @@ namespace Wox
App.Window.SetTheme(UserSettingStorage.Instance.Theme); App.Window.SetTheme(UserSettingStorage.Instance.Theme);
} }
} }
private void slOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
UserSettingStorage.Instance.Opacity = slOpacity.Value;
UserSettingStorage.Instance.Save();
if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow)
PreviewMainPanel.Opacity = UserSettingStorage.Instance.Opacity;
else
PreviewMainPanel.Opacity = 1;
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
}
#endregion #endregion
private void CbOpacityMode_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
UserSettingStorage.Instance.OpacityMode = (OpacityMode) CbOpacityMode.SelectedItem;
UserSettingStorage.Instance.Save();
slOpacity.IsEnabled = UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow;
if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow)
PreviewMainPanel.Opacity = UserSettingStorage.Instance.Opacity;
else
PreviewMainPanel.Opacity = 1;
}
} }
} }

View File

@ -115,6 +115,7 @@
<Compile Include="Helper\SyntaxSugars.cs" /> <Compile Include="Helper\SyntaxSugars.cs" />
<Compile Include="Helper\WallpaperPathRetrieval.cs" /> <Compile Include="Helper\WallpaperPathRetrieval.cs" />
<Compile Include="Helper\WindowIntelopHelper.cs" /> <Compile Include="Helper\WindowIntelopHelper.cs" />
<Compile Include="OpacityModeConverter.cs" />
<Compile Include="ProgramSourceSetting.xaml.cs"> <Compile Include="ProgramSourceSetting.xaml.cs">
<DependentUpon>ProgramSourceSetting.xaml</DependentUpon> <DependentUpon>ProgramSourceSetting.xaml</DependentUpon>
</Compile> </Compile>