private void undoRemovePaperFromCheckout() { if (checkoutPapersCollection.count() == 0) { MessageBox.Show("Nu exista ziare care sa poata fi sterse."); } checkoutPapersCollection.removeLast(); PaperStruct paperStruct = checkoutPapersCollection.getLastElement(); if (paperStruct != null) { lastPaperNameLabel.Text = paperStruct.nume; if (paperStruct.includeAddon) { lastPaperNameLabel.Text += " (cu CD/carte)"; } } else { lastPaperNameLabel.Text = "Niciun ziar adaugat"; } }
public void add(PaperStruct paperStruct) { // vreau ca acel scrollbar sa apara mereu acolo (altfel se ingusteaza panel-ul cand sunt prea putine elemente) ShowScrollBar(this.Handle, 1, true); Panel p = new Panel(); p.Width = this.Width - 20; p.Height = 60; p.Location = new Point(0, paperListElems.Count * (p.Height + 10)); p.BackColor = Color.FromArgb(219, 213, 110); // -- label (titlu) Label titleLabel = new Label(); titleLabel.Text = paperStruct.nume; titleLabel.Location = new Point(10, 10); titleLabel.Font = new Font("Calibri", 12); titleLabel.AutoSize = true; titleLabel.MaximumSize = new Size(p.Width - titleLabel.Location.X - 60, 0); titleLabel.Click += (sender, e) => P_Click(sender, e, paperStruct, p); p.Click += (sender, e) => P_Click(sender, e, paperStruct, p); p.Controls.Add(titleLabel); // -- optiuni Panel p2 = new Panel(); p2.Width = (int)(p.Width / 3.4); p2.Height = (int)(p.Height / 2.5); p2.Location = new Point(p.Width - 60, 10); p2.BorderStyle = BorderStyle.FixedSingle; CheckBox ch1 = new CheckBox(); ch1.Text = "cu CD / carte"; ch1.AutoSize = false; ch1.Font = new Font("Calibri", 8); ch1.MaximumSize = new Size(70, 100); ch1.MinimumSize = new Size(30, 70); ch1.Click += (sender, e) => Ch1_Click(sender, e, paperStruct); ch1.Location = new Point(p2.Width / 2 - ch1.Width / 2 + 10, p2.Height / 2 - ch1.Height / 2); p2.Controls.Add(ch1); p.Controls.Add(p2); Controls.Add(p); paperListElems.Add(p); }
private void Ch1_Click(object sender, EventArgs e, PaperStruct paperStruct) { if (((CheckBox)sender).Checked) { paperStruct.includeAddon = true; } else { paperStruct.includeAddon = false; } }
private void P_Click(object sender, EventArgs e, PaperStruct paperStruct, Panel sourcePanel) { addPaperToCheckout(paperStruct); // mica animatie pt click pe adaugare ziar Timer t1 = new Timer(); sourcePanel.BackColor = Color.FromArgb(249, 243, 140); t1.Interval = 100; t1.Tick += (sender2, e2) => T1_Tick(sender2, e2, sourcePanel, t1); t1.Start(); }
private void addPaperToCheckout(PaperStruct paperStruct) { // copie deep a obiectului using (MemoryStream memoryStream = new MemoryStream()) { var binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memoryStream, paperStruct); memoryStream.Position = 0; checkoutPapersCollection.add((PaperStruct)binaryFormatter.Deserialize(memoryStream)); } lastPaperNameLabel.Text = paperStruct.nume; if (paperStruct.includeAddon) { lastPaperNameLabel.Text += " (cu CD/carte)"; } }
private void loadData() { xmlDoc = new XmlDocument(); xmlDoc.Load("ziare.xml"); availablePapers = xmlDoc.SelectNodes("/cifre-difuzare/publicatii/publicatie[cifre/total_vanzari >= 15000]"); foreach (XmlNode paper in availablePapers) { PaperStruct paperStruct = new PaperStruct().withNume(paper["nume"].InnerText) .withEditor(paper["editor"].InnerText) .withCategorie(paper["categorie"].InnerText) .withPeriodicitate(paper["periodicitate"].InnerText) .withArie(paper["arie"].InnerText) .withTirajBrut(int.Parse(paper["cifre"]["tiraj_brut"].InnerText)) .withTotalVanzari(int.Parse(paper["cifre"]["total_vanzari"].InnerText)) .withTotalDifuzat(int.Parse(paper["cifre"]["total_difuzat"].InnerText)) .withSursa(paper["cifre"]["sursa"].InnerText) .withPretSimplu(paper["cifre"]["pret_simplu"] == null ? 0 : double.Parse(paper["cifre"]["pret_simplu"].InnerText)) .withPretAddon(paper["cifre"]["pret_addon"] == null ? 0 : double.Parse(paper["cifre"]["pret_addon"].InnerText)); availablePapersCollection.add(paperStruct); } }
public void remove(PaperStruct paperStruct) { papersList.Remove(paperStruct); }
public void add(PaperStruct paperStruct) { papersList.Add(paperStruct); }