From ea4e25ea28ffa19a663a8491ae8eef5e4e249cc6 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sat, 15 Mar 2014 00:17:37 +0800 Subject: [PATCH] Add round corner support for Wox. --- Wox/MainWindow.xaml | 24 ++-- Wox/MainWindow.xaml.cs | 9 +- Wox/ResultPanel.xaml | 6 +- Wox/SettingWindow.xaml.cs | 2 +- Wox/Themes/Dark.xaml | 40 +++++++ Wox/Themes/Default.xaml | 32 ++--- Wox/Themes/Light.xaml | 140 +++++----------------- Wox/Themes/ThemeBuilder/Template.xaml | 52 ++++++++ Wox/Themes/ThemeBuilder/ThemeConvertor.py | 26 ++++ Wox/Wox.csproj | 10 +- 10 files changed, 195 insertions(+), 146 deletions(-) create mode 100644 Wox/Themes/Dark.xaml create mode 100644 Wox/Themes/ThemeBuilder/Template.xaml create mode 100644 Wox/Themes/ThemeBuilder/ThemeConvertor.py diff --git a/Wox/MainWindow.xaml b/Wox/MainWindow.xaml index e77104126f..701214e680 100644 --- a/Wox/MainWindow.xaml +++ b/Wox/MainWindow.xaml @@ -9,17 +9,21 @@ WindowStyle="None" WindowStartupLocation="Manual" ShowInTaskbar="False" + AllowsTransparency="True" + Background="{x:Null}" Style="{DynamicResource WindowStyle}" Icon="Images\app.png" > - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index b91482f7f4..059658a1f0 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -53,7 +53,6 @@ namespace Wox resultCtrl.OnMouseClickItem += AcceptSelect; ThreadPool.SetMaxThreads(30, 10); - InitProgressbarAnimation(); try { SetTheme(CommonStorage.Instance.UserSetting.Theme); @@ -74,6 +73,8 @@ namespace Wox Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2; Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3; Plugins.Init(); + + InitProgressbarAnimation(); } private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) @@ -140,8 +141,8 @@ namespace Wox private void InitProgressbarAnimation() { - var da = new DoubleAnimation(progressBar.X2, Width + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); - var da1 = new DoubleAnimation(progressBar.X1, Width, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); + var da = new DoubleAnimation(progressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); + var da1 = new DoubleAnimation(progressBar.X1, ActualWidth, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)")); Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)")); progressBarStoryboard.Children.Add(da); @@ -366,7 +367,7 @@ namespace Wox { var dict = new ResourceDictionary { - Source = new Uri("pack://application:,,,/Themes/" + themeName + ".xaml") + Source = new Uri(Path.Combine(Directory.GetCurrentDirectory(),"Themes\\"+themeName+".xaml") , UriKind.Absolute) }; Application.Current.Resources.MergedDictionaries.Clear(); diff --git a/Wox/ResultPanel.xaml b/Wox/ResultPanel.xaml index dc02b93ef5..1391e4f8b4 100644 --- a/Wox/ResultPanel.xaml +++ b/Wox/ResultPanel.xaml @@ -11,12 +11,12 @@ - + - + - + diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index 919cf73d64..79a7778fc8 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -67,7 +67,7 @@ namespace Wox private List LoadAvailableThemes() { string themePath = Directory.GetCurrentDirectory() + "\\Themes\\"; - return Directory.GetFiles(themePath).Where(filePath => filePath.EndsWith(".xaml")).ToList(); + return Directory.GetFiles(themePath).Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Default.xaml")).ToList(); } private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) diff --git a/Wox/Themes/Dark.xaml b/Wox/Themes/Dark.xaml new file mode 100644 index 0000000000..2ca629d0c7 --- /dev/null +++ b/Wox/Themes/Dark.xaml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + #4F6180 + + + + + + diff --git a/Wox/Themes/Default.xaml b/Wox/Themes/Default.xaml index f2cf08c585..7eaf12f599 100644 --- a/Wox/Themes/Default.xaml +++ b/Wox/Themes/Default.xaml @@ -1,7 +1,7 @@  - - + - - - - - - - #4F6180 - - - - - + + + + + + + + - - - - - #543BFD - - - - - - - - - - - - - - - - - - - + #3875D7 - - \ No newline at end of file diff --git a/Wox/Themes/ThemeBuilder/Template.xaml b/Wox/Themes/ThemeBuilder/Template.xaml new file mode 100644 index 0000000000..c0978b4ba5 --- /dev/null +++ b/Wox/Themes/ThemeBuilder/Template.xaml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + {%selectedResultBackgroundColor%} + + + + + + diff --git a/Wox/Themes/ThemeBuilder/ThemeConvertor.py b/Wox/Themes/ThemeBuilder/ThemeConvertor.py new file mode 100644 index 0000000000..674728ec3d --- /dev/null +++ b/Wox/Themes/ThemeBuilder/ThemeConvertor.py @@ -0,0 +1,26 @@ +import os,plistlib + +def convert(path,templatePath): + pl = plistlib.readPlist(path) + with open(templatePath, 'r') as content_file: + template = content_file.read() + for key in pl: + if "rgba" in pl[key]: + template = template.replace("{%"+key+"%}",tohex(pl[key].replace("rgba","rgb"))) + f = open(path.replace(".alfredtheme",".xaml"),'w') + f.write(template) + f.close() + + +def tohex(string): + string = string[4:] + split = string.split(",") + split[2] = ''.join(split[2].split(")")[0]) + r = int(split[0]) + g = int(split[1]) + b = int(split[2]) + tu = (r, g, b) + return '#%02x%02x%02x' % tu + +#print tohex("rgb(255,255,255,0.50)") +print convert("Night.alfredtheme","Light.xaml") diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index a90218e473..6ce3c9aabc 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -188,10 +188,14 @@ Designer MSBuild:Compile - + MSBuild:Compile Designer - + + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -325,4 +329,4 @@ xcopy /Y $(ProjectDir)Themes\*.* $(TargetDir)Themes\ --> - + \ No newline at end of file