Example #1
0
 private void OnNumericFormatStringChanged(INumericFormat iNumericFormat)
 {
     if (NumericFormatStringChanged != null)
     {
         NumericFormatStringChanged(iNumericFormat);
     }
 }
Example #2
0
        private static IGridLabel CreateMixedFontGridLabel()
        {
            IMixedFontGridLabel mixedFontGridLabelClass = new MixedFontGridLabel() as IMixedFontGridLabel;
            IGridLabel          gridLabel    = mixedFontGridLabelClass as IGridLabel;
            IFontDisp           stdFontClass = new StdFont() as IFontDisp;

            stdFontClass.Name     = "Arial";
            stdFontClass.Size     = new decimal(16);
            gridLabel.Font        = stdFontClass;
            gridLabel.Color       = CartoHelper.BuildRGB(0, 0, 0);
            gridLabel.LabelOffset = 2;
            gridLabel.LabelAlignment[esriGridAxisEnum.esriGridAxisLeft]  = false;
            gridLabel.LabelAlignment[esriGridAxisEnum.esriGridAxisRight] = false;
            stdFontClass      = new StdFont() as IFontDisp;
            stdFontClass.Name = "Arial";
            stdFontClass.Size = new decimal(12);
            mixedFontGridLabelClass.SecondaryFont    = stdFontClass;
            mixedFontGridLabelClass.SecondaryColor   = CartoHelper.BuildRGB(0, 0, 0);
            mixedFontGridLabelClass.NumGroupedDigits = 6;
            IFormattedGridLabel formattedGridLabel = mixedFontGridLabelClass as IFormattedGridLabel;
            INumericFormat      format             = new NumericFormat() as INumericFormat;

            format.AlignmentOption = esriNumericAlignmentEnum.esriAlignRight;
            format.RoundingOption  = esriRoundingOptionEnum.esriRoundNumberOfDecimals;
            format.RoundingValue   = 2;
            format.ShowPlusSign    = true;
            format.UseSeparator    = false;
            format.ZeroPad         = true;
            INumericFormat numericFormatClass = format as INumericFormat;

            formattedGridLabel.Format = numericFormatClass as INumberFormat;
            return(gridLabel);
        }
Example #3
0
        public ProcVarsMoreThenOneOutOfRangeForm(INumericFormat iNumericFormat, IProcessVarOwner solvable, ErrorMessage error)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.solvable = solvable;
            this.Text     = error.Title;

            // display the message
            this.labelMessage.Text = error.Message;

            IEnumerator en = error.ProcessVarsAndValues.ProcessVarList.GetEnumerator();

            while (en.MoveNext())
            {
                ProcessVar pv                    = (ProcessVar)en.Current;
                object     minMaxVals            = error.ProcessVarsAndValues.GetVarRange(pv);
                MinMaxProcVarElementControl ctrl = new MinMaxProcVarElementControl(iNumericFormat, pv, minMaxVals);
                ctrl.Dock = DockStyle.Top;
                this.panelCenter.Controls.Add(ctrl);
                ctrl.BringToFront();
            }
        }
Example #4
0
 public void SetComponents(FossilFuelCache fossilFuelCache, INumericFormat iNumericFormat)
 {
     this.fossilFuelCache = fossilFuelCache;
     this.iNumericFormat  = iNumericFormat;
     this.UpdateTheUI(fossilFuelCache.MaterialComponentList, iNumericFormat);
     this.fossilFuelCache.FossilFuelComponentsChanged += new MaterialComponentsChangedEventHandler(fossilFuelCache_ComponentsChanged);
 }
Example #5
0
        //private void FossilFuelCacheInitialization()
        //{
        //   this.baseIndex = 0;
        //   this.panel.Click += new EventHandler(panel_Click);
        //   this.materialCache = new FossilFuelCache(FossilFuelCatalog.Instance);
        //   this.materialCache.MaterialComponentsChanged += new MaterialComponentsChangedEventHandler(materialCache_MaterialComponentsChanged);
        //}

        public void SetMaterialComponents(MaterialCache materialCache, INumericFormat iNumericFormat)
        {
            this.materialCache = materialCache;
            this.numericFormat = iNumericFormat;
            this.materialCache.MaterialComponentsChanged += new MaterialComponentsChangedEventHandler(materialCache_MaterialComponentsChanged);
            this.UpdateTheUI(this.materialCache.MaterialComponentList, iNumericFormat);
        }
Example #6
0
        private void InitializeTheUI(INumericFormat iNumericFormat, DuhringLine duhringLine, bool readOnly)
        {
            this.textBoxConcentration.InitializeVariable(iNumericFormat, duhringLine.Concentration);
            this.textBoxStartSolventBoilingPoint.InitializeVariable(iNumericFormat, duhringLine.StartSolventBoilingPoint);
            this.textBoxStartSolutionBoilingPoint.InitializeVariable(iNumericFormat, duhringLine.StartSolutionBoilingPoint);
            this.textBoxEndSolventBoilingPoint.InitializeVariable(iNumericFormat, duhringLine.EndSolventBoilingPoint);
            this.textBoxEndSolutionBoilingPoint.InitializeVariable(iNumericFormat, duhringLine.EndSolutionBoilingPoint);
            if (readOnly)
            {
                this.Controls.Remove(this.labelHook);
                this.Size = new Size(this.Width - 60, 20);

                this.textBoxConcentration.Location             = new Point(this.textBoxConcentration.Location.X - 60, 0);
                this.textBoxStartSolventBoilingPoint.Location  = new Point(this.textBoxStartSolventBoilingPoint.Location.X - 60, 0);
                this.textBoxStartSolutionBoilingPoint.Location = new Point(this.textBoxStartSolutionBoilingPoint.Location.X - 60, 0);
                this.textBoxEndSolventBoilingPoint.Location    = new Point(this.textBoxEndSolventBoilingPoint.Location.X - 60, 0);
                this.textBoxEndSolutionBoilingPoint.Location   = new Point(this.textBoxEndSolutionBoilingPoint.Location.X - 60, 0);

                this.textBoxConcentration.ReadOnly             = true;
                this.textBoxStartSolventBoilingPoint.ReadOnly  = true;
                this.textBoxStartSolutionBoilingPoint.ReadOnly = true;
                this.textBoxEndSolventBoilingPoint.ReadOnly    = true;
                this.textBoxEndSolutionBoilingPoint.ReadOnly   = true;
            }
        }
Example #7
0
        public void InitializeVariable(INumericFormat iNumericFormat, ProcessVar var)
        {
            if (var.Enabled)
            {
                this.iNumericFormat = iNumericFormat;
                this.var            = var;
                this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                if (this.var.Owner is Solvable)
                {
                    Solvable solvable = this.var.Owner as Solvable;
                    solvable.SolveComplete += new SolveCompleteEventHandler(solvable_SolveComplete);
                }
                else
                {
                    this.var.Owner.ProcessVarValueCommitted += new ProcessVarValueCommittedEventHandler(Owner_ProcessVarValueCommitted);
                }

                UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(ProcessVarTextBox_CurrentUnitSystemChanged);
                this.iNumericFormat.NumericFormatStringChanged += new NumericFormatStringChangedEventHandler(iNumericFormat_NumericFormatStringChanged);
                this.Validating += new System.ComponentModel.CancelEventHandler(ProcessVarTextBox_Validating);
                // NOTE: the subscription to the KeyUp event is done in the context where this textBox is used
            }
            else
            {
                this.Enabled = false;
            }
        }
Example #8
0
 public void SetMaterialComponents(DryingMaterialCache dryingMaterialCache, INumericFormat iNumericFormat)
 {
     this.dryingMaterialCache = dryingMaterialCache;
     this.iNumericFormat      = iNumericFormat;
     this.UpdateTheUI(this.dryingMaterialCache.MaterialComponentList, iNumericFormat);
     this.dryingMaterialCache.AbsoluteDryMaterialComponentsChanged += new MaterialComponentsChangedEventHandler(dryingMaterialCache_AbsoluteDryMaterialComponentsChanged);
 }
Example #9
0
        public DMDetailsForm(DryingMaterial dryingMaterial, INumericFormat numericFormat)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            DryingMaterialCache dryingMaterialCache = new DryingMaterialCache(dryingMaterial);

            this.dmDetailsControl.SetDryingMaterial(dryingMaterialCache, numericFormat);
            if (dryingMaterialCache.GetDuhringLinesCache() == null)
            {
                int w = this.Width - this.dmDetailsControl.Width;
                int h = this.Height;
                this.Size = new Size(w, h);
            }

            if (dryingMaterialCache.MaterialType == MaterialType.GenericMaterial)
            {
                this.labelSpecificHeat.Visible   = true;
                this.textBoxSpecificHeat.Visible = true;
                this.labelSpecificHeat.InitializeVariable(dryingMaterialCache.SpecificHeatOfAbsoluteDryMaterial);
                this.textBoxSpecificHeat.InitializeVariable(numericFormat, dryingMaterialCache.SpecificHeatOfAbsoluteDryMaterial);
            }
            else
            {
                this.labelSpecificHeat.Visible   = false;
                this.textBoxSpecificHeat.Visible = false;
            }
        }
Example #10
0
        public string Build(INumericFormat format)
        {
            var regex = string.Empty;

            if (format.DecimalDigits == 0)
            {
                //No decimal
                regex = string.Format(@"$");
            }
            else
            {
                //Decimal Separator
                regex = string.Format(@"\{0}", format.DecimalSeparator);

                //Decimal digits
                regex = string.Format(@"{0}[0-9]{{{1}}}$", regex, format.DecimalDigits);
            }

            //Group Separator
            if (string.IsNullOrEmpty(format.GroupSeparator))
                regex = string.Format(@"^?[0-9]*{0}", regex);
            else if (string.IsNullOrWhiteSpace(format.GroupSeparator))
                regex = string.Format(@"^?[0-9]{{1,3}}(?:\{1}?[0-9]{{3}})*{0}", regex, "s");
            else
                regex = string.Format(@"^?[0-9]{{1,3}}(?:\{1}?[0-9]{{3}})*{0}", regex, format.GroupSeparator);

            return regex;
        }
Example #11
0
        public void InitializeVariable(INumericFormat iNumericFormat, ProcessVar var)
        {
            if (var.Enabled)
            {
                this.iNumericFormat = iNumericFormat;
                this.var            = var;
                this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                if (this.var.Owner is Solvable)
                {
                    Solvable solvable = this.var.Owner as Solvable;
                    solvable.SolveComplete += new SolveCompleteEventHandler(solvable_SolveComplete);
                }
                else
                {
                    this.var.Owner.ProcessVarValueCommitted += new ProcessVarValueCommittedEventHandler(Owner_ProcessVarValueCommitted);
                }

                UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(ProcessVarNonEditableTextBox_CurrentUnitSystemChanged);
                this.iNumericFormat.NumericFormatStringChanged += new NumericFormatStringChangedEventHandler(iNumericFormat_NumericFormatStringChanged);
            }
            else
            {
                this.Enabled = false;
            }
        }
Example #12
0
        public string Build(INumericFormat format)
        {
            var regex = string.Empty;

            if (format.DecimalDigits == 0)
            {
                //No decimal
                regex = string.Format(@"$");
            }
            else
            {
                //Decimal Separator
                regex = string.Format(@"\{0}", format.DecimalSeparator);

                //Decimal digits
                regex = string.Format(@"{0}[0-9]{{{1}}}$", regex, format.DecimalDigits);
            }

            //Group Separator
            if (string.IsNullOrEmpty(format.GroupSeparator))
            {
                regex = string.Format(@"^?[0-9]*{0}", regex);
            }
            else if (string.IsNullOrWhiteSpace(format.GroupSeparator))
            {
                regex = string.Format(@"^?[0-9]{{1,3}}(?:\{1}?[0-9]{{3}})*{0}", regex, "s");
            }
            else
            {
                regex = string.Format(@"^?[0-9]{{1,3}}(?:\{1}?[0-9]{{3}})*{0}", regex, format.GroupSeparator);
            }

            return(regex);
        }
Example #13
0
        /// <summary>
        /// initialize the process variable object
        /// </summary>
        /// <param name="iNumericFormat"></param>
        /// <param name="var"></param>
        public ProcessVarObj(INumericFormat iNumericFormat, ProcessVar var)
        {
            if (var.Enabled)
            {
                this.iNumericFormat = iNumericFormat;
                this.var            = var;
                this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                if (this.var.Owner is Solvable)
                {
                    Solvable solvable = this.var.Owner as Solvable;
                    solvable.SolveComplete += new SolveCompleteEventHandler(solvable_SolveComplete);
                }
                else
                {
                    this.var.Owner.ProcessVarValueCommitted += new ProcessVarValueCommittedEventHandler(Owner_ProcessVarValueCommitted);
                }

                UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(ProcessVarTextBox_CurrentUnitSystemChanged);
                this.iNumericFormat.NumericFormatStringChanged += new NumericFormatStringChangedEventHandler(iNumericFormat_NumericFormatStringChanged);
                //     this.Validating += new System.ComponentModel.CancelEventHandler(ProcessVarTextBox_Validating);
            }
            else
            {
                //  this.Enabled = false;
            }
        }
Example #14
0
        public void SetDuhringLinesCache(DryingMaterialCache dryingMaterialCache, INumericFormat iNumericFormat)
        {
            this.SetUnits(UnitSystemService.GetInstance().CurrentUnitSystem);

            DuhringLinesCache duhringLinesCache = new DuhringLinesCache(dryingMaterialCache);

            this.UpdateTheUI(iNumericFormat, duhringLinesCache);
        }
Example #15
0
        internal void SetNumericFormat(INumericFormat iNumericFormat)
        {
            this.materialCache = new FossilFuelCache(FossilFuelCatalog.Instance);
            this.materialCache.MaterialComponentsChanged += new MaterialComponentsChangedEventHandler(materialCache_MaterialComponentsChanged);

            this.numericFormat = iNumericFormat;
            this.UpdateTheUI(this.materialCache.MaterialComponentList, iNumericFormat);
        }
Example #16
0
        public DuhringLineControl(INumericFormat iNumericFormat, DuhringLine duhringLine, bool readOnly)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            this.duhringLine = duhringLine;
            this.IsSelected  = false;
            this.InitializeTheUI(iNumericFormat, this.duhringLine, readOnly);
        }
Example #17
0
        public DuhringLinesForm(DryingMaterialCache dryingMaterialCache, INumericFormat iNumericFormat)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.dryingMaterialCache = dryingMaterialCache;
            this.duhringLinesControl.SetDuhringLinesCache(dryingMaterialCache, iNumericFormat);
        }
Example #18
0
 private void flowsheet_NumericFormatStringChanged(INumericFormat iNumericFormat)
 {
     this.plotCtrl.Graph.NumericFormatString = iNumericFormat.NumericFormatString;
     if (this.psychrometricChartModel.HCType == HCType.State)
     {
         this.plotCtrl.Graph.ShowCurrentCoordinate(this.currentState.ToString());
     }
     else if (this.psychrometricChartModel.HCType == HCType.Process)
     {
         this.plotCtrl.Graph.ShowCurrentCoordinate(this.process.ToString());
     }
 }
Example #19
0
 private void ApplicationPrefs_NumericFormatStringChanged(INumericFormat iNumericFormat)
 {
     this.plotCtrl.Graph.NumericFormatString = iNumericFormat.NumericFormatString;
     if (this.psychrometricChartModel.HCType == HCType.GasState)
     {
         this.plotCtrl.Graph.ShowCurrentCoordinate(this.currentState.ToString());
     }
     else if (this.psychrometricChartModel.HCType == HCType.IsenthalpicProcess)
     {
         this.plotCtrl.Graph.ShowCurrentCoordinate(this.process.ToString());
     }
 }
Example #20
0
 public void SetDryingMaterial(DryingMaterialCache dryingMaterialCache, INumericFormat iNumericFormat)
 {
     this.textBoxDMName.Text       = dryingMaterialCache.Name;
     this.textBoxUserDef.Text      = UI.GetBoolAsYesNo(dryingMaterialCache.IsUserDefined);
     this.textBoxMaterialType.Text = DryingMaterialsControl.GetDryingMaterialTypeAsString(dryingMaterialCache.MaterialType);
     this.textBoxMoisture.Text     = dryingMaterialCache.MoistureSubstance.ToString();
     this.SetMaterialComponents(dryingMaterialCache, iNumericFormat);
     this.readOnlyDuhringLinesControl.SetDuhringLinesCache(dryingMaterialCache, iNumericFormat);
     if (dryingMaterialCache.GetDuhringLinesCache() == null)
     {
         this.HideDuhringLinesUI();
     }
 }
Example #21
0
        public DryingMaterialsForm(MainForm mainForm, INumericFormat numericFormat)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.mainForm      = mainForm;
            this.numericFormat = numericFormat;
            this.EnableDisableButtons();
            this.dryingMaterialsControl.ListViewMaterials.SelectedIndexChanged += new EventHandler(ListViewMaterials_SelectedIndexChanged);
            this.ResizeEnd += new EventHandler(DryingMaterialsForm_ResizeEnd);
        }
Example #22
0
        public void UpdateTheUI(ArrayList materialComponentList, INumericFormat iNumericFormat)
        {
            this.panel.Controls.Clear();
            IEnumerator e = materialComponentList.GetEnumerator();
            int         i = 0;

            while (e.MoveNext())
            {
                MaterialComponent mc = (MaterialComponent)e.Current;
                MaterialComponentNameAndFractionControl ctrl = new MaterialComponentNameAndFractionControl(this, mc, iNumericFormat);
                ctrl.Location = new Point(0, ctrl.Height * i++);
                this.panel.Controls.Add(ctrl);
            }
        }
Example #23
0
 public FossilFuelCatalogForm(MainForm mainForm, INumericFormat numericFormat)
 {
     this.mainForm      = mainForm;
     this.numericFormat = numericFormat;
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     this.fossilFuelCatalogControl.Initialization();
     this.EnableDisableButtons();
     this.listViewFossilFuel = fossilFuelCatalogControl.ListViewFossilFuelList;
     this.listViewFossilFuel.SelectedIndexChanged += new EventHandler(ListViewFossilFuelCatalog_SelectedIndexChanged);
     //this.ResizeEnd += new EventHandler(DryingMaterialsForm_ResizeEnd);
 }
Example #24
0
        private void UpdateTheUI(INumericFormat iNumericFormat, DuhringLinesCache duhringLinesCache)
        {
            this.panel.Controls.Clear();
            IEnumerator e = duhringLinesCache.DuhringLines.GetEnumerator();
            int         i = 0;

            while (e.MoveNext())
            {
                DuhringLine        duhringLine = (DuhringLine)e.Current;
                DuhringLineControl ctrl        = new DuhringLineControl(iNumericFormat, duhringLine, true);
                ctrl.Location = new Point(0, ctrl.Height * i++);
                this.panel.Controls.Add(ctrl);
            }
        }
Example #25
0
        public void SetDuhringLinesCache(DryingMaterialCache dryingMaterialCache, INumericFormat iNumericFormat)
        {
            this.iNumericFormat = iNumericFormat;

            this.baseIndex    = 0;
            this.panel.Click += new EventHandler(panel_Click);

            this.SetUnits(UnitSystemService.GetInstance().CurrentUnitSystem);
            UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(DuhringLinesControl_CurrentUnitSystemChanged);

            this.duhringLinesCache = new DuhringLinesCache(dryingMaterialCache);
            this.UpdateTheUI(iNumericFormat, this.duhringLinesCache);
            this.duhringLinesCache.DuhringLinesChanged += new DuhringLinesChangedEventHandler(duhringLinesCache_DuhringLinesChanged);
        }
Example #26
0
        public RecommProcVarElementControl(INumericFormat iNumericFormat, ProcessVar var, object recommValue)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            this.var = var;

            this.labelName.InitializeVariable(var);
            this.textBoxExistingValue.InitializeVariable(iNumericFormat, var);

            // note: the recommended value is not converted to the current unit system,
            //       and it also needs formating
            if (var is ProcessVarDouble)
            {
                double val  = (double)recommValue;
                double val2 = 0.0;
                val2 = UnitSystemService.GetInstance().ConvertFromSIValue(var.Type, val);
                if (val2 == Constants.NO_VALUE)
                {
                    this.textBoxRecommendedValue.Text = "";
                }
                else
                {
                    this.textBoxRecommendedValue.Text = val2.ToString(iNumericFormat.NumericFormatString);
                }
            }
            else if (var is ProcessVarInt)
            {
                int val = (int)recommValue;
                if (val == Constants.NO_VALUE_INT)
                {
                    this.textBoxRecommendedValue.Text = "";
                }
                else
                {
                    this.textBoxRecommendedValue.Text = val.ToString(UI.DECIMAL);
                }
            }

            this.textBoxExistingValue.BackColor    = Color.Gainsboro;
            this.textBoxRecommendedValue.BackColor = Color.Gainsboro;

            // as convenience, initialize the new value with the recommended value
            this.textBoxNewValue.Text = this.textBoxRecommendedValue.Text;
        }
Example #27
0
        public FossilFuelSpecificationForm(FossilFuelCache fossilFuelCache, INumericFormat format)
        {
            numericFormat = format;
            InitializeComponent();

            if (fossilFuelCache != null)
            {
                isNew = false;
                this._ComponentsControl.SetMaterialComponents(fossilFuelCache, numericFormat);
                this.textBoxName.Text = fossilFuelCache.Name;
            }
            else
            {
                isNew = true;
                this._ComponentsControl.SetNumericFormat(numericFormat);
                this.textBoxName.Text = _ComponentsControl.MaterialCache.Name;
            }
        }
Example #28
0
        private void SetMaterialComponents(DryingMaterialCache cache, INumericFormat iNumericFormat)
        {
            IEnumerator en = cache.MaterialComponentList.GetEnumerator();

            while (en.MoveNext())
            {
                MaterialComponent mc  = (MaterialComponent)en.Current;
                ListViewItem      lvi = new ListViewItem();

                ListViewItem.ListViewSubItem lvsi = new ListViewItem.ListViewSubItem(lvi, mc.Name);
                lvi.SubItems.Insert(0, lvsi);

                lvsi = new ListViewItem.ListViewSubItem(lvi, mc.MassFraction.Value.ToString(iNumericFormat.NumericFormatString));
                lvi.SubItems.Insert(1, lvsi);

                this.listViewMaterialComponents.Items.Add(lvi);
            }
        }
Example #29
0
 protected void Initialize(INumericFormat format)
 {
     DecimalDigits = format.DecimalDigits;
     DecimalSeparator = format.DecimalSeparator;
     GroupSeparator = format.GroupSeparator;
 }
Example #30
0
        public ProcVarOutOfRangeForm(INumericFormat iNumericFormat, ProcessVar var, object varSpecifiedValue, ErrorMessage error)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.Text = error.Title;

            this.var = var;

            // display the message
            this.labelMessage.Text = error.Message;

            // dispaly the variable
            this.labelProcVarName.InitializeVariable(var);
            this.labelProcVarName.BorderStyle = BorderStyle.None;
            this.textBoxExistingValue.InitializeVariable(iNumericFormat, var);

            // note: the specified value is already converted to the current unit system,
            //       it needs only to be formated
            if (var is ProcessVarDouble)
            {
                double val = (double)varSpecifiedValue;
                if (val == Constants.NO_VALUE)
                {
                    this.textBoxSpecifiedValue.Text = "";
                }
                else
                {
                    this.textBoxSpecifiedValue.Text = val.ToString(iNumericFormat.NumericFormatString);
                }
            }
            else if (var is ProcessVarInt)
            {
                int val = (int)varSpecifiedValue;
                if (val == Constants.NO_VALUE_INT)
                {
                    this.textBoxSpecifiedValue.Text = "";
                }
                else
                {
                    this.textBoxSpecifiedValue.Text = val.ToString(UI.DECIMAL);
                }
            }

            string averageValStr = "";
            object minMaxValues  = error.ProcessVarsAndValues.GetVarRange(var);

            // note: the min and max values are not converted to the current unit system,
            //       and they also needs formating
            if (var is ProcessVarDouble)
            {
                DoubleRange doubleRange = (DoubleRange)minMaxValues;

                double valMin  = doubleRange.MinValue;
                double val2Min = 0.0;
                val2Min = UnitSystemService.GetInstance().ConvertFromSIValue(var.Type, valMin);
                if (val2Min == Constants.NO_VALUE)
                {
                    this.textBoxMinValue.Text = "";
                }
                else
                {
                    this.textBoxMinValue.Text = val2Min.ToString(iNumericFormat.NumericFormatString);
                }

                double valMax  = doubleRange.MaxValue;
                double val2Max = 0.0;
                val2Max = UnitSystemService.GetInstance().ConvertFromSIValue(var.Type, valMax);
                if (val2Max == Constants.NO_VALUE)
                {
                    this.textBoxMaxValue.Text = "";
                }
                else
                {
                    this.textBoxMaxValue.Text = val2Max.ToString(iNumericFormat.NumericFormatString);
                }

                double averageVal = (val2Min + val2Max) / 2;
                averageValStr = averageVal.ToString(iNumericFormat.NumericFormatString);
            }
            else if (var is ProcessVarInt)
            {
                IntRange intRange = (IntRange)minMaxValues;

                int valMin = intRange.MinValue;
                if (valMin == Constants.NO_VALUE_INT)
                {
                    this.textBoxMinValue.Text = "";
                }
                else
                {
                    this.textBoxMinValue.Text = valMin.ToString(UI.DECIMAL);
                }

                int valMax = intRange.MaxValue;
                if (valMax == Constants.NO_VALUE_INT)
                {
                    this.textBoxMaxValue.Text = "";
                }
                else
                {
                    this.textBoxMaxValue.Text = valMax.ToString(UI.DECIMAL);
                }

                int averageVal = (int)((valMin + valMax) / 2);
                averageValStr = averageVal.ToString(iNumericFormat.NumericFormatString);
            }

            // as convenience, initialize the new value with the recommended value
            this.textBoxNewValue.Text = averageValStr;

            this.textBoxExistingValue.BackColor  = Color.Gainsboro;
            this.textBoxSpecifiedValue.BackColor = Color.Gainsboro;
            this.textBoxMinValue.BackColor       = Color.Gainsboro;
            this.textBoxMaxValue.BackColor       = Color.Gainsboro;
        }
 public void SetObjects(object @object)
 {
     this.m_pNumericFormat = @object as INumericFormat;
 }
Example #32
0
        public AddOrEditDryingMaterialForm(DryingMaterial dryingMaterial, INumericFormat numericFormat)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

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

            // populate the moisture substance combobox
            IEnumerator en = SubstanceCatalog.GetInstance().GetMoistureSubstanceList().GetEnumerator();

            while (en.MoveNext())
            {
                Substance substance = (Substance)en.Current;
                this.comboBoxMoistureSubstance.Items.Add(substance);
            }
            this.comboBoxMoistureSubstance.SelectedIndex = 0;

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

                this.dryingMaterialCache = new DryingMaterialCache(DryingMaterialCatalog.GetInstance());
                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;
            }
            else
            {
                // edit
                this.isNew = false;
                this.Text  = "Edit Drying Material";

                this.dryingMaterialCache = new DryingMaterialCache(dryingMaterial, DryingMaterialCatalog.GetInstance());
                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.SelectedItem = this.dryingMaterialCache.MoistureSubstance;
            }

            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;
        }