protected override void TextBox_TextChanged(object sender, EventArgs e) { String sz; TextBox tb = (TextBox)sender; HHMMSS min = new HHMMSS(); HHMMSS max = new HHMMSS(); // If the changed text box isn't focused then it wasn't a user modification // so don't bother to check. if(tb.Focused == false) return; // Indicate the user has changed a value. m_bModified = true; // Run the numerical string the user entered into the text box through the // routine that returns a string correctly fomrated as an integral value by // removing non-numerical (and decimal) characters then compare the returned // string with the orginal. If it comes back identical then the string meets // integer format rules and continue. If not, set the text box to the // returned string. Doing so will forces this routine to be called again. if(tb.Text != (sz = CStringUtil.SzEnforceIntFmt(tb.Text))) { // Force the entered string back to what it was. Doing so will regenerate // the TextChanged event and cause this function to be called again. tb.Text = sz; return; } // A empty string is accepted as a valid intregal value for allowing user to // edit without hassle. If empty string is entered disable the OK button to // prevent user from entering a bad value. if(sz == "") { MyOKButton.Enabled = false; return; } min.hh = (uint)CStringUtil.SzToIntOrMin0(I1TextBox.Text); min.mm = (uint)CStringUtil.SzToIntOrMin0(I2TextBox.Text); min.ss = 0; max.hh = (uint)CStringUtil.SzToIntOrMin0(I4TextBox.Text); max.mm = (uint)CStringUtil.SzToIntOrMin0(I5TextBox.Text); max.ss = 0; m_minReslt = CUtil.HHMMSSTo3MBClock(min); m_maxReslt = CUtil.HHMMSSTo3MBClock(max); #if false if(m_minReslt > m_maxReslt || m_minReslt < m_lowerLim || m_maxReslt > m_upperLim || m_minReslt > 24.0 || m_maxReslt > 24.0) { MyOKButton.Enabled = false; return; } #endif // Everything checks out so set the OK button enabled. MyOKButton.Enabled = true; }
public FromSpanClock(FORMSPANINPUT FSI) : base(FSI.szCaption) { HHMMSS HMS = new HHMMSS(); int adjust; InputWidth = 24; // Instruction String InstrctnLabel.Visible = InstrctnLabel.Enabled = true; InstrctnLabel.Text = FSI.szInstruction; //--------------------------------------------------------------------------// // Minimum Clock //--------------// m_minReslt = m_minOrgnl = FSI.minInput; HMS = CUtil.TwentyHrFloatClockToHHMMSSOrZeroInclusive(FSI.minInput); // Input 1 (Minimum HH) I1TextBox.Visible = I1TextBox.Enabled = true; I1TextBox.Enabled = !FSI.minInputIsReadOnly; I1TextBox.Text = String.Format("{0:00}", HMS.hh); Colon1Label.Visible = Colon1Label.Enabled = true; Colon1Label.Text = ":"; // Input 2 (Minimum MM) I2TextBox.Visible = I2TextBox.Enabled = true; I2TextBox.Enabled = !FSI.minInputIsReadOnly; I2TextBox.Text = String.Format("{0:00}", HMS.mm); Colon2Label.Visible = Colon1Label.Enabled = true; Colon2Label.Text = ":"; I3TextBox.Visible = true; I3TextBox.Text = String.Format("{0:00}", 0); //--------------------------------------------------------------------------// //--------------------------------------------------------------------------// // Maximum Clock //--------------// m_maxReslt = m_maxOrgnl = FSI.maxInput; HMS = CUtil.TwentyHrFloatClockToHHMMSSOrZeroInclusive(FSI.maxInput); // Input 2 (Maximum HH) I4TextBox.Visible = I4TextBox.Enabled = true; I4TextBox.Enabled = !FSI.maxInputIsReadOnly; I4TextBox.Text = String.Format("{0:00}", HMS.hh); Colon3Label.Visible = Colon2Label.Enabled = true; Colon3Label.Text = ":"; // Input 2 (Maximum MM) I5TextBox.Visible = I5TextBox.Enabled = true; I5TextBox.Enabled = !FSI.maxInputIsReadOnly; I5TextBox.Text = String.Format("{0:00}", HMS.mm); Colon3Label.Visible = Colon2Label.Enabled = true; Colon3Label.Text = ":"; I6TextBox.Visible = true; I6TextBox.Text = String.Format("{0:00}", 0); //--------------------------------------------------------------------------// //--------------------------------------------------------------------------// // Low Clock Limit //----------------// HMS = CUtil.TwentyHrFloatClockToHHMMSSOrZeroInclusive(FSI.lowerLimit); m_lowerLim = FSI.lowerLimit; // Save the orginal input Input1Label.Visible = Input1Label.Enabled = true; Input1Label.Text = String.Format("Earliest Settable: {0:00}:{1:00}:00", HMS.hh, HMS.mm); //--------------------------------------------------------------------------// //--------------------------------------------------------------------------// // High Clock Limit //-----------------// HMS = CUtil.TwentyHrFloatClockToHHMMSSOrZeroInclusive(FSI.uppperLimit); m_upperLim = FSI.uppperLimit; Input2Label.Visible = Input2Label.Enabled = true; Input2Label.Text = String.Format("Latest Settable: {0:00}:{1:00}:00", HMS.hh, HMS.mm); //--------------------------------------------------------------------------// //--------------------------------------------------------------------------// // Range Span String //-------------------// RangeLabel.Visible = RangeLabel.Enabled = true; RangeLabel.Text = FSI.szRange; //--------------------------------------------------------------------------// //--------------------------------------------------------------------------// // Control Placement //-------------------// Colon1Label.Location = new Point(I1TextBox.Location.X + I1TextBox.Width-3, Colon1Label.Location.Y); I2TextBox.Location = new Point(Colon1Label.Location.X + Colon1Label.Width-3, I2TextBox.Location.Y); Colon2Label.Location = new Point(I2TextBox.Location.X + I2TextBox.Width-3, Colon2Label.Location.Y); I3TextBox.Location = new Point(Colon2Label.Location.X + Colon2Label.Width-3, I3TextBox.Location.Y); RangeLabel.Location = new Point(I3TextBox.Location.X + I3TextBox.Width, RangeLabel.Location.Y); I4TextBox.Location = new Point(RangeLabel.Location.X + RangeLabel.Width, I4TextBox.Location.Y); Colon3Label.Location = new Point(I4TextBox.Location.X + I4TextBox.Width-3, Colon3Label.Location.Y); I5TextBox.Location = new Point(Colon3Label.Location.X + Colon3Label.Width-3, I5TextBox.Location.Y); Colon4Label.Location = new Point(I5TextBox.Location.X + I5TextBox.Width-3, Colon4Label.Location.Y); I6TextBox.Location = new Point(Colon4Label.Location.X + Colon4Label.Width-3, I6TextBox.Location.Y); Input1Label.Location = new Point(I1TextBox.Location.X, Input1Label.Location.Y); Input2Label.Location = new Point(I4TextBox.Location.X, Input2Label.Location.Y); if(Input2Label.Location.X + Input2Label.Width > I6TextBox.Location.X + I6TextBox.Width) { this.Width = Input2Label.Location.X + Input2Label.Width + RIGHTMARGIN; adjust = ((Input2Label.Location.X + Input2Label.Width) - (I5TextBox.Location.X + I5TextBox.Width))/2; AdjustCntrlLoc(I1TextBox, adjust); AdjustCntrlLoc(Colon1Label, adjust); AdjustCntrlLoc(I2TextBox, adjust); AdjustCntrlLoc(Colon2Label, adjust); AdjustCntrlLoc(I3TextBox, adjust); AdjustCntrlLoc(RangeLabel, adjust); AdjustCntrlLoc(I4TextBox, adjust); AdjustCntrlLoc(Colon3Label, adjust); AdjustCntrlLoc(I5TextBox, adjust); AdjustCntrlLoc(Colon4Label, adjust); AdjustCntrlLoc(I6TextBox, adjust); } else { this.Width = I6TextBox.Location.X + I6TextBox.Width + RIGHTMARGIN; } //--------------------------------------------------------------------------// // Commented out until a better limit system is established. //if(m_minOrgnl > m_maxOrgnl || m_minOrgnl < m_lowerLim || m_maxOrgnl > m_upperLim || m_lowerLim > m_upperLim) // MyOKButton.Enabled = false; }