遊戲「你是XX麼」的VB.NET實現

〇、下載地址ide

本程序能夠在 這裏 下載到。測試

1、關於本遊戲的玩法spa

1)剛進程序,會有一個提示性的窗體,單擊「開始測試」按鈕正式進入遊戲命令行

2)正式進入遊戲窗體後,當鼠標挪向按鈕「不是」後,按鈕「不是」上的字樣會變成「是」,而原來的按鈕「是」上面會顯示「不是」。點擊兩個按鈕的任意一個後,都會被程序「羞辱」,而後程序會自動退出。code

3)不要試圖經過打開右上角的X或是用任務管理器(taskmgr)關閉這個窗口,若是你真的想關閉這個程序還不想認可本身是XX,請使用命令行。orm

4)你能夠用這個程序去搞一些惡做劇,仍是那句話:Just For Fun :-P遊戲

2、程序控件與代碼進程

1)窗體FormMain事件

窗體屬性:ip

StartPosition(初始位置) CenterScreen
MaximizeBox(最大化按鈕) False
MinimizeBox(最小化按鈕) False
FormBorderStyle(窗體風格) FixedSingle

窗體代碼

Public Class FormMain

    Private Sub btnTest_Click(sender As Object, e As EventArgs) _
        Handles btnTest.Click

        Me.Hide()
        FormTest.ShowDialog()

    End Sub

End Class

2)窗體FormTest

窗體屬性:

StartPosition(初始位置) CenterScreen
MaximizeBox(最大化按鈕) False
MinimizeBox(最小化按鈕) False
FormBorderStyle(窗體風格) Fixed3D
ShowIcon(顯示圖標) False
ShowInTaskbar(在任務欄出現) False

窗體代碼:

Public Class FormTest

    '選擇「是」或「不是」後該布爾值會變成True,此時窗口可關閉
    Dim isChoosen As Boolean = False

    '上方的Panel採用漸近色處理
    Private Sub pnlTop_Paint(sender As Object, e As PaintEventArgs) _
        Handles pnlTop.Paint

        Using LG As Drawing2D.LinearGradientBrush =
           New Drawing2D.LinearGradientBrush(
               New Point(0, 0),
               New Point(0, Me.Height),
               Color.FromArgb(192, 192, 255),
               Color.White)
            e.Graphics.FillRectangle(LG, New Rectangle(0, 0, Me.Width, Me.Height))
        End Using

    End Sub

    Private Sub FormTest_Load(sender As Object, e As EventArgs) _
        Handles MyBase.Load

        '鼠標移到右側按鈕,則按鈕上文字變化
        AddHandler btnRight.MouseEnter,
            Sub(obj As System.Object, arg As System.EventArgs)
                btnRight.Text = "是"
                btnLeft.Text = "不是"
            End Sub

        '鼠標移出右側按鈕,則按鈕上文字變回原樣
        AddHandler btnRight.MouseLeave,
            Sub(obj As System.Object, arg As System.EventArgs)
                btnRight.Text = "不是"
                btnLeft.Text = "是"
            End Sub

        '鼠標按下按鈕,若是按鈕上文字爲「是」則彈出MessageBox
        AddHandler btnLeft.MouseClick,
            Sub(obj As System.Object, arg As System.EventArgs)
                Dim btnTemp As Button = DirectCast(obj, Button)
                If btnTemp.Text = "是" Then
                    MessageBox.Show("我就知道你會選是的")
                    isChoosen = True
                    Application.Exit()
                End If
            End Sub

        '鼠標按下按鈕,若是按鈕上文字爲「是」則彈出MessageBox
        AddHandler btnRight.MouseClick,
            Sub(obj As System.Object, arg As System.EventArgs)
                Dim btnTemp As Button = DirectCast(obj, Button)
                If btnTemp.Text = "是" Then
                    MessageBox.Show("我就知道你會選是的")
                    isChoosen = True
                    Application.Exit()
                End If
            End Sub

        '計時器:禁止打開任務管理器
        Dim tmr As New Timer
        AddHandler tmr.Tick,
            Sub(obj As System.Object, arg As System.EventArgs)
                Dim pArray As Process() = Process.GetProcesses
                For Each p As Process In pArray
                    Try
                        If p.ProcessName.ToLower.Trim = "taskmgr" Then
                            p.Kill()
                            MessageBox.Show("小夥你不以爲你很逗麼?")
                            '將本窗口放到最前
                            Me.TopMost = True
                            Me.TopMost = False
                            Return
                        End If
                    Catch ex As Exception
                        Return
                    End Try
                Next
            End Sub
        tmr.Interval = 200
        tmr.Enabled = True
        tmr.Start()

    End Sub

    '關閉窗口事件
    Private Sub FormTest_FormClosing(sender As Object, e As FormClosingEventArgs) _
        Handles MyBase.FormClosing

        '若是沒有選擇禁止關閉窗口
        If isChoosen = False Then
            MessageBox.Show("關了我也改變不了事實,你仍是選一個吧")
            e.Cancel = True
            Return
        End If

        Me.Hide()
        Threading.Thread.Sleep(3000)
        MessageBox.Show(
            "This game is just for fun! Thx 4 playing." & vbCrLf & _
            "           -Tsybius 2014年8月1日 13:37:35")

    End Sub

End Class

END

相關文章
相關標籤/搜索