diff --git a/Greed/Dice.cs b/Greed/Dice.cs new file mode 100644 index 0000000..d2ad284 --- /dev/null +++ b/Greed/Dice.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Greed +{ + public class Dice + { + public bool Chosen { get; set; } = false; + public int Number { get; set; } + private Random rnd = null; + public Dice() + { + rnd = new Random(); + } + + public int Roll() + { + Number = rnd.Next(1, 7); + return Number; + } + } + +} diff --git a/Greed/Greed.csproj b/Greed/Greed.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Greed/Greed.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Greed/HandleThrow.cs b/Greed/HandleThrow.cs new file mode 100644 index 0000000..421f356 --- /dev/null +++ b/Greed/HandleThrow.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Greed +{ + public class HandleThrow + { + public string Who { get; set; } + public int Score { get; set; } + + private List _dices = new List(); + int roll; + public HandleThrow() + { + for (int i = 1; i < 7; i++) + { + _dices.Add(new Dice()); + } + roll = 0; + } + + public void Throw() + { + roll += 1; + Console.WriteLine($"Kast{roll}"); + foreach (Dice dice in _dices) + { + if (!dice.Chosen) + { + Console.Write($" {dice.Roll()}"); + } + } + Console.WriteLine(); + Console.WriteLine("----------------------"); + } + + + } + +} diff --git a/Greed/Program.cs b/Greed/Program.cs new file mode 100644 index 0000000..570404c --- /dev/null +++ b/Greed/Program.cs @@ -0,0 +1,8 @@ +// See https://aka.ms/new-console-template for more information +using Greed; + +Console.WriteLine("Welcome to World of Greed!"); + +var ht = new HandleThrow(); +ht.Throw(); +Console.ReadKey(); \ No newline at end of file diff --git a/GreedApp.sln b/GreedApp.sln new file mode 100644 index 0000000..4cd7cce --- /dev/null +++ b/GreedApp.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32526.322 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Greed", "Greed\Greed.csproj", "{63EAAA01-3686-41C5-A597-C66FCFD6B9C3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinGreed", "WinGreed\WinGreed.csproj", "{EB411B95-5147-4C59-9C0D-0E30F9E3CF9D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {63EAAA01-3686-41C5-A597-C66FCFD6B9C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63EAAA01-3686-41C5-A597-C66FCFD6B9C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63EAAA01-3686-41C5-A597-C66FCFD6B9C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63EAAA01-3686-41C5-A597-C66FCFD6B9C3}.Release|Any CPU.Build.0 = Release|Any CPU + {EB411B95-5147-4C59-9C0D-0E30F9E3CF9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB411B95-5147-4C59-9C0D-0E30F9E3CF9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB411B95-5147-4C59-9C0D-0E30F9E3CF9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB411B95-5147-4C59-9C0D-0E30F9E3CF9D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {74082CE9-3CD5-421F-9339-C6692DFCD388} + EndGlobalSection +EndGlobal diff --git a/WinGreed/ControlExtension.cs b/WinGreed/ControlExtension.cs new file mode 100644 index 0000000..2a39281 --- /dev/null +++ b/WinGreed/ControlExtension.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Diagnostics; + +namespace WinGreed +{ + public static class ControlExtensions + { + public static T Clone(this T controlToClone) + where T : Control + { + PropertyInfo[] controlProperties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance); + + T instance = Activator.CreateInstance(); + + foreach (PropertyInfo propInfo in controlProperties) + { + if (propInfo.CanWrite) + { + //Debug.WriteLine($"Can write :{propInfo.CanWrite} Name : {propInfo.Name}"); + if (propInfo.Name == "Image") + { + //switch (switch_on) + //{ + // default: + //} + } + else + { + if (propInfo.Name != "WindowTarget") + propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null); + } + + } + } + + return instance; + } + } +} diff --git a/WinGreed/Dice.cs b/WinGreed/Dice.cs new file mode 100644 index 0000000..fabbae3 --- /dev/null +++ b/WinGreed/Dice.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WinGreed +{ + public class Dice + { + public bool Chosen { get; set; } = false; + public int Number { get; set; } + public int DiceNumber { get; set; } + private Random rnd = null; + public Dice(int diceNumber) + { + rnd = new Random(); + DiceNumber = diceNumber; + } + + + public int Roll() + { + Number = rnd.Next(1, 7); + return Number; + } + } +} diff --git a/WinGreed/HandleThrow.cs b/WinGreed/HandleThrow.cs new file mode 100644 index 0000000..3ba8adf --- /dev/null +++ b/WinGreed/HandleThrow.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WinGreed +{ + public class HandleThrow + { + public string Who { get; set; } + public int Score { get; set; } + + private List _dices = new List(); + int roll; + public HandleThrow() + { + for (int i = 1; i < 7; i++) + { + _dices.Add(new Dice(i)); + } + roll = 0; + } + + public List Throw() + { + var rolled = new List(); + roll += 1; + foreach (Dice dice in _dices) + { + if (!dice.Chosen) + { + dice.Roll(); + rolled.Add(dice); + } + } + return rolled; + } + } +} diff --git a/WinGreed/Program.cs b/WinGreed/Program.cs new file mode 100644 index 0000000..3479793 --- /dev/null +++ b/WinGreed/Program.cs @@ -0,0 +1,17 @@ +namespace WinGreed +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new frmStart()); + } + } +} \ No newline at end of file diff --git a/WinGreed/Properties/Resources.Designer.cs b/WinGreed/Properties/Resources.Designer.cs new file mode 100644 index 0000000..40840b9 --- /dev/null +++ b/WinGreed/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WinGreed.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinGreed.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/WinGreed/Properties/Resources.resx b/WinGreed/Properties/Resources.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WinGreed/Properties/Resources.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WinGreed/WinGreed.csproj b/WinGreed/WinGreed.csproj new file mode 100644 index 0000000..13ee123 --- /dev/null +++ b/WinGreed/WinGreed.csproj @@ -0,0 +1,26 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + \ No newline at end of file diff --git a/WinGreed/frmPersonRound.Designer.cs b/WinGreed/frmPersonRound.Designer.cs new file mode 100644 index 0000000..ea03d1d --- /dev/null +++ b/WinGreed/frmPersonRound.Designer.cs @@ -0,0 +1,172 @@ +namespace WinGreed +{ + partial class frmPersonRound + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.btnThrow = new System.Windows.Forms.Button(); + this.btnDiceTmpl1 = new System.Windows.Forms.Button(); + this.btnDiceTmpl2 = new System.Windows.Forms.Button(); + this.btnDiceTmpl4 = new System.Windows.Forms.Button(); + this.btnDiceTmpl3 = new System.Windows.Forms.Button(); + this.btnDiceTmpl6 = new System.Windows.Forms.Button(); + this.btnDiceTmpl5 = new System.Windows.Forms.Button(); + this.btnClose = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label1.Location = new System.Drawing.Point(23, 17); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(105, 30); + this.label1.TabIndex = 0; + this.label1.Text = "Nu kör vi"; + // + // btnThrow + // + this.btnThrow.Location = new System.Drawing.Point(32, 71); + this.btnThrow.Name = "btnThrow"; + this.btnThrow.Size = new System.Drawing.Size(96, 23); + this.btnThrow.TabIndex = 1; + this.btnThrow.Text = "Kasta Tärningar"; + this.btnThrow.UseVisualStyleBackColor = true; + this.btnThrow.Click += new System.EventHandler(this.btnThrow_Click); + // + // btnDiceTmpl1 + // + this.btnDiceTmpl1.Location = new System.Drawing.Point(746, 82); + this.btnDiceTmpl1.Name = "btnDiceTmpl1"; + this.btnDiceTmpl1.Size = new System.Drawing.Size(42, 44); + this.btnDiceTmpl1.TabIndex = 2; + this.btnDiceTmpl1.Text = "1"; + this.btnDiceTmpl1.UseVisualStyleBackColor = true; + this.btnDiceTmpl1.Visible = false; + this.btnDiceTmpl1.Click += new System.EventHandler(this.btnDiceTmpl_Click); + // + // btnDiceTmpl2 + // + this.btnDiceTmpl2.Location = new System.Drawing.Point(746, 126); + this.btnDiceTmpl2.Name = "btnDiceTmpl2"; + this.btnDiceTmpl2.Size = new System.Drawing.Size(42, 44); + this.btnDiceTmpl2.TabIndex = 3; + this.btnDiceTmpl2.Text = "2"; + this.btnDiceTmpl2.UseVisualStyleBackColor = true; + this.btnDiceTmpl2.Visible = false; + this.btnDiceTmpl2.Click += new System.EventHandler(this.btnDiceTmpl_Click); + // + // btnDiceTmpl4 + // + this.btnDiceTmpl4.Location = new System.Drawing.Point(746, 214); + this.btnDiceTmpl4.Name = "btnDiceTmpl4"; + this.btnDiceTmpl4.Size = new System.Drawing.Size(42, 44); + this.btnDiceTmpl4.TabIndex = 5; + this.btnDiceTmpl4.Text = "4"; + this.btnDiceTmpl4.UseVisualStyleBackColor = true; + this.btnDiceTmpl4.Visible = false; + this.btnDiceTmpl4.Click += new System.EventHandler(this.btnDiceTmpl_Click); + // + // btnDiceTmpl3 + // + this.btnDiceTmpl3.Location = new System.Drawing.Point(746, 170); + this.btnDiceTmpl3.Name = "btnDiceTmpl3"; + this.btnDiceTmpl3.Size = new System.Drawing.Size(42, 44); + this.btnDiceTmpl3.TabIndex = 4; + this.btnDiceTmpl3.Text = "3"; + this.btnDiceTmpl3.UseVisualStyleBackColor = true; + this.btnDiceTmpl3.Visible = false; + this.btnDiceTmpl3.Click += new System.EventHandler(this.btnDiceTmpl_Click); + // + // btnDiceTmpl6 + // + this.btnDiceTmpl6.Location = new System.Drawing.Point(746, 302); + this.btnDiceTmpl6.Name = "btnDiceTmpl6"; + this.btnDiceTmpl6.Size = new System.Drawing.Size(42, 44); + this.btnDiceTmpl6.TabIndex = 7; + this.btnDiceTmpl6.Text = "6"; + this.btnDiceTmpl6.UseVisualStyleBackColor = true; + this.btnDiceTmpl6.Visible = false; + this.btnDiceTmpl6.Click += new System.EventHandler(this.btnDiceTmpl_Click); + // + // btnDiceTmpl5 + // + this.btnDiceTmpl5.Location = new System.Drawing.Point(746, 258); + this.btnDiceTmpl5.Name = "btnDiceTmpl5"; + this.btnDiceTmpl5.Size = new System.Drawing.Size(42, 44); + this.btnDiceTmpl5.TabIndex = 6; + this.btnDiceTmpl5.Text = "5"; + this.btnDiceTmpl5.UseVisualStyleBackColor = true; + this.btnDiceTmpl5.Visible = false; + this.btnDiceTmpl5.Click += new System.EventHandler(this.btnDiceTmpl_Click); + // + // btnClose + // + this.btnClose.Location = new System.Drawing.Point(678, 397); + this.btnClose.Name = "btnClose"; + this.btnClose.Size = new System.Drawing.Size(75, 23); + this.btnClose.TabIndex = 8; + this.btnClose.Text = "Stäng"; + this.btnClose.UseVisualStyleBackColor = true; + this.btnClose.Click += new System.EventHandler(this.btnClose_Click); + // + // frmPersonRound + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.btnClose); + this.Controls.Add(this.btnDiceTmpl6); + this.Controls.Add(this.btnDiceTmpl5); + this.Controls.Add(this.btnDiceTmpl4); + this.Controls.Add(this.btnDiceTmpl3); + this.Controls.Add(this.btnDiceTmpl2); + this.Controls.Add(this.btnDiceTmpl1); + this.Controls.Add(this.btnThrow); + this.Controls.Add(this.label1); + this.Name = "frmPersonRound"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Din tur -"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label label1; + private Button btnThrow; + private Button btnDiceTmpl1; + private Button btnDiceTmpl2; + private Button btnDiceTmpl4; + private Button btnDiceTmpl3; + private Button btnDiceTmpl6; + private Button btnDiceTmpl5; + private Button btnClose; + } +} \ No newline at end of file diff --git a/WinGreed/frmPersonRound.cs b/WinGreed/frmPersonRound.cs new file mode 100644 index 0000000..ad43f57 --- /dev/null +++ b/WinGreed/frmPersonRound.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WinGreed +{ + public partial class frmPersonRound : Form + { + int y = 79; + int x = 0; + int row = 0; + private List