public void ShowCategories() { Size EmptySize = new Size(0, 0); Size catPanelSize = new Size(228, 136); Size picBoxSize = new Size(228, 79); Size catNameSize = new Size(82, 25); Size catAmmSize = new Size(57, 17); Point emptyLoc = new Point(0, 0); Point catNameLoc = new Point(85, 93); Point catAmmLoc = new Point(168, 115); Font DefaultFont = new Font("Nirmala UI", 14, FontStyle.Bold); Font catAmmFont = new Font("Nirmala UI", 10, FontStyle.Regular); List <string> catList = GetCategories(Forms.Authentication.LoginForm.VendorDetails.VendorID.ToString()); //AddCategory.Click += new EventHandler(OpenAddCat); AddCategory.MouseMove += new MouseEventHandler(CursorChangeArgs); Panel AddCatPanel = AddCategory; flowLayoutPanel1.Controls.Clear(); foreach (string category in catList) { string orderStatus = $"16 Items:"; //hard Coded right now change later Panel catPanel = GenControls.AddPanel(category, Color.White, catPanelSize); PictureBox catImage = GenControls.AddPictureBox(category, emptyLoc, picBoxSize); //catImage.ImageLocation = ImageHandler.GetImage(ImageTypes.Avatar, ) catImage.SizeMode = PictureBoxSizeMode.CenterImage; catImage.Name = category + "picBox"; Label catTitleLabel = GenControls.AddLabel(category, category, catNameLoc, DefaultFont, Color.Black, Color.Transparent, EmptySize, true); Label catAmountLabel = GenControls.AddLabel(category, orderStatus, catAmmLoc, catAmmFont, Color.Black, Color.Transparent, EmptySize, true); //Label orderPriceLabel = GenControls.AddLabel(PriceText + "Rating", PriceText, PriceLoc, DefaultFont, Color.Black, Color.Transparent, EmptySize, true); //Label orderStatusLabel = GenControls.AddLabel(orderStatus + "Rating", orderStatus, StatusLoc, DefaultFont, Color.Black, Color.Transparent, StatusSize, false); Control[] controlArray = new Control[] { catImage, catTitleLabel, catAmountLabel }; foreach (Control curControl in controlArray) { //Add Event Handlers Below curControl.Click += new EventHandler(OpenOrder); curControl.MouseMove += new MouseEventHandler(CursorChangeArgs); catPanel.Controls.Add(curControl); curControl.Tag = category; } flowLayoutPanel1.Controls.Add(catPanel); flowLayoutPanel1.Controls.Add(AddCatPanel); flowLayoutPanel1.Click += new EventHandler(OpenOrder); flowLayoutPanel1.MouseMove += new MouseEventHandler(CursorChangeArgs); flowLayoutPanel1.Tag = category; } }
public void ShowItems() { Size EmptySize = new Size(0, 0); Size catPanelSize = new Size(228, 136); Size picBoxSize = new Size(228, 79); Size catNameSize = new Size(82, 25); Size catAmmSize = new Size(57, 17); Point emptyLoc = new Point(0, 0); Point ItemNameLoc = new Point(85, 93); Point catAmmLoc = new Point(155, 110); Font DefaultFont = new Font("Nirmala UI", 11, FontStyle.Bold); Font catAmmFont = new Font("Nirmala UI", 10, FontStyle.Regular); DataTable ItemsList = GetItems(Forms.Authentication.LoginForm.VendorDetails.VendorID.ToString()); EditCategory.Click += new EventHandler(OpenEditorCat); EditCategory.MouseMove += new MouseEventHandler(CursorChangeArgs); Panel EditCategoryPanel = EditCategory; flowLayoutPanel1.Controls.Clear(); foreach (DataRow Item in ItemsList.Rows) { string orderStatus = $"16 Items:"; //hard Coded right now change later string ItemName = Item[2].ToString(); string ItemPrice = "£" + Item[5].ToString(); string ItemID = Item[0].ToString(); string imageLoc = Item[4].ToString(); Panel catPanel = GenControls.AddPanel(ItemName, Color.White, catPanelSize); PictureBox catImage = GenControls.AddPictureBox(ItemID, emptyLoc, picBoxSize); catImage.ImageLocation = ImageHandler.GetImage(ImageTypes.Avatar, imageLoc); catImage.SizeMode = PictureBoxSizeMode.CenterImage; Label ItemNameLabel = GenControls.AddLabel(ItemID, ItemName, ItemNameLoc, DefaultFont, Color.Black, Color.Transparent, EmptySize, true); Label ItemPriceLabel = GenControls.AddLabel(ItemID, ItemPrice, catAmmLoc, catAmmFont, Color.Black, Color.Transparent, EmptySize, true); Control[] controlArray = new Control[] { catImage, ItemNameLabel, ItemPriceLabel }; foreach (Control curControl in controlArray) { //Add Event Handlers Below curControl.Click += new EventHandler(OpenEditor); curControl.MouseMove += new MouseEventHandler(CursorChangeArgs); catPanel.Controls.Add(curControl); curControl.Tag = (string)ItemID; //Store the ItemID so it can be referenced later on } catPanel.Tag = (string)ItemID; flowLayoutPanel1.Controls.Add(catPanel); flowLayoutPanel1.Controls.Add(EditCategoryPanel); } }
private void MasterGenerator() { string vendorID, vendorName, vendorDescription, vendorPostcode, vendorRating, imageLoc; string SQLQuery = "SELECT * FROM vendors"; using (DataTable DataResults = FeedMeLogic.Data.DAL.ExecCommand(SQLQuery)) { int vendorAmount = DataResults.Rows.Count; VendorAmountLabel.Text = string.Format("There are currently {0} restraunts/food places near you", vendorAmount.ToString()); //Updates Text to Match No of Vendors #region Initiaizling Location & Size For Controls //Initializing Height & Location Variables (Information from Design Version) Size vendorPanelSize = new Size(711, 96); Size TitleSize = new Size(142, 30); Size DescSize = new Size(556, 47); Size RatingSize = new Size(80, 21); Size PostcodeSize = new Size(84, 21); Size PictureBoxSize = new Size(127, 86); Point TitleLoc = new Point(344, 5); Point DescLoc = new Point(146, 36); Point RatingLoc = new Point(485, 5); Point PostcodeLoc = new Point(567, 5); Point PictureBoxLoc = new Point(4, 5); Font DefaultFont = new Font("Nirmala UI", 12, FontStyle.Regular); Font TitleFont = new Font("Nirmala UI", 14, FontStyle.Bold); #endregion Initiaizling Location & Size For Controls //string DefaultFnt = "Nirmala UI"; int maxGen = vendorAmount; #region Iterating Through Each Vendor for (int i = 0; i < maxGen; i++) { #region Getting Variables vendorID = DataResults.Rows[i][0].ToString(); vendorName = DataResults.Rows[i][1].ToString(); vendorDescription = DataResults.Rows[i][2].ToString(); vendorPostcode = ("(" + DataResults.Rows[i][4].ToString() + ")"); //vendorRating = DataResults.Rows[i][6].ToString(); vendorRating = "⭐⭐⭐⭐⭐"; imageLoc = ImageHandler.GetImage(ImageTypes.Avatar, DataResults.Rows[i][10].ToString()); #endregion Getting Variables #region Creating & Adding Event Handlers To Each Control Panel vendorPanelObject = GenControls.AddPanel(vendorName, Color.White, vendorPanelSize); Label vendorTitleLabel = GenControls.AddLabel(vendorName, vendorName, TitleLoc, TitleFont, Color.Black, Color.Transparent, TitleSize, true); Label vendorDescLabel = GenControls.AddLabel(vendorName + "Desc", vendorDescription, DescLoc, DefaultFont, Color.Black, Color.Transparent, DescSize, false); RatingLoc = new Point(vendorTitleLabel.Location.X + vendorTitleLabel.Width - 15, vendorTitleLabel.Location.Y); Label vendorRatingLabel = GenControls.AddLabel(vendorName + "Rating", vendorRating, RatingLoc, DefaultFont, Color.Black, Color.Transparent, RatingSize, true); PostcodeLoc = new Point(vendorRatingLabel.Location.X + vendorRatingLabel.Width - 15, vendorRatingLabel.Location.Y); Label vendorPostcodeLabel = GenControls.AddLabel(vendorName + "PostCode", vendorPostcode, PostcodeLoc, DefaultFont, Color.LightGray, Color.Transparent, PostcodeSize, true); PictureBox vendorPictureBox = GenControls.AddPictureBox(vendorName, PictureBoxLoc, PictureBoxSize); vendorPictureBox.ImageLocation = imageLoc; Control[] controlArray = new Control[] { vendorTitleLabel, vendorDescLabel, vendorRatingLabel, vendorPostcodeLabel, vendorPictureBox }; foreach (Control curControl in controlArray) { //Add Event Handlers Below curControl.Click += new EventHandler(OpenVendor); curControl.MouseMove += new MouseEventHandler(CursorChangeArgs); vendorPanelObject.Controls.Add(curControl); } VendorsFlowPanel.Controls.Add(vendorPanelObject); vendorPanelObject.Click += new EventHandler(OpenVendor); vendorPanelObject.MouseMove += new MouseEventHandler(CursorChangeArgs); #endregion Creating & Adding Event Handlers To Each Control } #endregion Iterating Through Each Vendor } }
private void GenerateItems(int vendorID, string itemType) { #region Initiaizling Variables & DataTable int ItemAmount; string ItemID, ItemType, ItemName, ItemDescription, ItemPrice, imageLoc; string SQLCommand = ($"SELECT * FROM items WHERE vendorID = {vendorID} AND Category = '{itemType}'"); DataTable ItemResults = DAL.ExecCommand(SQLCommand); ItemAmount = ItemResults.Rows.Count; #endregion Initiaizling Variables & DataTable #region Initiaizling Common Variables for Dynamic Controls //Size & Location Variables Size EmptySize = new Size(0, 0); Size PanelSize = new Size(678, 133); Size DescSize = new Size(434, 78); Size PicBoxSize = new Size(124, 97); Size ButtonSize = new Size(25, 31); Size TextBoxSize = new Size(29, 22); Point EmptyLoc = new Point(0, 0); Point TitleLoc = new Point(278, 10); Point DescLoc = new Point(141, 41); Point PriceLoc = new Point(594, 22); Point PicBoxLoc = new Point(6, 22); Point RemoveItemLoc = new Point(584, 53); Point ItemAmountLoc = new Point(609, 55); Point AddItemLoc = new Point(639, 53); Font TitleFont = new Font("Nirmala UI", 12, FontStyle.Regular); Font ButtonFont = new Font("Nirmala UI", 12, FontStyle.Bold); Font PriceFont = new Font("Nirmala UI", 14, FontStyle.Regular); Color BlackColour = Color.Black; Color WhiteColour = Color.White; Color TransparentColour = Color.Transparent; Color DimGrayColour = Color.DimGray; #endregion Initiaizling Common Variables for Dynamic Controls #region Iterating Through DataTable //Getting Data From Table & Creating Controls foreach (DataRow Item in ItemResults.Rows) { #region Getting Item Information ItemID = Item[0].ToString(); ItemName = Item[2].ToString(); ItemType = Item[3].ToString(); ItemDescription = Item[4].ToString(); ItemPrice = Item[5].ToString(); imageLoc = Item[6].ToString(); #endregion Getting Item Information #region Creating Dynamic Item Controls Panel ItemPanel = GenControls.AddPanel(ItemName, Color.White, PanelSize); Label TitleLabel = GenControls.AddLabel(ItemName + "Title", ItemName, TitleLoc, TitleFont, BlackColour, TransparentColour, EmptySize, true); Label DescLabel = GenControls.AddLabel(ItemName + "Desc", ItemDescription, DescLoc, TitleFont, Color.DarkGray, TransparentColour, DescSize, false); Label PriceLabel = GenControls.AddLabel(ItemName + "Price", "£" + ItemPrice, PriceLoc, PriceFont, Color.Maroon, Color.Transparent, EmptySize, true); Button RemoveButton = GenControls.AddButton(ItemName + "Remove", "-", RemoveItemLoc, ButtonFont, DimGrayColour, WhiteColour, ButtonSize, false); TextBox ItemAmountTBox = GenControls.AddTextBox(ItemName, "0", ItemID, ItemAmountLoc, TitleFont, BlackColour, WhiteColour, TextBoxSize); Button AddButton = GenControls.AddButton(ItemName + "Add", "+", AddItemLoc, ButtonFont, DimGrayColour, WhiteColour, ButtonSize, false); PictureBox ItemPictureBox = GenControls.AddPictureBox(ItemName, PicBoxLoc, PicBoxSize); ItemPictureBox.ImageLocation = ImageHandler.GetImage(ImageTypes.Item, imageLoc); #endregion Creating Dynamic Item Controls #region Adding to Form & Setting Event Handlers Control[] PanelControls = new Control[] { TitleLabel, DescLabel, PriceLabel, RemoveButton, ItemAmountTBox, AddButton, ItemPictureBox }; foreach (Control CurrentItemControl in PanelControls) { ItemPanel.Controls.Add(CurrentItemControl); } RemoveButton.Click += new EventHandler(ItemDecreased); AddButton.Click += new EventHandler(ItemIncreased); ItemAmountTBox.TextChanged += new EventHandler(ItemAmountChanged); ItemsFlowPanel.Controls.Add(ItemPanel); #endregion Adding to Form & Setting Event Handlers } #endregion Iterating Through DataTable }