private bool AddButtonMethod(Apartment agOutput) { if (agOutput.AptLines.Count == 0) { return(false); } double grossAreaRatio = agOutput.GetGrossAreaRatio(); double buildingCoverage = agOutput.GetBuildingCoverage(); int buildingNums = agOutput.Household.Count; int householdNums = agOutput.GetHouseholdCount(); int parkingLot = (int)(agOutput.ParkingLotOnEarth.GetCount() + agOutput.ParkingLotUnderGround.Count); int neededParkingLot = (int)System.Math.Round((double)agOutput.GetLegalParkingLotofHousing() + agOutput.GetLegalParkingLotOfCommercial()); Grid tempGrid = new Grid(); tempGrid.HorizontalAlignment = HorizontalAlignment.Stretch; tempGrid.Width = 560; ColumnDefinition firstColDef = new ColumnDefinition(); firstColDef.Width = new GridLength(2, GridUnitType.Star); tempGrid.ColumnDefinitions.Add(firstColDef); ColumnDefinition secondColDef = new ColumnDefinition(); secondColDef.Width = new GridLength(0, GridUnitType.Pixel); tempGrid.ColumnDefinitions.Add(secondColDef); for (int i = 0; i < 7; i++) { ColumnDefinition tempColDef = new ColumnDefinition(); tempColDef.Width = new GridLength(1, GridUnitType.Star); tempGrid.ColumnDefinitions.Add(tempColDef); } ColumnDefinition lastColDef = new ColumnDefinition(); lastColDef.Width = new GridLength(17, GridUnitType.Pixel); tempGrid.ColumnDefinitions.Add(lastColDef); TextBlock algorithmTextBlock = createTextBlock(CommonFunc.GetApartmentType(agOutput)); tempGrid.Children.Add(algorithmTextBlock); Grid.SetColumn(algorithmTextBlock, 0); TextBlock grossAreaRatioTextBlock = createTextBlock(((int)grossAreaRatio).ToString() + "%"); tempGrid.Children.Add(grossAreaRatioTextBlock); Grid.SetColumn(grossAreaRatioTextBlock, 2); TextBlock buildingCoverageTextBlock = createTextBlock(((int)buildingCoverage).ToString() + "%"); tempGrid.Children.Add(buildingCoverageTextBlock); Grid.SetColumn(buildingCoverageTextBlock, 3); //parameter 를 그대로 층수로 사용 했었으나, 지역 최적화에서 층수를 낮추는 과정에서 실제 층수와 맞지 않을수 있어 수정 //TextBlock storiesTextBlock = createTextBlock(((int)agOutput.ParameterSet.Stories + 1).ToString() + "층"); TextBlock storiesTextBlock = createTextBlock(((int)agOutput.Household.Count + 1).ToString() + "층"); tempGrid.Children.Add(storiesTextBlock); Grid.SetColumn(storiesTextBlock, 4); TextBlock householdNumsTextBlock = createTextBlock(householdNums.ToString() + "세대"); tempGrid.Children.Add(householdNumsTextBlock); Grid.SetColumn(householdNumsTextBlock, 5); TextBlock commerCialTextBlock = createTextBlock(Math.Round(agOutput.GetCommercialArea() / agOutput.GetGrossArea() * 100, 1).ToString() + "%"); tempGrid.Children.Add(commerCialTextBlock); Grid.SetColumn(commerCialTextBlock, 6); TextBlock parkingLotTextBlock = createTextBlock(parkingLot.ToString() + "/" + neededParkingLot); tempGrid.Children.Add(parkingLotTextBlock); Grid.SetColumn(parkingLotTextBlock, 7); TextBlock parkingLotUnderGroundTextBlock = createTextBlock(agOutput.ParkingLotUnderGround.Count.ToString()); tempGrid.Children.Add(parkingLotUnderGroundTextBlock); Grid.SetColumn(parkingLotUnderGroundTextBlock, 8); Button btn = new Button(); string[] stackPannelButtonStyle = { "stackPannelButtonStyle1", "stackPannelButtonStyle2" }; string tempStyle = stackPannelButtonStyle[stackPanel.Children.Count % 2]; System.Windows.Style style = this.FindResource(tempStyle) as System.Windows.Style; btn.Style = style; btn.Content = tempGrid; btn.Height = 21; btn.Click += StackButton_Click; btn.MouseDoubleClick += StackButton_DoubleClick; stackPanel.Children.Add(btn); return(true); }