private void DeleteColumnPrompt(object sender, MouseButtonEventArgs e) { ErrorBannerUpdater(""); try { string[] SourceSplitTypexName = e.Source.ToString().Split(':'); if (SourceSplitTypexName[0] == "System.Windows.Controls.TextBox" && e.Source.ToString().Contains(":")) { int selectedNameIndex = Convert.ToInt32(SourceSplitTypexName[1].Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None)[0].Split(new string[] { "option" }, StringSplitOptions.None)[1]); string selectedName = "option" + selectedNameIndex; for (int i = 0; i < VisualTreeHelper.GetChildrenCount(Container); i++) { Visual childVisual = (Visual)VisualTreeHelper.GetChild(Container, i); if (childVisual is TextBox) { if (childVisual.ToString().Contains(selectedName)) { if (MessageBox.Show("Do you want to delete " + selectedName, "Delete Option Prompt", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { Container.Children.RemoveAt(i); AllColumnsArr.RemoveAt(i); DeletedColumnCount++; // CurrentColumnValues.windowArray[0].RemoveAt(i + 1); // CurrentColumnValues.windowArray[1].RemoveAt(i + 1); // CurrentColumnValues.windowArray[2].RemoveAt(i + 1); } break; } } } if (Count - DeletedColumnCount < 10) { Upload.IsEnabled = true; } } } catch (Exception exception) { Console.WriteLine("Unexpected Error --- " + exception); ErrorBannerUpdater("Cannot Delete, if reproduceable please send xml and reproduction steps to IT."); } }
private void UploadXMLClicked(object sender, RoutedEventArgs e) { ErrorBannerUpdater(""); //uploads an xml file foreach (var doc in new UploadXML().doc) { //generates the header only once if (Count - DeletedColumnCount < 1) { try { Header = new HeaderGenerator(doc).HeaderToString; } catch (Exception exception) { Console.WriteLine(exception); ErrorBannerUpdater("Did you upload the CBECC XML? The takeoff XML is invalid!"); return; } } // gets usefull values then returns those in an array. var currentColumnArr = new List <string>(); try { currentColumnArr = new CurrentColumnValues(doc).currentColumnValuesArr; } catch (Exception exception) { string corruptedFileName = Convert.ToString(doc) .Split(new [] { "<ModelFile>" }, StringSplitOptions.None)[1] .Split(new [] { "</ModelFile>" }, StringSplitOptions.None)[0]; ErrorBannerUpdater($"Cannot Upload File {corruptedFileName}, Please send it to IT. "); Console.WriteLine("Invalid XML --- " + exception); continue; } //Adds current xml to an array containing all of them [currentColumnArr][Values] AllColumnsArr.Add(currentColumnArr); //WPF App - Adds a column as xml uploaded for visual representation WPFColumnUpdater(currentColumnArr); //this.Count++ Count++; if (Count - DeletedColumnCount >= 10) { Console.WriteLine("Limit reached - " + Count); ErrorBannerUpdater("Limit reached (10) - Will increase to 15 in the future"); Upload.IsEnabled = false; break; } } }