private void ShowSlopedFacilityWS() { double storageDepth2 = Convert.ToDouble(txtStorageDepth2.Text); double storageDepth3 = Convert.ToDouble(txtStorageDepth3.Text); double growingMediumDepth = Convert.ToDouble(txtGrowingMediumDepth.Text); double freeboardDepth = Convert.ToDouble(txtFreeboardDepth.Text); double rockStorageDepth = Convert.ToDouble(txtRockStorageDepth.Text); double rockStorageVoidRatio = Convert.ToDouble(txtRockVoidRatio.Text); FacilityShape shape = GetFacilityShape(cmbFacilityShape.Text); FacilityConfiguration config = (FacilityConfiguration)cmbFacilityConfiguration.Text[0]; FacilityType type = GetFacilityType(cmbFacilityType.Text); List <SlopedFacilitySegment> segments = new List <SlopedFacilitySegment>(); SlopedFacility facility = new SlopedFacility(type, config, new Catchment("test catchment"), segments) { StorageDepth2In = storageDepth2, StorageDepth3In = storageDepth3, GrowingMediumDepthIn = growingMediumDepth, FreeboardIn = freeboardDepth, RockStorageDepthIn = rockStorageDepth, RockVoidRatio = rockStorageVoidRatio, Shape = shape }; if (_sfws == null || _sfws.Disposing) { _sfws = new SlopedFacilityWorksheet(facility); } else { facility.Segments = _sfws.Segments; // connect new facility object to existing segments. _sfws.Facility = facility; // change worksheet object to new facility object. } try { _sfws.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private Facility ValidateFacility(string hierarchy, string facilityType, string configuration) { try { //Read catchment parameters to local variables double imperviousArea = Convert.ToDouble(txtImperviousArea.Text); double curveNumber = Convert.ToDouble(txtCurveNumber.Text); double preCurveNumber = Convert.ToDouble(txtPreCurveNumber.Text); double timeOfConcentration = Convert.ToDouble(txtTimeOfConcentration.Text); double nativeInfiltrationRate = Convert.ToDouble(txtNativeSoilInfiltrationRate.Text); InfiltrationTestType infiltrationTestType; switch (cmbInfiltrationProcedure.SelectedIndex) { case (0): infiltrationTestType = InfiltrationTestType.OpenPitFallingHead; break; case (1): infiltrationTestType = InfiltrationTestType.EncasedFallingHead; break; case (2): infiltrationTestType = InfiltrationTestType.DoubleRingInfiltometer; break; default: infiltrationTestType = InfiltrationTestType.OpenPitFallingHead; break; } //Create catchment object local variables Catchment catchment = new Catchment("Catchment A") { ImperviousAreaSquareFeet = imperviousArea, AcceptableSeparationFromGroundwater = chkMeetsGroundwaterRequirements.Checked, CurveNumber = curveNumber, TimeOfConcentrationMinutes = timeOfConcentration, TestedInfiltrationRateInchesPerHour = nativeInfiltrationRate, InfiltrationTestType = infiltrationTestType }; //Read facility parameters to local variables double bottomArea = Convert.ToDouble(txtBottomArea.Text); double bottomWidth = Convert.ToDouble(txtBottomWidth.Text); double sideSlope = Convert.ToDouble(txtSideSlope.Text); double storageDepth1 = Convert.ToDouble(txtStorageDepth1.Text); double storageDepth2 = Convert.ToDouble(txtStorageDepth2.Text); double storageDepth3 = Convert.ToDouble(txtStorageDepth3.Text); double growingMediumDepth = Convert.ToDouble(txtGrowingMediumDepth.Text); double freeboardDepth = Convert.ToDouble(txtFreeboardDepth.Text); double rockStorageDepth = Convert.ToDouble(txtRockStorageDepth.Text); double rockStorageVoidRatio = Convert.ToDouble(txtRockVoidRatio.Text); double rockStorageBottomArea = Convert.ToDouble(txtRockStorageBottomArea.Text); double surfaceAreaAtStorageDepth1 = Convert.ToDouble(txtSurfaceAreaAtDepth1.Text); double bottomPerimiterLength = Convert.ToDouble(txtBottomPerimeterLength.Text); double surfaceAreaAtStorageDepth2 = Convert.ToDouble(txtSurfaceAreaAtDepth2.Text); FacilityShape shape = GetFacilityShape(cmbFacilityShape.Text); FacilityConfiguration config; config = (FacilityConfiguration)cmbFacilityConfiguration.Text[0]; FacilityType type = GetFacilityType(cmbFacilityType.Text); Facility facility; if (type == FacilityType.Basin || type == FacilityType.PlanterFlat) { facility = new Facility(type, config, catchment) { BottomAreaSqFt = bottomArea, BottomWidthFt = bottomWidth, SideSlopeRatio = sideSlope, StorageDepth1In = storageDepth1, StorageDepth2In = storageDepth2, StorageDepth3In = storageDepth3, GrowingMediumDepthIn = growingMediumDepth, FreeboardIn = freeboardDepth, RockStorageDepthIn = rockStorageDepth, RockVoidRatio = rockStorageVoidRatio, RockStorageBottomAreaSqFt = rockStorageBottomArea, SurfaceAreaAtStorageDepth1SqFt = surfaceAreaAtStorageDepth1, BottomPerimeterLengthFt = bottomPerimiterLength, SurfaceAreaAtStorageDepth2SqFt = surfaceAreaAtStorageDepth2, Shape = shape }; } else //Write sloped facility parameters from UI to facility object and verify results { //ShowSlopedFacilityWS(); List <SlopedFacilitySegment> segments; if (_sfws != null) { if (_sfws.Segments != null) { segments = _sfws.Segments; } else { segments = new List <SlopedFacilitySegment>(); } } else { segments = new List <SlopedFacilitySegment>(); } facility = new SlopedFacility(type, config, catchment, segments) { BottomAreaSqFt = bottomArea, BottomWidthFt = bottomWidth, SideSlopeRatio = sideSlope, StorageDepth1In = storageDepth1, StorageDepth2In = storageDepth2, StorageDepth3In = storageDepth3, GrowingMediumDepthIn = growingMediumDepth, FreeboardIn = freeboardDepth, RockStorageDepthIn = rockStorageDepth, RockVoidRatio = rockStorageVoidRatio, RockStorageBottomAreaSqFt = rockStorageBottomArea, SurfaceAreaAtStorageDepth1SqFt = surfaceAreaAtStorageDepth1, Shape = shape }; } int hierarchyNumber = Convert.ToInt32(hierarchy); HierarchyCategory hierarchyCategory = (HierarchyCategory)hierarchyNumber; string message; _validFacility = Facility.Validate(facility, hierarchyNumber, out message); ToggleUIParameters(facility); if (!_validFacility) { DisableUI(message); } return(facility); } catch (Exception ex) { MessageBox.Show("Error with facility parameters: " + ex.Message); return(null); } }