using DevExpress.XtraBars.Navigation;
using DevExpress.XtraEditors;
using HStation.WinFrmUI;
using Yw;
using Yw.Untity;
using Yw.WinFrmUI;
namespace PBS.Desktop
{
public partial class LoginFrm : DevExpress.XtraEditors.XtraForm
{
public LoginFrm()
{
InitializeComponent();
this.layoutControl1.SetupLayoutControl();
this.Load += LoginFrm_Load;
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
this.systemLoginCtrl1.LoginCancelEvent += Cancel;
this.systemLoginCtrl1.LoginStartEvent += Start;
this.systemLoginCtrl1.LoginEndEvet += End;
this.smsLoginCtrl1.LoginCancelEvent += Cancel;
this.smsLoginCtrl1.LoginStartEvent += Start;
this.smsLoginCtrl1.LoginEndEvet += End;
this.wechatLoginCtrl1.LoginCancelEvent += Cancel;
this.wechatLoginCtrl1.LoginStartEvent += Start;
this.wechatLoginCtrl1.LoginEndEvet += End;
}
private void LoginFrm_Load(object sender, EventArgs e)
{
this.systemLoginCtrl1.Initial();
}
private void labSysTitle_MouseDown(object sender, MouseEventArgs e)
{
this.DragMove();
}
///
/// 新增绘制边框
///
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
//using (var pen = new Pen(Color.FromArgb(0, 122, 204), 1f))
//{
// e.Graphics.DrawRectangle(pen, 0.5f, 0.5f, this.Width - 1, this.Height - 1);
//}
}
//取消
private void Cancel()
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
//开始
private void Start()
{
this.itemForProgress.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
}
//结束
private async void End(Yw.Dto.UserLoginOutput result)
{
if (result.Status != Yw.Auth.eLoginStatus.Success)
{
TipFormHelper.ShowWarn($"登录失败,信息:{result.Status.GetDisplayText()}");
this.itemForProgress.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
return;
}
if (result.User.Corpration!=null)
{
Yw.WinFrmUI.LoginUserInfo.CorpID = result.User.Corpration.ID;
Yw.WinFrmUI.LoginUserInfo.CorpName = result.User.Corpration.Name;
}
Yw.WinFrmUI.LoginUserInfo.UserID = result.User.ID;
Yw.WinFrmUI.LoginUserInfo.AdminType = result.User.AdminType;
Yw.WinFrmUI.LoginUserInfo.UserName = result.User.Name;
Yw.WinFrmUI.LoginUserInfo.UserTag = result.User.Tag;
Yw.WinFrmUI.LoginUserInfo.LoginAccountID = result.User.LoginAccount.ID;
Yw.WinFrmUI.LoginUserInfo.LoginAccountName = result.User.LoginAccount.Identifier;
Yw.WinFrmUI.LoginUserInfo.LoginTypeID = result.User.LoginAccount.LoginType.ID;
Yw.WinFrmUI.LoginUserInfo.LoginTypeName = result.User.LoginAccount.LoginType.Name;
Yw.WinFrmUI.LoginUserInfo.ProjectID = result.Software.Project.ID;
Yw.WinFrmUI.LoginUserInfo.ProjectName = result.Software.Project.Name;
Yw.WinFrmUI.LoginUserInfo.SoftwareID = result.Software.ID;
Yw.WinFrmUI.LoginUserInfo.SoftwareName = result.Software.Name;
Yw.JwtToken2Helper.Set(result.AccessToken, result.RefreshToken);
//
var authTreelist = await BLLFactory.Instance.GetHaveMenuTreeList(LoginUserInfo.SoftwareID, LoginUserInfo.UserID);
AuthHelper.PageAuthHaveTreeList = authTreelist;
this.DialogResult = DialogResult.OK;
this.Close();
}
private void tabPane1_SelectedPageChanged(object sender, DevExpress.XtraBars.Navigation.SelectedPageChangedEventArgs e)
{
var page = e.Page as TabNavigationPage;
var login = page.Controls[0] as ILogin;
if (login != null)
{
login.Initial();
}
}
}
}