diff --git a/csharp/ApprovalTest.cs b/csharp/ApprovalTest.cs index 5334147e..ff34b37d 100644 --- a/csharp/ApprovalTest.cs +++ b/csharp/ApprovalTest.cs @@ -19,7 +19,7 @@ namespace csharp Console.SetOut(new StringWriter(fakeoutput)); Console.SetIn(new StringReader("a\n")); - Program.Main(new string[] { }); + appGUI.Main(new string[] { }); var output = fakeoutput.ToString(); Approvals.Verify(output); diff --git a/csharp/Program.cs b/csharp/Program.cs index bcf3bf2f..63412714 100644 --- a/csharp/Program.cs +++ b/csharp/Program.cs @@ -5,52 +5,6 @@ namespace csharp { public class Program { - public static void Main(string[] args) - { - Console.WriteLine("OMGHAI!"); - List Items = new List{ - new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20}, - new Item {Name = "Aged Brie", SellIn = 2, Quality = 0}, - new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7}, - new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80}, - new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80}, - new Item - { - Name = "Backstage passes to a TAFKAL80ETC concert", - SellIn = 15, - Quality = 20 - }, - new Item - { - Name = "Backstage passes to a TAFKAL80ETC concert", - SellIn = 10, - Quality = 49 - }, - new Item - { - Name = "Backstage passes to a TAFKAL80ETC concert", - SellIn = 5, - Quality = 49 - }, - // this conjured item does not work properly yet - new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6} - }; - - var app = new GildedRose(Items); - - - for (var i = 0; i < 31; i++) - { - Console.WriteLine("-------- day " + i + " --------"); - Console.WriteLine("name, sellIn, quality"); - for (var j = 0; j < Items.Count; j++) - { - System.Console.WriteLine(Items[j]); - } - Console.WriteLine(""); - app.UpdateQuality(); - } - } } } diff --git a/csharp/appGUI.cs b/csharp/appGUI.cs new file mode 100644 index 00000000..db30f615 --- /dev/null +++ b/csharp/appGUI.cs @@ -0,0 +1,169 @@ +using System.Windows.Forms; +using System.Drawing.Drawing2D; +using System; +using System.Collections.Generic; +using csharp; +using System.Data; + +public partial class appGUI : Form +{ + private DataGridView dataGridView1; + private DataGridViewTextBoxColumn Day; + private DataGridViewTextBoxColumn itemName; + private DataGridViewTextBoxColumn SellIn; + private DataGridViewTextBoxColumn Quality; + private Button button1; + + public appGUI() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.button1 = new System.Windows.Forms.Button(); + this.Day = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.itemName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SellIn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Quality = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToOrderColumns = true; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Day, + this.itemName, + this.SellIn, + this.Quality}); + this.dataGridView1.Location = new System.Drawing.Point(-7, 56); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowHeadersWidth = 51; + this.dataGridView1.RowTemplate.Height = 24; + this.dataGridView1.Size = new System.Drawing.Size(560, 414); + this.dataGridView1.TabIndex = 0; + this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick_1); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(199, 12); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(181, 23); + this.button1.TabIndex = 1; + this.button1.Text = "Show Data"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // Day + // + this.Day.HeaderText = "Day"; + this.Day.MinimumWidth = 6; + this.Day.Name = "Day"; + this.Day.ReadOnly = true; + this.Day.Width = 125; + // + // itemName + // + this.itemName.HeaderText = "itemName"; + this.itemName.MinimumWidth = 6; + this.itemName.Name = "itemName"; + this.itemName.ReadOnly = true; + this.itemName.Width = 125; + // + // SellIn + // + this.SellIn.HeaderText = "SellIn"; + this.SellIn.MinimumWidth = 6; + this.SellIn.Name = "SellIn"; + this.SellIn.ReadOnly = true; + this.SellIn.Width = 125; + // + // Quality + // + this.Quality.HeaderText = "Quality"; + this.Quality.MinimumWidth = 6; + this.Quality.Name = "Quality"; + this.Quality.ReadOnly = true; + this.Quality.Width = 125; + // + // appGUI + // + this.ClientSize = new System.Drawing.Size(554, 460); + this.Controls.Add(this.button1); + this.Controls.Add(this.dataGridView1); + this.Name = "appGUI"; + this.Text = "appGUI"; + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + + } + + public static void Main(string[] args) + { + var guiForm = new appGUI(); + guiForm.ShowDialog(); + } + + private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + + private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + List Items = new List{ + new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20}, + new Item {Name = "Aged Brie", SellIn = 2, Quality = 0}, + new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7}, + new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80}, + new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80}, + new Item + { + Name = "Backstage passes to a TAFKAL80ETC concert", + SellIn = 15, + Quality = 20 + }, + new Item + { + Name = "Backstage passes to a TAFKAL80ETC concert", + SellIn = 10, + Quality = 49 + }, + new Item + { + Name = "Backstage passes to a TAFKAL80ETC concert", + SellIn = 5, + Quality = 49 + }, + // this conjured item does not work properly yet + new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6} + }; + + var app = new GildedRose(Items); + + + for (var i = 0; i < 31; i++) + { + Console.WriteLine("-------- day " + i + " --------"); + Console.WriteLine("name, sellIn, quality"); + for (var j = 0; j < Items.Count; j++) + { + DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[j].Clone(); + row.Cells[0].Value = i; + row.Cells[1].Value = Items[j].Name; + row.Cells[2].Value = Items[j].SellIn; + row.Cells[3].Value = Items[j].Quality; + dataGridView1.Rows.Add(row); + } + app.UpdateQuality(); + } + } +} \ No newline at end of file diff --git a/csharp/appGUI.resx b/csharp/appGUI.resx new file mode 100644 index 00000000..f1e9548c --- /dev/null +++ b/csharp/appGUI.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/csharp/csharp.csproj b/csharp/csharp.csproj index 95d10cf1..0bd5be5c 100644 --- a/csharp/csharp.csproj +++ b/csharp/csharp.csproj @@ -7,7 +7,7 @@ Debug AnyCPU {176C0214-9136-4079-8DAB-11D7420C3881} - Exe + WinExe Properties csharp csharp @@ -36,6 +36,9 @@ prompt 4 + + + packages\ApprovalTests.3.0.13\lib\net40\ApprovalTests.dll @@ -66,6 +69,15 @@ + + + + + + + + + @@ -74,6 +86,9 @@ + + Form + @@ -88,6 +103,11 @@ + + + appGUI.cs + +