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(); }
private void CardDisplayer_Click(object sender, EventArgs e) { CardDisplayer displayer = (CardDisplayer)sender; int dispIndex = int.MinValue; for (int i = 0; i < usersCardsDisp.Length; ++i) { if (ReferenceEquals(displayer, usersCardsDisp[i])) { dispIndex = i; break; } } if (displayer.Selected) { state.LordAndSaviour.UnselectCard(dispIndex); } else { state.LordAndSaviour.SelectCard(dispIndex); } }
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); }