This commit is contained in:
bao-qian 2016-05-22 23:51:17 +01:00
parent b3119749d9
commit ba78637361
2 changed files with 80 additions and 69 deletions

View File

@ -254,9 +254,11 @@
<RowDefinition Height="400" /> <RowDefinition Height="400" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" Height="24" Margin="0,4,0,3"> <StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" Height="24"
Margin="0,4,0,3">
<TextBlock VerticalAlignment="Center" Margin="0 0 10 0" Text="{DynamicResource woxHotkey}" /> <TextBlock VerticalAlignment="Center" Margin="0 0 10 0" Text="{DynamicResource woxHotkey}" />
<wox:HotkeyControl x:Name="HotkeyControl" HotkeyChanged="OnHotkeyChanged" Loaded="OnHotkeyControlLoaded" /> <wox:HotkeyControl x:Name="HotkeyControl" HotkeyChanged="OnHotkeyChanged"
Loaded="OnHotkeyControlLoaded" />
</StackPanel> </StackPanel>
<TextBlock VerticalAlignment="Center" Grid.Row="1" Margin="0,3,10,2" <TextBlock VerticalAlignment="Center" Grid.Row="1" Margin="0,3,10,2"
Text="{DynamicResource customQueryHotkey}" /> Text="{DynamicResource customQueryHotkey}" />
@ -282,7 +284,8 @@
</GridView> </GridView>
</ListView.View> </ListView.View>
</ListView> </ListView>
<StackPanel Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Horizontal" Height="40" Width="360"> <StackPanel Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Orientation="Horizontal" Height="40" Width="360">
<Button Click="OnDeleteCustomHotkeyClick" Width="100" <Button Click="OnDeleteCustomHotkeyClick" Width="100"
Margin="10" Content="{DynamicResource delete}" /> Margin="10" Content="{DynamicResource delete}" />
<Button Click="OnnEditCustomHotkeyClick" Width="100" Margin="10" <Button Click="OnnEditCustomHotkeyClick" Width="100" Margin="10"

View File

@ -11,6 +11,7 @@ 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.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
using Wox.Plugin; using Wox.Plugin;
using static System.String; using static System.String;
@ -20,17 +21,36 @@ namespace Wox.ViewModel
[ImplementPropertyChanged] [ImplementPropertyChanged]
public class SettingWindowViewModel public class SettingWindowViewModel
{ {
public Settings Settings { get; set; }
private readonly JsonStrorage<Settings> _storage; private readonly JsonStrorage<Settings> _storage;
public SettingWindowViewModel()
{
_storage = new JsonStrorage<Settings>();
Settings = _storage.Load();
}
public Settings Settings { get; set; }
//todo happlebao save
public void Save()
{
_storage.Save();
}
#region general #region general
public List<Language> Languages => _translater.LoadAvailableLanguages(); public List<Language> Languages => _translater.LoadAvailableLanguages();
private Internationalization _translater => InternationalizationManager.Instance; private Internationalization _translater => InternationalizationManager.Instance;
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16); public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
#endregion #endregion
#region plugin #region plugin
public static string Plugin => "http://www.getwox.com/plugin"; public static string Plugin => "http://www.getwox.com/plugin";
public PluginViewModel SelectedPlugin { get; set; } public PluginViewModel SelectedPlugin { get; set; }
public IList<PluginViewModel> PluginViewModels public IList<PluginViewModel> PluginViewModels
{ {
get get
@ -93,23 +113,25 @@ namespace Wox.ViewModel
} }
} }
} }
#endregion #endregion
#region theme #region theme
public static string Theme => @"http://www.getwox.com/theme"; public static string Theme => @"http://www.getwox.com/theme";
public string SelectedTheme public string SelectedTheme
{ {
get get { return Settings.Theme; }
{
return Settings.Theme;
}
set set
{ {
Settings.Theme = value; Settings.Theme = value;
ThemeManager.Instance.ChangeTheme(value); ThemeManager.Instance.ChangeTheme(value);
} }
} }
public List<string> Themes => ThemeManager.Instance.LoadAvailableThemes().Select(Path.GetFileNameWithoutExtension).ToList();
public List<string> Themes
=> ThemeManager.Instance.LoadAvailableThemes().Select(Path.GetFileNameWithoutExtension).ToList();
public Brush PreviewBackground public Brush PreviewBackground
{ {
@ -139,45 +161,37 @@ namespace Wox.ViewModel
{ {
get get
{ {
var results = new List<Result>
const string image = "app.png";
List<Result> results = new List<Result>
{ {
new Result new Result
{ {
Title = "WoX is a launcher for Windows that simply works.", Title = "WoX is a launcher for Windows that simply works.",
SubTitle = "You can call it Windows omni-eXecutor if you want a long name.", SubTitle = "You can call it Windows omni-eXecutor if you want a long name."
IcoPath = image,
}, },
new Result new Result
{ {
Title = "Search for everything—applications, folders, files and more.", Title = "Search for everything—applications, folders, files and more.",
SubTitle = "Use pinyin to search for programs. (yyy / wangyiyun → 网易云音乐)", SubTitle = "Use pinyin to search for programs. (yyy / wangyiyun → 网易云音乐)"
IcoPath = image,
}, },
new Result new Result
{ {
Title = "Keyword plugin search.", Title = "Keyword plugin search.",
SubTitle = "search google with g search_term.", SubTitle = "search google with g search_term."
IcoPath = image,
}, },
new Result new Result
{ {
Title = "Build custom themes at: ", Title = "Build custom themes at: ",
SubTitle = Theme, SubTitle = Theme
}, },
new Result new Result
{ {
Title = "Install plugins from: ", Title = "Install plugins from: ",
SubTitle = Plugin, SubTitle = Plugin
IcoPath = image,
}, },
new Result new Result
{ {
Title = $"Open Source: {Infrastructure.Constant.Github}", Title = $"Open Source: {Constant.Github}",
SubTitle = "Please star it!", SubTitle = "Please star it!"
IcoPath = image,
} }
}; };
var vm = new ResultsViewModel(6); var vm = new ResultsViewModel(6);
@ -276,17 +290,21 @@ namespace Wox.ViewModel
} }
} }
#endregion
#region hotkey
public CustomPluginHotkey SelectedCustomPluginHotkey { get; set; }
#endregion #endregion
#region hotkey
public CustomPluginHotkey SelectedCustomPluginHotkey { get; set; }
#endregion
#region about #region about
public static string Github => Infrastructure.Constant.Github; public static string Github => Constant.Github;
public static string ReleaseNotes => @"https://github.com/Wox-launcher/Wox/releases/latest"; public static string ReleaseNotes => @"https://github.com/Wox-launcher/Wox/releases/latest";
public static string Version => Infrastructure.Constant.Version; public static string Version => Constant.Version;
public string ActivatedTimes => Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes); public string ActivatedTimes
=> Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
private string _newVersionTips; private string _newVersionTips;
public string NewVersionTips public string NewVersionTips
{ {
@ -298,17 +316,7 @@ namespace Wox.ViewModel
} }
} }
public Visibility NewVersionTipsVisibility { get; set; } public Visibility NewVersionTipsVisibility { get; set; }
#endregion
public SettingWindowViewModel()
{
_storage = new JsonStrorage<Settings>();
Settings = _storage.Load();
}
//todo happlebao save #endregion
public void Save()
{
_storage.Save();
}
} }
} }