public virtual void DeckViewer_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetData(typeof(CardBox)) != null) { System.Console.WriteLine("DragDrop"); //int cardHashCode = Convert.ToInt32(e.Data.GetData(DataFormats.Text).ToString()); //Card draggedCard = new Card(cardHashCode); CardBox draggedCard = (CardBox)e.Data.GetData(typeof(CardBox)); if (draggedCard != null && draggedCard.Parent.GetType() == typeof(DeckPileViewer)) { DeckViewer fromPanel = draggedCard.Parent as DeckPileViewer; DeckViewer toPanel = sender as DeckViewer; if (toPanel != null && fromPanel != null) { if (toPanel != fromPanel) { fromPanel.RemoveCard(draggedCard.Card); toPanel.AddCard(draggedCard.Card); } } } } }
/// <summary> /// Method which determines whether the card was 'dropped' /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void DeckViewer_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetData(typeof(CardBox)) != null && this.isFull() == false) { CardBox draggedCard = (CardBox)e.Data.GetData(typeof(CardBox)); // A logic structure which determines which panels to move the card to if (draggedCard != null && draggedCard.Parent.GetType() == typeof(DeckViewer)) { DeckViewer fromPanel = draggedCard.Parent as DeckViewer; BoutViewer toPanel = sender as BoutViewer; if (toPanel != null && fromPanel != null) { if (toPanel != fromPanel) { if(toPanel.canPlaceCard(draggedCard.Card)) { fromPanel.RemoveCard(draggedCard.Card); toPanel.AddCard(draggedCard.Card, true); } } } } } }
/// <summary> /// Durak form /// </summary> private void Initialize() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DurakPage)); this.lbMyPlayerName = new Label(); this.lbEnemyPlayerName = new Label(); this.lbEnemyPlayerHandCount = new Label(); this.lbMyPlayerHandCount = new Label(); this.pbMenuOptions = new PictureBox(); this.lblCurrentTurn = new Label(); this.panel1 = new System.Windows.Forms.Panel(); this.pbSkipButton = new System.Windows.Forms.PictureBox(); this.pbMyPlayerImage = new System.Windows.Forms.PictureBox(); this.panel9 = new System.Windows.Forms.Panel(); this.pbEnemyPlayerImage = new System.Windows.Forms.PictureBox(); this.boutDeckViewer = new BoutViewer(); this.pnlGameMenu = new Panel(); this.btnCancel = new Button(); this.btnReturnMainMenu = new Button(); //this.drawDeckViewer = new DeckPileViewer(); this.playerDeckViewer = new DeckViewer(); this.enemyDeckViewer = new DeckViewer(true); this.enemyDeckViewer.Tag = "enemyDeck"; this.enemyDeckViewer.AllowDrop = false; this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbMenuOptions)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbSkipButton)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbMyPlayerImage)).BeginInit(); this.panel9.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbEnemyPlayerImage)).BeginInit(); this.SuspendLayout(); // // MenuOptonPictureBox // this.pbMenuOptions.BackColor = System.Drawing.Color.Transparent; this.pbMenuOptions.Image = Properties.Resources.menu_lime_t; this.pbMenuOptions.Location = new System.Drawing.Point(11, 28); this.pbMenuOptions.Name = "pbMenuOptions"; this.pbMenuOptions.Size = new System.Drawing.Size(88, 83); this.pbMenuOptions.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pbMenuOptions.TabIndex = 4; this.pbMenuOptions.TabStop = false; // // deckViewer1 // this.playerDeckViewer.BackColor = System.Drawing.Color.Lime; this.playerDeckViewer.Location = new System.Drawing.Point(11, 502); this.playerDeckViewer.Margin = new System.Windows.Forms.Padding(2); this.playerDeckViewer.Name = "deckViewer1"; this.playerDeckViewer.Size = new System.Drawing.Size(1171, 167); this.playerDeckViewer.TabIndex = 11; this.playerDeckViewer.ControlAdded += UpdatePlayersHandCount; this.playerDeckViewer.ControlRemoved += UpdatePlayersHandCount; // // panel1 // this.panel1.Controls.Add(this.pbSkipButton); this.panel1.Controls.Add(this.pbMyPlayerImage); this.panel1.Location = new System.Drawing.Point(this.playerDeckViewer.Location.X, 667); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(this.playerDeckViewer.Size.Width, 120); this.panel1.TabIndex = 5; // // pictureBox4 // this.pbSkipButton.Location = new System.Drawing.Point(820, 32); this.pbSkipButton.Name = "pictureBox4"; this.pbSkipButton.Size = new System.Drawing.Size(61, 50); this.pbSkipButton.TabIndex = 11; this.pbSkipButton.TabStop = false; this.pbSkipButton.Image = Properties.Resources.skip; this.pbSkipButton.SizeMode = PictureBoxSizeMode.StretchImage; this.pbSkipButton.Click += pbSkipButton_Click; // // pictureBox3 // this.pbMyPlayerImage.Location = new System.Drawing.Point(564, 7); this.pbMyPlayerImage.Name = "pictureBox3"; this.pbMyPlayerImage.Size = new System.Drawing.Size(100, 85); this.pbMyPlayerImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pbMyPlayerImage.TabIndex = 10; this.pbMyPlayerImage.TabStop = false; this.pbMyPlayerImage.BackColor = System.Drawing.Color.AliceBlue; // // panel9 // this.panel9.Controls.Add(this.enemyDeckViewer); this.panel9.Controls.Add(this.pbEnemyPlayerImage); this.panel9.Location = new System.Drawing.Point(467, 28); this.panel9.Name = "panel9"; this.panel9.Size = new System.Drawing.Size(292, 160); this.panel9.TabIndex = 7; // // pnlGameMenu // this.pnlGameMenu.BackgroundImage = Properties.Resources.menu_shade; this.pnlGameMenu.Controls.Add(this.btnCancel); this.pnlGameMenu.Controls.Add(this.btnReturnMainMenu); this.pnlGameMenu.Location = new System.Drawing.Point(-3, -1); this.pnlGameMenu.Name = "pnlGameMenu"; this.pnlGameMenu.Size = new System.Drawing.Size(1187, 760); this.pnlGameMenu.TabIndex = 14; this.pnlGameMenu.Visible = false; // // btnCancel // this.btnCancel.BackColor = System.Drawing.Color.Lime; this.btnCancel.Font = new System.Drawing.Font("Gill Sans Ultra Bold Condensed", 30F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnCancel.Location = new System.Drawing.Point(385, 369); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(438, 87); this.btnCancel.TabIndex = 1; this.btnCancel.Text = "Cancel"; this.btnCancel.UseVisualStyleBackColor = false; this.btnCancel.Click += BtnCancel_Click; // // btnReturnMainMenu // this.btnReturnMainMenu.BackColor = System.Drawing.Color.Lime; this.btnReturnMainMenu.Font = new System.Drawing.Font("Gill Sans Ultra Bold Condensed", 30F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnReturnMainMenu.Location = new System.Drawing.Point(385, 250); this.btnReturnMainMenu.Name = "btnReturnMainMenu"; this.btnReturnMainMenu.Size = new System.Drawing.Size(438, 87); this.btnReturnMainMenu.TabIndex = 0; this.btnReturnMainMenu.Text = "Return to Main Menu"; this.btnReturnMainMenu.UseVisualStyleBackColor = false; this.btnReturnMainMenu.Click += BtnReturnMainMenu_Click; // // lblCurrentTurn // this.lblCurrentTurn.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.lblCurrentTurn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblCurrentTurn.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); this.lblCurrentTurn.Location = new System.Drawing.Point(762, 676); this.lblCurrentTurn.Name = "lblCurrentTurn"; this.lblCurrentTurn.Size = new System.Drawing.Size(100, 23); this.lblCurrentTurn.TabIndex = 13; this.lblCurrentTurn.Text = "Attacker"; this.lblCurrentTurn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // pbEnemyPlyerImage // this.pbEnemyPlayerImage.Location = new System.Drawing.Point(97, 3); this.pbEnemyPlayerImage.Name = "pictureBox2"; this.pbEnemyPlayerImage.Size = new System.Drawing.Size(100, 85); this.pbEnemyPlayerImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pbEnemyPlayerImage.TabIndex = 9; this.pbEnemyPlayerImage.TabStop = false; // // lbMyPlayerName // this.lbMyPlayerName.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.lbMyPlayerName.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbMyPlayerName.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); this.lbMyPlayerName.Location = new System.Drawing.Point(458, 676); this.lbMyPlayerName.Name = "lbMyPlayerName"; this.lbMyPlayerName.Size = new System.Drawing.Size(100, 23); this.lbMyPlayerName.TabIndex = 13; this.lbMyPlayerName.Text = " "; this.lbMyPlayerName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // lbMyPlayerHandCount // this.lbMyPlayerHandCount.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.lbMyPlayerHandCount.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbMyPlayerHandCount.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); this.lbMyPlayerHandCount.Location = new System.Drawing.Point(672, 676); this.lbMyPlayerHandCount.Name = "lbMyPlayerHandCount"; this.lbMyPlayerHandCount.Size = new System.Drawing.Size(100, 23); this.lbMyPlayerHandCount.TabIndex = 13; this.lbMyPlayerHandCount.Text = playerDeckViewer.Controls.Count.ToString(); this.lbMyPlayerHandCount.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // lbEnemyPlayerName // this.lbEnemyPlayerName.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.lbEnemyPlayerName.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbEnemyPlayerName.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); this.lbEnemyPlayerName.Location = new System.Drawing.Point(465, 30); this.lbEnemyPlayerName.Name = "lbEnemyPlayerName"; this.lbEnemyPlayerName.Size = new System.Drawing.Size(88, 23); this.lbEnemyPlayerName.TabIndex = 14; this.lbEnemyPlayerName.Text = "Computer"; this.lbEnemyPlayerName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // // lbEnemyPlayerHandCount // this.lbEnemyPlayerHandCount.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.lbEnemyPlayerHandCount.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbEnemyPlayerHandCount.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); this.lbEnemyPlayerHandCount.Location = new System.Drawing.Point(670, 30); this.lbEnemyPlayerHandCount.Name = "lbEnemyPlayerHandCount"; this.lbEnemyPlayerHandCount.Size = new System.Drawing.Size(88, 23); this.lbEnemyPlayerHandCount.TabIndex = 14; this.lbEnemyPlayerHandCount.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // boutDeckViewer // this.boutDeckViewer.BackColor = System.Drawing.Color.Lime; this.boutDeckViewer.Location = new System.Drawing.Point(215, 211); this.boutDeckViewer.Margin = new System.Windows.Forms.Padding(2); this.boutDeckViewer.Name = "deckViewer3"; this.boutDeckViewer.Size = new System.Drawing.Size(967, 287); this.boutDeckViewer.TabIndex = 9; this.boutDeckViewer.CardAdded += OnNextTurn; // // deckViewer4 // this.enemyDeckViewer.BackColor = System.Drawing.Color.Lime; this.enemyDeckViewer.Location = new System.Drawing.Point(0, 92); this.enemyDeckViewer.Margin = new System.Windows.Forms.Padding(2); this.enemyDeckViewer.Name = "deckViewer4"; this.enemyDeckViewer.Size = new System.Drawing.Size(292, 66); this.enemyDeckViewer.TabIndex = 10; this.enemyDeckViewer.ControlAdded += UpdatePlayersHandCount; this.enemyDeckViewer.ControlRemoved += UpdatePlayersHandCount; // // DurakDeck // this.BackgroundImage = Properties.Resources.mainMenuBackgroundCenter; this.Dock = DockStyle.Fill; this.ClientSize = new System.Drawing.Size(1184, 761); this.Controls.Add(this.lbEnemyPlayerName); this.Controls.Add(this.lbMyPlayerName); this.Controls.Add(this.lbMyPlayerHandCount); this.Controls.Add(this.lbEnemyPlayerHandCount); this.Controls.Add(this.lblCurrentTurn); this.Controls.Add(this.playerDeckViewer); this.Controls.Add(this.boutDeckViewer); this.Controls.Add(this.panel9); this.Controls.Add(this.panel1); this.Controls.Add(this.pbMenuOptions); this.Name = "pnlDurakPage"; this.Text = "DurakDeck"; this.panel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pbMenuOptions)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pbSkipButton)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pbMyPlayerImage)).EndInit(); this.panel9.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pbEnemyPlayerImage)).EndInit(); this.ResumeLayout(false); }