diff --git a/StandardDesign.Assets/Fonts/iconfont.ttf b/StandardDesign.Assets/Fonts/iconfont.ttf index a3b3693..e317628 100644 Binary files a/StandardDesign.Assets/Fonts/iconfont.ttf and b/StandardDesign.Assets/Fonts/iconfont.ttf differ diff --git a/StandardDesign.Assets/Fonts/方正楷体简体.ttf b/StandardDesign.Assets/Fonts/方正楷体简体.ttf new file mode 100644 index 0000000..1ef7053 Binary files /dev/null and b/StandardDesign.Assets/Fonts/方正楷体简体.ttf differ diff --git a/StandardDesign.Assets/Images/bitbug_favicon.ico b/StandardDesign.Assets/Images/bitbug_favicon.ico new file mode 100644 index 0000000..74d5283 Binary files /dev/null and b/StandardDesign.Assets/Images/bitbug_favicon.ico differ diff --git a/StandardDesign.Assets/StandardDesign.Assets.csproj b/StandardDesign.Assets/StandardDesign.Assets.csproj index affad41..0a84958 100644 --- a/StandardDesign.Assets/StandardDesign.Assets.csproj +++ b/StandardDesign.Assets/StandardDesign.Assets.csproj @@ -9,6 +9,8 @@ + + @@ -21,6 +23,12 @@ Always + + Always + + + Always + Always diff --git a/StandardDesign.DataAccess/Class1.cs b/StandardDesign.DataAccess/Class1.cs deleted file mode 100644 index 9041b5d..0000000 --- a/StandardDesign.DataAccess/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ - -namespace StandardDesign.DataAccess -{ - public class Class1 - { - } - -} diff --git a/StandardDesign.DataAccess/LoacalDataAccess.cs b/StandardDesign.DataAccess/LoacalDataAccess.cs new file mode 100644 index 0000000..027150a --- /dev/null +++ b/StandardDesign.DataAccess/LoacalDataAccess.cs @@ -0,0 +1,10 @@ + +using StandardDesign.IDataAccess; + +namespace StandardDesign.DataAccess +{ + public class LoacalDataAccess : ILoacalDataAccess + { + } + +} diff --git a/StandardDesign.DataAccess/StandardDesign.DataAccess.csproj b/StandardDesign.DataAccess/StandardDesign.DataAccess.csproj index 01eaad7..db5f21f 100644 --- a/StandardDesign.DataAccess/StandardDesign.DataAccess.csproj +++ b/StandardDesign.DataAccess/StandardDesign.DataAccess.csproj @@ -7,4 +7,8 @@ enable + + + + diff --git a/StandardDesign.IDataAccess/Class1.cs b/StandardDesign.IDataAccess/Class1.cs deleted file mode 100644 index dfcc03a..0000000 --- a/StandardDesign.IDataAccess/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ - -namespace StandardDesign.IDataAccess -{ - public class Class1 - { - } - -} diff --git a/StandardDesign.IDataAccess/ILoacalDataAccess.cs b/StandardDesign.IDataAccess/ILoacalDataAccess.cs new file mode 100644 index 0000000..0d90979 --- /dev/null +++ b/StandardDesign.IDataAccess/ILoacalDataAccess.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StandardDesign.IDataAccess +{ + public interface ILoacalDataAccess + { + + } +} diff --git a/StandardDesign.Models/Class1.cs b/StandardDesign.Models/Class1.cs deleted file mode 100644 index 303e67f..0000000 --- a/StandardDesign.Models/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ - -namespace StandardDesign.Models -{ - public class Class1 - { - } - -} diff --git a/StandardDesign.Models/SocketModel.cs b/StandardDesign.Models/SocketModel.cs new file mode 100644 index 0000000..1f85d1d --- /dev/null +++ b/StandardDesign.Models/SocketModel.cs @@ -0,0 +1,12 @@ + +namespace StandardDesign.Models +{ + public class SocketModel + { + public string IP { get; set; } + public string Port { get; set; } + + public string AuthorizeCode { get; set; } + } + +} diff --git a/StandardDesign.Models/StandardDesign.Models.csproj b/StandardDesign.Models/StandardDesign.Models.csproj index 309ebbe..01eaad7 100644 --- a/StandardDesign.Models/StandardDesign.Models.csproj +++ b/StandardDesign.Models/StandardDesign.Models.csproj @@ -7,11 +7,4 @@ enable - - - - - - - diff --git a/StandardDesign.ViewModels/LoginViewModel.cs b/StandardDesign.ViewModels/LoginViewModel.cs index caf2018..c74e5fb 100644 --- a/StandardDesign.ViewModels/LoginViewModel.cs +++ b/StandardDesign.ViewModels/LoginViewModel.cs @@ -1,10 +1,159 @@ using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using StandardDesign.IDataAccess; +using StandardDesign.Models; +using System.CodeDom; +using System.IO; +using System.Net.Sockets; +using System.Text.RegularExpressions; +using System.Windows; namespace StandardDesign.ViewModels { public class LoginViewModel : ViewModelBase { + ILoacalDataAccess _localDataAccess; + + + //ip + public string ip; + public string IP + { + get { return ip; } + set { Set(ref ip, value); } + } + //Port + public string port; + public string Port + { + get { return port; } + set { Set(ref port, value); } + } + + //Ȩ + public string _authorizeCode; + public string AuthorizeCode + { + get { return _authorizeCode; } + set { Set(ref _authorizeCode, value); } + } + + //쳣Ϣ + public string _failedMsg; + public string FailedMsg + { + get { return _failedMsg; } + set { Set(ref _failedMsg, value); } + } + + //Ƿ񱣴¼ + private bool _isRecord; + + public bool IsRecord + { + get { return _isRecord; } + set { Set(ref _isRecord, value); } + } + + + //¼ť + public RelayCommand LoginCommand { get; set; } + public RelayCommand SkipCommand { get; set; } + + + public LoginViewModel(ILoacalDataAccess localDataAccess) + { + _localDataAccess = localDataAccess; + + if (File.Exists("temp.txt")) + { + string info = File.ReadAllText("temp.txt"); + this.IP = info.Split("|")[0]; + this.Port = info.Split("|")[1]; + } + if (!IsInDesignMode) + { + LoginCommand = new RelayCommand(DoLogin); + SkipCommand = new RelayCommand(SkipLogin); + } + } + private void DoLogin(object obj) + { + try + { + // ѡϢ¼ + if (IsRecord) + { + string info = $"{this.IP}|{this.Port}"; + File.WriteAllText("temp.txt", info); + } + else + { + if (File.Exists("temp.txt")) + File.Delete("temp.text"); + } + + if (string.IsNullOrEmpty(IP)) + { + throw new Exception("IPַΪ!"); + } + else if (!ValidateIPAddress(IP)) + { + throw new Exception("IP!"); + } + else if (string.IsNullOrEmpty(Port)) + { + throw new Exception("˿ںΪ!"); + } + else if (!ValidatePortAddress(Port)) + { + throw new Exception("˿ں!"); + } + else + { + (obj as Window).DialogResult = true; + } + } + catch (Exception ex) + { + FailedMsg = ex.Message; + } + } + + /// + /// + /// + /// + + private void SkipLogin(object obj) + { + (obj as Window).DialogResult = true; + } + + + /// + /// УIp + /// + /// + /// + public static bool ValidateIPAddress(string ipAddress) + { + Regex validipregex = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"); + return (ipAddress != "" && validipregex.IsMatch(ipAddress.Trim())) ? true : false; + } + + /// + /// У˿ں + /// + /// + /// + public static bool ValidatePortAddress(string prtAddress) + { + Regex validipregex = new Regex(@"^(\d|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$"); + return (prtAddress != "" && validipregex.IsMatch(prtAddress.Trim())) ? true : false; + } + } } diff --git a/StandardDesign.ViewModels/StandardDesign.ViewModels.csproj b/StandardDesign.ViewModels/StandardDesign.ViewModels.csproj index bbc4e12..c962a29 100644 --- a/StandardDesign.ViewModels/StandardDesign.ViewModels.csproj +++ b/StandardDesign.ViewModels/StandardDesign.ViewModels.csproj @@ -11,4 +11,11 @@ + + + + + + + diff --git a/StandardDesign.ViewModels/ViewModelLocator.cs b/StandardDesign.ViewModels/ViewModelLocator.cs index 108634a..197b60a 100644 --- a/StandardDesign.ViewModels/ViewModelLocator.cs +++ b/StandardDesign.ViewModels/ViewModelLocator.cs @@ -1,6 +1,8 @@ using CommonServiceLocator; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Ioc; +using StandardDesign.DataAccess; +using StandardDesign.IDataAccess; using System; using System.Collections.Generic; using System.Linq; @@ -20,7 +22,7 @@ namespace StandardDesign.ViewModels SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); - // SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); } // 这种属性定义方式会有歧义,感觉好像定义的字段 public LoginViewModel LoginViewModel => ServiceLocator.Current.GetInstance(); diff --git a/StandardDesign.Views/LoginView.xaml b/StandardDesign.Views/LoginView.xaml index 240a963..658a663 100644 --- a/StandardDesign.Views/LoginView.xaml +++ b/StandardDesign.Views/LoginView.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:StandardDesign.Views" xmlns:c="clr-namespace:StandardDesign.Common;assembly=StandardDesign.Common" DataContext="{Binding Source={StaticResource locator},Path=LoginViewModel}" - mc:Ignorable="d" Name="win" FontFamily="Microsoft YaHei" + mc:Ignorable="d" Name="win" FontFamily="{StaticResource DigitalDisplay}" ResizeMode="NoResize" Background="#f1f5fd" WindowStartupLocation="CenterScreen" Title="系统登录" Height="540" Width="900"> @@ -21,24 +21,20 @@ - - + + + + + @@ -182,28 +224,50 @@ - - - - - - - - + + + + + + -