public void EditMaterial(MaterialDataPanel caller) { var calling = new EditMaterial(Connector.connections[0].GetMaterial(materials[panel1.Controls.IndexOf(caller)].ID), this) { Anchor = AnchorStyles.Top | AnchorStyles.Bottom }; calling.Size = this.Size; this.Controls.Add(calling); calling.BringToFront(); }
async void Initialize() { searched = false; pictureBox1.Visible = true; panel1.Enabled = false; panel1.Controls.Clear(); materialdatas.Clear(); panel1.SuspendLayout(); await Task.Run(() => { if (materials.Count >= 7) { for (int i = 0; i < materials.Count; i++) { MaterialDataPanel panel = new MaterialDataPanel(this); panel.Dock = DockStyle.Top; panel.namelb.Text = materials[i].Name; panel.secnolb.Text += materials[i].NumberOfSections; panel.pagenolb.Text += materials[i].NumberOfBooks; panel.lecnolb.Text += materials[i].NumberOfLectures; panel.Width = 764; materialdatas.Add(panel); } } else { for (int i = 0; i < materials.Count; i++) { var panel = new MaterialDataPanel(this); panel.Dock = DockStyle.Top; panel.namelb.Text = materials[i].Name; panel.secnolb.Text += materials[i].NumberOfSections; panel.pagenolb.Text += materials[i].NumberOfBooks; panel.lecnolb.Text += materials[i].NumberOfLectures; panel.Width = 781; materialdatas.Add(panel); } } }); panel1.Controls.AddRange(materialdatas.ToArray()); panel1.ResumeLayout(); pictureBox1.Visible = false; panel1.Enabled = true; }
void SearchInitialize(string Name) { searched = true; pictureBox1.Visible = true; panel1.Enabled = false; searchmaterials = Task.Run(() => Connector.connections[0].SearchMaterials(Name)).Result; panel1.Controls.Clear(); materialdatas.Clear(); panel1.SuspendLayout(); Task.Run(() => { if (searchmaterials.Count >= 7) { for (int i = 0; i < searchmaterials.Count; i++) { var panel = new MaterialDataPanel(this); panel.Dock = DockStyle.Top; panel.namelb.Text = searchmaterials[i].Name; panel.secnolb.Text += searchmaterials[i].NumberOfSections; panel.pagenolb.Text += searchmaterials[i].NumberOfBooks; panel.lecnolb.Text += searchmaterials[i].NumberOfLectures; panel.Width = 764; materialdatas.Add(panel); } } else { for (int i = 0; i < searchmaterials.Count; i++) { var panel = new MaterialDataPanel(this); panel.Dock = DockStyle.Top; panel.namelb.Text = searchmaterials[i].Name; panel.secnolb.Text += searchmaterials[i].NumberOfSections; panel.pagenolb.Text += searchmaterials[i].NumberOfBooks; panel.lecnolb.Text += searchmaterials[i].NumberOfLectures; panel.Width = 781; materialdatas.Add(panel); } } }).Wait(); panel1.Controls.AddRange(materialdatas.ToArray()); panel1.ResumeLayout(); pictureBox1.Visible = false; panel1.Enabled = true; }