/// <summary> /// With the click of the "Kursplan Generieren" button, this function will be called /// It will call a window, where you could give the stored place of the pdfs and the grades you want to export /// </summary> public void btnCreatePlan_Click(Office.IRibbonControl ctrl) { Excel.Worksheet noteBoard = Globals.ThisAddIn.Application.ActiveSheet; //check if the course plan is imported bool allRight = true; //If the course plan is not imported if (_coursePlan == null) { allRight = false; MessageBox.Show("Der Kursplan existiert nicht.\r\nImportieren Sie zuerst den Kursplan und versuchen nochmal.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } string[] datesStrings = new string[2]; //Test if the note board is not right try { var datesCell = noteBoard.get_Range("I1", Type.Missing).Value2; datesStrings = datesCell.Split('~'); //If the length of the datesString does not fit if (datesStrings.Length != 3) { allRight = false; MessageBox.Show("Die Bemerkungsbogen ist beschädigt oder existert nicht\r\nSind Sie vielleicht auf falscher Seite?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (FormatException Fe) { System.Diagnostics.Debug.WriteLine(Fe); allRight = false; MessageBox.Show("Die Bemerkungsbogen ist beschädigt oder existert nicht\r\nSind Sie vielleicht auf falscher Seite?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (RuntimeBinderException Re) { System.Diagnostics.Debug.WriteLine(Re); MessageBox.Show("Die Bemerkungsbogen ist beschädigt oder existert nicht\r\nSind Sie vielleicht auf falscher Seite?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); allRight = false; } if (allRight) { DateTime[] periods = new DateTime[3]; foreach (string s in datesStrings) { periods[Array.IndexOf(datesStrings, s)] = DateTime.ParseExact(s, "dd-MM-yyyy", new CultureInfo("de-DE")); } using (FormForGeneratingPlans form = new FormForGeneratingPlans(noteBoard, periods, _coursePlan)) form.ShowDialog(); } }
public FormProgress(FormForGeneratingPlans mForm, int maximalLength) { InitializeComponent(); this.ProgressBar.Maximum = maximalLength; mainForm = mForm; }