Пример #1
0
        public override void InitializeWindow()
        {
            mainWindow.BackColor = Color.FromArgb(0, 128, 0);
            mainWindow.Paint    += new PaintEventHandler(MainWnd_Paint);
            mainWindow.MouseUp  += new MouseEventHandler(MainWnd_MouseUp);
            mainWindow.Resize   += new EventHandler(MainWnd_Resize);

            state.MakaoStack.Shuffled += new EventHandler(MakaoStack_Shuffled);

            state.LordAndSaviour.CardsPushed             += new CardsPushedEventHandler(User_CardsPushed);
            state.LordAndSaviour.CardsPushed             += new CardsPushedEventHandler(Players_CardsPushed);
            state.LordAndSaviour.CardsTaken              += new CardsTakenEventHandler(User_CardsTaken);
            state.LordAndSaviour.CardsTaken              += new CardsTakenEventHandler(Players_CardsTaken);
            state.LordAndSaviour.SelectionChanged        += new UserSelectionChangeEventHandler(User_SelectionChange);
            state.LordAndSaviour.VisibleCardIndexChanged += new EventHandler(User_VisibleCardIndexChanged);
            state.LordAndSaviour.UsersTurn          += new EventHandler(User_UsersTurn);
            state.LordAndSaviour.UsersMoveMade      += new EventHandler(User_UsersMoveMade);
            state.LordAndSaviour.Makao              += new MakaoEventHandler(User_Makao);
            state.LordAndSaviour.TurnsToWaitChanged += new EventHandler(Players_TurnsToWaitChanged);

            state.LordAndSaviour.RankDemand     = new RankDemandDelegate(User_JackDemandChoice);
            state.LordAndSaviour.SuitDemand     = new SuitDemandDelegate(User_AceDemandChoice);
            state.LordAndSaviour.FirstCardMatch = new FirstCardMatchDelegate(User_IfPushFirstMatch);

            foreach (var player in state.CpuPlayers)
            {
                player.CardsPushed        += new CardsPushedEventHandler(Players_CardsPushed);
                player.CardsTaken         += new CardsTakenEventHandler(Players_CardsTaken);
                player.TurnsToWaitChanged += new EventHandler(Players_TurnsToWaitChanged);
            }

            try
            {
                InitializeUIComponents();
            }
            catch (FileNotFoundException ex)
            {
                string msg = string.Format("{0}: {1}", ex.Message, ex.FileName);
                MessageBox.Show(mainWindow, msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                CtrlInstance = new PlayersMenu();
                return;
            }

            mainWindow.RaiseResizeEvent();

            keepMeAlive  = new HookProc(KeyboardHook);
            keyboardHook = SetWindowsHookEx(2, keepMeAlive, IntPtr.Zero, GetCurrentThreadId()); // 2 == WH_KEYBOARD

            mainLoop.BeginGame();
        }
Пример #2
0
 private void Play_Click(object sender, EventArgs e)
 {
     CtrlInstance = new PlayersMenu();
 }