private void Mnu_Metaldeck_Click(object sender, RoutedEventArgs e) { CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem; bool fieldready = false; if (carboGroup != null) { if (carboGroup.AllElements.Count > 0) { MessageBoxResult result = MessageBox.Show("To apply a profile decking to this item you need to trucate all elements", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { CarboLifeProject.PurgeElements(carboGroup); fieldready = true; } } else { fieldready = true; } if (fieldready == true) { ProfileWindow ProfileWindowWindow = new ProfileWindow(CarboLifeProject.CarboDatabase, carboGroup); ProfileWindowWindow.ShowDialog(); if (ProfileWindowWindow.isAccepted == true) { CarboLifeProject.AddGroup(ProfileWindowWindow.profileGroup); } } } SortData(); }
private void Dgv_Overview_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem; if (carboGroup != null) { TextBox t = e.EditingElement as TextBox; DataGridColumn dgc = e.Column; if (t != null) { //Corrections: if (dgc.Header.ToString() == "Correction") { string textExpression = t.Text; if (Utils.isValidExpression(textExpression) == true) { carboGroup.Correction = textExpression; CarboLifeProject.UpdateGroup(carboGroup); } } if (dgc.Header.ToString() == "Volume (m³)") { if (carboGroup.AllElements.Count > 0) { MessageBox.Show("Volume is based on Element Totals, Purge the elements before overriding the volume"); carboGroup.CalculateTotals(); btn_Calculate.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); } } } } }
public ReinforcementWindow(CarboDatabase materialDatabase, CarboGroup myConcreteGroup) { isAccepted = false; materials = materialDatabase; concreteGroup = myConcreteGroup; reinforcementGroup = new CarboGroup(); InitializeComponent(); }
private void Dgv_Overview_SelectionChanged(object sender, SelectionChangedEventArgs e) { CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem; if (carboGroup != null) { dgv_Elements.ItemsSource = carboGroup.AllElements; } }
public ProfileWindow(CarboDatabase materialDatabase, CarboGroup myConcreteGroup) { isAccepted = false; materials = materialDatabase; concreteGroup = myConcreteGroup; profileGroup = new CarboGroup(); profileGroup.Category = "Floor"; profileGroup.Description = "Metal deck / Profile"; InitializeComponent(); }
private void Mnu_DuplicateGroup_Click(object sender, RoutedEventArgs e) { CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem; if (carboGroup != null) { CarboLifeProject.DuplicateGroup(carboGroup); } SortData(); }
private void Mnu_Reinforce_Click(object sender, RoutedEventArgs e) { if (dgv_Overview.SelectedItems.Count > 0) { var selectedItems = dgv_Overview.SelectedItems; IList <CarboGroup> selectedGroups = new List <CarboGroup>(); // ... Add all Names to a List. foreach (var item in selectedItems) { CarboGroup cg = item as CarboGroup; selectedGroups.Add(cg); } CarboGroup bufferGroup = selectedGroups[0].Copy(); for (int i = 1; i <= (selectedGroups.Count - 1); i++) { CarboGroup carboGroupTemp = selectedGroups[i]; bufferGroup.Volume += carboGroupTemp.Volume; } if (bufferGroup != null) { ReinforcementWindow reinforementWindow = new ReinforcementWindow(CarboLifeProject.CarboDatabase, bufferGroup); reinforementWindow.ShowDialog(); if (reinforementWindow.isAccepted == true) { if (reinforementWindow.createNew == true) { CarboLifeProject.AddGroup(reinforementWindow.reinforcementGroup); } else { foreach (var item in selectedItems) { CarboGroup cg = item as CarboGroup; if (cg != null) { cg.Additional = reinforementWindow.addtionalValue; cg.AdditionalDescription = reinforementWindow.additionalDescription; } } } } } } CarboLifeProject.CalculateProject(); refreshData(); }
private void Btn_Delete_Click(object sender, RoutedEventArgs e) { CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem; if (carboGroup != null) { CarboLifeProject.DeleteGroup(carboGroup); } CarboLifeProject.CalculateProject(); refreshData(); }
private void refreshInterface() { CarboMaterial material = materials.GetExcactMatch(cbb_ReinforcementMaterial.Text); double volume = CarboLifeAPI.Utils.ConvertMeToDouble(txt_Volume.Text); double density = CarboLifeAPI.Utils.ConvertMeToDouble(txt_Density.Text); if (material != null && txt_Volume.Text != "" && txt_Density.Text != "") { reinforcementGroup = calculateRebar(material, reinforcementGroup, volume, density); txt_VolumeRebar.Text = reinforcementGroup.Volume.ToString(); txt_WeightRebar.Text = reinforcementGroup.Mass.ToString(); } }
private void Mnu_Reinforce_Click(object sender, RoutedEventArgs e) { CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem; if (carboGroup != null) { ReinforcementWindow reinforementWindow = new ReinforcementWindow(CarboLifeProject.CarboDatabase, carboGroup); reinforementWindow.ShowDialog(); if (reinforementWindow.isAccepted == true) { CarboLifeProject.AddGroup(reinforementWindow.reinforcementGroup); } } SortData(); }
private void Mnu_Metaldeck_Click(object sender, RoutedEventArgs e) { CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem; if (carboGroup != null) { ProfileWindow ProfileWindowWindow = new ProfileWindow(CarboLifeProject.CarboDatabase, carboGroup); ProfileWindowWindow.ShowDialog(); if (ProfileWindowWindow.isAccepted == true) { CarboLifeProject.AddGroup(ProfileWindowWindow.profileGroup); } } SortData(); }
private CarboGroup calculateRebar(CarboMaterial material, CarboGroup reinforcementGroup, double volume, double density) { double steelDensity = material.Density; double steelWeight = volume * density; double steelVolume = steelWeight / steelDensity; reinforcementGroup.Volume = steelVolume; reinforcementGroup.Mass = steelWeight; reinforcementGroup.SubCategory = ""; reinforcementGroup.Category = "Reinforcement"; reinforcementGroup.Material = material; reinforcementGroup.MaterialName = material.Name; reinforcementGroup.Density = material.Density; reinforcementGroup.ECI = material.ECI; reinforcementGroup.Description = "Reinforcement of: " + volume + "m³ " + "/ With: " + density + " kg/m³ Reinforcement"; return(reinforcementGroup); }
private void refreshInterface() { CarboMaterial material = materials.GetExcactMatch(cbb_ReinforcementMaterial.Text); double volume = CarboLifeAPI.Utils.ConvertMeToDouble(txt_Volume.Text); double density = CarboLifeAPI.Utils.ConvertMeToDouble(txt_Density.Text); if (material != null && txt_Volume.Text != "" && txt_Density.Text != "") { reinforcementGroup = calculateRebar(material, reinforcementGroup, volume, density); addtionalValue = calculateMixedMaterial(material, concreteGroup.Density, density); additionalDescription = reinforcementGroup.Description; txt_VolumeRebar.Text = reinforcementGroup.Volume.ToString(); txt_WeightRebar.Text = reinforcementGroup.Mass.ToString(); txt_MixResult.Text = Math.Round(addtionalValue, 3).ToString(); } }
private static string getTotalsRow(CarboGroup totalGroup) { string html = ""; html += "<TR>" + System.Environment.NewLine; html += "<TD width=" + 50 + "><B>" + "TOTAL" + "</B></TD>" + System.Environment.NewLine; html += "<TD width=" + 50 + "><B>" + "" + "</B></TD>" + System.Environment.NewLine; html += "<TD width=" + 50 + "><B>" + "" + "</B></TD>" + System.Environment.NewLine; html += "<TD width=" + 50 + "><B>" + "" + "</B></TD>" + System.Environment.NewLine; html += "<TD width=" + 50 + "><B>" + "" + "</B></TD>" + System.Environment.NewLine; html += "<TD width=" + 50 + "><B>" + "" + "</B></TD>" + System.Environment.NewLine; html += "<TD width=" + 50 + "><B>" + "" + "</B></TD>" + System.Environment.NewLine; html += "<TD width=" + 50 + "><B>" + totalGroup.EC + "</B></TD>" + System.Environment.NewLine; html += "<TD width=" + 50 + "><B>" + "100 %" + "</B></TD>" + System.Environment.NewLine; html += "</TR>" + System.Environment.NewLine; return(html); }
private void Mnu_PurgeElements_Click(object sender, RoutedEventArgs e) { CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem; if (carboGroup != null) { if (carboGroup.AllElements.Count > 0) { MessageBoxResult result = MessageBox.Show("Do you really want to remove all elements from this collection? This action is can NOT be undone", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Stop); if (result == MessageBoxResult.Yes) { CarboLifeProject.PurgeElements(carboGroup); } } else { MessageBoxResult result = MessageBox.Show("This collection contains no elements", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Stop); } } SortData(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string result = ""; double totalEC = 0; double totalPC = 0; try { var cvg = value as CollectionViewGroup; var field = parameter as string; if (cvg == null || field == null) { return(null); } for (int i = 0; i < cvg.ItemCount; i++) { // DataRowView dr = cvg.Items[i] as DataRowView; CarboGroup gr = cvg.Items[i] as CarboGroup; if (gr != null) { totalEC += gr.EC; totalPC += gr.PerCent; } } //Total: {0} tCO₂ string totECstr = Math.Round(totalEC, 4).ToString(); string totPerCstr = Math.Round(totalPC, 2).ToString(); result = totECstr + " tCO₂ / " + totPerCstr + " % "; } catch (Exception ex) { result = "error: " + ex.Message; } return(result); }
private void btn_EditAdvanced_Click(object sender, RoutedEventArgs e) { CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem; if (carboGroup != null) { GroupAdvancedEditor advancedEditor = new GroupAdvancedEditor(carboGroup, CarboLifeProject.CarboDatabase); advancedEditor.ShowDialog(); if (advancedEditor.isAccepted == true) { carboGroup = advancedEditor.group; } } else { MessageBox.Show("Please select a group"); } CarboLifeProject.CalculateProject(); refreshData(); }
private void Mnu_MergeGroup_Click(object sender, RoutedEventArgs e) { try { List <CarboGroup> selectedCarboGroupList = new List <CarboGroup>(); selectedCarboGroupList = dgv_Overview.SelectedItems.Cast <CarboGroup>().ToList(); if (selectedCarboGroupList != null && selectedCarboGroupList.Count > 1) { CarboGroup FirstCarboGroup = selectedCarboGroupList[0]; CarboGroup mergedCarboGroup = FirstCarboGroup.Copy(); mergedCarboGroup.AllElements = new List <CarboElement>(); foreach (CarboGroup gc in selectedCarboGroupList) { if (gc.AllElements.Count > 0) { foreach (CarboElement ce in gc.AllElements) { mergedCarboGroup.AllElements.Add(ce); } } } CarboLifeProject.AddGroup(mergedCarboGroup); foreach (CarboGroup cg in selectedCarboGroupList) { CarboLifeProject.DeleteGroup(cg); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButton.OK); } }
private void Btn_Material_Click(object sender, RoutedEventArgs e) { CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem; if (carboGroup != null) { MaterialEditor materialEditor = new MaterialEditor(carboGroup.Material.Name, CarboLifeProject.CarboDatabase); materialEditor.ShowDialog(); if (materialEditor.acceptNew == true) { CarboLifeProject.CarboDatabase = materialEditor.returnedDatabase; CarboLifeProject.UpdateMaterial(carboGroup, materialEditor.selectedMaterial); /* * carboGroup.Material = materialEditor.selectedMaterial; * carboGroup.MaterialName = materialEditor.selectedMaterial.Name; */ } } CarboLifeProject.CalculateProject(); refreshData(); }
private void Dgv_Overview_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (dgv_Overview != null) { CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem; if (carboGroup != null) { TextBox t = e.EditingElement as TextBox; DataGridColumn dgc = e.Column; if (t != null) { //Corrections: if (dgc.Header.ToString().StartsWith("Correction")) { string textExpression = t.Text; if (Utils.isValidExpression(textExpression) == true) { carboGroup.Correction = textExpression; carboGroup.CalculateTotals(); CarboLifeProject.UpdateGroup(carboGroup); } else { carboGroup.Correction = ""; carboGroup.CalculateTotals(); CarboLifeProject.UpdateGroup(carboGroup); } } if (dgc.Header.ToString().StartsWith("Volume")) { if (carboGroup.AllElements.Count > 0) { MessageBox.Show("The volume of this group is calculated using the element volumes extracted from the 3D model," + Environment.NewLine + " you need to purge the elements before overriding the volume"); carboGroup.CalculateTotals(); CarboLifeProject.UpdateGroup(carboGroup); //System.Threading.Thread.Sleep(500); //Calculate(); } else { double volumeEdit = Utils.ConvertMeToDouble(t.Text); if (volumeEdit != 0) { carboGroup.Volume = volumeEdit; carboGroup.CalculateTotals(); CarboLifeProject.UpdateGroup(carboGroup); //carboGroup.CalculateTotals(); } } } //Waste //Corrections: if (dgc.Header.ToString().StartsWith("Waste")) { double wastevalue = Utils.ConvertMeToDouble(t.Text); if (wastevalue != 0) { carboGroup.Waste = wastevalue; carboGroup.CalculateTotals(); CarboLifeProject.UpdateGroup(carboGroup); //carboGroup.CalculateTotals(); } } //Additional: if (dgc.Header.ToString().StartsWith("Additional")) { double additional = Utils.ConvertMeToDouble(t.Text); if (additional != 0) { carboGroup.Additional = additional; carboGroup.CalculateTotals(); CarboLifeProject.UpdateGroup(carboGroup); //carboGroup.CalculateTotals(); } } //B4: if (dgc.Header.ToString().StartsWith("Group")) { double b4 = Utils.ConvertMeToDouble(t.Text); if (b4 != 0) { carboGroup.B4Factor = b4; carboGroup.CalculateTotals(); CarboLifeProject.UpdateGroup(carboGroup); //carboGroup.CalculateTotals(); } } //The below triggers an error when switching cells too fast, no idea why need to resolve. //dgv_Overview.ItemsSource = null; //dgv_Overview.ItemsSource = CarboLifeProject.getGroupList; //SortData(); } } } }
private void Mnu_MoveToNewGroup_Click(object sender, RoutedEventArgs e) { //IList<DataGridCellInfo> selectedElementList = dgv_Elements.SelectedCells; try { List <CarboElement> selectedCarboElementList = new List <CarboElement>(); selectedCarboElementList = dgv_Elements.SelectedItems.Cast <CarboElement>().ToList(); if (selectedCarboElementList.Count > 0) { CarboGroup selectedCarboGroup = (CarboGroup)dgv_Overview.SelectedItem; int carbogroupId = selectedCarboGroup.Id; List <CarboElement> allCarboElementList = selectedCarboGroup.AllElements; CarboGroup newGroup = new CarboGroup(); newGroup.AllElements = selectedCarboElementList; newGroup.Category = selectedCarboGroup.Category; newGroup.SubCategory = selectedCarboGroup.SubCategory; newGroup.Description = "A new Group"; newGroup.Material = allCarboElementList[0].Material; newGroup.MaterialName = allCarboElementList[0].MaterialName; int delcounter = 0; foreach (CarboElement ce in selectedCarboElementList) { for (int i = 0; i >= 0; i--) { CarboElement oldce = allCarboElementList[i]; if (ce.Id == oldce.Id) { allCarboElementList.RemoveAt(i); delcounter++; } } } //Now there should be two lists, one with the selcted items and one without. foreach (CarboGroup cg in CarboLifeProject.getGroupList) { if (cg.Id == carbogroupId) { cg.AllElements = allCarboElementList; } } CarboLifeProject.AddGroup(newGroup); MessageBox.Show(delcounter + " Elements moved to new group", "Warning", MessageBoxButton.OK); CarboLifeProject.CalculateProject(); refreshData(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButton.OK); } //List<CarboElement> selectedElement = dgv_Elements.SelectedCells; }
private void btn_OpenMaterialEditor_Click(object sender, RoutedEventArgs e) { try { //Check if a group has been selected: CarboGroup PotentialSelectedCarboGroup = new CarboGroup(); PotentialSelectedCarboGroup.MaterialName = ""; if (dgv_Overview.SelectedItems.Count > 0) { var selectedItems = dgv_Overview.SelectedItems; IList <CarboGroup> selectedGroups = new List <CarboGroup>(); // ... Add all Names to a List. foreach (var item in selectedItems) { CarboGroup cg = item as CarboGroup; if (cg != null) { selectedGroups.Add(cg); } } if (selectedGroups.Count > 0) { PotentialSelectedCarboGroup = selectedGroups[0]; } } if (CarboLifeProject.CarboDatabase.CarboMaterialList.Count > 0) { CarboMaterial carbomat = CarboLifeProject.CarboDatabase.CarboMaterialList[0]; if (PotentialSelectedCarboGroup.MaterialName != "") { //A group with a valid material was selected carbomat = PotentialSelectedCarboGroup.Material; } if (carbomat == null) { carbomat = new CarboMaterial(); } MaterialEditor materialEditor = new MaterialEditor(carbomat.Name, CarboLifeProject.CarboDatabase); materialEditor.ShowDialog(); if (materialEditor.acceptNew == true) { CarboLifeProject.CarboDatabase = materialEditor.returnedDatabase; CarboLifeProject.UpdateAllMaterials(); } } else { MessageBox.Show("There were no materials found in the project, please re-create your project"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } CarboLifeProject.CalculateProject(); refreshData(); }
private void Btn_Material_Click(object sender, RoutedEventArgs e) { /* * if (dgv_Overview.SelectedItems.Count > 0) * { * try * { * var selectedItems = dgv_Overview.SelectedItems; * IList<CarboGroup> selectedGroups = new List<CarboGroup>(); * * // ... Add all Names to a List. * foreach (var item in selectedItems) * { * CarboGroup cg = item as CarboGroup; * selectedGroups.Add(cg); * } * * if (selectedGroups.Count > 0) * { * CarboGroup carboGroup = selectedGroups[0]; * * MaterialEditor materialEditor = new MaterialEditor(carboGroup.Material.Name, CarboLifeProject.CarboDatabase); * materialEditor.ShowDialog(); * * if (materialEditor.acceptNew == true) * { * CarboLifeProject.CarboDatabase = materialEditor.returnedDatabase; * * foreach (CarboGroup cg in selectedGroups) * { * CarboLifeProject.UpdateMaterial(cg, materialEditor.selectedMaterial); * } * CarboLifeProject.UpdateAllMaterials(); * } * } * } * catch(Exception ex) * { * MessageBox.Show(ex.Message); * } * } */ if (dgv_Overview.SelectedItems.Count > 0) { try { //Select all the groups var selectedItems = dgv_Overview.SelectedItems; IList <CarboGroup> selectedGroups = new List <CarboGroup>(); // ... Add all Names to a List. foreach (var item in selectedItems) { CarboGroup cg = item as CarboGroup; selectedGroups.Add(cg); } if (selectedGroups.Count > 0) { CarboGroup carboGroup = selectedGroups[0]; MaterialSelector materialEditor = new MaterialSelector(carboGroup.Material.Name, CarboLifeProject.CarboDatabase); materialEditor.ShowDialog(); //If okay change the materials and re-calculate project if (materialEditor.isAccepted == true) { foreach (CarboGroup cg in selectedGroups) { CarboLifeProject.UpdateMaterial(cg, materialEditor.selectedMaterial); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } CarboLifeProject.CalculateProject(); refreshData(); }
public GroupAdvancedEditor(CarboGroup carboGroup, CarboDatabase dataBase) { this.group = carboGroup; this.database = dataBase; InitializeComponent(); }
private void Mnu_MoveToNewGroup_Click(object sender, RoutedEventArgs e) { //IList<DataGridCellInfo> selectedElementList = dgv_Elements.SelectedCells; try { List <CarboElement> selectedCarboElementList = new List <CarboElement>(); selectedCarboElementList = dgv_Elements.SelectedItems.Cast <CarboElement>().ToList(); if (selectedCarboElementList.Count > 0) { CarboGroup selectedCarboGroup = (CarboGroup)dgv_Overview.SelectedItem; //Reset all findme flags. CarboLifeProject.ResetElementFlags(); //Flag the elements that require updating foreach (CarboElement ce in selectedCarboElementList) { ce.isUpdated = true; } int carbogroupId = selectedCarboGroup.Id; List <CarboElement> allCarboElementList = selectedCarboGroup.AllElements; CarboGroup newGroup = selectedCarboGroup.Copy(); //move all elements to the new group newGroup.AllElements = selectedCarboElementList; newGroup.Description = "A new Group"; int delcounter = 0; //remove the old ones from the list foreach (CarboElement ce in selectedCarboElementList) { for (int i = 0; i >= 0; i--) { CarboElement oldce = allCarboElementList[i]; if (oldce.isUpdated == true) { allCarboElementList.RemoveAt(i); delcounter++; } } } //Now there should be two lists, one with the selcted items and one without. foreach (CarboGroup cg in CarboLifeProject.getGroupList) { if (cg.Id == carbogroupId) { cg.AllElements = allCarboElementList; } } CarboLifeProject.AddGroup(newGroup); MessageBox.Show(delcounter + " Elements moved to new group", "Message", MessageBoxButton.OK); CarboLifeProject.CalculateProject(); refreshData(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButton.OK); } //List<CarboElement> selectedElement = dgv_Elements.SelectedCells; }