private void CreateInitialSelectors() { panel1.AutoScroll = true; panel1.FlowDirection = FlowDirection.TopDown; panel1.WrapContents = false; var selector = new PdfSelectorControl(1); selector.RemoveFile += Selector_RemoveFile; panel1.Controls.Add(selector); var selector2 = new PdfSelectorControl(2); selector2.RemoveFile += Selector_RemoveFile; panel1.Controls.Add(selector2); saveControl = new SaveOutputSelectorControl((val) => richConsole.AppendText(val)); panel1.Controls.Add(saveControl); addMoreFiles = new Button() { Margin = new Padding(12, 0, 0, 0), Width = 518, Text = "Add more files", Visible = true }; addMoreFiles.Click += AddMoreFiles_Click; panel1.Controls.Add(addMoreFiles); }
private void FillOrAddFile(string file) { PdfSelectorControl lastEmptyPdfSelector = GetFirstEmptyPDFSelector(); if (lastEmptyPdfSelector == null) { AddMoreFiles_Click(null, null); lastEmptyPdfSelector = GetFirstEmptyPDFSelector(); } lastEmptyPdfSelector.SetFileName(file); }
private void AddMoreFiles_Click(object sender, EventArgs e) { var selectorX = new PdfSelectorControl(panel1.Controls.Count - 1) { Width = panel1.Width - 50 }; panel1.Controls.Add(selectorX); //Adding again will make it stick to bottom panel1.Controls.Add(saveControl); panel1.Controls.Add(addMoreFiles); }
private void AddMoreFiles(bool selectFile = false) { var selectorX = new PdfSelectorControl(panel1.Controls.Count - 1) { Width = panel1.Width - 50 }; selectorX.RemoveFile += Selector_RemoveFile; panel1.Controls.Add(selectorX); //Adding again will make it stick to bottom panel1.Controls.Add(saveControl); panel1.Controls.Add(addMoreFiles); if (selectFile) { selectorX.OpenFileSelection(); } }
private PdfSelectorControl GetFirstEmptyPDFSelector() { PdfSelectorControl result = null; foreach (Control control in panel1.Controls) { if (control.GetType().Name.Equals("PdfSelectorControl")) { result = (PdfSelectorControl)control; if (string.IsNullOrEmpty(result.FileName)) { break; } else { result = null; } } } return(result); }