add theme function. And provide two themes default.

This commit is contained in:
qianlifeng
2014-01-25 18:00:13 +08:00
parent abedc0be80
commit 71b5d4fe5a
21 changed files with 899 additions and 81 deletions

View File

@@ -0,0 +1,46 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using WinAlfred.Helper;
namespace WinAlfred
{
public partial class SettingWidow : Window
{
private MainWindow mainWindow;
public SettingWidow(MainWindow mainWindow)
{
this.mainWindow = mainWindow;
InitializeComponent();
Loaded += Setting_Loaded;
}
private void Setting_Loaded(object sender, RoutedEventArgs e)
{
foreach (string theme in LoadAvailableThemes())
{
string themeName = theme.Substring(theme.LastIndexOf('\\') + 1).Replace(".xaml", "");
themeComboBox.Items.Add(themeName);
}
themeComboBox.SelectedItem = Settings.Instance.Theme;
}
private List<string> LoadAvailableThemes()
{
string themePath = Directory.GetCurrentDirectory() + "\\Themes\\";
return Directory.GetFiles(themePath).Where(filePath => filePath.EndsWith(".xaml")).ToList();
}
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
string themeName = themeComboBox.SelectedItem.ToString();
mainWindow.ChangeStyles(themeName);
Settings.Instance.Theme = themeName;
Settings.Instance.SaveSettings();
}
}
}