Window Forms
namespace G24W10WFCardDealer {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void OnDeal(object sender, EventArgs e) {
string[] suits = ["spades", "hearts", "diamonds", "clubs"];
string[] values = ["ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "jack", "queen", "king"];
Random random = new Random();
int card = random.Next(suits.Length * values.Length);
string suit = suits[card / values.Length];
string value = values[card % values.Length];
if (value == "jack" || value == "queen" || value == "king") {
suit += "2";
}
Card1.Image = Properties.Resources
.ResourceManager
.GetObject($"{value}_of_{suit}")
as Image;
}
}
}
namespace G24W10WFCardDealer {
partial class Form1 {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
Card1 = new PictureBox();
((System.ComponentModel.ISupportInitialize)Card1).BeginInit();
SuspendLayout();
//
// Card1
//
Card1.Image = Properties.Resources.red_joker;
Card1.Location = new Point(12, 12);
Card1.Name = "Card1";
Card1.Size = new Size(261, 379);
Card1.SizeMode = PictureBoxSizeMode.Zoom;
Card1.TabIndex = 0;
Card1.TabStop = false;
//
// Form1
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(286, 458);
Controls.Add(Card1);
Name = "Form1";
Text = "카드딜러";
((System.ComponentModel.ISupportInitialize)Card1).EndInit();
ResumeLayout(false);
}
#endregion
private PictureBox Card1;
}
}