private void KeyUpNavigator(object sender, KeyEventArgs e) { ArrayList list = new ArrayList(); IEnumerator en = this.userCtrlFractions.Controls.GetEnumerator(); while (en.MoveNext()) { TeeStreamAndFractionControl sfCtrl = (TeeStreamAndFractionControl)en.Current; list.Add(sfCtrl.textBoxFraction); } if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Down) { UI.NavigateKeyboard(list, sender, this.userCtrlFractions, KeyboardNavigation.Down); } else if (e.KeyCode == Keys.Up) { UI.NavigateKeyboard(list, sender, this.userCtrlFractions, KeyboardNavigation.Up); } }
private void UpdateTheUI() { this.panel.Visible = false; this.userCtrlFractions.Visible = false; this.userCtrlFractions.Controls.Clear(); this.groupBoxStreams.Visible = false; this.groupBoxStreams.Controls.Clear(); this.outletControls.Clear(); int x = INITIAL_LOCATION; int w = VALUE_WIDTH; int s = INITIAL_GROUPBOX_WIDTH; int p = INITIAL_FORM_WIDTH; Tee tee = this.TeeCtrl.Tee; bool hasStreamIn = false; bool hasStreamOut = false; ProcessStreamBase streamOut = null; if (tee.OutletStreams.Count > 0) { hasStreamOut = true; streamOut = (ProcessStreamBase)tee.OutletStreams[0]; this.userCtrlFractions.Visible = true; } ProcessStreamBase streamIn = tee.Inlet; if (streamIn != null) { hasStreamIn = true; } if (hasStreamIn || hasStreamOut) { this.groupBoxStreams.Visible = true; ProcessStreamBase labelsStream = null; if (hasStreamIn) { labelsStream = streamIn; } else if (hasStreamOut) { labelsStream = streamOut; } UserControl ctrl = null; if (labelsStream is ProcessStream) { ctrl = new ProcessStreamLabelsControl((ProcessStream)labelsStream); } else if (labelsStream is DryingGasStream) { ctrl = new GasStreamLabelsControl((DryingGasStream)labelsStream); } else if (labelsStream is DryingMaterialStream) { ctrl = new MaterialStreamLabelsControl((DryingMaterialStream)labelsStream); } ctrl.Location = new Point(4, 12 + 20 + 2); this.groupBoxStreams.Size = new Size(s, this.groupBoxHeight); this.groupBoxFractions.Location = new System.Drawing.Point(this.groupBoxStreams.Width + 4, 24); this.groupBoxStreams.Controls.Add(ctrl); s = s + w; p = p + w; } if (hasStreamIn) { UserControl ctrl = null; if (streamIn is ProcessStream) { ProcessStreamControl processInCtrl = (ProcessStreamControl)this.TeeCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(streamIn.Name); ctrl = new ProcessStreamValuesControl(processInCtrl); } else if (streamOut is DryingGasStream) { GasStreamControl gasInCtrl = (GasStreamControl)this.TeeCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(streamIn.Name); ctrl = new GasStreamValuesControl(gasInCtrl); } else if (streamOut is DryingMaterialStream) { MaterialStreamControl materialInCtrl = (MaterialStreamControl)this.TeeCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(streamIn.Name); ctrl = new MaterialStreamValuesControl(materialInCtrl); } ctrl.Location = new Point(x, 12 + 20 + 2); this.groupBoxStreams.Size = new Size(s, this.groupBoxHeight); this.groupBoxFractions.Location = new System.Drawing.Point(this.groupBoxStreams.Width + 4, 24); this.groupBoxStreams.Controls.Add(ctrl); this.Size = new Size(p, this.formHeight); this.textBoxStreamInName.Text = streamIn.Name; this.textBoxStreamInName.Location = new Point(x, 12); this.textBoxStreamInName.SetSolvable(streamIn); this.groupBoxStreams.Controls.Add(this.textBoxStreamInName); UI.SetStatusColor(this.textBoxStreamInName, streamIn.SolveState); } if (hasStreamOut) { IEnumerator e = tee.OutletStreams.GetEnumerator(); while (e.MoveNext()) { s = s + w; x = x + w; p = p + w; ProcessStreamBase processStreamBase = (ProcessStreamBase)e.Current; UserControl ctrl = null; if (processStreamBase is ProcessStream) { ProcessStreamControl processOutCtrl = (ProcessStreamControl)this.TeeCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(processStreamBase.Name); ctrl = new ProcessStreamValuesControl(processOutCtrl); } else if (processStreamBase is DryingGasStream) { GasStreamControl gasOutCtrl = (GasStreamControl)this.TeeCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(processStreamBase.Name); ctrl = new GasStreamValuesControl(gasOutCtrl); } else if (processStreamBase is DryingMaterialStream) { MaterialStreamControl materialOutCtrl = (MaterialStreamControl)this.TeeCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(processStreamBase.Name); ctrl = new MaterialStreamValuesControl(materialOutCtrl); } ctrl.Location = new Point(x, 12 + 20 + 2); this.groupBoxStreams.Size = new Size(s, this.groupBoxHeight); this.groupBoxFractions.Location = new System.Drawing.Point(this.groupBoxStreams.Width + 4, 24); this.groupBoxStreams.Controls.Add(ctrl); this.Size = new Size(p, this.formHeight); ProsimoUI.SolvableNameTextBox textBoxStreamOutName = new ProsimoUI.SolvableNameTextBox(processStreamBase); textBoxStreamOutName.Width = 80; textBoxStreamOutName.Height = 20; textBoxStreamOutName.Text = processStreamBase.Name; textBoxStreamOutName.Location = new Point(x, 12); this.outletControls.Add(textBoxStreamOutName, textBoxStreamOutName.Text); this.groupBoxStreams.Controls.Add(textBoxStreamOutName); UI.SetStatusColor(textBoxStreamOutName, processStreamBase.SolveState); } // build the fractions for (int i = 0; i < this.TeeCtrl.Tee.OutletStreamAndFractions.Count; i++) { StreamAndFraction sf = (StreamAndFraction)this.TeeCtrl.Tee.OutletStreamAndFractions[i]; TeeStreamAndFractionControl sfCtrl = new TeeStreamAndFractionControl(this.TeeCtrl.Flowsheet, sf); sfCtrl.Location = new Point(0, i * sfCtrl.Height); this.userCtrlFractions.Controls.Add(sfCtrl); sfCtrl.textBoxFraction.KeyUp += new KeyEventHandler(KeyUpNavigator); } } this.Size = new Size(p + this.groupBoxFractions.Width, this.formHeight); this.panel.Visible = true; }
private void UpdateStreamsUI() { Tee tee = this.TeeCtrl.Tee; bool hasStreamIn = false; bool hasStreamOut = false; ProcessStreamBase streamOut = null; if (tee.OutletStreams.Count > 0) { hasStreamOut = true; streamOut = (ProcessStreamBase)tee.OutletStreams[0]; //this.userCtrlFractions.Visible = true; } ProcessStreamBase streamIn = tee.Inlet; if (streamIn != null) { hasStreamIn = true; } if (hasStreamIn) { ProcessStreamBaseControl processInCtrl = (ProcessStreamBaseControl)this.TeeCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(streamIn.Name); initializeGrid(processInCtrl, columnIndex, false, "Inlet/Outlets"); columnIndex += 2; } if (hasStreamOut) { Boolean bFirstControl = true; if (hasStreamIn) { bFirstControl = false; } IEnumerator e = tee.OutletStreams.GetEnumerator(); while (e.MoveNext()) { ProcessStreamBase processStreamBase = (ProcessStreamBase)e.Current; ProcessStreamBaseControl processOutCtrl = (ProcessStreamBaseControl)this.TeeCtrl.Flowsheet.StreamManager.GetProcessStreamBaseControl(processStreamBase.Name); if (bFirstControl) { initializeGrid(processOutCtrl, columnIndex, false, "Inlet/Outlets"); columnIndex += 2; bFirstControl = false; } else { initializeGrid(processOutCtrl, columnIndex, true, "Inlet/Outlets"); columnIndex++; } //this.groupBoxStreams.Controls.Add(textBoxStreamOutName); //UI.SetStatusColor(this,statusBar, processStreamBase.SolveState); } // build the fractions for (int i = 0; i < this.TeeCtrl.Tee.OutletStreamAndFractions.Count; i++) { StreamAndFraction sf = (StreamAndFraction)this.TeeCtrl.Tee.OutletStreamAndFractions[i]; TeeStreamAndFractionControl sfCtrl = new TeeStreamAndFractionControl(this.TeeCtrl.Flowsheet, sf); //sfCtrl.Location = new Point(0, i*sfCtrl.Height); //this.userCtrlFractions.Controls.Add(sfCtrl); //sfCtrl.textBoxFraction.KeyUp += new KeyEventHandler(KeyUpNavigator); } } }