private void _bcController_OnCounterChanged() { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { if (this._bcController.Counter >= 10) { this.SendButton.Enabled = false; this.BcCounterLabel.Text = "100%"; } else { this.SendButton.Enabled = true; this.BcCounterLabel.Text = ((this._bcController.Counter * 10)).ToString() + "%"; } } else { if (method == null) { method = delegate { this._bcController_OnCounterChanged(); }; } base.Invoke(method); } }
private void AppendText(string text) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { if (this.DisplayText.TextLength > 0) { this.DisplayText.Text = this.DisplayText.Text + "\r\n"; } this.DisplayText.Text = this.DisplayText.Text + string.Format("{0}", text); this.DisplayText.SelectionStart = this.DisplayText.Text.Length - 1; this.DisplayText.ScrollToCaret(); } else { if (method == null) { method = delegate { this.AppendText(text); }; } base.Invoke(method); } }
private void _chatManager_OnAddChat(int identity) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { User user = this._client.GetUser(identity); if (user != null) { ToolStripMenuItem item = new ToolStripMenuItem(user.Name); item.Name = identity.ToString(); item.Tag = identity; item.Click += new EventHandler(this.chatMenu_Click); this.ChatsMenuItem.DropDownItems.Add(item); if (!this.ChatsMenuItem.Enabled) { this.ChatsMenuItem.Enabled = true; } } } else { if (method == null) { method = delegate { this._chatManager_OnAddChat(identity); }; } base.Invoke(method); } }
private void BuildBattleServerForm(BattleMode battleMode, BattleRuleSequence rules) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { Form form = this.HandleBuildBattleServerFormEvent(this._myInfo.Name, battleMode, rules.Elements); if (form != null) { this.SetUserState(UserState.Battling); form.FormClosed += new FormClosedEventHandler(this.BattleFormClosed); form.Show(); } else { MessageBox.Show("please build battle server form"); this.SetUserState(UserState.Free); } } else { if (method == null) { method = delegate { this.BuildBattleServerForm(battleMode, rules); }; } base.Invoke(method); } }
private void BuildBattleClientForm(string serverAddress, BattleMode battleMode) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { Form form = this.HandleBuildBattleClientFormEvent(serverAddress, 2, this._myInfo.Name, battleMode); if (form != null) { this.SetUserState(UserState.Battling); form.FormClosed += new FormClosedEventHandler(this.BattleFormClosed); form.Show(); } else { MessageBox.Show("please build battle client form"); this.SetUserState(UserState.Free); } } else { if (method == null) { method = delegate { this.BuildBattleClientForm(serverAddress, battleMode); }; } base.Invoke(method); } }
private void UpdateUserList(List <User> users) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { this.UserList.BeginUpdate(); this.UserList.Items.Clear(); foreach (User user in users) { this.AddUserInfo(user); } this.UserList.EndUpdate(); } else { if (method == null) { method = delegate { this.UpdateUserList(users); }; } base.Invoke(method); } }
private void _client_OnLogoned(User info) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { this._myInfo.Identity = info.Identity; this._myInfo.Address = info.Address; this.SendButton.Enabled = true; this.RoomMenuItem.Enabled = true; this.CreateButton.Enabled = true; this._chatManager = new ChatManager(); this._chatManager.OnAddChat += new ChatDelegate(this._chatManager_OnAddChat); this._chatManager.OnRemoveChat += new ChatDelegate(this._chatManager_OnRemoveChat); this._bcController = new BroadcastController(); this._bcController.OnCounterChanged += new VoidFunctionDelegate(this._bcController_OnCounterChanged); } else { if (method == null) { method = delegate { this._client_OnLogoned(info); }; } base.Invoke(method); } }
private void UpdateUserInfo(User userInfo) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { ListViewItem[] itemArray = this.UserList.Items.Find(userInfo.Identity.ToString(), false); if (itemArray.Length > 0) { itemArray[0].SubItems[0].Text = userInfo.Name; itemArray[0].SubItems[1].Text = this.GetStateString(userInfo.State); itemArray[0].ImageIndex = userInfo.ImageKey; } if (userInfo.Identity == this._myInfo.Identity) { this.UpdateUserState(); } } else { if (method == null) { method = delegate { this.UpdateUserInfo(userInfo); }; } base.Invoke(method); } }
public void Start() { if (this.SupportHighFreqTimer()) { QueryPerformanceFrequency(ref this._frequency); this._reset = new VoidFunctionDelegate(this.ResetHighFreqTimer); this._timing = new DoubleFunctionDelegate(this.TimingHighFreqTimer); } else { this._reset = new VoidFunctionDelegate(this.ResetLowFreqTimer); this._timing = new DoubleFunctionDelegate(this.TimingLowFreqTimer); } this._reset(); }
private void _client_OnSetting(RoomBattleSetting setting) { VoidFunctionDelegate method = null; this._roomSetting = setting; if (!string.IsNullOrEmpty(setting.Version) && (this._version != setting.Version)) { if (method == null) { method = delegate { MessageBox.Show(string.Format("当前房间限制用户版本为{0}", setting.Version), "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); }; } base.Invoke(method); } }
private void _client_OnLogonFailed(string message) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { MessageBox.Show(string.Format("无法登录房间服务器 : {0}.", message), "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); base.Close(); } else { if (method == null) { method = delegate { this._client_OnLogonFailed(message); }; } base.Invoke(method); } }
private void _client_OnKicked() { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { MessageBox.Show("你被请出了房间.", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); base.Close(); } else { if (method == null) { method = delegate { this._client_OnKicked(); }; } base.Invoke(method); } }
public void updateMap(VoidFunctionDelegate callback = null) { if (!mainMesh) { mainMesh = gameObject.GetComponent <MeshFilter>().mesh; } createMesh(mainMesh); if (isCircle) { turnIntoCircle(mainMesh, mainMesh.vertices[0], Radius); } makeCollision(mainMesh.vertices); mainMesh.RecalculateBounds(); if (callback != null) { callback(); } }
private void BuildBattleObserverForm(int identity, string serverAddress, byte position) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { Form form = this.HandleBuildBattleObserverFormEvent(identity, serverAddress, position); if (form != null) { form.Show(); } } else { if (method == null) { method = delegate { this.BuildBattleObserverForm(identity, serverAddress, position); }; } base.Invoke(method); } }
private void _chatManager_OnRemoveChat(int identity) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { this.ChatsMenuItem.DropDownItems.RemoveByKey(identity.ToString()); if (this.ChatsMenuItem.DropDownItems.Count == 0) { this.ChatsMenuItem.Enabled = false; } } else { if (method == null) { method = delegate { this._chatManager_OnRemoveChat(identity); }; } base.Invoke(method); } }
private void OnUpdate4PRoom(int identity, byte count) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { ListViewItem[] itemArray = this.FourPlayerList.Items.Find(identity.ToString(), false); if (itemArray.Length > 0) { itemArray[0].SubItems[1].Text = count.ToString(); } } else { if (method == null) { method = delegate { this.OnUpdate4PRoom(identity, count); }; } base.Invoke(method); } }
private void BuildBattleAgentForm(int identity, byte myPosition, BattleMode battleMode) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { AgentBattleInfo battleInfo = new AgentBattleInfo(); battleInfo.AgentID = identity; battleInfo.BattleMode = battleMode; battleInfo.Position = myPosition; battleInfo.ServerAddress = this._serverIP; battleInfo.UserName = this._myInfo.Name; battleInfo.MoveInterval = this._roomSetting.MoveInterval; Form form = this.HandleBuildBattleAgentFormEvent(battleInfo); if (form != null) { this.SetUserState(UserState.Battling); form.FormClosed += new FormClosedEventHandler(this.BattleFormClosed); form.Show(); } else { MessageBox.Show("please build battle agent form"); this.SetUserState(UserState.Free); } } else { if (method == null) { method = delegate { this.BuildBattleAgentForm(identity, myPosition, battleMode); }; } base.Invoke(method); } }
private void OnStart4PHost(int identity) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { Form form = this.HandleBuildFourPlayerFormEvent(identity, this._serverIP, this._myInfo.Name, true, new FourPlayerFormCallback(this.Build4PBattleForm)); if (form != null) { form.Show(); form.FormClosed += new FormClosedEventHandler(this.FourPlayerForm_FormClosed); } } else { if (method == null) { method = delegate { this.OnStart4PHost(identity); }; } base.Invoke(method); } }
public void RunThread(int updateInterval, VoidFunctionDelegate logicUpdate) { this._updateInterval = updateInterval; this.OnLogicUpdate = (VoidFunctionDelegate)Delegate.Combine(this.OnLogicUpdate, logicUpdate); this.RunThread(); }