diff --git a/WorkStation.Client/App.xaml b/WorkStation.Client/App.xaml new file mode 100644 index 0000000..18a3c3c --- /dev/null +++ b/WorkStation.Client/App.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/WorkStation.Client/App.xaml.cs b/WorkStation.Client/App.xaml.cs new file mode 100644 index 0000000..1df9d57 --- /dev/null +++ b/WorkStation.Client/App.xaml.cs @@ -0,0 +1,37 @@ +using Prism.Ioc; +using Prism.Services.Dialogs; +using System.Windows; +using WorkStation.Client.ViewModels.Dialogs; +using WorkStation.Client.Views; +using WorkStation.Client.Views.Dialogs; + +namespace WorkStation.Client +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App + { + protected override Window CreateShell() + { + return Container.Resolve(); + } + protected override void OnInitialized() + { + var dialogService = Container.Resolve(); + dialogService.ShowDialog("LoginView", result => + { + if (result.Result == ButtonResult.OK) + { + base.OnInitialized(); + } + }); + + + } + protected override void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterDialog(); + } + } +} diff --git a/WorkStation.Client/Images/LoginImage.png b/WorkStation.Client/Images/LoginImage.png new file mode 100644 index 0000000..f586e0a Binary files /dev/null and b/WorkStation.Client/Images/LoginImage.png differ diff --git a/WorkStation.Client/ViewModels/Dialogs/LoginViewModel.cs b/WorkStation.Client/ViewModels/Dialogs/LoginViewModel.cs new file mode 100644 index 0000000..2c4a25c --- /dev/null +++ b/WorkStation.Client/ViewModels/Dialogs/LoginViewModel.cs @@ -0,0 +1,90 @@ +using Prism.Commands; +using Prism.Mvvm; +using Prism.Services.Dialogs; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace WorkStation.Client.ViewModels.Dialogs +{ + public class LoginViewModel : BindableBase, IDialogAware + { + /// + /// 弹窗标题 + /// + public string Title => "登录界面"; + + /// + /// 账户 + /// + private string _account = string.Empty; + public string Account + { + get => _account; + set => SetProperty(ref _account, value); + } + + /// + /// 密码 + /// + private string _password = string.Empty; + public string Password + { + get => _password; + set => SetProperty(ref _password, value); + } + + /// + /// 用于关闭窗口时,判断是否登录成功。 + /// 如果登录失败就终止当前应用。 + /// + private bool _isSuccess = false; + + /// + /// 登录名利 + /// + public DelegateCommand LoginCommand { get; set; } + + /// + /// 请求关闭委托 + /// + public event Action RequestClose; + + /// + /// Determines whether the dialog can be closed. + /// + /// if the dialog can be closed; otherwise, . + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + if (_isSuccess == false) + { + Application.Current.Shutdown(); + } + } + + public void OnDialogOpened(IDialogParameters parameters) + { + + } + public LoginViewModel() + { + LoginCommand = new DelegateCommand(() => + { + if (Account == "11" && Password == "22") + { + _isSuccess = true; + RequestClose(new DialogResult(ButtonResult.OK)); + } + }); + } + } +} diff --git a/WorkStationClient/ViewModels/MainWindowViewModel.cs b/WorkStation.Client/ViewModels/MainWindowViewModel.cs similarity index 89% rename from WorkStationClient/ViewModels/MainWindowViewModel.cs rename to WorkStation.Client/ViewModels/MainWindowViewModel.cs index 0df0abe..7f5c705 100644 --- a/WorkStationClient/ViewModels/MainWindowViewModel.cs +++ b/WorkStation.Client/ViewModels/MainWindowViewModel.cs @@ -1,6 +1,6 @@ using Prism.Mvvm; -namespace WorkStationClient.ViewModels +namespace WorkStation.Client.ViewModels { public class MainWindowViewModel : BindableBase { diff --git a/WorkStation.Client/Views/Dialogs/LoginView.xaml b/WorkStation.Client/Views/Dialogs/LoginView.xaml new file mode 100644 index 0000000..e698cae --- /dev/null +++ b/WorkStation.Client/Views/Dialogs/LoginView.xaml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + +