コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: Snoopy1866/Mine
        //右键点击方块
        private void MineBlock_i_j_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (hasClickedPauseButton)
            {
                return;
            }
            MineBlock  mineBlock  = (MineBlock)sender;
            Status     status     = mineBlock.Status;
            StackPanel stackPanel = new StackPanel();

            if (!(status == Status.Excluded || status == Status.Hint))
            {
                if (status == Status.UnDetected)
                {
                    mineBlock.Status    = Status.SignedHasMine;
                    mineBlock.Content   = SetContentOfMineBlock(stackPanel, Properties.Resources.flag);
                    numOfRemainingMine -= 1;
                    if (numOfRemainingMine < 0)
                    {
                        lblRemainingMine.Foreground = Brushes.Red;
                    }
                    lblRemainingMine.Content = numOfRemainingMine;
                    if (mineBlock.HasMine)
                    {
                        numOfRealRemainingMine--;
                        if (numOfRealRemainingMine == 0)
                        {
                            dpcElapsedTime.Stop();
                            stopwatch.Stop();
                            btnPause.Visibility = Visibility.Collapsed;
                            ShowMine();
                            //if (level != null)
                            //{
                            //    new WinSuccess().ShowDialog();
                            //}
                            MessageBox.Show("恭喜通关!");
                        }
                    }
                    else
                    {
                        misjudgedBlockList.Add(mineBlock);
                    }
                }
                else if (status == Status.SignedHasMine)
                {
                    mineBlock.Status    = Status.SignedNotSure;
                    mineBlock.Content   = SetContentOfMineBlock(stackPanel, Properties.Resources.question);
                    numOfRemainingMine += 1;
                    if (numOfRemainingMine > 0)
                    {
                        lblRemainingMine.Foreground = Brushes.Black;
                    }
                    lblRemainingMine.Content = numOfRemainingMine;
                    if (mineBlock.HasMine)
                    {
                        numOfRealRemainingMine++;
                    }
                    else
                    {
                        misjudgedBlockList.Remove(mineBlock);
                    }
                }
                else if (status == Status.SignedNotSure)
                {
                    mineBlock.Status     = Status.UnDetected;
                    mineBlock.Content    = "";
                    mineBlock.Background = new SolidColorBrush(Color.FromRgb(127, 171, 237));
                }
            }
        }