public xmlBuildingReport(Apartment AGoutput)
 {
     InitializeComponent();
     this.projectName.Text              = TuringAndCorbusierPlugIn.InstanceClass.page1Settings.ProjectName;
     this.address.Text                  = TuringAndCorbusierPlugIn.InstanceClass.page1Settings.Address;
     this.plotType.Text                 = TuringAndCorbusierPlugIn.InstanceClass.page1Settings.PlotType;
     this.plotArea_Manual.Text          = Math.Round(TuringAndCorbusierPlugIn.InstanceClass.page1Settings.PlotArea, 2).ToString() + "m\xB2";
     this.plotArea_Manual_Py.Text       = Math.Round(TuringAndCorbusierPlugIn.InstanceClass.page1Settings.PlotArea / 3.3, 2).ToString() + "평";
     this.plotArea_Unusable.Text        = (0).ToString() + "m\xB2";
     this.plotArea_Unusable_Py.Text     = (0 / 3.3).ToString() + "평";
     this.plotArea_Usable.Text          = Math.Round(AGoutput.Plot.GetArea() / 1000000, 2).ToString() + "m\xB2";
     this.plotArea_Usable_Py.Text       = Math.Round(AGoutput.Plot.GetArea() / 1000000 / 3.3, 2).ToString() + "평";
     this.buildingType.Text             = "공동주택(" + CommonFunc.GetApartmentType(AGoutput) + ")";
     this.buildingScale.Text            = buildingScaleForReport(AGoutput);
     this.buildingArea.Text             = Math.Round(AGoutput.GetBuildingArea() / 1000000, 2).ToString() + "m\xB2";
     this.buildingArea_Py.Text          = Math.Round(AGoutput.GetBuildingArea() / 1000000 / 3.3, 2).ToString() + "평";
     this.grossArea_UnderGround.Text    = Math.Round(AGoutput.ParkingLotUnderGround.ParkingArea / 1000000, 2).ToString() + "m\xB2";   //////////////////////////////////////////////////////////////
     this.grossArea_UnderGround_Py.Text = Math.Round(AGoutput.ParkingLotUnderGround.ParkingArea / 1000000 / 3.3, 2).ToString() + "평"; //////////////////////////////////////////////////////////////
     this.grossArea_OverGround.Text     = Math.Round(AGoutput.GetGrossArea() / 1000000, 2).ToString() + "m\xB2";
     this.grossArea_OverGround_Py.Text  = Math.Round(AGoutput.GetGrossArea() / 1000000 / 3.3, 2).ToString() + "평";
     this.grossArea.Text                = Math.Round((AGoutput.GetGrossArea() + 1) / 1000000, 2).ToString() + "m\xB2";   //////////////////////////////////////////////////////////////
     this.grossArea_Py.Text             = Math.Round((AGoutput.GetGrossArea() + 1) / 1000000 / 3.3, 2).ToString() + "평"; //////////////////////////////////////////////////////////////
     this.BPR.Text                    = Math.Round((AGoutput.GetBalconyArea() + AGoutput.ParkingLotUnderGround.ParkingArea + AGoutput.GetCoreAreaOnEarthSum()) / 1000000, 2).ToString() + "m\xB2";
     this.BPR_Py.Text                 = Math.Round((AGoutput.GetBalconyArea() + AGoutput.ParkingLotUnderGround.ParkingArea + AGoutput.GetCoreAreaOnEarthSum()) / 1000000 / 3.3, 2).ToString() + "평";
     this.ConstructionArea.Text       = Math.Round((AGoutput.GetGrossArea() + AGoutput.GetBalconyArea() + AGoutput.ParkingLotUnderGround.ParkingArea + AGoutput.GetCoreAreaOnEarthSum()) / 1000000, 2).ToString() + "m\xB2";
     this.ConstructionArea_Py.Text    = Math.Round((AGoutput.GetGrossArea() + AGoutput.GetBalconyArea() + AGoutput.ParkingLotUnderGround.ParkingArea + AGoutput.GetCoreAreaOnEarthSum()) / 1000000 / 3.3, 2).ToString() + "평";
     this.buildingCoverage.Text       = Math.Round(AGoutput.GetBuildingCoverage(), 2).ToString() + "%";
     this.buildingCoverage_legal.Text = "(법정 : " + Math.Round(TuringAndCorbusierPlugIn.InstanceClass.page1Settings.MaxBuildingCoverage) + "%)";
     this.floorAreaRatio.Text         = Math.Round(AGoutput.GetGrossAreaRatio(), 2).ToString() + "%";
     this.floorAreaRatio_legal.Text   = "(법정 : " + Math.Round(TuringAndCorbusierPlugIn.InstanceClass.page1Settings.MaxFloorAreaRatio) + "%)";
     this.numOfHouseHolds.Text        = AGoutput.GetHouseholdCount().ToString() + "세대";
     this.NumOfPakringLots.Text       = (AGoutput.ParkingLotOnEarth.GetCount() + AGoutput.ParkingLotUnderGround.Count).ToString() + "대";
     this.ParkingLotArea.Text         = "(주차장면적 : " + (AGoutput.ParkingLotUnderGround.ParkingArea / 1000000).ToString() + "m\xB2)";
 }
        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);
        }
        public void UpdateSummary(Apartment agOutput)
        {
            BuildingType.Text = "공동주택(" + agOutput.BuildingType.ToString() + ")";

            BuildingScale.Text = "지상 1층 ~ " + (agOutput.ParameterSet.Stories + 1).ToString() + "층";

            BuildingArea.Text          = Math.Round(agOutput.GetBuildingArea() / 1000000, 2).ToString() + " m\xB2";
            BuildingArea_Py.Text       = "(" + Math.Round(agOutput.GetBuildingArea() / 1000000 / 3.3, 2).ToString() + " 평)";
            BuildingCoverage.Text      = ((int)agOutput.GetBuildingCoverage()).ToString() + " %";
            LegalBuildingCoverage.Text = "(법정 : " + TuringAndCorbusierPlugIn.InstanceClass.page1Settings.MaxBuildingCoverage.ToString() + " %)";

            GrossArea.Text      = Math.Round(agOutput.GetGrossArea() / 1000000, 2).ToString() + " m\xB2";
            GrossArea_Py.Text   = "(" + Math.Round(agOutput.GetGrossArea() / 1000000 / 3.3, 2).ToString() + " 평)";
            FloorAreaRatio.Text = ((int)agOutput.GetGrossAreaRatio()).ToString() + " %";

            int numberOfHousing = 0;

            foreach (List <List <Household> > i in agOutput.Household)
            {
                foreach (List <Household> j in i)
                {
                    numberOfHousing += j.Count();
                }
            }
            NumOfHousing.Text = numberOfHousing.ToString() + "세대";

            NumOfParking.Text = (agOutput.ParkingLotOnEarth.GetCount() + agOutput.ParkingLotUnderGround.Count).ToString() + "대";


            List <double> firstFloorHHArea = new List <double>();

            for (int i = 0; i < agOutput.Household[0].Count; i++)
            {
                for (int j = 0; j < agOutput.Household[0][i].Count; j++)
                {
                    double round = Math.Round(agOutput.Household[0][i][j].ExclusiveArea / 1000000);
                    if (!firstFloorHHArea.Contains(round))
                    {
                        firstFloorHHArea.Add(round);
                    }
                }
            }
            var ta = firstFloorHHArea.OrderBy(n => n).ToList();

            int[] type = new int[ta.Count];
            type = type.Select(n => 0).ToArray();
            foreach (var hh in agOutput.Household)
            {
                foreach (var h in hh)
                {
                    foreach (var x in h)
                    {
                        for (int i = 0; i < ta.Count; i++)
                        {
                            double round = Math.Round(x.ExclusiveArea / 1000000);
                            if (round == ta[i])
                            {
                                type[i]++;
                                break;
                            }
                        }
                    }
                }
            }

            TextBlock[] title = new TextBlock[] { most1, most2, most3, most4, most5 };
            TextBlock[] count = new TextBlock[] { nummost1, nummost2, nummost3, nummost4, nummost5 };


            for (int i = 0; i < title.Length; i++)
            {
                if (i < ta.Count)
                {
                    title[i].Text = ta[i].ToString() + " m2 형";
                    count[i].Text = type[i].ToString();
                }

                else
                {
                    title[i].Text = "";
                    count[i].Text = "";
                }
            }
        }