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

@ -63,7 +63,7 @@
<DockPanel Grid.Column="0">
<TextBlock DockPanel.Dock="Top" Margin="10">
<Hyperlink NavigateUri="{Binding Plugin, Mode=OneWay}" RequestNavigate="OnRequestNavigate">
<Run Text="{DynamicResource browserMorePlugins}"/>
<Run Text="{DynamicResource browserMorePlugins}" />
</Hyperlink>
</TextBlock>
<ListBox SelectedIndex="0" SelectedItem="{Binding SelectedPlugin}"
@ -164,13 +164,13 @@
<DockPanel Grid.Column="0">
<TextBlock DockPanel.Dock="Top" Margin="10" HorizontalAlignment="Left">
<Hyperlink NavigateUri="{Binding Theme, Mode=OneWay}" RequestNavigate="OnRequestNavigate">
<Run Text="{DynamicResource browserMoreThemes}"/>
<Run Text="{DynamicResource browserMoreThemes}" />
</Hyperlink>
</TextBlock>
<ListBox SelectedItem="{Binding SelectedTheme}" ItemsSource="{Binding Themes}"
Margin="10, 0, 10, 10" Width="180"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</DockPanel>
<Grid Margin="0" Grid.Column="1">
<Grid.RowDefinitions>
@ -201,7 +201,7 @@
<TextBlock Text="{DynamicResource queryBoxFont}" />
<ComboBox ItemsSource="{x:Static Fonts.SystemFontFamilies}"
SelectedItem="{Binding SelectedQueryBoxFont}"
HorizontalAlignment="Left" VerticalAlignment="Top" Width="160" Margin="10 -2 5 0"/>
HorizontalAlignment="Left" VerticalAlignment="Top" Width="160" Margin="10 -2 5 0" />
<ComboBox ItemsSource="{Binding SelectedQueryBoxFont.FamilyTypefaces}"
SelectedItem="{Binding SelectedQueryBoxFontFaces}"
HorizontalAlignment="Left" VerticalAlignment="Top"
@ -250,16 +250,18 @@
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition Height="20"/>
<RowDefinition Height="400"/>
<RowDefinition Height="20" />
<RowDefinition Height="400" />
<RowDefinition Height="Auto" />
</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}" />
<wox:HotkeyControl x:Name="HotkeyControl" HotkeyChanged="OnHotkeyChanged" Loaded="OnHotkeyControlLoaded" />
<wox:HotkeyControl x:Name="HotkeyControl" HotkeyChanged="OnHotkeyChanged"
Loaded="OnHotkeyControlLoaded" />
</StackPanel>
<TextBlock VerticalAlignment="Center" Grid.Row="1" Margin="0,3,10,2"
Text="{DynamicResource customQueryHotkey}"/>
Text="{DynamicResource customQueryHotkey}" />
<ListView ItemsSource="{Binding Settings.CustomPluginHotkeys}"
SelectedItem="{Binding SelectedCustomPluginHotkey}"
Margin="0 5 0 0" Grid.Row="2">
@ -268,7 +270,7 @@
<GridViewColumn Header="{DynamicResource hotkey}" Width="180">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="s:CustomPluginHotkey">
<TextBlock Text="{Binding Hotkey}"/>
<TextBlock Text="{Binding Hotkey}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
@ -282,7 +284,8 @@
</GridView>
</ListView.View>
</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"
Margin="10" Content="{DynamicResource delete}" />
<Button Click="OnnEditCustomHotkeyClick" Width="100" Margin="10"
@ -292,7 +295,7 @@
</StackPanel>
</Grid>
</TabItem>
<TabItem Header="{DynamicResource proxy}" >
<TabItem Header="{DynamicResource proxy}">
<StackPanel>
<CheckBox Margin="10" IsChecked="{Binding Settings.ProxyEnabled}">
<TextBlock Text="{DynamicResource enableProxy}" />
@ -306,19 +309,19 @@
<ColumnDefinition Width="100" />
<ColumnDefinition Width="200" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<TextBlock Text="{DynamicResource server}" Grid.Row="0" Grid.Column="0" Padding="5" />
<TextBox Text="{Binding Settings.ProxyServer}" Grid.Row="0" Grid.Column="1" Padding="5" />
<TextBlock Text="{DynamicResource port}" Grid.Row="0" Grid.Column="2" Padding="5"/>
<TextBox Text="{Binding Settings.ProxyPort}" Grid.Row="0" Grid.Column="3" Padding="5"/>
<TextBlock Text="{DynamicResource userName}" Grid.Row="1" Grid.Column="0" Padding="5"/>
<TextBox Text="{Binding Settings.ProxyUserName}" Grid.Row="1" Grid.Column="1" Padding="5"/>
<TextBlock Text="{DynamicResource port}" Grid.Row="0" Grid.Column="2" Padding="5" />
<TextBox Text="{Binding Settings.ProxyPort}" Grid.Row="0" Grid.Column="3" Padding="5" />
<TextBlock Text="{DynamicResource userName}" Grid.Row="1" Grid.Column="0" Padding="5" />
<TextBox Text="{Binding Settings.ProxyUserName}" Grid.Row="1" Grid.Column="1" Padding="5" />
<TextBlock Text="{DynamicResource password}" Grid.Row="1" Grid.Column="2" Padding="5" />
<TextBox Text="{Binding Settings.ProxyPassword}" Grid.Row="1" Grid.Column="3" Padding="5" />
</Grid>
<Button Content="{DynamicResource testProxy}" IsEnabled="{Binding Settings.ProxyEnabled}"
Width="80" HorizontalAlignment="Left" Margin="10" Click="OnTestProxyClick"/>
Width="80" HorizontalAlignment="Left" Margin="10" Click="OnTestProxyClick" />
</StackPanel>
</TabItem>
<TabItem Header="{DynamicResource about}">
@ -340,24 +343,24 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.ColumnSpan="2" Text="{Binding ActivatedTimes}" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="{DynamicResource website}"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="{DynamicResource website}" />
<TextBlock Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left">
<Hyperlink NavigateUri="{Binding Github, Mode=OneWay}" RequestNavigate="OnRequestNavigate">
<Run Text="{Binding Github, Mode=OneWay}"/>
<Run Text="{Binding Github, Mode=OneWay}" />
</Hyperlink>
</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0" Text="{DynamicResource version}" />
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Version}" />
<TextBlock Grid.Row="3" Grid.Column="0" Text="{DynamicResource releaseNotes}" />
<TextBlock Grid.Row="3" Grid.Column="1" >
<TextBlock Grid.Row="3" Grid.Column="1">
<Hyperlink NavigateUri="{Binding ReleaseNotes, Mode=OneWay}"
RequestNavigate="OnRequestNavigate">
<Run Text="{Binding ReleaseNotes, Mode=OneWay}"/>
<Run Text="{Binding ReleaseNotes, Mode=OneWay}" />
</Hyperlink>
</TextBlock>
<Button Grid.Row="4" Grid.Column="0"
Content="{DynamicResource checkUpdates}" Click="OnCheckUpdates"
HorizontalAlignment="Left" Margin="10 10 10 10" />
HorizontalAlignment="Left" Margin="10 10 10 10" />
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding NewVersionTips}"
HorizontalAlignment="Left" Visibility="{Binding NewVersionTipsVisibility}" />
</Grid>

View File

@ -11,6 +11,7 @@ using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
using static System.String;
@ -20,17 +21,36 @@ namespace Wox.ViewModel
[ImplementPropertyChanged]
public class SettingWindowViewModel
{
public Settings Settings { get; set; }
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
public List<Language> Languages => _translater.LoadAvailableLanguages();
private Internationalization _translater => InternationalizationManager.Instance;
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
#endregion
#region plugin
public static string Plugin => "http://www.getwox.com/plugin";
public PluginViewModel SelectedPlugin { get; set; }
public IList<PluginViewModel> PluginViewModels
{
get
@ -75,7 +95,7 @@ namespace Wox.ViewModel
{
// update in-memory data
PluginManager.UpdateActionKeywordForPlugin(SelectedPlugin.PluginPair, e.OldActionKeyword,
e.NewActionKeyword);
e.NewActionKeyword);
// update persistant data
Settings.PluginSettings.UpdateActionKeyword(SelectedPlugin.Metadata);
@ -93,23 +113,25 @@ namespace Wox.ViewModel
}
}
}
#endregion
#region theme
public static string Theme => @"http://www.getwox.com/theme";
public string SelectedTheme
{
get
{
return Settings.Theme;
}
get { return Settings.Theme; }
set
{
Settings.Theme = 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
{
@ -123,7 +145,7 @@ namespace Wox.ViewModel
bitmap.BeginInit();
bitmap.StreamSource = memStream;
bitmap.EndInit();
var brush = new ImageBrush(bitmap) { Stretch = Stretch.UniformToFill };
var brush = new ImageBrush(bitmap) {Stretch = Stretch.UniformToFill};
return brush;
}
else
@ -139,45 +161,37 @@ namespace Wox.ViewModel
{
get
{
const string image = "app.png";
List<Result> results = new List<Result>
var results = new List<Result>
{
new Result
{
Title = "WoX is a launcher for Windows that simply works.",
SubTitle = "You can call it Windows omni-eXecutor if you want a long name.",
IcoPath = image,
SubTitle = "You can call it Windows omni-eXecutor if you want a long name."
},
new Result
{
Title = "Search for everything—applications, folders, files and more.",
SubTitle = "Use pinyin to search for programs. (yyy / wangyiyun → 网易云音乐)",
IcoPath = image,
SubTitle = "Use pinyin to search for programs. (yyy / wangyiyun → 网易云音乐)"
},
new Result
{
Title = "Keyword plugin search.",
SubTitle = "search google with g search_term.",
IcoPath = image,
SubTitle = "search google with g search_term."
},
new Result
{
Title = "Build custom themes at: ",
SubTitle = Theme,
SubTitle = Theme
},
new Result
{
Title = "Install plugins from: ",
SubTitle = Plugin,
IcoPath = image,
SubTitle = Plugin
},
new Result
{
Title = $"Open Source: {Infrastructure.Constant.Github}",
SubTitle = "Please star it!",
IcoPath = image,
Title = $"Open Source: {Constant.Github}",
SubTitle = "Please star it!"
}
};
var vm = new ResultsViewModel(6);
@ -276,17 +290,21 @@ namespace Wox.ViewModel
}
}
#endregion
#region hotkey
public CustomPluginHotkey SelectedCustomPluginHotkey { get; set; }
#endregion
#region hotkey
public CustomPluginHotkey SelectedCustomPluginHotkey { get; set; }
#endregion
#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 Version => Infrastructure.Constant.Version;
public string ActivatedTimes => Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
public static string Version => Constant.Version;
public string ActivatedTimes
=> Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
private string _newVersionTips;
public string NewVersionTips
{
@ -298,17 +316,7 @@ namespace Wox.ViewModel
}
}
public Visibility NewVersionTipsVisibility { get; set; }
#endregion
public SettingWindowViewModel()
{
_storage = new JsonStrorage<Settings>();
Settings = _storage.Load();
}
//todo happlebao save
public void Save()
{
_storage.Save();
}
#endregion
}
}