public ChallengeForm Challenge(User target) { this._myChallenge = new ChallengeForm(target); this._myChallenge.OK_Button.Click += new EventHandler(this.ConfirmChallenge); this._myChallenge.FormClosing += new FormClosingEventHandler(this._myChallenge_FormClosing); if (this._battleSetting.SingleBan) { this._myChallenge.ModeCombo.SelectedIndex = 1; this._myChallenge.ModeCombo.Enabled = false; } if (this._battleSetting.DoubleBan) { this._myChallenge.ModeCombo.SelectedIndex = 0; this._myChallenge.ModeCombo.Enabled = false; } if (this._battleSetting.RandomOnly) { this._myChallenge.RandomCheck.Checked = true; this._myChallenge.RandomCheck.Enabled = false; } List <ChallengeForm> list = new List <ChallengeForm>(this._challenges.Values); foreach (ChallengeForm form in list) { form.Cancel_Button.PerformClick(); } return(this._myChallenge); }
private void CancelChallenge(object sender, EventArgs e) { ChallengeForm form = this._myChallenge; this._roomClient.CancelChallenge(this._myChallenge.TargetInfo.Identity); this._myChallenge = null; form.Close(); }
private void AcceptChallenge(object sender, EventArgs e) { ChallengeForm form = (sender as Button).FindForm() as ChallengeForm; int identity = form.TargetInfo.Identity; this._roomClient.AcceptChallenge(identity); this._challenges.Remove(identity); form.Close(); }
public void ChallengeCanceled(int identity) { if (this._challenges.ContainsKey(identity)) { ChallengeForm challenge = this._challenges[identity]; this._challenges.Remove(identity); MethodInvoker methodInvokerDelegate = delegate() { challenge.Close(); }; challenge.Invoke(methodInvokerDelegate); } }
public ChallengeForm ReceiveChallenge(User from, ChallengeInfo challenge) { ChallengeForm form = new ChallengeForm(from, challenge); form.OK_Button.Click += new EventHandler(this.AcceptChallenge); form.Cancel_Button.Click += new EventHandler(this.RefuseChallenge); form.FormClosing += new FormClosingEventHandler(this.challengeForm_FormClosing); this._challenges[from.Identity] = form; return(form); }
public void ChallengeAccepted() { this._roomClient.StartBattle(this._myChallenge.TargetInfo.Identity, this._myChallenge.ChallengeInfo); if (this._myChallenge != null) { ChallengeForm form = this._myChallenge; this._myChallenge = null; MethodInvoker methodInvokerDelegate = delegate() { form.Close(); }; form.Invoke(methodInvokerDelegate); } }
private void _client_OnReceiveChallenge(ChallengeForm challenge) { MethodInvoker methodInvokerDelegate = delegate() { challenge.Icon = this.Icon; challenge.MdiParent = this.MdiParent; challenge.Show(); challenge.Activate(); }; base.Invoke(methodInvokerDelegate); }
public void ChallengeRefused() { if (this._myChallenge != null) { ChallengeForm form = this._myChallenge; this._myChallenge = null; MethodInvoker methodInvokerDelegate = delegate() { form.Close(); MessageBox.Show("对方拒绝了你的挑战", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }; form.Invoke(methodInvokerDelegate); } }
private void ChallengeMenuItem_Click(object sender, EventArgs e) { if (this._roomSetting.SingleBan && this._roomSetting.DoubleBan) { this.AppendText("提示 : 当前房间禁止单打与双打"); } else { int selectedUserIdentity = this.SelectedUserIdentity; if ((selectedUserIdentity != -1) && (selectedUserIdentity != this._myInfo.Identity)) { ChallengeForm challengeForm = this._client.GetChallengeForm(selectedUserIdentity); if (challengeForm != null) { challengeForm.Icon = base.Icon; challengeForm.MdiParent = base.MdiParent; challengeForm.Show(); this.SetUserState(UserState.Challenging); } } } }