private void Ok_Button_Click(object sender, RoutedEventArgs e) { //MessageBox.Show(string.Format(System.Globalization.CultureInfo.CurrentUICulture, "Invoked '{0}'", this.ToString()), "SpecifierDialog"); ReturnCode = EReturnCode.RETURN_OK; OutputResult = CompileSpecifier(); Close(); }
/// <summary> /// 返回值为Player /// </summary> /// <param name="conn"></param> /// <param name="protocol"></param> public void CreateRole(Conn conn, ProtocolBase protocol) { int start = sizeof(Int32) * 3; ProtocolBytes p = protocol as ProtocolBytes; string name = p.GetString(start, ref start); ProtocolBytes result; if (dataMgr.GetPlayerIDByName(name) != -1) { result = new ProtocolBytes(requestCode, EActionCode.CreateRole, EReturnCode.RepeatName); } else { string jobStr = p.GetString(start, ref start); EPlayerJob job = (EPlayerJob)Enum.Parse(typeof(EPlayerJob), jobStr); string characterStr = p.GetString(start, ref start); ECharacter character = (ECharacter)Enum.Parse(typeof(ECharacter), characterStr); bool isSuccess = dataMgr.CreateRole(conn.user.ID, name, job, character); EReturnCode returnCode = isSuccess ? EReturnCode.Success : EReturnCode.Failed; result = new ProtocolBytes(requestCode, EActionCode.CreateRole, returnCode); } Send(conn, result); }
private void Ok_Button_Click(object sender, RoutedEventArgs e) { ListBoxItem li = specList.SelectedItem as ListBoxItem; ChosenSpecifier = li.Content.ToString(); ReturnCode = EReturnCode.RETURN_OK; Close(); }
/// <summary> /// 构造一个新的协议并初始化协议头部. /// </summary> /// <param name="request">一级,类</param> /// <param name="action">二级,方法</param> /// <param name="returncode">三级,返回值</param> public ProtocolBytes(ERequestCode request, EActionCode action, EReturnCode returncode = EReturnCode.None) { RequestCode = request; ActionCode = action; ReturnCode = returncode; AddInt((int)RequestCode); AddInt((int)ActionCode); AddInt((int)ReturnCode); }
public SpecifierDialog(ESpecifierMode mode, string property, string parameters) : base() { this.InitializeComponent(); SpecifierListBox.SelectionMode = SelectionMode.Multiple; OutputResult = ""; ReturnCode = EReturnCode.RETURN_CANCELLED; m_Data = new SortedDictionary <string, SpecifierData>(); Title += " - " + property; MetaScroller.Content = metaPanel; CreateCheckBoxList(mode); currentMode = mode; ParseExistingSpecifier(parameters); }
public void DeleteRole(Conn conn, ProtocolBase protocol) { int start = sizeof(Int32) * 3; ProtocolBytes p = protocol as ProtocolBytes; int playerid = p.GetInt(start); Player player = dataMgr.GetPlayer(playerid); ProtocolBytes result; if (player.UserID != conn.user.ID) { Console.WriteLine($"【警告】Player[{player.UserID}]不属于User[{conn.user.ID}]"); result = new ProtocolBytes(requestCode, EActionCode.DeleteRole, EReturnCode.Failed); } else { bool isSucceed = dataMgr.DeleteRole(playerid); EReturnCode returnCode = isSucceed ? EReturnCode.Success : EReturnCode.Failed; result = new ProtocolBytes(requestCode, EActionCode.DeleteRole, returnCode); } Send(conn, result); }
public void Register(Conn conn, ProtocolBase proto) { int start = sizeof(Int32) * 3; ProtocolBytes p = proto as ProtocolBytes; string username = p.GetString(start, ref start); ProtocolBytes result; if (dataMgr.CanGetUser(username)) { result = new ProtocolBytes(requestCode, EActionCode.Register, EReturnCode.RepeatName); } else { string password = p.GetString(start, ref start); bool createResult = dataMgr.CreateUser(username, password); // 有可能会创建失败,返回未知错误编号 EReturnCode returnCode = createResult ? EReturnCode.Success : EReturnCode.None; result = new ProtocolBytes(requestCode, EActionCode.Register, returnCode); } Send(conn, result); }
/// <summary> /// 解析出协议头部的RequestCode和ActionCode,并设置在协议中. /// </summary> public void Init() { RequestCode = (ERequestCode)Enum.Parse(typeof(ERequestCode), GetInt(0).ToString()); ActionCode = (EActionCode)Enum.Parse(typeof(EActionCode), GetInt(sizeof(int)).ToString()); ReturnCode = (EReturnCode)Enum.Parse(typeof(EReturnCode), GetInt(sizeof(int) * 2).ToString()); }
private void Cancel_Button_Click(object sender, RoutedEventArgs e) { ReturnCode = EReturnCode.RETURN_CANCELLED; Close(); }