Merge branch 'master' of http://git.51dayu.com.cn/diamond-cut/SparkClient
commit
72574cfa83
15 changed files with 534 additions and 66 deletions
@ -0,0 +1,146 @@ |
||||
<Window x:Class="SparkClient.LoginWindow" |
||||
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:SparkClient" |
||||
xmlns:hc="https://handyorg.github.io/handycontrol" |
||||
mc:Ignorable="d" |
||||
WindowStyle="None" |
||||
AllowsTransparency="True" |
||||
Background="Transparent" |
||||
ResizeMode="NoResize" |
||||
Title="LoginWindow" Height="450" Width="450"> |
||||
<Grid MouseLeftButtonDown="Grid_MouseLeftButtonDown"> |
||||
<Border CornerRadius="20" |
||||
BorderThickness="1" |
||||
BorderBrush="LightGray" |
||||
Background="White"> |
||||
<Grid> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition Height="20"/> |
||||
<RowDefinition Height="80"/> |
||||
<RowDefinition Height="20"/> |
||||
<RowDefinition Height="Auto"/> |
||||
<RowDefinition Height="Auto"/> |
||||
<RowDefinition Height="Auto"/> |
||||
<RowDefinition Height="Auto"/> |
||||
<RowDefinition Height="Auto"/> |
||||
<RowDefinition Height="Auto"/> |
||||
</Grid.RowDefinitions> |
||||
<!-- 标题 --> |
||||
<Grid Grid.Row="1" > |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="*"/> |
||||
<ColumnDefinition Width="Auto"/> |
||||
<ColumnDefinition Width="*"/> |
||||
</Grid.ColumnDefinitions> |
||||
<Grid Grid.Column="1"> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="Auto"/> |
||||
<ColumnDefinition Width="Auto"/> |
||||
</Grid.ColumnDefinitions> |
||||
<Image Grid.Column="0" Source="/Resource/Images/icon_200.png" Width="70"/> |
||||
<TextBlock Grid.Column="1" Text="{StaticResource LoginWindowTitle}" |
||||
FontSize="32" FontWeight="Bold" VerticalAlignment="Center"> |
||||
<TextBlock.Foreground> |
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> |
||||
<GradientStop Color="#58b9e3" Offset="0"/> |
||||
<GradientStop Color="#349ad0" Offset="1"/> |
||||
</LinearGradientBrush> |
||||
</TextBlock.Foreground> |
||||
</TextBlock> |
||||
</Grid> |
||||
</Grid> |
||||
<!-- 账号输入 --> |
||||
<Grid Grid.Row="3" > |
||||
<Border Height="40" CornerRadius="20" BorderBrush="#ebeef5" |
||||
BorderThickness="1" Background="#ebeef5" |
||||
Margin="40 10" Padding="20 0"> |
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="30" /> |
||||
<ColumnDefinition Width="*" /> |
||||
<ColumnDefinition Width="30" /> |
||||
</Grid.ColumnDefinitions> |
||||
<Image Grid.Column="0" Width="25" Height="25" Source="Resource/Images/UIResource/08-2.png" /> |
||||
<hc:TextBox Grid.Column="1" Grid.ColumnSpan="2" BorderThickness="0" FontSize="18" HorizontalAlignment="Stretch" |
||||
Background="Transparent" Padding="5 0" hc:InfoElement.ShowClearButton="True" |
||||
VerticalAlignment="Stretch" TextAlignment="Left" x:Name="AccountTextBox" |
||||
hc:InfoElement.Placeholder="{StaticResource LoginWindowAccount}" |
||||
/> |
||||
<!-- <Image Grid.Column="2" Width="25" Height="25" Source="Resource/Images/UIResource/08-4.png" MouseLeftButtonDown="UIElement_OnMouseLeftButtonDown" /> --> |
||||
</Grid> |
||||
</Border> |
||||
</Grid> |
||||
<!-- 密码输入 --> |
||||
<Grid Grid.Row="4" > |
||||
<Border Height="40" CornerRadius="20" BorderBrush="#ebeef5" |
||||
BorderThickness="1" Background="#ebeef5" |
||||
Margin="40 10" Padding="20 0"> |
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="30" /> |
||||
<ColumnDefinition Width="*" /> |
||||
<ColumnDefinition Width="30" /> |
||||
</Grid.ColumnDefinitions> |
||||
<Image Grid.Column="0" Width="25" Height="25" Source="Resource/Images/UIResource/08-3.png" /> |
||||
<hc:PasswordBox Grid.Column="1" Grid.ColumnSpan="2" ShowEyeButton="True" BorderThickness="0" |
||||
FontSize="18" HorizontalAlignment="Stretch" hc:InfoElement.Necessary="True" Background="Transparent" |
||||
hc:InfoElement.Placeholder="{StaticResource LoginWindowPassword}"/> |
||||
|
||||
</Grid> |
||||
</Border> |
||||
</Grid> |
||||
<!-- 记住密码 --> |
||||
<CheckBox Grid.Row="5" Content="{StaticResource LoginWindowRemember}" |
||||
Background="#8ea4c9" IsChecked="True" Foreground="#8c8c8c" FontSize="16" |
||||
Margin="45 5"/> |
||||
<!-- 登录按钮 --> |
||||
<Button x:Name="ConfirmButton" Grid.Row="6" Padding="0" Margin="0 10 0 10" Height="50" |
||||
Width="360 " |
||||
BorderThickness="0" Background="Transparent" FocusVisualStyle="{x:Null}"> |
||||
<Border |
||||
HorizontalAlignment="Center" |
||||
VerticalAlignment="Center" |
||||
Margin="0 0 0 0" |
||||
Padding="10, 10" |
||||
Width="360" |
||||
BorderThickness="0" |
||||
CornerRadius="20"> |
||||
<Border.Background> |
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> |
||||
<GradientStop Color="#61bde2" Offset="0"/> |
||||
<GradientStop Color="#53abd9" Offset="1"/> |
||||
</LinearGradientBrush> |
||||
</Border.Background> |
||||
<TextBlock FontSize="18" Text="{StaticResource LoginWindowLogin}" TextAlignment="Center" Foreground="#ffffff"></TextBlock> |
||||
</Border> |
||||
</Button> |
||||
<Button x:Name="CloseButton" Grid.Row="7" Padding="0" Margin="0 0 0 20" Height="50" |
||||
Width="360 " Click="CloseButton_OnClick" |
||||
BorderThickness="0" Background="Transparent" FocusVisualStyle="{x:Null}"> |
||||
<Border |
||||
HorizontalAlignment="Center" |
||||
VerticalAlignment="Center" |
||||
Margin="0 0 0 0" |
||||
Padding="10, 10" |
||||
Width="360" |
||||
BorderThickness="0" |
||||
CornerRadius="20"> |
||||
<Border.Background> |
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> |
||||
<GradientStop Color="#e3687d" Offset="0"/> |
||||
<GradientStop Color="#d95464" Offset="1"/> |
||||
</LinearGradientBrush> |
||||
</Border.Background> |
||||
<TextBlock FontSize="18" Text="{StaticResource LoginWindowExit}" TextAlignment="Center" Foreground="#ffffff"></TextBlock> |
||||
</Border> |
||||
</Button> |
||||
<!-- 联系我们 --> |
||||
<TextBlock Grid.Row="8" Text="{StaticResource LoginWindowForgot}" TextAlignment="Center" |
||||
Margin="20,0" FontSize="14" Foreground="#8e8e8e" Padding="0 10 0 0" VerticalAlignment="Bottom"/> |
||||
</Grid> |
||||
</Border> |
||||
</Grid> |
||||
</Window> |
@ -0,0 +1,31 @@ |
||||
using System.Windows; |
||||
using System.Windows.Input; |
||||
|
||||
namespace SparkClient; |
||||
|
||||
public partial class LoginWindow : Window |
||||
{ |
||||
public LoginWindow() |
||||
{ |
||||
InitializeComponent(); |
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen; |
||||
} |
||||
private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
||||
{ |
||||
if (e.ButtonState == MouseButtonState.Pressed) |
||||
{ |
||||
this.DragMove(); |
||||
} |
||||
} |
||||
|
||||
private void UIElement_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
||||
{ |
||||
AccountTextBox.Text = string.Empty; |
||||
} |
||||
|
||||
private void CloseButton_OnClick(object sender, RoutedEventArgs e) |
||||
{ |
||||
this.Close(); |
||||
Environment.Exit(0); |
||||
} |
||||
} |
@ -0,0 +1,81 @@ |
||||
using Microsoft.Win32; |
||||
|
||||
namespace SparkClient.Model.Helper; |
||||
|
||||
public static class RegistryHelper |
||||
{ |
||||
private const string BaseRegistryKey = @"SOFTWARE\Dayu\Spark"; |
||||
/// <summary> |
||||
/// 向注册表写入字符串类型值 |
||||
/// </summary> |
||||
/// <param name="keyName">存储的键名</param> |
||||
/// <param name="value">要写入的字符串值</param> |
||||
public static void WriteString(string keyName, string value) |
||||
{ |
||||
using (var key = Registry.CurrentUser.CreateSubKey(BaseRegistryKey)) |
||||
{ |
||||
key?.SetValue(keyName, value, RegistryValueKind.String); |
||||
} |
||||
} |
||||
|
||||
/// <summary> |
||||
/// 从注册表读取字符串类型值 |
||||
/// </summary> |
||||
/// <param name="keyName">存储的键名</param> |
||||
/// <returns>读取到的字符串值,若不存在则返回 null</returns> |
||||
public static string ReadString(string keyName) |
||||
{ |
||||
using (var key = Registry.CurrentUser.OpenSubKey(BaseRegistryKey)) |
||||
{ |
||||
if (key == null) return null; |
||||
return key.GetValue(keyName) as string; |
||||
} |
||||
} |
||||
|
||||
/// <summary> |
||||
/// 向注册表写入布尔类型值(以 0/1 方式) |
||||
/// </summary> |
||||
public static void WriteBool(string keyName, bool value) |
||||
{ |
||||
using (var key = Registry.CurrentUser.CreateSubKey(BaseRegistryKey)) |
||||
{ |
||||
key?.SetValue(keyName, value ? 1 : 0, RegistryValueKind.DWord); |
||||
} |
||||
} |
||||
|
||||
/// <summary> |
||||
/// 从注册表读取布尔类型值(从 0/1 转换) |
||||
/// </summary> |
||||
public static bool ReadBool(string keyName, bool defaultValue = false) |
||||
{ |
||||
using (var key = Registry.CurrentUser.OpenSubKey(BaseRegistryKey)) |
||||
{ |
||||
if (key == null) return defaultValue; |
||||
object regValue = key.GetValue(keyName); |
||||
if (regValue == null) return defaultValue; |
||||
|
||||
int intVal; |
||||
if (int.TryParse(regValue.ToString(), out intVal)) |
||||
{ |
||||
return intVal != 0; // 1->true, 0->false |
||||
} |
||||
return defaultValue; |
||||
} |
||||
} |
||||
|
||||
/// <summary> |
||||
/// 删除某个键值 |
||||
/// </summary> |
||||
/// <param name="keyName">要删除的键名</param> |
||||
public static void DeleteKey(string keyName) |
||||
{ |
||||
using (var key = Registry.CurrentUser.OpenSubKey(BaseRegistryKey, writable: true)) |
||||
{ |
||||
if (key != null) |
||||
{ |
||||
key.DeleteValue(keyName, throwOnMissingValue: false); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in new issue