private void pnlMain_ControlAdded(object sender, ControlEventArgs e) { int lastCnt = this.pnlMain.Controls.Count - 1; FileSection c = e.Control as FileSection; if (lastCnt > 0) { int cntPerRow = Convert.ToInt32(Math.Floor((double)(this.pnlMain.Width - c.Margin.Left) / (c.Width + c.Margin.Right))); int fittableWidth = cntPerRow * c.Width + (cntPerRow + 1) * c.Margin.Left; } }
private void pnlMain_DragDrop(object sender, DragEventArgs e) { if (e.Data != null) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { this.files = ((string[])e.Data.GetData(DataFormats.FileDrop)).ToList(); if (this.files.Count > 0) { for (int i = 0; i < this.files.Count; i++) { string path = files[i]; FileSection section = new FileSection(path); this.pnlMain.Controls.Add(section); } } } } }