private void buttonPrintLabels_Click(object sender, EventArgs e) { IList<PatientData> toPrintPatients = new List<PatientData>(); int topBorder; int leftBorder; int noOfColumns; int noOfRows; int startingRow; int labelFontSize; try { topBorder = Int32.Parse(textBoxTopBorder.Text); } catch(FormatException) { MessageBox.Show("TopBorder has a wrong Format!"); return; } try { leftBorder = Int32.Parse(textBoxLeftBorder.Text); } catch(FormatException) { MessageBox.Show("LeftBorder has a wrong Format!"); return; } try { noOfColumns = Int32.Parse(textBoxNumberOfColumns.Text); } catch(FormatException) { MessageBox.Show("Number Of Columns has a wrong Format!"); return; } try { noOfRows = Int32.Parse(textBoxNumberOfRows.Text); } catch(FormatException) { MessageBox.Show("Number Of Rows has a wrong Format!"); return; } try { startingRow = Int32.Parse(textBoxStartingRow.Text); } catch(FormatException) { MessageBox.Show("Starting Row has a wrong Format!"); return; } try { labelFontSize = Int32.Parse(textBoxLabelFontSize.Text); } catch(FormatException) { MessageBox.Show("Label Font Size has a wrong Format!"); return; } if(topBorder < 0) { MessageBox.Show("Top Border has to be positive"); return; } if(leftBorder < 0) { MessageBox.Show("Left Border has to be positive"); return; } if(noOfColumns < 1 || noOfColumns > 8) { MessageBox.Show("The number of Columns has to be between 1 and 8"); return; } if(noOfRows < 1 || noOfColumns > 30) { MessageBox.Show("The number of Rows has to be between 1 and 30"); return; } if(startingRow < 1 || startingRow >= noOfRows) { MessageBox.Show("The Starting Row has to be between 1 and the number of Rows -1"); return; } if(labelFontSize < 4 || labelFontSize > 30) { MessageBox.Show("The Label Font Size has to be between 4 and 30"); return; } List<long> pIds = new List<long>(); foreach(ListViewItem item in listViewAllPatients.SelectedItems) { pIds.Add(Int64.Parse(item.Text)); } toPrintPatients = this.patComp.FindPatientByIds(pIds); if(toPrintPatients.Count <= 0) { MessageBox.Show("No patients selected!\nPlease select one or more Patients to print"); return; } SPD.GUI.Properties.Settings.Default.TopBorder = topBorder; SPD.GUI.Properties.Settings.Default.LeftBorder = leftBorder; SPD.GUI.Properties.Settings.Default.NoOfColumns = noOfColumns; SPD.GUI.Properties.Settings.Default.NoOfRows = noOfRows; SPD.GUI.Properties.Settings.Default.LabelFontSize = labelFontSize; SPD.GUI.Properties.Settings.Default.Save(); SPDPrint print = new SPDPrint(this.patComp); print.PrintLabels(topBorder, leftBorder, noOfColumns, noOfRows, startingRow, labelFontSize, toPrintPatients); }