protected void Page_Load(object sender, EventArgs e) { Roof aRoof = (Roof)Session["completedRoof"]; RoofModule aRoofModule = aRoof.RoofModules[0]; RoofModule aGableModule = aRoof.RoofModules[1]; List <RoofItem> aRoofModuleItemList = aRoofModule.RoofItems; List <RoofItem> aGableModuleItemList = aGableModule.RoofItems; Label aLabel = new Label(); aLabel.Text = "Roof is of sizes: Projection: " + aRoof.Projection + ", Width: " + aRoof.Width; testHolder.Controls.Add(aLabel); testHolder.Controls.Add(new LiteralControl("<br/><br/>")); for (int i = 0; i < aRoofModuleItemList.Count; i++) { aLabel = new Label(); aLabel.Text = "Type: " + aRoofModuleItemList[i].ItemType + ", Projection: " + aRoofModuleItemList[i].Projection + ", Width: " + aRoofModuleItemList[i].Width; testHolder.Controls.Add(aLabel); testHolder.Controls.Add(new LiteralControl("<br/>")); } testHolder.Controls.Add(new LiteralControl("<br/><br/>")); for (int i = 0; i < aGableModuleItemList.Count; i++) { aLabel = new Label(); aLabel.Text = "Type: " + aGableModuleItemList[i].ItemType + ", Projection: " + aGableModuleItemList[i].Projection + ", Width: " + aGableModuleItemList[i].Width; testHolder.Controls.Add(aLabel); testHolder.Controls.Add(new LiteralControl("<br/>")); } }
protected RoofModule buildStudioRoofModule(float roofProjection, float roofWidth) { //Variables that will be used to build the roof float panelWidth; string panelType; string panelBeamType; float panelBeamWidth; //set PanelBeamType based on the ddlPanelType value: ie I-beam or pressure cap if (hidPanelType.Value.Contains("I-Beam")) { panelBeamType = "I-Beam"; panelBeamWidth = Constants.ROOF_IBEAM_WIDTH; } else if (hidPanelType.Value.Contains("Pressure Cap")) { panelBeamType = "Pressure Cap"; panelBeamWidth = Constants.ROOF_PRESSURECAP_WIDTH; } else { panelBeamType = "Thermadeck"; //Thermadeck uses wood underneath the panels, so there is essentially no width to seperator beams panelBeamWidth = 0f; } //If its an acrylic roof, our panels will use the acrylic constants, otherwise foam if (hidSystem.Value == "Traditional") { panelWidth = Constants.FOAM_PANEL_WIDTH; panelType = "Foam Panel"; } else if (hidSystem.Value == "Acrylic") { panelBeamType = "T-Bar"; panelWidth = Constants.ACRYLIC_PANEL_WIDTH; panelType = "Acrylic Panel"; Session.Add("roofAcrylicPanelColour", hidAcrylicColour.Value); } else { panelBeamType = "None"; panelWidth = Constants.THERMADECK_PANEL_WIDTH; panelType = "Thermadeck Panel"; } //build roof objects float numberOfPanels = (float)Math.Ceiling(roofWidth / panelWidth); //If it requires 'part' of a panel, that is essentially another panel, just cut. Cut will be handled later. //lets start making a list of roof items List<RoofItem> itemList = new List<RoofItem>(); if (hidSystem.Value != "Thermadeck") { //Add the first panel, because if we loop adding panel+seperator, we will end with one extra itemList.Add(new RoofItem(panelType, roofProjection, panelWidth, -1f, -1f)); //loop adding seperator then panels, minus one iteration because one panel is already added for (int i = 0; i < (numberOfPanels - 1); i++) { itemList.Add(new RoofItem(panelBeamType, roofProjection, (float)panelBeamWidth, -1f, -1f)); itemList.Add(new RoofItem(panelType, roofProjection, panelWidth, -1f, -1f)); } } //if it is thermadeck else { for (int i = 0; i < numberOfPanels; i++) { itemList.Add(new RoofItem(panelType, roofProjection, panelWidth, -1f, -1f)); } } float itemWidthTotal = 0; //Total width of items for (int i = 0; i < itemList.Count; i++) { itemWidthTotal += itemList[i].Width; } //If this width doesn't fit perfectly (is more than roof width) we'll need to make a cut on the last panel if (itemWidthTotal > roofWidth) { //at .count-1 to get last item, which should be the final panel //We subtract the difference that the panel exceeds to make the 'cut' itemList[itemList.Count - 1].Width -= (itemWidthTotal - roofWidth); } string panelExteriorSkin = hidExteriorRoofSkin.Value; string panelInteriorSkin = hidInteriorRoofSkin.Value; if (hidSystem.Value == "Thermadeck") { //Thermadeck systems must be osb/osb panelExteriorSkin = "OSB"; panelInteriorSkin = "OSB"; } RoofModule aModule = new RoofModule(roofProjection, roofWidth, panelInteriorSkin, panelExteriorSkin, itemList); return aModule; }
protected List <RoofModule> buildGableRoofModule(float roofProjection1, float roofProjection2, float roofWidth) { //Variables that will be used to build the roof float panelWidth; string panelType; string panelBeamType; float panelBeamWidth; //set PanelBeamType based on the ddlPanelType value: ie I-beam or pressure cap if (hidPanelType.Value.Contains("I-Beam")) { panelBeamType = "I-Beam"; panelBeamWidth = Constants.ROOF_IBEAM_WIDTH; } else if (hidPanelType.Value.Contains("Pressure Cap")) { panelBeamType = "Pressure Cap"; panelBeamWidth = Constants.ROOF_PRESSURECAP_WIDTH; } else { panelBeamType = "Thermadeck"; //Thermadeck uses wood underneath the panels, so there is essentially no width to seperator beams panelBeamWidth = 0f; } //If its an acrylic roof, our panels will use the acrylic constants, otherwise foam if (hidSystem.Value == "Traditional") { panelWidth = Constants.FOAM_PANEL_WIDTH; panelType = "Foam Panel"; } else if (hidSystem.Value == "Acrylic") { panelBeamType = "T-Bar"; panelWidth = Constants.ACRYLIC_PANEL_WIDTH; panelType = "Acrylic Panel"; Session.Add("roofAcrylicPanelColour", hidAcrylicColour.Value); } else { panelBeamType = "None"; panelWidth = Constants.THERMADECK_PANEL_WIDTH; panelType = "Thermadeck Panel"; } //build roof objects float numberOfPanels = (float)Math.Ceiling(roofWidth / panelWidth); //If it requires 'part' of a panel, that is essentially another panel, just cut. Cut will be handled later. float projectionOne = roofProjection1; float projectionTwo = roofProjection2; //lets start making a list of roof items List <RoofItem> itemList = new List <RoofItem>(); List <RoofItem> gableList = new List <RoofItem>(); List <Wall> listOfWalls = (List <Wall>)Session["listOfWalls"]; if (hidSystem.Value != "Thermadeck") { //Add the first panel, because if we loop adding panel+seperator, we will end with one extra //We use roofProjection / 2 for the following, because this is just one side of the gable roof, thus half the projection itemList.Add(new RoofItem(panelType, projectionOne, panelWidth, -1f, -1f)); //loop adding seperator then panels, minus one iteration because one panel is already added for (int i = 0; i < (numberOfPanels - 1); i++) { itemList.Add(new RoofItem(panelBeamType, projectionOne, (float)panelBeamWidth, -1f, -1f)); itemList.Add(new RoofItem(panelType, projectionOne, panelWidth, -1f, -1f)); } } //if it is thermadeck else { for (int i = 0; i < numberOfPanels; i++) { itemList.Add(new RoofItem(panelType, projectionOne, panelWidth, -1f, -1f)); } } float itemWidthTotal = 0; //Total width of items for (int i = 0; i < itemList.Count; i++) { itemWidthTotal += itemList[i].Width; } //If this width doesn't fit perfectly (is more than roof width) we'll need to make a cut on the last panel if (itemWidthTotal > roofWidth) { //at .count-1 to get last item, which should be the final panel //We subtract the difference that the panel exceeds to make the 'cut' itemList[itemList.Count - 1].Width -= (itemWidthTotal - roofWidth); } string panelExteriorSkin = hidExteriorRoofSkin.Value; string panelInteriorSkin = hidInteriorRoofSkin.Value; if (hidSystem.Value == "Thermadeck") { //Thermadeck systems must be osb/osb panelExteriorSkin = "OSB"; panelInteriorSkin = "OSB"; } List <RoofModule> moduleList = new List <RoofModule>(); RoofModule aModule = new RoofModule(projectionOne, roofWidth, panelInteriorSkin, panelExteriorSkin, itemList); moduleList.Add(aModule); //We make a second module with the reverse roof items, because the gable is mirrored on the other side for (int i = (itemList.Count - 1); i >= 0; i--) { gableList.Add(itemList[i]); } //Now set the duplication to their actual projections for (int i = 0; i < gableList.Count; i++) { gableList[i].Projection = projectionTwo; } RoofModule aSecondModule = new RoofModule(projectionTwo, roofWidth, panelInteriorSkin, panelExteriorSkin, gableList); moduleList.Add(aSecondModule); return(moduleList); }
protected void Page_Load(object sender, EventArgs e) { projectId = Convert.ToInt32(HttpContext.Current.Session["project_id"].ToString()); #region hit the DB using (SqlConnection aConnection = new SqlConnection(sdsDBConnection.ConnectionString)) { aConnection.Open(); SqlCommand aCommand = aConnection.CreateCommand(); SqlTransaction aTransaction; SqlDataReader aReader; // Start a local transaction. aTransaction = aConnection.BeginTransaction("SampleTransaction"); // Must assign both transaction object and connection // to Command object for a pending local transaction aCommand.Connection = aConnection; aCommand.Transaction = aTransaction; try { //get number of walls floors and roofs aCommand.CommandText = "SELECT number_walls, number_floors, number_roofs FROM sunrooms WHERE project_id = '" + projectId + "'"; aReader = aCommand.ExecuteReader(); if (aReader.HasRows) { aReader.Read(); wallCount = Convert.ToInt32(aReader[0]); floorCount = Convert.ToInt32(aReader[1]); roofCount = Convert.ToInt32(aReader[2]); } aReader.Close(); #region walls //for each wall in the project //aCommand.CommandText = "SELECT wall_type, model_type, total_length, orientation, set_back, name, first_item_index, last_item_index, start_height, end_height, soffit_length, gable_peak, obstructions, fire_protection, wall_index " // + "FROM walls WHERE project_id = '" + projectId + "'"; //SqlDataReader wallReader = aCommand.ExecuteReader(); //if (wallReader.HasRows) //{ // while (wallReader.Read()) for (int i = 0; i < wallCount; i++) { aCommand.CommandText = "SELECT wall_type, model_type, total_length, orientation, set_back, name, first_item_index, last_item_index, start_height, end_height, soffit_length, gable_peak, obstructions, fire_protection, wall_index " + "FROM walls WHERE project_id = '" + projectId + "' AND wall_index = '" + i + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); //create a new instance of a wall and set all its attributes from the db Wall aWall = new Wall(); aWall.WallType = Convert.ToString(aReader[0]); aWall.ModelType = Convert.ToString(aReader[1]); aWall.Length = Convert.ToSingle(aReader[2]); aWall.Orientation = Convert.ToString(aReader[3]); aWall.SetBack = Convert.ToSingle(aReader[4]); aWall.Name = Convert.ToString(aReader[5]); aWall.FirstItemIndex = Convert.ToInt32(aReader[6]); aWall.LastItemIndex = Convert.ToInt32(aReader[7]); aWall.StartHeight = Convert.ToSingle(aReader[8]); aWall.EndHeight = Convert.ToSingle(aReader[9]); aWall.SoffitLength = Convert.ToSingle(aReader[10]); aWall.GablePeak = Convert.ToSingle(aReader[11]); aWall.FireProtection = Convert.ToBoolean(aReader[13]); int wallIndex = Convert.ToInt32(aReader[14]); aReader.Close(); List<LinearItem> listOfLinearItems = new List<LinearItem>(); //Get linear items //aCommand.CommandText = "SELECT linear_index, linear_type, start_height, end_height, length, frame_colour, sex, fixed_location, attached_to " // + "FROM linear_items WHERE project_id = '" + projectId + "' AND last_item_index < '" + aWall.LastItemIndex + "' AND first_item_index > '" + aWall.FirstItemIndex + "'"; //aReader = aCommand.ExecuteReader(); //for each linear item/mod in the wall //if (linearItemReader.HasRows) //{ // while (linearItemReader.Read()) // { for (int j = aWall.FirstItemIndex; j < aWall.LastItemIndex; j++) { //Get linear items aCommand.CommandText = "SELECT linear_index, linear_type, start_height, end_height, length, frame_colour, sex, fixed_location, attached_to " + "FROM linear_items WHERE project_id = '" + projectId + "' AND linear_index = '" + j + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); int linearIndex = Convert.ToInt32(aReader[0]); string linearItemType = Convert.ToString(aReader[1]); float startHeight = Convert.ToSingle(aReader[2]); float endHeight = Convert.ToSingle(aReader[3]); float length = Convert.ToSingle(aReader[4]); string frameColour = Convert.ToString(aReader[5]); string sex = Convert.ToString(aReader[6]); float fixedLocation = Convert.ToSingle(aReader[7]); bool attachedTo = Convert.ToBoolean(aReader[8]); aReader.Close(); switch (linearItemType) { case "Mod": #region Mod List<ModuleItem> listOfModuleItems = new List<ModuleItem>(); Mod aMod = new Mod(); aMod.LinearIndex = linearIndex; aMod.ItemType = linearItemType; aMod.StartHeight = startHeight; aMod.EndHeight = endHeight; aMod.Length = length; aMod.FrameColour = frameColour; aMod.Sex = sex; aMod.FixedLocation = fixedLocation; aMod.AttachedTo = attachedTo; //get number of mods aCommand.CommandText = "SELECT COUNT(*) FROM module_items WHERE project_id = '" + projectId + "' " + " AND linear_index = '" + aMod.LinearIndex + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); int modCount = Convert.ToInt32(aReader[0]); //get the number of walls in the project aReader.Close(); //aCommand.CommandText = "SELECT module_index, item_type, start_height, end_height, length FROM moduleItems " // + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "'"; //SqlDataReader moduleItemReader = aCommand.ExecuteReader(); //for each modular item in the mod //if (moduleItemReader.HasRows) //{ // while (moduleItemReader.Read()) for (int k = 0; k < modCount; k++) { //Get module items aCommand.CommandText = "SELECT module_index, item_type, start_height, end_height, length FROM module_items " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + k + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); int moduleIndex = Convert.ToInt32(aReader[0]); string itemType = Convert.ToString(aReader[1]); float fStartHeight = Convert.ToSingle(aReader[2]); float fEndHeight = Convert.ToSingle(aReader[3]); float fLength = Convert.ToSingle(aReader[4]); aReader.Close(); //different types of mods switch (itemType) { case "Kneewall": case "Window": #region Window //Get window aCommand.CommandText = "SELECT window_type, screen_type, start_height, end_height, length, window_colour, number_vents FROM windows " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; aReader = aCommand.ExecuteReader(); //if (windowReader.HasRows) //{ aReader.Read(); string windowStyle = Convert.ToString(aReader[0]); string screenType = Convert.ToString(aReader[1]); float windowStartHeight = Convert.ToSingle(aReader[2]); float windowEndHeight = Convert.ToSingle(aReader[3]); float windowLength = Convert.ToSingle(aReader[4]); string windowColour = Convert.ToString(aReader[5]); int numVents = Convert.ToInt32(aReader[6]); aReader.Close(); //types of windows switch (windowStyle) { case "Double Slider": //glass model 300 case "Single Slider": //glass model 400 case "Horizontal Roller XX": //glass model 300 case "Horizontal Roller": case "Horizontal 2 Track": case "H2T": case "Vertical 4 Track": case "Vertical Four Track": case "V4T": case "Vinyl": #region Vinyl Window VinylWindow aVinylWindow = new VinylWindow(); aVinylWindow.ModuleIndex = moduleIndex; aVinylWindow.ItemType = itemType; aVinylWindow.FStartHeight = fStartHeight; aVinylWindow.FEndHeight = fEndHeight; aVinylWindow.FLength = fLength; //aVinylWindow.Colour = windowColour; //replaced by FrameColour aVinylWindow.WindowStyle = windowStyle; aVinylWindow.ScreenType = screenType; aVinylWindow.LeftHeight = windowStartHeight; aVinylWindow.RightHeight = windowEndHeight; aVinylWindow.Width = windowLength; aVinylWindow.FrameColour = windowColour; // aVinylWindow.VinylTint = ""; // tint of each vent will be concatenated //numVents = (numVents == 0) ? 1 : numVents; aVinylWindow.NumVents = numVents; List<float> listOfVentHeights = new List<float>(); //Get vinyl item //aCommand.CommandText = "SELECT start_height, vinyl_tint, spreader_bar FROM vinyl_items " // + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; //aReader = aCommand.ExecuteReader(); //if (vinylReader.HasRows) //{ //while (vinylReader.Read()) //for each vinyl item in the in the vinyl window for (int l = 0; l < numVents; l++) { aCommand.CommandText = "SELECT start_height, vinyl_tint, spreader_bar FROM vinyl_items " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "' AND vent_index = '" + l + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); listOfVentHeights.Add(Convert.ToSingle(aReader[0])); aVinylWindow.VinylTint += Convert.ToString(aReader[1]); aVinylWindow.SpreaderBar = Convert.ToSingle(aReader[2]); aReader.Close(); } //vinylReader.Close(); aVinylWindow.VentHeights = listOfVentHeights; listOfModuleItems.Add(aVinylWindow); #endregion break; case "Screen": #region Screen Window Window aWindow = new Window(); aWindow.ModuleIndex = moduleIndex; aWindow.ItemType = itemType; aWindow.FStartHeight = fStartHeight; aWindow.FEndHeight = fEndHeight; aWindow.FLength = fLength; //aWindow.Colour = windowColour; //replaced by FrameColour aWindow.WindowStyle = windowStyle; aWindow.ScreenType = screenType; aWindow.LeftHeight = windowStartHeight; aWindow.RightHeight = windowEndHeight; aWindow.Width = windowLength; aWindow.FrameColour = windowColour; // //aWindow.VinylTint = ""; // tint of each vent will be concatenated //aWindow.NumVents = numVents; listOfModuleItems.Add(aWindow); #endregion break; case "Glass": case "Fixed Glass 2\"": #region Glass Window GlassWindow aGlassWindow = new GlassWindow(); aGlassWindow.ModuleIndex = moduleIndex; aGlassWindow.ItemType = itemType; aGlassWindow.FStartHeight = fStartHeight; aGlassWindow.FEndHeight = fEndHeight; aGlassWindow.FLength = fLength; //aGlassWindow.Colour = windowColour; //replaced by frameColour aGlassWindow.WindowStyle = windowStyle; aGlassWindow.ScreenType = screenType; aGlassWindow.LeftHeight = windowStartHeight; aGlassWindow.RightHeight = windowEndHeight; aGlassWindow.Width = windowLength; aGlassWindow.FrameColour = windowColour; // aGlassWindow.GlassTint = ""; // tint of each vent will be concatenated aGlassWindow.Operation = ""; // XX, XO, OX will be concatenated aGlassWindow.NumVents = numVents; //Get glass item //aCommand.CommandText = "SELECT glass_type, glass_tint, tempered, operation FROM glass_items " // + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; //SqlDataReader glassReader = aCommand.ExecuteReader(); for (int l = 0; l < numVents; l++) { //if (glassReader.HasRows) //{ // while (glassReader.Read()) // { aCommand.CommandText = "SELECT glass_type, glass_tint, tempered, operation FROM glass_items " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "' AND vent_index = '" + l + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); aGlassWindow.GlassType = Convert.ToString(aReader[0]); aGlassWindow.GlassTint += Convert.ToString(aReader[1]); aGlassWindow.Tempered = Convert.ToBoolean(aReader[2]); aGlassWindow.Operation += Convert.ToString(aReader[3]); aReader.Close(); } //glassReader.Close(); listOfModuleItems.Add(aGlassWindow); #endregion break; case "Open": #region Open Window Window openWindow = new Window(); openWindow.ModuleIndex = moduleIndex; openWindow.ItemType = itemType; openWindow.FStartHeight = fStartHeight; openWindow.FEndHeight = fEndHeight; openWindow.FLength = fLength; openWindow.WindowStyle = windowStyle; openWindow.ScreenType = screenType; openWindow.LeftHeight = windowStartHeight; openWindow.RightHeight = windowEndHeight; openWindow.Width = windowLength; openWindow.FrameColour = windowColour; listOfModuleItems.Add(openWindow); //add the modular item to the list #endregion break; case "Panel": case "Solid Wall": #region Open Window Window panel = new Window(); panel.ModuleIndex = moduleIndex; panel.ItemType = itemType; panel.FStartHeight = fStartHeight; panel.FEndHeight = fEndHeight; panel.FLength = fLength; panel.WindowStyle = windowStyle; panel.ScreenType = screenType; panel.LeftHeight = windowStartHeight; panel.RightHeight = windowEndHeight; panel.Width = windowLength; panel.FrameColour = windowColour; listOfModuleItems.Add(panel); //add the modular item to the list #endregion break; } //windowReader.Close(); #endregion break; case "Door": #region Door //Get door //aCommand.CommandText = "SELECT door_type, door_style, screen_type, height, length, door_colour, kick_plate FROM doors " // + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; //SqlDataReader doorReader = aCommand.ExecuteReader(); //if (doorReader.HasRows) //{ // while (doorReader.Read()) aCommand.CommandText = "SELECT door_type, door_style, screen_type, height, length, door_colour, kick_plate FROM doors " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); string doorType = Convert.ToString(aReader[0]); string doorStyle = Convert.ToString(aReader[1]); string doorScreenType = Convert.ToString(aReader[2]); float doorFrameHeight = Convert.ToSingle(aReader[3]); float doorFrameLength = Convert.ToSingle(aReader[4]); string doorColour = Convert.ToString(aReader[5]); float doorKickPlate = Convert.ToSingle(aReader[6]); aReader.Close(); //get the window in this door aCommand.CommandText = "SELECT door_index, window_type, screen_type, start_height, end_height, length, window_colour, number_vents FROM windows " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; aReader = aCommand.ExecuteReader(); VinylWindow aDoorWindow = new VinylWindow(); if (aReader.HasRows) { while (aReader.Read()) { //int doorIndex = Convert.ToInt32(aReader[0]); aDoorWindow.WindowStyle = Convert.ToString(aReader[1]); aDoorWindow.ScreenType = Convert.ToString(aReader[2]); aDoorWindow.LeftHeight = Convert.ToSingle(aReader[3]); aDoorWindow.RightHeight = Convert.ToSingle(aReader[4]); aDoorWindow.Width = Convert.ToSingle(aReader[5]); aDoorWindow.FrameColour = Convert.ToString(aReader[6]); aDoorWindow.NumVents = Convert.ToInt32(aReader[7]); } } aReader.Close(); switch (aDoorWindow.WindowStyle) //door/window style { case "Full Screen": //screen break; case "Vertical Four Track": //vinyl #region V4T List<float> listOfV4TVentHeights = new List<float>(); //for each vinyl item in the in the vinyl window //for (int l = 0; l < aDoorWindow.NumVents; l++) //Get vinyl item aCommand.CommandText = "SELECT start_height, vinyl_tint, spreader_bar FROM vinyl_items " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; SqlDataReader vinylReader = aCommand.ExecuteReader(); if (vinylReader.HasRows) { while (vinylReader.Read()) { listOfV4TVentHeights.Add(Convert.ToSingle(vinylReader[0])); aDoorWindow.VinylTint += Convert.ToString(vinylReader[1]); aDoorWindow.SpreaderBar = Convert.ToSingle(vinylReader[2]); } } vinylReader.Close(); aDoorWindow.VentHeights = listOfV4TVentHeights; #endregion break; case "Full View": //glass break; case "Full View Colonial": //glass break; case "Half Lite": //glass break; case "Half Lite Venting": //glass break; case "Half Lite with Mini Blinds": //glass break; case "Full View with Mini Blinds": //glass break; case "Aluminum Storm Screen": //screen break; case "Aluminum Storm Glass": //glass break; case "Vinyl Guard": //vinyl break; } //types of doors switch (doorType) { case "Cabana": case "Cabana Door": #region Cabana Door aCommand.CommandText = "SELECT glass_tint, hinge, swing, hardware_type, screen_type FROM cabana_doors " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; SqlDataReader cabanaReader = aCommand.ExecuteReader(); if (cabanaReader.HasRows) { cabanaReader.Read(); CabanaDoor aCabanaDoor = new CabanaDoor(); aCabanaDoor.ModuleIndex = moduleIndex; aCabanaDoor.ItemType = itemType; aCabanaDoor.FStartHeight = fStartHeight; aCabanaDoor.FEndHeight = fEndHeight; aCabanaDoor.FLength = fLength; aCabanaDoor.DoorType = doorType; aCabanaDoor.DoorStyle = doorStyle; aCabanaDoor.ScreenType = doorScreenType; aCabanaDoor.Height = doorFrameHeight; aCabanaDoor.Length = doorFrameLength; aCabanaDoor.Colour = doorColour; // aCabanaDoor.Kickplate = doorKickPlate; // aCabanaDoor.GlassTint = Convert.ToString(cabanaReader[0]); aCabanaDoor.Hinge = Convert.ToString(cabanaReader[1]); aCabanaDoor.Swing = Convert.ToString(cabanaReader[2]); aCabanaDoor.HardwareType = Convert.ToString(cabanaReader[3]); aCabanaDoor.ScreenType = Convert.ToString(cabanaReader[4]); aCabanaDoor.DoorWindow = aDoorWindow; listOfModuleItems.Add(aCabanaDoor); //add the modular item to the list } cabanaReader.Close(); #endregion break; case "French": case "French Door": #region French Door aCommand.CommandText = "SELECT glass_tint, swing, operator, hardware_type, screen_type FROM french_doors " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; SqlDataReader frenchReader = aCommand.ExecuteReader(); if (frenchReader.HasRows) { frenchReader.Read(); FrenchDoor aFrenchDoor = new FrenchDoor(); aFrenchDoor.ModuleIndex = moduleIndex; aFrenchDoor.ItemType = itemType; aFrenchDoor.FStartHeight = fStartHeight; aFrenchDoor.FEndHeight = fEndHeight; aFrenchDoor.FLength = fLength; aFrenchDoor.DoorType = doorType; aFrenchDoor.DoorStyle = doorStyle; aFrenchDoor.ScreenType = doorScreenType; aFrenchDoor.Height = doorFrameHeight; aFrenchDoor.Length = doorFrameLength; aFrenchDoor.Colour = doorColour; // aFrenchDoor.Kickplate = doorKickPlate; // aFrenchDoor.GlassTint = Convert.ToString(frenchReader[0]); aFrenchDoor.Swing = Convert.ToString(frenchReader[1]); aFrenchDoor.OperatingDoor = Convert.ToString(frenchReader[2]); ///this needs to be fixed, operator in db is bool and C# is string aFrenchDoor.HardwareType = Convert.ToString(frenchReader[3]); aFrenchDoor.ScreenType = Convert.ToString(frenchReader[4]); aFrenchDoor.DoorWindow = aDoorWindow; listOfModuleItems.Add(aFrenchDoor); //add the modular item to the list } frenchReader.Close(); #endregion break; case "Patio": case "Patio Door": #region Patio Door aCommand.CommandText = "SELECT glass_tint, moving_door FROM patio_doors " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; //change k to moduleIndex. Couldn't compile other pages. SqlDataReader patioReader = aCommand.ExecuteReader(); if (patioReader.HasRows) { patioReader.Read(); PatioDoor aPatioDoor = new PatioDoor(); aPatioDoor.ModuleIndex = moduleIndex; aPatioDoor.ItemType = itemType; aPatioDoor.FStartHeight = fStartHeight; aPatioDoor.FEndHeight = fEndHeight; aPatioDoor.FLength = fLength; aPatioDoor.DoorType = doorType; aPatioDoor.DoorStyle = doorStyle; aPatioDoor.ScreenType = doorScreenType; aPatioDoor.Height = doorFrameHeight; aPatioDoor.Length = doorFrameLength; aPatioDoor.Colour = doorColour; // aPatioDoor.Kickplate = doorKickPlate; // aPatioDoor.GlassTint = Convert.ToString(patioReader[0]); aPatioDoor.MovingDoor = Convert.ToString(patioReader[1]); ///this needs to be fixed, operator in db is bool and C# is string aPatioDoor.DoorWindow = aDoorWindow; listOfModuleItems.Add(aPatioDoor); //add the modular item to the list } patioReader.Close(); #endregion break; case "Half Lite": case "Half Lite Venting": case "Half Lite With Mini Blinds": case "Full View With Mini Blinds": break; case "NoDoor": case "No Door": #region No Door Door aDoor = new Door(); aDoor.ModuleIndex = moduleIndex; aDoor.ItemType = itemType; aDoor.FStartHeight = fStartHeight; aDoor.FEndHeight = fEndHeight; aDoor.FLength = fLength; aDoor.DoorType = doorType; //aDoor.DoorStyle = doorStyle; //aDoor.ScreenType = doorScreenType; aDoor.Height = doorFrameHeight; aDoor.Length = doorFrameLength; //aDoor.Colour = doorColour; // //aDoor.Kickplate = doorKickPlate; // listOfModuleItems.Add(aDoor); //add the modular item to the list //aReader.Close(); #endregion break; } //doorReader.Close(); #endregion break; case "Box Header": // #region H BoxHeader HBoxHeader hBoxHeader = new HBoxHeader(); hBoxHeader.ModuleIndex = moduleIndex; hBoxHeader.ItemType = itemType; hBoxHeader.FStartHeight = fStartHeight; hBoxHeader.FEndHeight = fEndHeight; hBoxHeader.FLength = fLength; listOfModuleItems.Add(hBoxHeader); //add the modular item to the list #endregion break; // case "Receiver": // #region H Receiver HReceiver hReceiver = new HReceiver(); hReceiver.ModuleIndex = moduleIndex; hReceiver.ItemType = itemType; hReceiver.FStartHeight = fStartHeight; hReceiver.FEndHeight = fEndHeight; hReceiver.FLength = fLength; listOfModuleItems.Add(hReceiver); //add the modular item to the list #endregion break; case "Panel": // same as open wall window #region Solid Wall Window Window solid = new Window(); solid.ModuleIndex = moduleIndex; solid.ItemType = itemType; solid.FStartHeight = fStartHeight; solid.FEndHeight = fEndHeight; solid.FLength = fLength; listOfModuleItems.Add(solid); //add the modular item to the list #endregion break; } aMod.ModularItems = listOfModuleItems; } listOfLinearItems.Add(aMod);//add the linear item to the list //moduleItemReader.Close(); #endregion break; case "Receiver": case "Receiever": #region Receiver BoxHeader aBoxHeader = new BoxHeader(); aBoxHeader.LinearIndex = linearIndex; aBoxHeader.ItemType = linearItemType; aBoxHeader.StartHeight = startHeight; aBoxHeader.EndHeight = endHeight; aBoxHeader.Length = length; aBoxHeader.FrameColour = frameColour; aBoxHeader.Sex = sex; aBoxHeader.FixedLocation = fixedLocation; aBoxHeader.AttachedTo = attachedTo; aBoxHeader.IsReceiver = true; aBoxHeader.IsTwoPiece = false; listOfLinearItems.Add(aBoxHeader);//add the linear item to the list #endregion break; case "2 Piece Receiver": case "2PieceReceiver": #region 2 Piece Receiver aBoxHeader = new BoxHeader(); aBoxHeader.LinearIndex = linearIndex; aBoxHeader.ItemType = linearItemType; aBoxHeader.StartHeight = startHeight; aBoxHeader.EndHeight = endHeight; aBoxHeader.Length = length; aBoxHeader.FrameColour = frameColour; aBoxHeader.Sex = sex; aBoxHeader.FixedLocation = fixedLocation; aBoxHeader.AttachedTo = attachedTo; aBoxHeader.IsReceiver = true; aBoxHeader.IsTwoPiece = true; listOfLinearItems.Add(aBoxHeader);//add the linear item to the list #endregion break; case "BoxHeader": // case "Box Header": // #region Box Header aBoxHeader = new BoxHeader(); aBoxHeader.LinearIndex = linearIndex; aBoxHeader.ItemType = linearItemType; aBoxHeader.StartHeight = startHeight; aBoxHeader.EndHeight = endHeight; aBoxHeader.Length = length; aBoxHeader.FrameColour = frameColour; aBoxHeader.Sex = sex; aBoxHeader.FixedLocation = fixedLocation; aBoxHeader.AttachedTo = attachedTo; aBoxHeader.IsReceiver = false; //aBoxHeader.IsTwoPiece = false; listOfLinearItems.Add(aBoxHeader);//add the linear item to the list #endregion break; case "BoxHeaderReceiver": case "Box Header Receiver": // #region Box Header Receiver aBoxHeader = new BoxHeader(); aBoxHeader.LinearIndex = linearIndex; aBoxHeader.ItemType = linearItemType; aBoxHeader.StartHeight = startHeight; aBoxHeader.EndHeight = endHeight; aBoxHeader.Length = length; aBoxHeader.FrameColour = frameColour; aBoxHeader.Sex = sex; aBoxHeader.FixedLocation = fixedLocation; aBoxHeader.AttachedTo = attachedTo; aBoxHeader.IsReceiver = true; //aBoxHeader.IsTwoPiece = false; listOfLinearItems.Add(aBoxHeader);//add the linear item to the list #endregion break; case "Filler": #region Filler Filler aFiller = new Filler(); aFiller.LinearIndex = linearIndex; aFiller.ItemType = linearItemType; aFiller.StartHeight = startHeight; aFiller.EndHeight = endHeight; aFiller.Length = length; //aFiller.FrameColour = frameColour; aFiller.Sex = "MM"; aFiller.FixedLocation = fixedLocation; aFiller.AttachedTo = attachedTo; listOfLinearItems.Add(aFiller);//add the linear item to the list #endregion break; case "Corner Post": case "Corner": #region Corner Post Corner aCorner = new Corner(); aCorner.LinearIndex = linearIndex; aCorner.ItemType = linearItemType; aCorner.StartHeight = startHeight; aCorner.EndHeight = endHeight; aCorner.Length = length; aCorner.FrameColour = frameColour; aCorner.Sex = sex; aCorner.FixedLocation = fixedLocation; aCorner.AttachedTo = attachedTo; //aCorner.AngleIs90 = true; //hard coded, because I don't know where its coming from //aCorner.OutsideCorner = true; // hard coded because I don't know where its coming from listOfLinearItems.Add(aCorner); //add the linear item to the list #endregion break; case "ElectricalChase": case "Electrical Chase": #region ElectricalChase ElectricalChase aElectricalChase = new ElectricalChase(); aElectricalChase.LinearIndex = linearIndex; aElectricalChase.ItemType = linearItemType; aElectricalChase.StartHeight = startHeight; aElectricalChase.EndHeight = endHeight; aElectricalChase.Length = length; //aElectricalChase.FrameColour = frameColour; aElectricalChase.Sex = "MM"; aElectricalChase.FixedLocation = fixedLocation; aElectricalChase.AttachedTo = attachedTo; listOfLinearItems.Add(aElectricalChase);//add the linear item to the list #endregion break; case "HChannel": case "H Channel": #region H Channel HChannel aHChannel = new HChannel(); aHChannel.LinearIndex = linearIndex; aHChannel.ItemType = linearItemType; aHChannel.StartHeight = startHeight; aHChannel.EndHeight = endHeight; aHChannel.Length = length; aHChannel.FrameColour = frameColour; aHChannel.Sex = sex; aHChannel.FixedLocation = fixedLocation; aHChannel.AttachedTo = attachedTo; listOfLinearItems.Add(aHChannel);//add the linear item to the list #endregion break; } } aWall.LinearItems = listOfLinearItems; listOfWalls.Add(aWall); //add the wall to the list } //linearItemReader.Close(); //wallReader.Close(); #endregion #region floors if (floorCount != 0) { } #endregion #region roofs //if there is a roof in the project if (roofCount != 0) { for(int i = 0; i < roofCount; i++) { aCommand.CommandText = "SELECT roof_type, interior_skin, exterior_skin, thickness, fire_protection, thermadeck, acrylic, gutter, gutter_pro, gutter_colour, number_supports, stripe_colour, projection, width, roof_index " + "FROM roofs WHERE project_id = '" + projectId + "' roof_index = '" + i + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); //if (roofReader.HasRows) //{ // while (roofReader.Read()) // { //create a new instance of a wall and set all its attributes from the db aRoof = new Roof(); aRoof.Type = Convert.ToString(aReader[0]); aRoof.InteriorSkin = Convert.ToString(aReader[1]); aRoof.ExteriorSkin = Convert.ToString(aReader[2]); aRoof.Thickness = Convert.ToDouble(aReader[3]); aRoof.FireProtection = Convert.ToBoolean(aReader[4]); aRoof.Thermadeck = Convert.ToBoolean(aReader[5]); aRoof.Acrylic = Convert.ToBoolean(aReader[6]); aRoof.Gutters = Convert.ToBoolean(aReader[7]); aRoof.GutterPro = Convert.ToBoolean(aReader[8]); aRoof.GutterColour = Convert.ToString(aReader[9]); aRoof.NumberSupports = Convert.ToInt32(aReader[10]); aRoof.StripeColour = Convert.ToString(aReader[11]); aRoof.Projection = Convert.ToDouble(aReader[12]); //how do we deal with obstructions aRoof.Width = Convert.ToDouble(aReader[13]); int roofIndex = Convert.ToInt32(aReader[14]); aReader.Close(); List<RoofModule> listOfRoofModules = new List<RoofModule>(); aCommand.CommandText = "SELECT COUNT(*) FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); int roofModCount = Convert.ToInt32(aReader[0]); //aCommand.CommandText = "SELECT projection, width, interior_skin, exterior_skin, roof_view " //+ "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "'"; //SqlDataReader moduleReader = aCommand.ExecuteReader(); //if (moduleReader.HasRows) //{ // while (moduleReader.Read()) for(int j = 0; j < roofModCount; j++) { aCommand.CommandText = "SELECT projection, width, interior_skin, exterior_skin, roof_view " + "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); RoofModule aModule = new RoofModule(); aModule.Projection = Convert.ToDouble(aReader[0]); aModule.Width = Convert.ToDouble(aReader[1]); aModule.InteriorSkin = Convert.ToString(aReader[2]); aModule.ExteriorSkin = Convert.ToString(aReader[3]); int roofView = Convert.ToInt32(aReader[4]); aReader.Close(); List<RoofItem> listOfRoofItems = new List<RoofItem>(); aCommand.CommandText = "SELECT COUNT(*) FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); int roofItemCount = Convert.ToInt32(aReader[0]); //aCommand.CommandText = "SELECT roof_item, projection, width, item_index " //+ "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "'"; //SqlDataReader itemReader = aCommand.ExecuteReader(); //if (itemReader.HasRows) //{ // while(itemReader.Read()) for (int k = 0; k < roofItemCount; k++) { aCommand.CommandText = "SELECT roof_item, projection, width, item_index " + "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "' AND item_index = '" + k + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); // store in an object RoofItem aRoofItem = new RoofItem(); aRoofItem.ItemType = Convert.ToString(aReader[0]); aRoofItem.Projection = Convert.ToSingle(aReader[1]); aRoofItem.Width = Convert.ToSingle(aReader[2]); int itemIndex = Convert.ToInt32(aReader[3]); aReader.Close(); ///different types of roof items switch (aRoofItem.ItemType) { case "Receiver": //no class.. what to do .. same as panel receiver? break; case "Awning Track": //no class.. what to do break; case "I-Beam": //no class.. what to do break; case "Pressure Cap I-Beam": //no class.. what to do break; case "T-Bar": //no class.. what to do break; case "Acrylic Panel": //no class.. no class ... where is colour, width, setback, projection being stored? break; case "Foam Panel": //no class ... where is colour, width, setback, projection being stored? //accordding the to db, this is the only item in which you can have fanbeams and skylight //check for skylight in this roof item //are all skylights the same? length/width etc? .. //there is no skylight object.. roof item should have a attribute for a skylight object aCommand.CommandText = "SELECT skylight_type, set_back, operator " + "FROM skylights WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "' AND item_index '" + itemIndex + "'"; SqlDataReader skylightReader = aCommand.ExecuteReader(); if (skylightReader.HasRows) { while (skylightReader.Read()) { //Skylight aSkylight = new Skylight(); //create object and set attribute if required aRoofItem.SkyLight = Convert.ToSingle(skylightReader[1]); } } else { aRoofItem.SkyLight = -1; } skylightReader.Close(); //check for fanbeams in this roof item //no info in the db or in C# aCommand.CommandText = "SELECT skylight_type, set_back, operator " + "FROM fanbeams WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "' AND item_index = '" + itemIndex + "'"; SqlDataReader fanbeamReader = aCommand.ExecuteReader(); if (fanbeamReader.HasRows) { while (fanbeamReader.Read()) { //Skylight aSkylight = new Skylight(); //create object and set attribute if required aRoofItem.FanBeam = Convert.ToSingle(skylightReader[1]); } } else { aRoofItem.FanBeam = -1; } fanbeamReader.Close(); break; } listOfRoofItems.Add(aRoofItem); } //itemReader.Close(); aModule.RoofItems = listOfRoofItems; listOfRoofModules.Add(aModule); } //moduleReader.Close(); aRoof.RoofModules = listOfRoofModules; } //roofReader.Close(); } #endregion aTransaction.Commit(); hidJsonObjects.Value = JsonConvert.SerializeObject(listOfWalls); } catch (Exception ex) { //lblError.Text = "Commit Exception Type: " + ex.GetType(); //lblError.Text += " Message: " + ex.Message; // Attempt to roll back the transaction. try { aTransaction.Rollback(); } catch (Exception ex2) { //This catch block will handle any errors that may have occurred //on the server that would cause the rollback to fail, such as //a closed connection. //lblError.Text = "Rollback Exception Type: " + ex2.GetType(); //lblError.Text += " Message: " + ex2.Message; } } } #endregion hidJsonObjects.Value = JsonConvert.SerializeObject(listOfWalls); PopulateDropdown(floorCount, roofCount); PopulateModOptions(); //lnkUpdateSunroom.Attributes.Add("onclick", "updateSunroom()"); //lnkSubmitSunroom.Attributes.Add("onclick", "submitSunroom()"); //lnkEditorNavMods.Attributes.Add("onclick", "$('.overlayContainer').slideToggle()"); //lnkEditorNavTools.Attributes.Add("onclick", "$('#saveButtons').fadeToggle(); $('.btnTools').slideToggle();"); lnkEditorNavSave.Attributes.Add("onclick", "updateSunroom()"); lnkEditorNavUndo.Attributes.Add("onclick", "undo()"); lnkEditorNavRedo.Attributes.Add("onclick", "redo()"); //Add list of all objects to session, for use by other pages accessed through project editor try { Session.Add("listOfWalls", listOfWalls); } catch (Exception ex) { Session["listOfWalls"] = listOfWalls; } }
private RoofModule buildStudioRoofModule(float roofProjection, float roofWidth) { //Variables that will be used to build the roof module float panelWidth; string panelBeamType; string panelType; float panelBeamWidth; float numberOfPanels; float itemWidthTotal; List<RoofItem> itemList = new List<RoofItem>(); List<RoofModule> moduleList = new List<RoofModule>(); string roofStyle = Request.Form["ctl00$MainContent$roofStyleRadiosStudio"]; //float roofFrontHeight = float.Parse(Request.Form["ctl00$MainContent$txtFrontHeightStudio"]); //May not be needed since no slope is required //float roofBackHeight = float.Parse(Request.Form["ctl00$MainContent$txtBackHeightStudio"]); //May not be needed since no slope is required string panelExteriorSkin; string panelInteriorSkin; if (roofStyle == "Alum. Skin or O.S.B.") { panelType = Request.Form["ctl00$MainContent$ddlPanelTypeStudio"]; panelExteriorSkin = Request.Form["ctl00$MainContent$ddlExteriorSkinStudio"]; panelInteriorSkin = Request.Form["ctl00$MainContent$ddlInteriorSkinStudio"]; } else { panelType = "Pressure Cap"; if (roofStyle == "Thermadeck System") { //Thermadeck systems must be osb/osb panelExteriorSkin = "OSB"; panelInteriorSkin = "OSB"; } else { panelExteriorSkin = Request.Form["ctl00$MainContent$ddlExteriorSkinStudio"]; panelInteriorSkin = Request.Form["ctl00$MainContent$ddlInteriorSkinStudio"]; } } if (panelType.Contains("I-Beam")) { panelBeamType = "I-Beam"; panelBeamWidth = Constants.ROOF_IBEAM_WIDTH; } else if (panelType.Contains("Pressure Cap")) { panelBeamType = "Pressure Cap"; panelBeamWidth = Constants.ROOF_PRESSURECAP_WIDTH; } else { panelBeamType = "Thermadeck"; //Thermadeck uses wood underneath the panels, so there is essentially no width to seperator beams panelBeamWidth = 0f; } if (roofStyle == "Alum. Skin or O.S.B.") { panelWidth = Constants.FOAM_PANEL_WIDTH; panelType = "Foam Panel"; } else if (roofStyle == "Acrylic T-Bar System") { panelBeamType = "T-Bar"; panelWidth = Constants.ACRYLIC_PANEL_WIDTH; panelType = "Acrylic Panel"; } else { panelBeamType = "None"; panelWidth = Constants.THERMADECK_PANEL_WIDTH; panelType = "Thermadeck Panel"; } numberOfPanels = (float)Math.Ceiling(roofWidth / panelWidth); //If it requires 'part' of a panel, that is essentially another panel, just cut. Cut will be handled later. if (roofStyle != "Thermadeck System") { //Add the first panel, because if we loop adding panel+seperator, we will end with one extra itemList.Add(new RoofItem(panelType, roofProjection, panelWidth, -1f, -1f)); //loop adding seperator then panels, minus one iteration because one panel is already added for (int i = 0; i < (numberOfPanels - 1); i++) { itemList.Add(new RoofItem(panelBeamType, roofProjection, (float)panelBeamWidth, -1f, -1f)); itemList.Add(new RoofItem(panelType, roofProjection, panelWidth, -1f, -1f)); } } //if it is thermadeck else { for (int i = 0; i < numberOfPanels; i++) { itemList.Add(new RoofItem(panelType, roofProjection, panelWidth, -1f, -1f)); } } itemWidthTotal = 0; //Total width of items for (int i = 0; i < itemList.Count; i++) { itemWidthTotal += itemList[i].Width; } //If this width doesn't fit perfectly (is more than roof width) we'll need to make a cut on the last panel if (itemWidthTotal > roofWidth) { //at .count-1 to get last item, which should be the final panel //We subtract the difference that the panel exceeds to make the 'cut' itemList[itemList.Count - 1].Width -= (itemWidthTotal - roofWidth); } RoofModule aModule = new RoofModule(roofProjection, roofWidth, panelInteriorSkin, panelExteriorSkin, itemList); return aModule; }