Ejemplo n.º 1
0
        public AddOrEditDryingMaterialForm(DryingMaterial dryingMaterial, INumericFormat numericFormat)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.inConstruction = true;
            this.iNumericFormat = numericFormat;

            if (dryingMaterial == null)
            {
                // new
                this.isNew = true;
                this.Text  = "New Drying Material";

                this.dryingMaterialCache = new DryingMaterialCache(DryingMaterialCatalog.Instance);
                this.textBoxName.Text    = "New Drying Material";

                // populate the material type combobox
                this.comboBoxType.Items.Add(DryingMaterialsControl.STR_MAT_TYPE_GENERIC_MATERIAL);
                this.comboBoxType.Items.Add(DryingMaterialsControl.STR_MAT_TYPE_GENERIC_FOOD);
                //this.comboBoxType.Items.Add(DryingMaterialsControl.STR_MAT_TYPE_SPECIAL_FOOD);
                this.comboBoxType.SelectedIndex = 0;

                string       matTypeStr  = this.comboBoxType.SelectedItem as string;
                MaterialType matTypeEnum = DryingMaterialsControl.GetDryingMaterialTypeAsEnum(matTypeStr);
                this.dryingMaterialCache.SetMaterialType(matTypeEnum);

                //Substance subst = this.comboBoxMoistureSubstance.SelectedItem as Substance;
                //this.dryingMaterialCache.MoistureSubstance = subst;
                this.comboBoxType.SelectedIndex = 0;

                // populate the moisture substance combobox
                this.comboBoxMoistureSubstance.Items.Clear();
                IList <Substance> moistureSubstanceList = SubstanceCatalog.GetInstance().GetMoistureSubstanceList();
                foreach (Substance s in moistureSubstanceList)
                {
                    this.comboBoxMoistureSubstance.Items.Add(s);
                }
                this.comboBoxMoistureSubstance.SelectedIndex = 0;
            }
            else
            {
                // edit
                this.isNew = false;
                this.Text  = "Edit Drying Material";

                this.dryingMaterialCache = new DryingMaterialCache(dryingMaterial, DryingMaterialCatalog.Instance);
                this.textBoxName.Text    = this.dryingMaterialCache.Name;

                // populate the material type combobox
                this.comboBoxType.Items.Add(DryingMaterialsControl.GetDryingMaterialTypeAsString(this.dryingMaterialCache.MaterialType));
                this.comboBoxType.SelectedIndex = 0;

                this.comboBoxMoistureSubstance.Items.Clear();
                this.comboBoxMoistureSubstance.Items.Add(this.dryingMaterialCache.MoistureSubstance);
                this.comboBoxMoistureSubstance.SelectedIndex = 0;
            }

            this.labelSpecificHeat.InitializeVariable(this.dryingMaterialCache.SpecificHeatOfAbsoluteDryMaterial);
            this.textBoxSpecificHeat.InitializeVariable(numericFormat, this.dryingMaterialCache.SpecificHeatOfAbsoluteDryMaterial);

            //this.substancesControl.SubstancesToShow = SubstancesToShow.Material;
            this.dmComponentsControl.SetMaterialComponents(this.dryingMaterialCache, numericFormat);
            this.UpdateTheUI(this.dryingMaterialCache.MaterialType);

            this.dryingMaterialCache.MaterialTypeChanged      += new MaterialTypeChangedEventHandler(dryingMaterialCache_MaterialTypeChanged);
            this.dryingMaterialCache.MoistureSubstanceChanged += new MoistureSubstanceChangedEventHandler(dryingMaterialCache_MoistureSubstanceChanged);
            //this.substancesControl.ListViewSubstances.SelectedIndexChanged += new EventHandler(ListViewSubstances_SelectedIndexChanged);

            this.inConstruction = false;
        }
Ejemplo n.º 2
0
 private void DryingMaterialsControl_DryingMaterialChanged(DryingMaterial material)
 {
     this.PopulateDryingMaterialList();
 }