123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using PDF_Office.CustomControl;
- using PDF_Office.Helper;
- using PDF_Office.Properties;
- using PDF_Office.Views.Dialog.ServiceDialog;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- namespace PDF_Office.ViewModels.Dialog.ServiceDialog
- {
- public class UserDialogViewModel : BindableBase, IDialogAware
- {
- private static Guid myuuid = Guid.NewGuid();
- private string uuid = myuuid.ToString();
- public IRegionManager Region;
- public string Title => "用户窗口";
- public event Action<IDialogResult> RequestClose;
-
- private string _UserEmail=ServiceHelper.GetUser() ;
- public string UserEmail
- {
- get { return _UserEmail; }
- set { _UserEmail = value; }
- }
- private string _UserRegionName;
- public string UserRegionName
- {
- get { return _UserRegionName; }
- set { _UserRegionName = value; }
- }
- public void Close()
- {
-
- RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
- }
- public bool CanCloseDialog()
- {
- return true;
- }
- public void OnDialogClosed()
- {
- }
- public void OnDialogOpened(IDialogParameters parameters)
- {
-
- }
- public DelegateCommand UserOutCommand { get; set; }
- public DelegateCommand LogOutCommand { get; set; }
- UserDialogViewModel(IRegionManager regionManager, IDialogService dialogService)
- {
- this.Region = regionManager;
- UserRegionName = Guid.NewGuid().ToString();
- UserOutCommand = new DelegateCommand(UserOut);
- LogOutCommand = new DelegateCommand(LogOut);
- if (ServiceHelper.ALLEmail!="")
- {
- UserEmail = ServiceHelper.ALLEmail;
- }
- }
- public void UserOut()
- {
- AlertsMessage alertsMessage = new AlertsMessage();
- alertsMessage.ShowDialog("Are you sure you want to cancel?", "Cancellation cannot be withdrawn, it will be completed within 3 working days, until then your account will be frozen and cannot be logged in, are you sure you want to cancel your account?", "Cancel", "OK");
- if (alertsMessage.result == ContentResult.Ok)
- {
- ServiceHelper.Get_code("user_log_off", UserEmail);
- RegionMan("UserOutCodeRegion");
- }
- }
- public void LogOut()
- {
- ServiceHelper.Logout(uuid);
- Settings.Default.AppProperties.LoginToken = "";
- Settings.Default.Save();
- App.mainWindowViewModel.UserVis = Visibility.Collapsed;
- App.mainWindowViewModel.RegisterVis = Visibility.Collapsed;
- App.mainWindowViewModel.LoginVis = Visibility.Visible;
- Close();
- }
- public void RegionMan(string name)
- {
- NavigationParameters param = new NavigationParameters();
- param.Add("UserDialogViewModel", this);
- Region.RequestNavigate(UserRegionName, name, e => {
- var r = e.Result;
- }, param);
- }
- }
- }
|