From 2369889020a47753410bf6aceb3ad61aebe9a694 Mon Sep 17 00:00:00 2001 From: ieZaky Date: Sun, 31 Oct 2021 17:16:34 +0200 Subject: [PATCH] Finished the program --- csharp/ApprovalTest.cs | 2 +- csharp/GildedRose.cs | 30 ++-- csharp/GildedRoseTest.cs | 4 +- csharp/Item.cs | 9 ++ csharp/MainForm.cs | 119 +++++++++++++++ csharp/MainForm.resx | 120 +++++++++++++++ csharp/RuleSet1.ruleset | 3 + csharp/addItemForm.cs | 164 +++++++++++++++++++++ csharp/addItemForm.resx | 120 +++++++++++++++ csharp/appGUI.cs | 169 ---------------------- csharp/csharp.csproj | 19 ++- csharp/showDataForm.cs | 164 +++++++++++++++++++++ csharp/{appGUI.resx => showDataForm.resx} | 8 +- 13 files changed, 741 insertions(+), 190 deletions(-) create mode 100644 csharp/MainForm.cs create mode 100644 csharp/MainForm.resx create mode 100644 csharp/RuleSet1.ruleset create mode 100644 csharp/addItemForm.cs create mode 100644 csharp/addItemForm.resx delete mode 100644 csharp/appGUI.cs create mode 100644 csharp/showDataForm.cs rename csharp/{appGUI.resx => showDataForm.resx} (92%) diff --git a/csharp/ApprovalTest.cs b/csharp/ApprovalTest.cs index ff34b37d..07cc07ca 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")); - appGUI.Main(new string[] { }); + MainForm.Main(new string[] { }); var output = fakeoutput.ToString(); Approvals.Verify(output); diff --git a/csharp/GildedRose.cs b/csharp/GildedRose.cs index 0d29d659..a6ef6e4e 100644 --- a/csharp/GildedRose.cs +++ b/csharp/GildedRose.cs @@ -5,18 +5,15 @@ namespace csharp { public class GildedRose { - IList Items; public const int sulfurasMaxQuality = 80; public const int itemMaxQuality = 50; - public const int qualityScore = 50; public const int daysToDoublePassesQuantity = 11; public const int daysToTriplePassesQuantity = 6; - public GildedRose(IList Items) + public GildedRose() { - this.Items = Items; } - public void UpdateQuality() + public void UpdateQuality(IList Items) { for (var i = 0; i < Items.Count; i++) { @@ -31,20 +28,29 @@ namespace csharp if (Items[i].SellIn < daysToTriplePassesQuantity) { - Items[i].Quality = Items[i].Quality + 2; + Items[i].Quality = Items[i].Quality + 3; } else if (Items[i].SellIn < daysToDoublePassesQuantity) { - Items[i].Quality = Items[i].Quality + 1; + Items[i].Quality = Items[i].Quality + 2; } - + else + { + Items[i].Quality = Items[i].Quality +1; + } + + if (Items[i].Quality > 50) + { + Items[i].Quality = 50; + } + } else if(Items[i].Name == "Conjured Mana Cake" && Items[i].Quality > 0) { Items[i].Quality = Items[i].Quality - 2; } - else if (Items[i].Quality > 0 && Items[i].Name != "Sulfuras, Hand of Ragnaros") + else if (Items[i].Quality > 0 && Items[i].Name != "Aged Brie" && Items[i].Name != "Backstage passes to a TAFKAL80ETC concert" && Items[i].Name != "Sulfuras, Hand of Ragnaros") { Items[i].Quality = Items[i].Quality - 1; } @@ -63,11 +69,7 @@ namespace csharp { Items[i].Quality = 0; } - else if (Items[i].Name == "Aged Brie" && Items[i].Quality < itemMaxQuality) - { - Items[i].Quality = Items[i].Quality + 1; - } - else if(Items[i].Quality > 0 && Items[i].Name != "Sulfuras, Hand of Ragnaros") + else if(Items[i].Quality > 0 && Items[i].Name != "Sulfuras, Hand of Ragnaros" && Items[i].Name != "Aged Brie") { Items[i].Quality = Items[i].Quality - 1; } diff --git a/csharp/GildedRoseTest.cs b/csharp/GildedRoseTest.cs index 911df1be..d615c750 100644 --- a/csharp/GildedRoseTest.cs +++ b/csharp/GildedRoseTest.cs @@ -10,8 +10,8 @@ namespace csharp public void foo() { IList Items = new List { new Item { Name = "foo", SellIn = 0, Quality = 0 } }; - GildedRose app = new GildedRose(Items); - app.UpdateQuality(); + GildedRose app = new GildedRose(); + app.UpdateQuality(Items); Assert.AreEqual("fixme", Items[0].Name); } } diff --git a/csharp/Item.cs b/csharp/Item.cs index c0174285..89394c65 100644 --- a/csharp/Item.cs +++ b/csharp/Item.cs @@ -5,7 +5,16 @@ public string Name { get; set; } public int SellIn { get; set; } public int Quality { get; set; } + public Item() + { + } + public Item(Item item) + { + this.Name = item.Name; + this.SellIn = item.SellIn; + this.Quality = item.Quality; + } public override string ToString() { return this.Name + ", " + this.SellIn + ", " + this.Quality; diff --git a/csharp/MainForm.cs b/csharp/MainForm.cs new file mode 100644 index 00000000..68ac98f2 --- /dev/null +++ b/csharp/MainForm.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Drawing.Drawing2D; +using System; +using System.Collections.Generic; +using csharp; +using System.Data; + +namespace csharp +{ + class MainForm :Form + { + private Button btnShowData; + private Button btnInsertItem; + private IList Items; + private GildedRose app; + public MainForm() + { + InitializeComponent(); + Items = new List{ + new Item {Name = "+5 Dexterity Vest", SellIn = 5, Quality = 20}, + new Item {Name = "Aged Brie", SellIn = 8, Quality = 0}, + new Item {Name = "Elixir of the Mongoose", SellIn = 10, 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} + }; + + app = new GildedRose(); + } + + private void InitializeComponent() + { + this.btnShowData = new System.Windows.Forms.Button(); + this.btnInsertItem = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // btnShowData + // + this.btnShowData.Location = new System.Drawing.Point(61, 53); + this.btnShowData.Name = "btnShowData"; + this.btnShowData.Size = new System.Drawing.Size(163, 37); + this.btnShowData.TabIndex = 0; + this.btnShowData.Text = "Show Items"; + this.btnShowData.UseVisualStyleBackColor = true; + this.btnShowData.Click += new System.EventHandler(this.btnShowData_Click); + // + // btnInsertItem + // + this.btnInsertItem.Location = new System.Drawing.Point(61, 136); + this.btnInsertItem.Name = "btnInsertItem"; + this.btnInsertItem.Size = new System.Drawing.Size(163, 41); + this.btnInsertItem.TabIndex = 1; + this.btnInsertItem.Text = "Insert item"; + this.btnInsertItem.UseVisualStyleBackColor = true; + this.btnInsertItem.Click += new System.EventHandler(this.btnInsertItem_Click); + // + // MainForm + // + this.ClientSize = new System.Drawing.Size(282, 253); + this.Controls.Add(this.btnInsertItem); + this.Controls.Add(this.btnShowData); + this.Name = "MainForm"; + this.Text = "Gilded Rose"; + this.Load += new System.EventHandler(this.MainForm_Load); + this.ResumeLayout(false); + + } + + private void MainForm_Load(object sender, EventArgs e) + { + + } + public static void Main(string[] args) + { + var mainForm = new MainForm(); + mainForm.ShowDialog(); + } + + private void btnShowData_Click(object sender, EventArgs e) + { + + var showDataForm = new showDataForm(app, Items); + showDataForm.ShowDialog(); + + } + + private void btnInsertItem_Click(object sender, EventArgs e) + { + + var Additemform = new addItemForm(Items); + Additemform.ShowDialog(); + + } + } +} diff --git a/csharp/MainForm.resx b/csharp/MainForm.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/csharp/MainForm.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/csharp/RuleSet1.ruleset b/csharp/RuleSet1.ruleset new file mode 100644 index 00000000..84f383f0 --- /dev/null +++ b/csharp/RuleSet1.ruleset @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/csharp/addItemForm.cs b/csharp/addItemForm.cs new file mode 100644 index 00000000..ce916584 --- /dev/null +++ b/csharp/addItemForm.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Drawing.Drawing2D; +using System; +using System.Collections.Generic; +using csharp; +using System.Data; + + +namespace csharp +{ + class addItemForm :Form + { + private ComboBox cbType; + private Label lblItemType; + private Label lblSellIn; + private Label lblQuality; + private NumericUpDown nudlSellIn; + private Button btnAdd; + private NumericUpDown nudlQuality; + private IList Items; + public addItemForm(IList Items) + { + this.Items = Items; + InitializeComponent(); + } + + private void InitializeComponent() + { + this.cbType = new System.Windows.Forms.ComboBox(); + this.lblItemType = new System.Windows.Forms.Label(); + this.lblSellIn = new System.Windows.Forms.Label(); + this.lblQuality = new System.Windows.Forms.Label(); + this.nudlSellIn = new System.Windows.Forms.NumericUpDown(); + this.nudlQuality = new System.Windows.Forms.NumericUpDown(); + this.btnAdd = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.nudlSellIn)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudlQuality)).BeginInit(); + this.SuspendLayout(); + // + // cbType + // + this.cbType.FormattingEnabled = true; + this.cbType.Location = new System.Drawing.Point(99, 40); + this.cbType.Name = "cbType"; + this.cbType.Size = new System.Drawing.Size(121, 24); + this.cbType.TabIndex = 0; + this.cbType.SelectedIndexChanged += new System.EventHandler(this.cbType_SelectedIndexChanged); + // + // lblItemType + // + this.lblItemType.AutoSize = true; + this.lblItemType.Location = new System.Drawing.Point(13, 40); + this.lblItemType.Name = "lblItemType"; + this.lblItemType.Size = new System.Drawing.Size(70, 17); + this.lblItemType.TabIndex = 1; + this.lblItemType.Text = "Item Type"; + // + // lblSellIn + // + this.lblSellIn.AutoSize = true; + this.lblSellIn.Location = new System.Drawing.Point(12, 86); + this.lblSellIn.Name = "lblSellIn"; + this.lblSellIn.Size = new System.Drawing.Size(46, 17); + this.lblSellIn.TabIndex = 2; + this.lblSellIn.Text = "Sell In"; + // + // lblQuality + // + this.lblQuality.AutoSize = true; + this.lblQuality.Location = new System.Drawing.Point(13, 142); + this.lblQuality.Name = "lblQuality"; + this.lblQuality.Size = new System.Drawing.Size(52, 17); + this.lblQuality.TabIndex = 3; + this.lblQuality.Text = "Quality"; + // + // nudlSellIn + // + this.nudlSellIn.Location = new System.Drawing.Point(99, 86); + this.nudlSellIn.Name = "nudlSellIn"; + this.nudlSellIn.Size = new System.Drawing.Size(120, 22); + this.nudlSellIn.TabIndex = 4; + // + // nudlQuality + // + this.nudlQuality.Location = new System.Drawing.Point(99, 137); + this.nudlQuality.Name = "nudlQuality"; + this.nudlQuality.Size = new System.Drawing.Size(120, 22); + this.nudlQuality.TabIndex = 5; + // + // btnAdd + // + this.btnAdd.Location = new System.Drawing.Point(99, 202); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(75, 23); + this.btnAdd.TabIndex = 6; + this.btnAdd.Text = "Add Item"; + this.btnAdd.UseVisualStyleBackColor = true; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // addItemForm + // + this.ClientSize = new System.Drawing.Size(282, 253); + this.Controls.Add(this.btnAdd); + this.Controls.Add(this.nudlQuality); + this.Controls.Add(this.nudlSellIn); + this.Controls.Add(this.lblQuality); + this.Controls.Add(this.lblSellIn); + this.Controls.Add(this.lblItemType); + this.Controls.Add(this.cbType); + this.Name = "addItemForm"; + this.Text = "Add an item"; + this.Load += new System.EventHandler(this.addItemForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.nudlSellIn)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudlQuality)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + private void btnAdd_Click(object sender, EventArgs e) + { + var itemType = cbType.SelectedItem; + if(itemType == null) + { + MessageBox.Show("Please Select Item Type"); + return; + } + var sellIn = nudlSellIn.Value; + var Quality = nudlQuality.Value; + this.Items.Add(new Item { Name = itemType.ToString(), SellIn = (int)sellIn, Quality = (int)Quality }); + MessageBox.Show("Item Added Sucessfully"); + this.Hide(); + } + + private void addItemForm_Load(object sender, EventArgs e) + { + cbType.Items.Add("+5 Dexterity Vest"); + cbType.Items.Add("Aged Brie"); + cbType.Items.Add("Elixir of the Mongoose"); + cbType.Items.Add("Sulfuras, Hand of Ragnaros"); + cbType.Items.Add("Backstage passes to a TAFKAL80ETC concert"); + cbType.Text = "Choose an item"; + } + + private void cbType_SelectedIndexChanged(object sender, EventArgs e) + { + if(cbType.SelectedItem.ToString() == "Sulfuras, Hand of Ragnaros") + { + nudlQuality.Maximum = 80; + nudlQuality.Minimum = 80; + nudlQuality.Value = 80; + } else + { + nudlQuality.Minimum = 0; + nudlQuality.Maximum = 50; + } + } + } +} diff --git a/csharp/addItemForm.resx b/csharp/addItemForm.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/csharp/addItemForm.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/csharp/appGUI.cs b/csharp/appGUI.cs deleted file mode 100644 index db30f615..00000000 --- a/csharp/appGUI.cs +++ /dev/null @@ -1,169 +0,0 @@ -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/csharp.csproj b/csharp/csharp.csproj index 0bd5be5c..829b8ab8 100644 --- a/csharp/csharp.csproj +++ b/csharp/csharp.csproj @@ -86,26 +86,39 @@ - + + Form + + Form + + Form + + - - appGUI.cs + + addItemForm.cs + + + showDataForm.cs + + + MainForm.cs diff --git a/csharp/showDataForm.cs b/csharp/showDataForm.cs new file mode 100644 index 00000000..ba72cc17 --- /dev/null +++ b/csharp/showDataForm.cs @@ -0,0 +1,164 @@ +using System.Windows.Forms; +using System.Drawing.Drawing2D; +using System; +using System.Collections.Generic; +using csharp; +using System.Data; + +public partial class showDataForm : Form +{ + private DataGridView dgvData; + private Label lblDay; + private DataGridViewTextBoxColumn itemName; + private DataGridViewTextBoxColumn SellIn; + private DataGridViewTextBoxColumn Quality; + private GildedRose app; + private ComboBox cbDay; + private IList Items; + + public showDataForm(GildedRose app, IList Items) + { + this.app = app; + this.Items = Items; + InitializeComponent(); + for(int i=1; i<31; i++) + { + cbDay.Items.Add(i); + } + } + + private void InitializeComponent() + { + this.dgvData = new System.Windows.Forms.DataGridView(); + this.itemName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SellIn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Quality = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.lblDay = new System.Windows.Forms.Label(); + this.cbDay = new System.Windows.Forms.ComboBox(); + ((System.ComponentModel.ISupportInitialize)(this.dgvData)).BeginInit(); + this.SuspendLayout(); + // + // dgvData + // + this.dgvData.AllowUserToOrderColumns = true; + this.dgvData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.itemName, + this.SellIn, + this.Quality}); + this.dgvData.Location = new System.Drawing.Point(79, 128); + this.dgvData.Name = "dgvData"; + this.dgvData.RowHeadersWidth = 51; + this.dgvData.RowTemplate.Height = 24; + this.dgvData.Size = new System.Drawing.Size(426, 327); + this.dgvData.TabIndex = 0; + this.dgvData.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick_1); + // + // 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; + // + // lblDay + // + this.lblDay.AutoSize = true; + this.lblDay.Location = new System.Drawing.Point(171, 48); + this.lblDay.Name = "lblDay"; + this.lblDay.Size = new System.Drawing.Size(33, 17); + this.lblDay.TabIndex = 3; + this.lblDay.Text = "Day"; + // + // cbDay + // + this.cbDay.FormattingEnabled = true; + this.cbDay.Location = new System.Drawing.Point(229, 45); + this.cbDay.Name = "cbDay"; + this.cbDay.Size = new System.Drawing.Size(121, 24); + this.cbDay.TabIndex = 4; + this.cbDay.SelectedIndexChanged += new System.EventHandler(this.cbDay_SelectedIndexChanged); + // + // showDataForm + // + this.ClientSize = new System.Drawing.Size(554, 460); + this.Controls.Add(this.cbDay); + this.Controls.Add(this.lblDay); + this.Controls.Add(this.dgvData); + this.Name = "showDataForm"; + this.Text = "Show Data"; + this.Load += new System.EventHandler(this.showDataForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgvData)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + + + private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + + private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e) + { + + } + + private void btnShowData_Click(object sender, EventArgs e) + { + + } + + private void showDataForm_Load(object sender, EventArgs e) + { + + } + + private void cbDay_SelectedIndexChanged(object sender, EventArgs e) + { + dgvData.Rows.Clear(); + int counter = 0; + IList tempItems = new List(); + foreach (var it in Items) + { + tempItems.Add(new Item(it)); + } + + for (var i = 0; i < (int)cbDay.SelectedItem; i++) + { + app.UpdateQuality(tempItems); + } + + for (var j = 0; j < tempItems.Count; j++) + { + if (tempItems[j].Quality > 0) + { + DataGridViewRow row = (DataGridViewRow)dgvData.Rows[counter].Clone(); + row.Cells[0].Value = tempItems[j].Name; + row.Cells[1].Value = tempItems[j].SellIn < 0 ? 0 : tempItems[j].SellIn; + row.Cells[2].Value = tempItems[j].Quality; + dgvData.Rows.Add(row); + counter++; + } + } + } +} \ No newline at end of file diff --git a/csharp/appGUI.resx b/csharp/showDataForm.resx similarity index 92% rename from csharp/appGUI.resx rename to csharp/showDataForm.resx index f1e9548c..37913796 100644 --- a/csharp/appGUI.resx +++ b/csharp/showDataForm.resx @@ -117,7 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + True + + + True + + True