forked from project-redbud/FunGame-Core
添加注册逻辑,完善MailSender
This commit is contained in:
parent
736cab93b5
commit
a9306d2495
@ -23,7 +23,7 @@ namespace Milimoe.FunGame.Core.Api.Transmittal
|
|||||||
_SmtpClientInfo = new SmtpClientInfo(SenderMailAddress, SenderName, SenderPassword, Host, Port, OpenSSL);
|
_SmtpClientInfo = new SmtpClientInfo(SenderMailAddress, SenderName, SenderPassword, Host, Port, OpenSSL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MailObject CreateMail(string Subject, string Body, MailPriority Priority, bool HTML, string[] ToList, string[] CCList, string[] BCCList)
|
public MailObject CreateMail(string Subject, string Body, MailPriority Priority, bool HTML, string[] ToList, string[]? CCList = null, string[]? BCCList = null)
|
||||||
{
|
{
|
||||||
return new MailObject(this, Subject, Body, Priority, HTML, ToList, CCList, BCCList);
|
return new MailObject(this, Subject, Body, Priority, HTML, ToList, CCList, BCCList);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -179,7 +179,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
|||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.Now;
|
||||||
return type switch
|
return type switch
|
||||||
{
|
{
|
||||||
TimeType.DateOnly => now.Date.ToString(""),
|
TimeType.DateOnly => now.Date.ToString("D"),
|
||||||
TimeType.TimeOnly => now.ToString("T"),
|
TimeType.TimeOnly => now.ToString("T"),
|
||||||
TimeType.Year4 => now.Year.ToString(),
|
TimeType.Year4 => now.Year.ToString(),
|
||||||
TimeType.Year2 => "'" + now.ToString("yy"),
|
TimeType.Year2 => "'" + now.ToString("yy"),
|
||||||
|
|||||||
@ -8,7 +8,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
|||||||
/*
|
/*
|
||||||
* 声明API函数
|
* 声明API函数
|
||||||
*/
|
*/
|
||||||
[LibraryImport("kernel32", StringMarshalling = StringMarshalling.Utf16)]
|
[LibraryImport("kernel32", EntryPoint = "WritePrivateProfileStringW", StringMarshalling = StringMarshalling.Utf16)]
|
||||||
private static partial long WritePrivateProfileString(string section, string key, string val, string filePath);
|
private static partial long WritePrivateProfileString(string section, string key, string val, string filePath);
|
||||||
[LibraryImport("Kernel32.dll", EntryPoint = "GetPrivateProfileStringW", StringMarshalling = StringMarshalling.Utf16)]
|
[LibraryImport("Kernel32.dll", EntryPoint = "GetPrivateProfileStringW", StringMarshalling = StringMarshalling.Utf16)]
|
||||||
private static partial int GetPrivateProfileString(string section, string key, string def, char[] val, int size, string filePath);
|
private static partial int GetPrivateProfileString(string section, string key, string def, char[] val, int size, string filePath);
|
||||||
@ -83,6 +83,11 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
|||||||
WriteINI("Server", "Notice", "This is the FunGame Server's Notice.");
|
WriteINI("Server", "Notice", "This is the FunGame Server's Notice.");
|
||||||
WriteINI("Server", "Key", "");
|
WriteINI("Server", "Key", "");
|
||||||
WriteINI("Server", "Status", "1");
|
WriteINI("Server", "Status", "1");
|
||||||
|
/**
|
||||||
|
* ServerMail
|
||||||
|
*/
|
||||||
|
WriteINI("ServerMail", "OfficialMail", "");
|
||||||
|
WriteINI("ServerMail", "SupportMail", "");
|
||||||
/**
|
/**
|
||||||
* Socket
|
* Socket
|
||||||
*/
|
*/
|
||||||
@ -97,6 +102,16 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
|||||||
WriteINI("MySQL", "DBName", "fungame");
|
WriteINI("MySQL", "DBName", "fungame");
|
||||||
WriteINI("MySQL", "DBUser", "root");
|
WriteINI("MySQL", "DBUser", "root");
|
||||||
WriteINI("MySQL", "DBPassword", "pass");
|
WriteINI("MySQL", "DBPassword", "pass");
|
||||||
|
/**
|
||||||
|
* Mailer
|
||||||
|
*/
|
||||||
|
WriteINI("Mailer", "UseMailSender", "false");
|
||||||
|
WriteINI("Mailer", "MailAddress", "");
|
||||||
|
WriteINI("Mailer", "Name", "");
|
||||||
|
WriteINI("Mailer", "Password", "");
|
||||||
|
WriteINI("Mailer", "Host", "");
|
||||||
|
WriteINI("Mailer", "Port", "587");
|
||||||
|
WriteINI("Mailer", "OpenSSL", "true");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,10 +12,10 @@ namespace Milimoe.FunGame.Core.Library.Common.Network
|
|||||||
public MailPriority Priority { get; } = MailPriority.Normal;
|
public MailPriority Priority { get; } = MailPriority.Normal;
|
||||||
public bool HTML { get; } = false;
|
public bool HTML { get; } = false;
|
||||||
public string[] ToList { get; } = Array.Empty<string>();
|
public string[] ToList { get; } = Array.Empty<string>();
|
||||||
public string[] CCList { get; } = Array.Empty<string>();
|
public string[]? CCList { get; } = Array.Empty<string>();
|
||||||
public string[] BCCList { get; } = Array.Empty<string>();
|
public string[]? BCCList { get; } = Array.Empty<string>();
|
||||||
|
|
||||||
public MailObject(MailSender Sender, string Subject, string Body, MailPriority Priority, bool HTML, string[] ToList, string[] CCList, string[] BCCList)
|
public MailObject(MailSender Sender, string Subject, string Body, MailPriority Priority, bool HTML, string[] ToList, string[]? CCList = null, string[]? BCCList = null)
|
||||||
{
|
{
|
||||||
this.Sender = Sender.SmtpClientInfo.SenderMailAddress;
|
this.Sender = Sender.SmtpClientInfo.SenderMailAddress;
|
||||||
this.SenderName = Sender.SmtpClientInfo.SenderName;
|
this.SenderName = Sender.SmtpClientInfo.SenderName;
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
namespace Milimoe.FunGame.Core.Library.Constant
|
|
||||||
{
|
|
||||||
public class SQLConstant
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Commands
|
|
||||||
*/
|
|
||||||
public const string Command_Select = "Select";
|
|
||||||
public const string Command_Update = "Update";
|
|
||||||
public const string Command_Delete = "Delete";
|
|
||||||
public const string Command_Insert = "Insert";
|
|
||||||
public const string Command_Set = "Set";
|
|
||||||
public const string Command_Where = "Where";
|
|
||||||
public const string Command_From = "From";
|
|
||||||
public const string Command_All = "*";
|
|
||||||
public const string Command_Into = "Into";
|
|
||||||
public const string Command_Values = "Values";
|
|
||||||
public const string Command_And = "And";
|
|
||||||
public const string Command_Or = "Or";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tables
|
|
||||||
*/
|
|
||||||
public const string Table_Users = "Users";
|
|
||||||
public const string Table_ServerLoginLogs = "ServerLoginLogs";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select
|
|
||||||
*/
|
|
||||||
public const string Select_Users = $"{Command_Select} {Command_All} {Command_From} {Table_Users}";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Insert
|
|
||||||
*/
|
|
||||||
public static string Insert_ServerLoginLogs(string ServerName, string ServerKey)
|
|
||||||
{
|
|
||||||
return $"{Command_Insert} {Command_Into} {Table_ServerLoginLogs} (ServerName, ServerKey, LoginTime) {Command_Values} ('{ServerName}', '{ServerKey}', '{DateTime.Now}')";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -58,7 +58,9 @@
|
|||||||
Disconnect,
|
Disconnect,
|
||||||
HeartBeat,
|
HeartBeat,
|
||||||
IntoRoom,
|
IntoRoom,
|
||||||
Chat
|
Chat,
|
||||||
|
Reg,
|
||||||
|
CheckReg
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SocketRuntimeType
|
public enum SocketRuntimeType
|
||||||
|
|||||||
@ -124,4 +124,9 @@
|
|||||||
{
|
{
|
||||||
public override string Message => "无法发送邮件 (#10025)";
|
public override string Message => "无法发送邮件 (#10025)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SmtpHelperException : Exception
|
||||||
|
{
|
||||||
|
public override string Message => "无法创建Smtp服务 (#10026)";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
56
FunGame.Core/Library/SQLScript/Common/Common.cs
Normal file
56
FunGame.Core/Library/SQLScript/Common/Common.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
namespace Milimoe.FunGame.Core.Library.SQLScript
|
||||||
|
{
|
||||||
|
public class Constant
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Commands
|
||||||
|
*/
|
||||||
|
public const string Command_Select = "Select";
|
||||||
|
public const string Command_Update = "Update";
|
||||||
|
public const string Command_Delete = "Delete";
|
||||||
|
public const string Command_Insert = "Insert";
|
||||||
|
public const string Command_Set = "Set";
|
||||||
|
public const string Command_Where = "Where";
|
||||||
|
public const string Command_From = "From";
|
||||||
|
public const string Command_All = "*";
|
||||||
|
public const string Command_Into = "Into";
|
||||||
|
public const string Command_Values = "Values";
|
||||||
|
public const string Command_And = "And";
|
||||||
|
public const string Command_Or = "Or";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Core.Library.SQLScript.Common
|
||||||
|
{
|
||||||
|
public class ServerLoginLogs
|
||||||
|
{
|
||||||
|
public const string TableName = "ServerLoginLogs";
|
||||||
|
public const string Column_ServerName = "ServerName";
|
||||||
|
public const string Column_ServerKey = "ServerKey";
|
||||||
|
public const string Column_LoginTime = "LoginTime";
|
||||||
|
|
||||||
|
public static string Insert_ServerLoginLogs(string ServerName, string ServerKey)
|
||||||
|
{
|
||||||
|
return $"{Constant.Command_Insert} {Constant.Command_Into} {TableName} ({Column_ServerName}, {Column_ServerKey}, {Column_LoginTime}) {Constant.Command_Values} ('{ServerName}', '{ServerKey}', '{DateTime.Now}')";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RegVerifyCodes
|
||||||
|
{
|
||||||
|
public const string TableName = "RegVerifyCodes";
|
||||||
|
public const string Column_Username = "Username";
|
||||||
|
public const string Column_Email = "Email";
|
||||||
|
public const string Column_RegVerifyCode = "RegVerifyCode";
|
||||||
|
public const string Column_RegTime = "RegTime";
|
||||||
|
|
||||||
|
public static string Insert_RegVerifyCodes(string Username, string Email, string RegVerifyCodes)
|
||||||
|
{
|
||||||
|
return $"{Constant.Command_Insert} {Constant.Command_Into} {TableName} ({Column_Username}, {Column_Email}, {Column_RegVerifyCode}, {Column_RegTime}) {Constant.Command_Values} ('{Username}', '{Email}', '{RegVerifyCodes}', '{DateTime.Now}')";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Select_RegVerifyCode(string Username, string Email, string RegVerifyCode)
|
||||||
|
{
|
||||||
|
return $"{Constant.Command_Select} {Constant.Command_All} {Constant.Command_From} {TableName} {Constant.Command_Where} {Column_Username} = '{Username}' and {Column_Email} = '{Email}' and {Column_RegVerifyCode} = '{RegVerifyCode}'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
FunGame.Core/Library/SQLScript/Entity/User.cs
Normal file
45
FunGame.Core/Library/SQLScript/Entity/User.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
namespace Milimoe.FunGame.Core.Library.SQLScript.Entity
|
||||||
|
{
|
||||||
|
public class UserQuery
|
||||||
|
{
|
||||||
|
public const string TableName= "User";
|
||||||
|
public const string Column_UID = "UID";
|
||||||
|
public const string Column_Username = "Username";
|
||||||
|
public const string Column_Password = "Password";
|
||||||
|
public const string Column_RegTime = "RegTime";
|
||||||
|
public const string Column_LastTime = "LastTime";
|
||||||
|
public const string Column_LastIP = "LastIP";
|
||||||
|
public const string Column_Email = "Email";
|
||||||
|
public const string Column_Nickname = "Nickname";
|
||||||
|
public const string Column_IsAdmin = "IsAdmin";
|
||||||
|
public const string Column_IsOperator = "IsOperator";
|
||||||
|
public const string Column_IsEnable = "IsEnable";
|
||||||
|
public const string Column_OnlineState = "OnlineState";
|
||||||
|
public const string Column_Credits = "Credits";
|
||||||
|
public const string Column_Materials = "Materials";
|
||||||
|
public const string Column_GameTime = "GameTime";
|
||||||
|
public const string Select_Users = $"{Constant.Command_Select} {Constant.Command_All} {Constant.Command_From} {TableName}";
|
||||||
|
|
||||||
|
public static string Select_Users_LoginQuery(string Username, string Password)
|
||||||
|
{
|
||||||
|
return $"{Select_Users} {Constant.Command_Where} {Column_Username} = '{Username}' and {Column_Password} = '{Password}'";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Select_Users_Where(string Where)
|
||||||
|
{
|
||||||
|
return $"{Select_Users} {Constant.Command_Where} {Where}'";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string CheckLogin(string Username, string IP)
|
||||||
|
{
|
||||||
|
return @$"{Constant.Command_Update} {TableName} {Constant.Command_Set} {Column_LastTime} = '{DateTime.Now}', {Column_LastIP} = '{IP}'
|
||||||
|
{Constant.Command_Where} {Column_Username} = '{Username}'";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Register(string UserName, string Password, string Email)
|
||||||
|
{
|
||||||
|
return @$"{Constant.Command_Insert} {Constant.Command_Into} {TableName} ({Column_Username}, {Column_Password}, {Column_Email}, {Column_RegTime})
|
||||||
|
{Constant.Command_Values} ('{UserName}', '{Password}', {Email}, '{DateTime.Now}')";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -37,22 +37,32 @@ namespace Milimoe.FunGame.Core.Service
|
|||||||
MailMessage Msg = new()
|
MailMessage Msg = new()
|
||||||
{
|
{
|
||||||
Subject = Mail.Subject,
|
Subject = Mail.Subject,
|
||||||
SubjectEncoding = General.DefaultEncoding,
|
SubjectEncoding = System.Text.Encoding.UTF8,
|
||||||
Body = Mail.Body,
|
Body = Mail.Body,
|
||||||
BodyEncoding = General.DefaultEncoding,
|
BodyEncoding = System.Text.Encoding.UTF8,
|
||||||
From = new MailAddress(Mail.Sender, Mail.SenderName, General.DefaultEncoding),
|
From = new MailAddress(Mail.Sender, Mail.SenderName, System.Text.Encoding.UTF8),
|
||||||
IsBodyHtml = Mail.HTML,
|
IsBodyHtml = Mail.HTML,
|
||||||
Priority = Mail.Priority
|
Priority = Mail.Priority
|
||||||
};
|
};
|
||||||
foreach (string To in Mail.ToList)
|
foreach (string To in Mail.ToList)
|
||||||
{
|
{
|
||||||
Msg.To.Add(To);
|
if (To.Trim() != "") Msg.To.Add(To);
|
||||||
}
|
}
|
||||||
|
if (Mail.CCList != null)
|
||||||
|
{
|
||||||
foreach (string CC in Mail.CCList)
|
foreach (string CC in Mail.CCList)
|
||||||
{
|
{
|
||||||
Msg.CC.Add(CC);
|
if (CC.Trim() != "") Msg.CC.Add(CC);
|
||||||
}
|
}
|
||||||
Smtp.Send(Msg);
|
}
|
||||||
|
if (Mail.BCCList != null)
|
||||||
|
{
|
||||||
|
foreach (string BCC in Mail.BCCList)
|
||||||
|
{
|
||||||
|
if (BCC.Trim() != "") Msg.Bcc.Add(BCC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Smtp.SendMailAsync(Msg);
|
||||||
return MailSendResult.Success;
|
return MailSendResult.Success;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@ -1,21 +1,22 @@
|
|||||||
using Milimoe.FunGame.Desktop.Library.Interface;
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
|
using Milimoe.FunGame.Desktop.Library.Component;
|
||||||
|
using Milimoe.FunGame.Desktop.Library;
|
||||||
using Milimoe.FunGame.Desktop.Model;
|
using Milimoe.FunGame.Desktop.Model;
|
||||||
using Milimoe.FunGame.Desktop.UI;
|
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Desktop.Controller
|
namespace Milimoe.FunGame.Desktop.Controller
|
||||||
{
|
{
|
||||||
public class RegisterController : IReg
|
public class RegisterController
|
||||||
{
|
{
|
||||||
RegisterModel RegisterModel { get; }
|
public static bool Reg(params object[]? objs)
|
||||||
|
|
||||||
public RegisterController(Register Register)
|
|
||||||
{
|
{
|
||||||
RegisterModel = new RegisterModel(Register);
|
RunTime.Register?.OnBeforeRegEvent(new GeneralEventArgs());
|
||||||
|
bool result = RegisterModel.Reg(objs);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
ShowMessage.ErrorMessage("注册失败!!", "注册失败", 5);
|
||||||
|
RunTime.Register?.OnFailedRegEvent(new GeneralEventArgs());
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
public bool Reg()
|
|
||||||
{
|
|
||||||
return RegisterModel.Reg();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
51
FunGame.Desktop/Library/Base/BaseReg.cs
Normal file
51
FunGame.Desktop/Library/Base/BaseReg.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using Milimoe.FunGame.Core.Interface;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
using Milimoe.FunGame.Desktop.Library.Component;
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Desktop.Library.Base
|
||||||
|
{
|
||||||
|
public class BaseReg : GeneralForm, IRegEventHandler
|
||||||
|
{
|
||||||
|
public event IEventHandler.BeforeEventHandler? BeforeReg;
|
||||||
|
public event IEventHandler.AfterEventHandler? AfterReg;
|
||||||
|
public event IEventHandler.SucceedEventHandler? SucceedReg;
|
||||||
|
public event IEventHandler.FailedEventHandler? FailedReg;
|
||||||
|
|
||||||
|
public EventResult OnAfterRegEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (AfterReg != null)
|
||||||
|
{
|
||||||
|
return AfterReg(this, e);
|
||||||
|
}
|
||||||
|
else return EventResult.NoEventImplement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventResult OnBeforeRegEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (BeforeReg != null)
|
||||||
|
{
|
||||||
|
return BeforeReg(this, e);
|
||||||
|
}
|
||||||
|
else return EventResult.NoEventImplement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventResult OnFailedRegEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (FailedReg != null)
|
||||||
|
{
|
||||||
|
return FailedReg(this, e);
|
||||||
|
}
|
||||||
|
else return EventResult.NoEventImplement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventResult OnSucceedRegEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (SucceedReg != null)
|
||||||
|
{
|
||||||
|
return SucceedReg(this, e);
|
||||||
|
}
|
||||||
|
else return EventResult.NoEventImplement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +0,0 @@
|
|||||||
namespace Milimoe.FunGame.Desktop.Library.Interface
|
|
||||||
{
|
|
||||||
public interface IReg
|
|
||||||
{
|
|
||||||
public bool Reg();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,23 +1,33 @@
|
|||||||
using Milimoe.FunGame.Desktop.Library;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Desktop.Library.Interface;
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
using Milimoe.FunGame.Desktop.UI;
|
using Milimoe.FunGame.Desktop.Library;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Desktop.Model
|
namespace Milimoe.FunGame.Desktop.Model
|
||||||
{
|
{
|
||||||
public class RegisterModel : IReg
|
public class RegisterModel
|
||||||
{
|
{
|
||||||
private readonly Register Register;
|
public static bool Reg(params object[]? objs)
|
||||||
private Core.Library.Common.Network.Socket? Socket;
|
|
||||||
|
|
||||||
public RegisterModel(Register register)
|
|
||||||
{
|
{
|
||||||
Register = register;
|
try
|
||||||
Socket = RunTime.Socket;
|
{
|
||||||
}
|
Core.Library.Common.Network.Socket? Socket = RunTime.Socket;
|
||||||
|
if (Socket != null && objs != null)
|
||||||
public bool Reg()
|
{
|
||||||
|
string username = "";
|
||||||
|
string email = "";
|
||||||
|
if (objs.Length > 0) username = (string)objs[0];
|
||||||
|
if (objs.Length > 1) email = (string)objs[1];
|
||||||
|
if (Socket.Send(SocketMessageType.Reg, username, email) == SocketResult.Success)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.GetErrorInfo();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,8 +19,10 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
protected override void BindEvent()
|
protected override void BindEvent()
|
||||||
{
|
{
|
||||||
base.BindEvent();
|
base.BindEvent();
|
||||||
SucceedLogin += SucceedLoginEvent;
|
BeforeLogin += BeforeLoginEvent;
|
||||||
|
AfterLogin += AfterLoginEvent;
|
||||||
FailedLogin += FailedLoginEvent;
|
FailedLogin += FailedLoginEvent;
|
||||||
|
SucceedLogin += SucceedLoginEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Login_Handler()
|
private bool Login_Handler()
|
||||||
@ -56,7 +58,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void RegButton_Click(object sender, EventArgs e)
|
private void RegButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OpenForm.SingleForm(Core.Library.Constant.FormType.Register, Core.Library.Constant.OpenFormType.Dialog);
|
OpenForm.SingleForm(FormType.Register, OpenFormType.Dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FastLogin_Click(object sender, EventArgs e)
|
private void FastLogin_Click(object sender, EventArgs e)
|
||||||
|
|||||||
37
FunGame.Desktop/UI/Register/Register.Designer.cs
generated
37
FunGame.Desktop/UI/Register/Register.Designer.cs
generated
@ -46,6 +46,15 @@
|
|||||||
this.TransparentRect.SuspendLayout();
|
this.TransparentRect.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
// Title
|
||||||
|
//
|
||||||
|
this.Title.Font = new System.Drawing.Font("LanaPixel", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.Title.Location = new System.Drawing.Point(4, 4);
|
||||||
|
this.Title.Size = new System.Drawing.Size(391, 47);
|
||||||
|
this.Title.TabIndex = 8;
|
||||||
|
this.Title.Text = "FunGame Register";
|
||||||
|
this.Title.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
// ExitButton
|
// ExitButton
|
||||||
//
|
//
|
||||||
this.ExitButton.Anchor = System.Windows.Forms.AnchorStyles.None;
|
this.ExitButton.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||||
@ -60,6 +69,7 @@
|
|||||||
this.ExitButton.ForeColor = System.Drawing.Color.Red;
|
this.ExitButton.ForeColor = System.Drawing.Color.Red;
|
||||||
this.ExitButton.Location = new System.Drawing.Point(453, 4);
|
this.ExitButton.Location = new System.Drawing.Point(453, 4);
|
||||||
this.ExitButton.Name = "ExitButton";
|
this.ExitButton.Name = "ExitButton";
|
||||||
|
this.ExitButton.RelativeForm = null;
|
||||||
this.ExitButton.Size = new System.Drawing.Size(47, 47);
|
this.ExitButton.Size = new System.Drawing.Size(47, 47);
|
||||||
this.ExitButton.TabIndex = 7;
|
this.ExitButton.TabIndex = 7;
|
||||||
this.ExitButton.TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
this.ExitButton.TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||||
@ -80,21 +90,12 @@
|
|||||||
this.MinButton.ForeColor = System.Drawing.Color.Black;
|
this.MinButton.ForeColor = System.Drawing.Color.Black;
|
||||||
this.MinButton.Location = new System.Drawing.Point(401, 4);
|
this.MinButton.Location = new System.Drawing.Point(401, 4);
|
||||||
this.MinButton.Name = "MinButton";
|
this.MinButton.Name = "MinButton";
|
||||||
|
this.MinButton.RelativeForm = null;
|
||||||
this.MinButton.Size = new System.Drawing.Size(47, 47);
|
this.MinButton.Size = new System.Drawing.Size(47, 47);
|
||||||
this.MinButton.TabIndex = 6;
|
this.MinButton.TabIndex = 6;
|
||||||
this.MinButton.TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
this.MinButton.TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||||
this.MinButton.UseVisualStyleBackColor = false;
|
this.MinButton.UseVisualStyleBackColor = false;
|
||||||
//
|
//
|
||||||
// Title
|
|
||||||
//
|
|
||||||
this.Title.Font = new System.Drawing.Font("LanaPixel", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.Title.Location = new System.Drawing.Point(4, 4);
|
|
||||||
this.Title.Name = "Title";
|
|
||||||
this.Title.Size = new System.Drawing.Size(391, 47);
|
|
||||||
this.Title.TabIndex = 8;
|
|
||||||
this.Title.Text = "FunGame Register";
|
|
||||||
this.Title.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
||||||
//
|
|
||||||
// Username
|
// Username
|
||||||
//
|
//
|
||||||
this.Username.Font = new System.Drawing.Font("LanaPixel", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.Username.Font = new System.Drawing.Font("LanaPixel", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
@ -160,6 +161,7 @@
|
|||||||
this.RegButton.TabIndex = 4;
|
this.RegButton.TabIndex = 4;
|
||||||
this.RegButton.Text = "注册";
|
this.RegButton.Text = "注册";
|
||||||
this.RegButton.UseVisualStyleBackColor = true;
|
this.RegButton.UseVisualStyleBackColor = true;
|
||||||
|
this.RegButton.Click += new System.EventHandler(this.RegButton_Click);
|
||||||
//
|
//
|
||||||
// GoToLogin
|
// GoToLogin
|
||||||
//
|
//
|
||||||
@ -170,6 +172,7 @@
|
|||||||
this.GoToLogin.TabIndex = 5;
|
this.GoToLogin.TabIndex = 5;
|
||||||
this.GoToLogin.Text = "登录";
|
this.GoToLogin.Text = "登录";
|
||||||
this.GoToLogin.UseVisualStyleBackColor = true;
|
this.GoToLogin.UseVisualStyleBackColor = true;
|
||||||
|
this.GoToLogin.Click += new System.EventHandler(this.GoToLogin_Click);
|
||||||
//
|
//
|
||||||
// EmailText
|
// EmailText
|
||||||
//
|
//
|
||||||
@ -214,6 +217,19 @@
|
|||||||
this.TransparentRect.Size = new System.Drawing.Size(503, 319);
|
this.TransparentRect.Size = new System.Drawing.Size(503, 319);
|
||||||
this.TransparentRect.TabIndex = 13;
|
this.TransparentRect.TabIndex = 13;
|
||||||
this.TransparentRect.TabStop = false;
|
this.TransparentRect.TabStop = false;
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.UsernameText, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.CheckPassword, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.PasswordText, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.Password, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.CheckPasswordText, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.Username, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.RegButton, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.GoToLogin, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.Title, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.Email, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.ExitButton, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.EmailText, 0);
|
||||||
|
this.TransparentRect.Controls.SetChildIndex(this.MinButton, 0);
|
||||||
//
|
//
|
||||||
// Register
|
// Register
|
||||||
//
|
//
|
||||||
@ -222,7 +238,6 @@
|
|||||||
this.BackColor = System.Drawing.Color.WhiteSmoke;
|
this.BackColor = System.Drawing.Color.WhiteSmoke;
|
||||||
this.ClientSize = new System.Drawing.Size(503, 319);
|
this.ClientSize = new System.Drawing.Size(503, 319);
|
||||||
this.Controls.Add(this.TransparentRect);
|
this.Controls.Add(this.TransparentRect);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.Name = "Register";
|
this.Name = "Register";
|
||||||
this.Opacity = 0.9D;
|
this.Opacity = 0.9D;
|
||||||
|
|||||||
@ -1,14 +1,66 @@
|
|||||||
using Milimoe.FunGame.Desktop.Library.Component;
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
|
using Milimoe.FunGame.Desktop.Controller;
|
||||||
|
using Milimoe.FunGame.Desktop.Library;
|
||||||
|
using Milimoe.FunGame.Desktop.Library.Base;
|
||||||
|
using Milimoe.FunGame.Desktop.Library.Component;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Desktop.UI
|
namespace Milimoe.FunGame.Desktop.UI
|
||||||
{
|
{
|
||||||
public partial class Register : GeneralForm
|
public partial class Register : BaseReg
|
||||||
{
|
{
|
||||||
public Register()
|
public Register()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void BindEvent()
|
||||||
|
{
|
||||||
|
base.BindEvent();
|
||||||
|
SucceedReg += SucceedRegEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool Reg_Handler()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string username = UsernameText.Text.Trim();
|
||||||
|
string password = PasswordText.Text.Trim();
|
||||||
|
string checkpassword = CheckPasswordText.Text.Trim();
|
||||||
|
string email = EmailText.Text.Trim();
|
||||||
|
if (username == "" || password == "" || checkpassword == "")
|
||||||
|
{
|
||||||
|
ShowMessage.ErrorMessage("账号或密码不能为空!");
|
||||||
|
UsernameText.Focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (password != checkpassword)
|
||||||
|
{
|
||||||
|
ShowMessage.ErrorMessage("两个密码不相同,请重新输入!");
|
||||||
|
CheckPasswordText.Focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (email == "")
|
||||||
|
{
|
||||||
|
ShowMessage.ErrorMessage("邮箱不能为空!");
|
||||||
|
UsernameText.Focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!RegisterController.Reg(username, email))
|
||||||
|
{
|
||||||
|
ShowMessage.Message("注册失败!!", "注册失败");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
RunTime.WritelnSystemInfo(e.GetErrorInfo());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关闭窗口
|
/// 关闭窗口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -18,5 +70,20 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
Dispose();
|
Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EventResult SucceedRegEvent(object sender, GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
return EventResult.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RegButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Reg_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GoToLogin_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user