private void ContextMenuCopyButton_Click(object sender, RoutedEventArgs e) { if (AudiencesList.SelectedItems != null) { foreach (SchoolAudience item in AudiencesList.SelectedItems) { var audience = new SchoolAudience(item.Name, item.AudienceType, item.Capacity); SchoolAudienceDict.dictionaryList.Add(audience); AudiencesList.Items.Add(audience); } } }
public void Add_Click(object sender, RoutedEventArgs e) { if (!IsWrongTextBoxValue()) { var OwnerWindowInstance = this.Owner as AudiencesWindow; var audience = new SchoolAudience(NameTextBox.Text, AudienceTypeTextBox.Text, int.Parse(CapacityTextBox.Text)); OwnerWindowInstance.SchoolAudienceDict.dictionaryList.Add(audience); OwnerWindowInstance.AudiencesList.Items.Add(audience); ((Owner as AudiencesWindow).Owner as EditorWindow).HomePage.AudiencesIndicator.Fill = ColorPalette.GetPredefinedColor(PredefinedColors.Green); ElementsModification.ResetControlText <TextBox>(this); } }
private void ImportExcel_Click(object sender, RoutedEventArgs e) { string[,] data = ExcelFileTools.UploadExcelData(); // HACK: Change Length Checker if (data?.GetLength(1) >= ElementsModification.FindVisualChildren <GridViewColumnHeader>(this).Count() - 2) { for (int i = 0; i < data.GetLength(0); i++) { int.TryParse(data[i, 2], out int capacity); var audience = new SchoolAudience(data[i, 0], data[i, 1], capacity); SchoolAudienceDict.dictionaryList.Add(audience); AudiencesList.Items.Add(audience); } (Owner as EditorWindow).HomePage.AudiencesIndicator.Fill = ColorPalette.GetPredefinedColor(PredefinedColors.Green); } else if (data?.GetLength(1) < ElementsModification.FindVisualChildren <GridViewColumnHeader>(this).Count() - 2) { MessageBox.Show("Wrong Columns Format"); } }