private void MainForm_MouseClick(object sender, MouseEventArgs e) { //this.Text = "X=" + e.X + ",Y=" + e.Y + ";" + e.Clicks; //左键 //只有发牌时和该我出牌时才能相应鼠标事件 if (((currentState.CurrentCardCommands == CardCommands.WaitingForMySending) || (currentState.CurrentCardCommands == CardCommands.WaitingForSending8Cards)) && (whoseOrder == 1)) { if (e.Button == MouseButtons.Left) { if ((e.X >= (int)myCardsLocation[0] && e.X <= ((int)myCardsLocation[myCardsLocation.Count - 1] + 71)) && (e.Y >= 355 && e.Y < 472)) { if (calculateRegionHelper.CalculateClickedRegion(e, 1)) { drawingFormHelper.DrawMyPlayingCards(currentPokers[0]); Refresh(); } } } else if (e.Button == MouseButtons.Right) //右键 { int i = calculateRegionHelper.CalculateRightClickedRegion(e); if (i > -1 && i < myCardIsReady.Count) { bool b = (bool)myCardIsReady[i]; int x = (int)myCardsLocation[i]; for (int j = 1; j <= i; j++) { if ((int)myCardsLocation[i - j] == (x - 13)) { myCardIsReady[i - j] = b; x = x - 13; } else { break; } } drawingFormHelper.DrawMyPlayingCards(currentPokers[0]); Refresh(); } } //判断是否点击了小猪*********和以上的点击不同 Rectangle pigRect = new Rectangle(296, 300, 53, 46); Region region = new Region(pigRect); if (region.IsVisible(e.X, e.Y)) { //判断是否处在扣牌阶段 if ((currentState.CurrentCardCommands == CardCommands.WaitingForSending8Cards)) //如果等我扣牌 { //扣牌,所以擦去小猪 Graphics g = Graphics.FromImage(bmp); g.DrawImage(image, pigRect, pigRect, GraphicsUnit.Pixel); g.Dispose(); ArrayList readyCards = new ArrayList(); for (int i = 0; i < myCardIsReady.Count; i++) { if ((bool)myCardIsReady[i]) { readyCards.Add((int)myCardsNumber[i]); } } if (readyCards.Count == 8) { send8Cards = new ArrayList(); for (int i = 0; i < 8; i++) { CommonMethods.SendCards(send8Cards, currentPokers[0], pokerList[0], (int)readyCards[i]); } initSendedCards(); currentState.CurrentCardCommands = CardCommands.DrawMySortedCards; } } else if (currentState.CurrentCardCommands == CardCommands.WaitingForMySending) //如果等我发牌 { //如果我准备出的牌合法 if (TractorRules.IsInvalid(this, currentSendCards, 1)) { //出牌,所以擦去小猪 Graphics g = Graphics.FromImage(bmp); g.DrawImage(image, pigRect, pigRect, GraphicsUnit.Pixel); g.Dispose(); //在这里检查甩牌的检查 if (firstSend == 1) { whoIsBigger = 1; ArrayList minCards = new ArrayList(); if (TractorRules.CheckSendCards(this, minCards, 0)) { currentSendCards[0] = new ArrayList(); for (int i = 0; i < myCardIsReady.Count; i++) { if ((bool)myCardIsReady[i]) { CommonMethods.SendCards(currentSendCards[0], currentPokers[0], pokerList[0], (int)myCardsNumber[i]); } } } else { for (int i = 0; i < minCards.Count; i++) { CommonMethods.SendCards(currentSendCards[0], currentPokers[0], pokerList[0], (int)minCards[i]); } } } else { currentSendCards[0] = new ArrayList(); for (int i = 0; i < myCardIsReady.Count; i++) { if ((bool)myCardIsReady[i]) { CommonMethods.SendCards(currentSendCards[0], currentPokers[0], pokerList[0], (int)myCardsNumber[i]); } } } drawingFormHelper.DrawMyFinishSendedCards(); } } } } else if (currentState.CurrentCardCommands == CardCommands.ReadyCards) { drawingFormHelper.IsClickedRanked(e); } }