示例#1
0
        /// <summary>
        /// This is what updates the datagrid when the compound selection is changed
        /// </summary>
        /// <param name="sender">not used</param>
        /// <param name="e">not used</param>
        private void Compound_ComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            List <CompoundTableData>  elements  = new List <CompoundTableData>();
            List <ConstantsTableData> constants = new List <ConstantsTableData>();
            Compound compound;

            if (Compound_ComboBox.SelectedItem != null)
            {
                compound = CompoundFactory.GetElementsOfCompound((Compound_ComboBox.SelectedItem as string).ToLower());

                foreach (KeyValuePair <Element, int> element in compound.elements)
                {
                    elements.Add(new CompoundTableData(element.Key.Name, element.Value));
                }

                constants.Add(new ConstantsTableData("Cp (kJ/mol-C)", "Cp" + compound.Abbr));
                constants.Add(new ConstantsTableData("Hf (kJ/mol)", "Hf" + compound.Abbr));
                constants.Add(new ConstantsTableData("Hv (kJ/mol)", "Hv" + compound.Abbr));
                constants.Add(new ConstantsTableData("Tb (C)", "Tb" + compound.Abbr));
                constants.Add(new ConstantsTableData("Tm (C)", "Tm" + compound.Abbr));

                Compound_DataGrid.ItemsSource  = elements;
                Constants_DataGrid.ItemsSource = constants;
            }
            else
            {
                Compound_DataGrid.ItemsSource  = elements;
                Constants_DataGrid.ItemsSource = constants;
            }
        }
示例#2
0
        public static ObservableCollection <EquationType> BuildTypeOptions(Workspace workspace)
        {
            IList <string> compounds = WorkspaceUtility.GetUniqueSelectedCompounds(workspace);

            List <string> elements = new List <string>();

            foreach (string compoundstr in compounds)
            {
                Compound compound = CompoundFactory.GetElementsOfCompound((compoundstr).ToLower());

                foreach (KeyValuePair <Element, int> element in compound.elements)
                {
                    if (!elements.Contains(element.Key.Name))
                    {
                        elements.Add(element.Key.Name);
                    }
                }
            }

            ObservableCollection <EquationType> equationTypes = new ObservableCollection <EquationType>();

            equationTypes.Add(new EquationType(EquationTypeClassification.Total, "Total"));
            equationTypes.Add(new EquationType(EquationTypeClassification.Specification, "Specification"));
            equationTypes.Add(new EquationType(EquationTypeClassification.Basis, "Basis"));

            foreach (string compound in compounds)
            {
                if (compound != "Overall")
                {
                    equationTypes.Add(new EquationType(EquationTypeClassification.Compound, compound));
                }
            }

            if (workspace.Difficulty != OptionDifficultySetting.MaterialBalance)
            {
                foreach (string element in elements)
                {
                    equationTypes.Add(new EquationType(EquationTypeClassification.Atom, element + "(e)"));
                }
            }

            return(equationTypes);
        }
        private static List <string> GetTypeOptions(Workspace workspace, IStreamDataRow excludeMe)
        {
            // Start by making a list of unique selected compounds from all rows in all stream tables,
            // except for the one we need to exclude.
            List <string> compounds = new List <string>();

            foreach (AbstractStream stream in workspace.Streams)
            {
                ChemicalStream cs = stream as ChemicalStream;
                if (null != cs)
                {
                    // Go through all the rows in the properties table
                    foreach (IStreamDataRow otherRow in cs.PropertiesTable.Rows)
                    {
                        // Skip the row if it's the one we need to exclude
                        if (object.ReferenceEquals(otherRow, excludeMe))
                        {
                            continue;
                        }

                        string selectedCompound = (otherRow as ChemicalStreamData).SelectedCompound;
                        if (!string.IsNullOrEmpty(selectedCompound) &&
                            !compounds.Contains(selectedCompound))
                        {
                            compounds.Add(selectedCompound);
                        }
                    }
                }
            }

            // Now build a list of elements for the compounds in the list
            List <string> elements = new List <string>();

            foreach (string compoundstr in compounds)
            {
                Compound compound = CompoundFactory.GetElementsOfCompound((compoundstr).ToLower());

                foreach (KeyValuePair <Element, int> element in compound.elements)
                {
                    if (!elements.Contains(element.Key.Name))
                    {
                        elements.Add(element.Key.Name);
                    }
                }
            }

            List <string> equationTypes = new List <string>();

            equationTypes.Add("Total");
            equationTypes.Add("Specification");
            equationTypes.Add("Basis");
            foreach (string compound in compounds)
            {
                if (compound != "Overall")
                {
                    equationTypes.Add((new EquationType(EquationTypeClassification.Compound, compound)).ToString());
                }
            }
            if (workspace.Difficulty != OptionDifficultySetting.MaterialBalance)
            {
                foreach (string element in elements)
                {
                    equationTypes.Add((new EquationType(EquationTypeClassification.Atom, element + "(e)")).ToString());
                }
            }

            return(equationTypes);
        }