public void EditBook(BooksDataPanel caller) { var calling = new EditBooks(Connector.connections[0].GetBook(books[panel1.Controls.IndexOf(caller)].Id), this) { Anchor = AnchorStyles.Top | AnchorStyles.Bottom }; calling.Size = this.Size; this.Controls.Add(calling); calling.BringToFront(); }
void SearchInitialize(string Name) { searched = true; pictureBox1.Visible = true; panel1.Enabled = false; searchbooks = Task.Run(() => Connector.connections[0].SearchBooks(Name)).Result; panel1.Controls.Clear(); booksdatas.Clear(); panel1.SuspendLayout(); Task.Run(() => { if (searchbooks.Count >= 7) { for (int i = 0; i < searchbooks.Count; i++) { BooksDataPanel panel = new BooksDataPanel(this); panel.Dock = DockStyle.Top; panel.namelb.Text = searchbooks[i].Name; panel.publisher.Text = searchbooks[i].Publisher; panel.author.Text = (searchbooks[i].Authors.Count != 0) ? searchbooks[i].Authors[0] : "UnKnown Author"; panel.chapternolb.Text += searchbooks[i].ChapterCount; panel.pagenolb.Text += searchbooks[i].PageCount; panel.datelb.Text += searchbooks[i].Date; panel.Width = 764; booksdatas.Add(panel); } } else { for (int i = 0; i < searchbooks.Count; i++) { var panel = new BooksDataPanel(this); panel.Dock = DockStyle.Top; panel.namelb.Text = searchbooks[i].Name; panel.publisher.Text = searchbooks[i].Publisher; panel.author.Text = (searchbooks[i].Authors.Count != 0) ? searchbooks[i].Authors[0] : "UnKnown Author"; panel.chapternolb.Text += searchbooks[i].ChapterCount; panel.pagenolb.Text += searchbooks[i].PageCount; panel.datelb.Text += searchbooks[i].Date; panel.Width = 781; booksdatas.Add(panel); } } }).Wait(); panel1.Controls.AddRange(booksdatas.ToArray()); panel1.ResumeLayout(); pictureBox1.Visible = false; panel1.Enabled = true; }
async void Initialize() { searched = false; panel1.Controls.Clear(); booksdatas.Clear(); panel1.SuspendLayout(); await Task.Run(() => { if (books.Count >= 7) { for (int i = 0; i < books.Count; i++) { BooksDataPanel panel = new BooksDataPanel(this); panel.Dock = DockStyle.Top; panel.namelb.Text = books[i].Name; panel.publisher.Text = books[i].Publisher; panel.author.Text = (books[i].Authors.Count != 0) ? books[i].Authors[0] : "UnKnown Author"; panel.chapternolb.Text += books[i].ChapterCount; panel.pagenolb.Text += books[i].PageCount; panel.datelb.Text += books[i].Date; panel.Width = 764; booksdatas.Add(panel); } } else { for (int i = 0; i < books.Count; i++) { var panel = new BooksDataPanel(this); panel.Dock = DockStyle.Top; panel.namelb.Text = books[i].Name; panel.publisher.Text = books[i].Publisher; panel.author.Text = (books[i].Authors.Count != 0) ? books[i].Authors[0] : "UnKnown Author"; panel.chapternolb.Text += books[i].ChapterCount; panel.pagenolb.Text += books[i].PageCount; panel.datelb.Text += books[i].Date; panel.Width = 781; booksdatas.Add(panel); } } }); panel1.Controls.AddRange(booksdatas.ToArray()); panel1.ResumeLayout(); }