Skip to content

Commit

Permalink
更新图标和界面
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnycase committed Apr 24, 2017
1 parent 2c88857 commit 4cee884
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 6 deletions.
14 changes: 14 additions & 0 deletions src/Moesocks.Client/Areas/Pages/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Caliburn.Micro;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Moesocks.Client.Areas.Pages.ViewModels
{
class SettingsViewModel : PropertyChangedBase
{
public string Title => "设置";
}
}
73 changes: 73 additions & 0 deletions src/Moesocks.Client/Areas/Pages/Views/SettingsView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<UserControl x:Class="Moesocks.Client.Areas.Pages.Views.SettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Moesocks.Client.Areas.Pages.Views"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="508">
<UserControl.Resources>
<ResourceDictionary>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignTextBox}">
<Setter Property="Margin" Value="0 8 0 8" />
</Style>
<Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource MaterialDesignPasswordBox}">
<Setter Property="Margin" Value="0 8 0 8" />
</Style>
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource MaterialDesignComboBox}">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Margin" Value="0 8 0 8" />
</Style>
<Style TargetType="{x:Type Viewbox}">
<Setter Property="Width" Value="18" />
<Setter Property="Height" Value="18" />
<Setter Property="Margin" Value="0 0 8 0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style TargetType="{x:Type Slider}" BasedOn="{StaticResource MaterialDesignSlider}">
<Setter Property="Margin" Value="0 8 0 8" />
</Style>
<Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignSwitchToggleButton}">
<Setter Property="Margin" Value="14 8 0 8" />
<Setter Property="HorizontalAlignment" Value="Left"/>
</Style>
<!--<Style TargetType="{x:Type materialDesign:PackIcon}" BasedOn="{StaticResource {x:Type materialDesign:PackIcon}}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="4 0 4 0" />
</Style>-->
</ResourceDictionary>
</UserControl.Resources>
<ScrollViewer VerticalScrollBarVisibility="Visible">
<Grid Margin="18 10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MaxWidth="330"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" VerticalAlignment="Center" Margin="0 0 8 0" Style="{StaticResource MaterialDesignBody1TextBlock}">启用自动更新</TextBlock>
<ToggleButton Grid.Row="0" Grid.Column="1"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Margin="16 0 8 0" Style="{StaticResource MaterialDesignBody1TextBlock}">允许使用流量更新</TextBlock>
<ToggleButton Grid.Row="1" Grid.Column="1"/>
<TextBlock Grid.Row="2" Style="{StaticResource MaterialDesignBody1TextBlock}" Margin="0 8" VerticalAlignment="Center">模式选择</TextBlock>
<RadioButton Grid.Row="3" Margin="16 8 8 8">全局模式</RadioButton>
<RadioButton Grid.Row="4" Margin="16 8 8 8">PAC 模式</RadioButton>
<Grid Grid.Row="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Margin="38 0 8 0" VerticalAlignment="Center">PAC 地址</TextBlock>
<TextBox Grid.Column="1"/>
</Grid>
<Button Grid.Row="5" Grid.Column="1" Style="{StaticResource MaterialDesignFlatButton}">立即更新</Button>
</Grid>
</ScrollViewer>
</UserControl>
Binary file modified src/Moesocks.Client/Assets/moesocks.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Moesocks.Client/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<Costura/>
<Costura IncludeDebugSymbols='false'/>

</Weavers>
9 changes: 6 additions & 3 deletions src/Moesocks.Client/Logging/FlowDocumentLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -14,10 +15,11 @@ class FlowDocumentLoggerProvider : ILoggerProvider
{
public event EventHandler Added;
public Paragraph Paragraph { get; } = new Paragraph();
private readonly Stopwatch _watch = new Stopwatch();

public FlowDocumentLoggerProvider()
{

_watch.Start();
}

public ILogger CreateLogger(string categoryName)
Expand All @@ -34,12 +36,12 @@ private void Log<TState>(string categoryName, LogLevel logLevel, EventId eventId
var color = LogLevelToBrush(logLevel);
var inlines = new Inline[]
{
new Run($"{LogLevelToString(logLevel)}:\t{categoryName}[{eventId}]")
new Run($"[{_watch.Elapsed.ToString(@"hh\:mm\:ss")}] {LogLevelToString(logLevel)}:\t{categoryName}[{eventId}]")
{
Foreground = color
},
new LineBreak(),
new Run($"\t{formatter(state, exception)}")
new Run($"\t\t{formatter(state, exception)}")
{
Foreground = color
},
Expand Down Expand Up @@ -104,6 +106,7 @@ public void Dispose()
Execute.OnUIThread(() =>
{
Paragraph.Inlines.Clear();
_watch.Stop();
});
}

Expand Down
5 changes: 5 additions & 0 deletions src/Moesocks.Client/Moesocks.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
</ApplicationDefinition>
<Compile Include="AppBootstrapper.cs" />
<Compile Include="Areas\Pages\ViewModels\LoggingViewModel.cs" />
<Compile Include="Areas\Pages\ViewModels\SettingsViewModel.cs" />
<Compile Include="IShell.cs" />
<Compile Include="Logging\FlowDocumentLoggerProvider.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" />
Expand All @@ -271,6 +272,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Areas\Pages\Views\SettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ShellView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
1 change: 1 addition & 0 deletions src/Moesocks.Client/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddTransient<IShell, ShellViewModel>();
services.AddTransient<SystemTrayIconViewModel>();
services.AddTransient<Areas.Pages.ViewModels.LoggingViewModel>();
services.AddTransient<Areas.Pages.ViewModels.SettingsViewModel>();
services.AddSingleton<FlowDocumentLoggerProvider>();

services.AddConnectionRouter(Configuration.GetSection("connectionRouter"));
Expand Down
5 changes: 3 additions & 2 deletions src/Moesocks.Client/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ public class ShellViewModel : PropertyChangedBase, IShell

public ShellViewModel()
{
Pages = new[]
Pages = new object[]
{
IoC.Get<LoggingViewModel>()
IoC.Get<LoggingViewModel>(),
IoC.Get<SettingsViewModel>()
};
}
}
Expand Down

0 comments on commit 4cee884

Please sign in to comment.