1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152:
| using System; using System.Drawing; using System.Windows.Forms; using System.Drawing.Drawing2D;
namespace Wuerfel { public class MainForm : System.Windows.Forms.Form { private System.Windows.Forms.Button wuerfelButton; private System.Windows.Forms.PictureBox pictureBox; private System.Windows.Forms.Label ergebnisLabel; public MainForm() { InitializeComponent(); } [STAThread] public static void Main(string[] args) { Application.Run(new MainForm()); } #region Windows Forms Designer generated code private void InitializeComponent() { this.ergebnisLabel = new System.Windows.Forms.Label(); this.pictureBox = new System.Windows.Forms.PictureBox(); this.wuerfelButton = new System.Windows.Forms.Button(); this.SuspendLayout(); this.ergebnisLabel.Font = new System.Drawing.Font("Arial", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.ergebnisLabel.Location = new System.Drawing.Point(160, 24); this.ergebnisLabel.Name = "ergebnisLabel"; this.ergebnisLabel.Size = new System.Drawing.Size(168, 72); this.ergebnisLabel.TabIndex = 2; this.ergebnisLabel.Text = "0"; this.ergebnisLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.ergebnisLabel.Click += new System.EventHandler(this.Label2Click); this.pictureBox.BackColor = System.Drawing.Color.Crimson; this.pictureBox.Location = new System.Drawing.Point(8, 8); this.pictureBox.Name = "pictureBox"; this.pictureBox.Size = new System.Drawing.Size(140, 140); this.pictureBox.TabIndex = 0; this.pictureBox.TabStop = false; this.wuerfelButton.Location = new System.Drawing.Point(160, 120); this.wuerfelButton.Name = "wuerfelButton"; this.wuerfelButton.Size = new System.Drawing.Size(168, 24); this.wuerfelButton.TabIndex = 3; this.wuerfelButton.Text = "Würfeln"; this.wuerfelButton.Click += new System.EventHandler(this.Button1Click); this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(336, 158); this.Controls.Add(this.wuerfelButton); this.Controls.Add(this.ergebnisLabel); this.Controls.Add(this.pictureBox); this.Name = "MainForm"; this.Text = "MainForm"; this.ResumeLayout(false); } #endregion void Label1Click(object sender, System.EventArgs e) { } void Label2Click(object sender, System.EventArgs e) { } void Button1Click(object sender, System.EventArgs e) { int zahl; Random r = new Random(); zahl = r.Next(1,6); ergebnisLabel.Text = "Die Würfel sind gefallen! Die "+zahl+" wurde gewürfelt"; Graphics g = e.Graphics; Pen pen = new Pen(Color.White,3); SolidBrush solidBrush = new SolidBrush(Color.FromArgb(0, 255, 0, 125)); if(zahl=1){ g.FillEllipse(solidBrush, 60, 60, 80, 80); } if(zahl=2){ g.FillEllipse(solidBrush, 100, 20, 120, 40); g.FillEllipse(solidBrush, 20, 100, 40, 120); } if(zahl=3){ g.FillEllipse(solidBrush, 100, 20, 120, 40); g.FillEllipse(solidBrush, 60, 60, 80, 80); g.FillEllipse(solidBrush, 20, 100, 40, 120); } if(zahl=4){ g.FillEllipse(solidBrush, 20, 20, 40, 40); g.FillEllipse(solidBrush, 100, 20, 120, 40); g.FillEllipse(solidBrush, 20, 100, 40, 120); g.FillEllipse(solidBrush, 100, 100, 120, 120); } if(zahl=5){ g.FillEllipse(solidBrush, 20, 20, 40, 40); g.FillEllipse(solidBrush, 100, 20, 120, 40); g.FillEllipse(solidBrush, 20, 100, 40, 120); g.FillEllipse(solidBrush, 100, 100, 120, 120); g.FillEllipse(solidBrush, 20, 100, 40, 120); } if(zahl=6){ g.FillEllipse(solidBrush, 20, 20, 40, 40); g.FillEllipse(solidBrush, 60, 20, 80, 40); g.FillEllipse(solidBrush, 100, 20, 120, 40); g.FillEllipse(solidBrush, 20, 100, 40, 120); g.FillEllipse(solidBrush, 60, 100, 80, 120); g.FillEllipse(solidBrush, 100, 100, 120, 120); } } } } |