예제 #1
0
        public void InitializeComponents(Card displayedCard)
        {
            btnYes    = new MButton();
            btnNo     = new MButton();
            lblInfo   = new Label();
            firstCard = new CardDisplayer();

            SuspendLayout();

            Controls.Add(btnYes);
            Controls.Add(btnNo);
            Controls.Add(lblInfo);

            // firstCard

            firstCard.Size      = new Size((int)(0.6f * Width), (int)(0.54f * Height));
            firstCard.Location  = new Point((Width - firstCard.Size.Width) / 2, (int)(0.05f * Height));
            firstCard.Displayed = displayedCard;

            // lblInfo

            lblInfo.AutoSize  = true;
            lblInfo.BackColor = Color.FromArgb(0, Color.Black);
            lblInfo.Font      = SystemFonts.DefaultFont;
            lblInfo.Name      = "lblInfo";
            lblInfo.Text      = string.Format("Wyciągnąłeś kartę: {0} {1}\nCzy chcesz wrzucić tą kartę na stos?",
                                              displayedCard.RankString, displayedCard.SuitString);
            lblInfo.Location  = new Point((Width - lblInfo.Width) / 2, firstCard.Location.Y + firstCard.Size.Height + 10);
            lblInfo.TextAlign = ContentAlignment.TopCenter;

            // buttons
            const int buttonWidth = 50, buttonHeight = 25;
            const int buttonDist = 10;

            // btnYes

            btnYes.Name     = "btnYes";
            btnYes.Text     = "Tak";
            btnYes.Size     = new Size(buttonWidth, buttonHeight);
            btnYes.Location = new Point((Width - 2 * buttonWidth - buttonDist) / 2, lblInfo.Location.Y + lblInfo.Height + 5);
            btnYes.Click   += new EventHandler(Buttons_Click);

            // btnNo

            btnNo.Name     = "btnNo";
            btnNo.Text     = "Nie";
            btnNo.Size     = btnYes.Size;
            btnNo.Location = new Point(btnYes.Location.X + buttonWidth + buttonDist, btnYes.Location.Y);
            btnNo.Click   += new EventHandler(Buttons_Click);

            ResumeLayout();
        }
예제 #2
0
파일: StartingMenu.cs 프로젝트: LwPol/Makao
        public override void InitializeWindow()
        {
            mainWindow.BackColor = Color.FromArgb(0, 128, 0);
            mainWindow.Paint    += new PaintEventHandler(MainWnd_Paint);
            mainWindow.Resize   += new EventHandler(MainWnd_Resize);

            btnPlay        = new MButton();
            btnPlay.Name   = "btnPlay";
            btnPlay.Text   = "Graj";
            btnPlay.Click += new EventHandler(Play_Click);
            btnQuit        = new MButton();
            btnQuit.Name   = "btnQuit";
            btnQuit.Text   = "Wyjdź";
            btnQuit.Click += new EventHandler(Quit_Click);

            mainWindow.Controls.Add(btnPlay);
            mainWindow.Controls.Add(btnQuit);
            mainWindow.RaiseResizeEvent();
        }
예제 #3
0
파일: Game.cs 프로젝트: LwPol/Makao
        private void InitializeUIComponents()
        {
            drawableObjects  = new List <Drawable>();
            clickableObjects = new List <IClickable>();

            CardDisplayer.LoadCardsImages();

            topOfStack     = new CardDisplayer();
            usersCardsDisp = new CardDisplayer[5];
            for (int i = 0; i < usersCardsDisp.Length; ++i)
            {
                usersCardsDisp[i]        = new CardDisplayer();
                usersCardsDisp[i].Click += new EventHandler(CardDisplayer_Click);
            }

            arrows           = new Arrow[2];
            arrows[0]        = new Arrow(ArrowOrientation.Right);
            arrows[0].Click += new EventHandler(RightArrow_Click);
            arrows[1]        = new Arrow(ArrowOrientation.Left);
            arrows[1].Click += new EventHandler(LeftArrow_Click);

            namesTable.Location = new Point(0, 0);
            namesTable.Font     = AppFont;

            drawableObjects.Add(topOfStack);
            drawableObjects.AddRange(usersCardsDisp);
            drawableObjects.AddRange(arrows);
            drawableObjects.Add(namesTable);
            clickableObjects.AddRange(usersCardsDisp);
            clickableObjects.AddRange(arrows);


            btnPushCards         = new MButton();
            btnPushCards.Name    = "btnPushCards";
            btnPushCards.Text    = "Wyłóż karty";
            btnPushCards.Enabled = false;
            btnPushCards.Click  += new EventHandler(ButtonPush_Click);
            btnTakeCards         = new MButton();
            btnTakeCards.Name    = "btnTakeCards";
            btnTakeCards.Text    = "Pobierz karty";
            btnTakeCards.Enabled = false;
            btnTakeCards.Click  += new EventHandler(ButtonTake_Click);
            btnFourFold          = new MButton();
            btnFourFold.Name     = "btnFourFold";
            btnFourFold.Text     = "Odpuść";
            btnFourFold.Visible  = false;
            btnFourFold.Click   += new EventHandler(ButtonFourFold_Click);
            btnSkip         = new MButton();
            btnSkip.Name    = "btnSkip";
            btnSkip.Text    = "Przewiń grę";
            btnSkip.Visible = false;
            btnSkip.Click  += new EventHandler(ButtonSkip_Click);

            lbTemporaryMsg           = new Label();
            lbTemporaryMsg.Name      = "lbTemporaryMsg";
            lbTemporaryMsg.AutoSize  = true;
            lbTemporaryMsg.Visible   = false;
            lbTemporaryMsg.Font      = AppFont;
            lbTemporaryMsg.ForeColor = Color.FromArgb(230, 0, 0);

            lbGameStateMsg           = new Label();
            lbGameStateMsg.Name      = "lbGameStateMsg";
            lbGameStateMsg.AutoSize  = true;
            lbGameStateMsg.Visible   = false;
            lbGameStateMsg.Font      = AppFont;
            lbGameStateMsg.ForeColor = Color.FromArgb(230, 0, 0);

            Control[] ctrls = new Control[] {
                btnPushCards,
                btnTakeCards,
                btnFourFold,
                btnSkip,
                lbTemporaryMsg,
                lbGameStateMsg
            };
            mainWindow.Controls.AddRange(ctrls);
        }
예제 #4
0
        private void InitializeComponents()
        {
            lbPossibleValues = new ListBox();
            btnOk            = new MButton();
            lblInfo          = new Label();

            SuspendLayout();

            Controls.Add(lbPossibleValues);
            Controls.Add(btnOk);
            Controls.Add(lblInfo);

            // lbPossibleValues

            string[] values;
            if (type == DemandDialogType.JackDemand)
            {
                values = new string[] { "Piątka", "Szóstka", "Siódemka", "Ósemka", "Dziewiątka", "Dziesiątka", "Brak żadania" }
            }
            ;
            else
            {
                values = new string[] { "Pik", "Trefl", "Karo", "Kier", "Bez zmian" }
            };

            lbPossibleValues.Name = "lbPossibleValues";
            lbPossibleValues.Items.AddRange(values);
            const int listBoxWidth = 150;

            lbPossibleValues.Size     = new Size(listBoxWidth, (lbPossibleValues.Items.Count + 1) * lbPossibleValues.ItemHeight);
            lbPossibleValues.Location = new Point((Width - lbPossibleValues.Width) / 2, (Height - lbPossibleValues.Height) / 2);

            // btnOk

            btnOk.Name = "btnOk";
            btnOk.Text = "OK";
            const int buttonWidth = 100, buttonHeight = 27;
            int       xButton = (Width - buttonWidth) / 2;
            int       yButton = lbPossibleValues.Location.Y + lbPossibleValues.Height + 30;

            btnOk.Location = new Point(xButton, yButton);
            btnOk.Size     = new Size(buttonWidth, buttonHeight);
            btnOk.Enabled  = false;

            // lblInfo

            lblInfo.AutoSize  = true;
            lblInfo.Name      = "lblInfo";
            lblInfo.Font      = AppControl.AppFont;
            lblInfo.Text      = (type == DemandDialogType.JackDemand ? "Wybierz żądaną kartę:" : "Wybierz żądany kolor:");
            lblInfo.BackColor = Color.FromArgb(0, Color.Black);
            lblInfo.Size      = new Size(0, 0);

            const int yInfo = 65;
            int       xInfo = (Width - lblInfo.Width) / 2;

            lblInfo.Location = new Point(xInfo, yInfo);

            ResumeLayout();

            lbPossibleValues.SelectedIndexChanged += new EventHandler(PossibleValue_SelectedIndexChanged);
            btnOk.Click += new EventHandler(OKButton_Click);

            MouseEventHandler forLabelMouseDown = (sender, e) =>
            {
                OnMouseDown(new MouseEventArgs(e.Button,
                                               e.Clicks,
                                               lblInfo.Location.X + e.Location.X,
                                               lblInfo.Location.Y + e.Location.Y,
                                               e.Delta));
            };
            MouseEventHandler forLabelMouseMove = (sender, e) =>
            {
                OnMouseMove(new MouseEventArgs(e.Button,
                                               e.Clicks,
                                               lblInfo.Location.X + e.Location.X,
                                               lblInfo.Location.Y + e.Location.Y,
                                               e.Delta));
            };

            lblInfo.MouseDown += forLabelMouseDown;
            lblInfo.MouseMove += forLabelMouseMove;
        }
예제 #5
0
파일: PlayersMenu.cs 프로젝트: LwPol/Makao
        public override void InitializeWindow()
        {
            mainWindow.BackColor = Color.FromArgb(0, 128, 0);
            mainWindow.Paint    += new PaintEventHandler(MainWnd_Paint);
            mainWindow.Resize   += new EventHandler(MainWnd_Resize);

            cbNumOfPlayers               = new ComboBox();
            cbNumOfPlayers.Name          = "cbNumOfPlayers";
            cbNumOfPlayers.DropDownStyle = ComboBoxStyle.DropDownList;
            cbNumOfPlayers.Items.AddRange(new object[]
            {
                "2", "3", "4", "5", "6"
            });
            cbNumOfPlayers.Size = new Size(comboWidth, comboHeight);
            cbNumOfPlayers.SelectedIndexChanged += new EventHandler(NumOfPlayers_SelectedIndexChanged);

            lbComboLabel          = new Label();
            lbComboLabel.Name     = "lbComboLabel";
            lbComboLabel.Text     = "Określ liczbę graczy:";
            lbComboLabel.Font     = AppFont;
            lbComboLabel.AutoSize = true;

            btnStartGame        = new MButton();
            btnStartGame.Name   = "btnStartGame";
            btnStartGame.Text   = "Rozpocznij grę";
            btnStartGame.Size   = new Size(buttonsWidth, buttonsHeight);
            btnStartGame.Click += new EventHandler(StartGame_Click);
            btnReturn           = new MButton();
            btnReturn.Name      = "btnReturn";
            btnReturn.Text      = "Wróć";
            btnReturn.Size      = new Size(buttonsWidth, buttonsHeight);
            btnReturn.Click    += new EventHandler(Return_Click);

            tbPlayersName = new TextBox[6];
            for (int i = 0; i < tbPlayersName.Length; ++i)
            {
                tbPlayersName[i]           = new TextBox();
                tbPlayersName[i].Name      = string.Format("tbPlayersName[{0}]", i);
                tbPlayersName[i].Size      = new Size(textboxWidth, textboxHeight);
                tbPlayersName[i].Font      = AppFont;
                tbPlayersName[i].MaxLength = 30;
            }

            lbPlayersOrder = new Label[6];
            for (int i = 0; i < lbPlayersOrder.Length; ++i)
            {
                lbPlayersOrder[i]          = new Label();
                lbPlayersOrder[i].Name     = string.Format("lbPlayersOrder[{0}]", i);
                lbPlayersOrder[i].Text     = string.Format("{0}.", i + 1);
                lbPlayersOrder[i].AutoSize = true;
                lbPlayersOrder[i].Font     = AppFont;
            }
            lbCpuMarks = new Label[5];
            for (int i = 0; i < lbCpuMarks.Length; ++i)
            {
                lbCpuMarks[i]          = new Label();
                lbCpuMarks[i].Name     = string.Format("lbCpuMarks[{0}]", i);
                lbCpuMarks[i].Text     = "CPU";
                lbCpuMarks[i].AutoSize = true;
                lbCpuMarks[i].Font     = AppFont;
            }

            lbMissingNames           = new Label();
            lbMissingNames.Name      = "lbMissingNames";
            lbMissingNames.Text      = "Nie wpisano imion wszystkich graczy";
            lbMissingNames.ForeColor = Color.Red;
            lbMissingNames.AutoSize  = true;
            lbMissingNames.Font      = AppFont;
            lbMissingNames.Visible   = false;

            Control[] ctrls = new Control[22];
            ctrls[0] = cbNumOfPlayers;
            ctrls[1] = btnStartGame;
            ctrls[2] = btnReturn;
            tbPlayersName.CopyTo(ctrls, 3);
            ctrls[9] = lbComboLabel;
            lbPlayersOrder.CopyTo(ctrls, 10);
            lbCpuMarks.CopyTo(ctrls, 16);
            ctrls[21] = lbMissingNames;
            foreach (Control c in ctrls)
            {
                c.TabStop = false;
            }
            mainWindow.Controls.AddRange(ctrls);

            Configure();

            mainWindow.RaiseResizeEvent();

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