Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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));
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 public ReinforcementWindow(CarboDatabase materialDatabase, CarboGroup myConcreteGroup)
 {
     isAccepted         = false;
     materials          = materialDatabase;
     concreteGroup      = myConcreteGroup;
     reinforcementGroup = new CarboGroup();
     InitializeComponent();
 }
Exemplo n.º 4
0
        private void Dgv_Overview_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem;

            if (carboGroup != null)
            {
                dgv_Elements.ItemsSource = carboGroup.AllElements;
            }
        }
Exemplo n.º 5
0
 public ProfileWindow(CarboDatabase materialDatabase, CarboGroup myConcreteGroup)
 {
     isAccepted               = false;
     materials                = materialDatabase;
     concreteGroup            = myConcreteGroup;
     profileGroup             = new CarboGroup();
     profileGroup.Category    = "Floor";
     profileGroup.Description = "Metal deck / Profile";
     InitializeComponent();
 }
Exemplo n.º 6
0
        private void Mnu_DuplicateGroup_Click(object sender, RoutedEventArgs e)
        {
            CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem;

            if (carboGroup != null)
            {
                CarboLifeProject.DuplicateGroup(carboGroup);
            }
            SortData();
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
        private void Btn_Delete_Click(object sender, RoutedEventArgs e)
        {
            CarboGroup carboGroup = (CarboGroup)dgv_Overview.SelectedItem;

            if (carboGroup != null)
            {
                CarboLifeProject.DeleteGroup(carboGroup);
            }
            CarboLifeProject.CalculateProject();

            refreshData();
        }
Exemplo n.º 9
0
        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();
            }
        }
Exemplo n.º 10
0
        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();
        }
Exemplo n.º 11
0
        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();
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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();
            }
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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();
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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();
        }
Exemplo n.º 18
0
        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);
            }
        }
Exemplo n.º 19
0
        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();
        }
Exemplo n.º 20
0
        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();
                    }
                }
            }
        }
Exemplo n.º 21
0
        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;
        }
Exemplo n.º 22
0
        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();
        }
Exemplo n.º 23
0
        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();
 }
Exemplo n.º 25
0
        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;
        }