Exemplo n.º 1
0
 public void ExportCsv()
 {
     Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog {
         Filter = "Comma Separated Values (*.csv)|*.csv"
     };
     if (sfd.ShowDialog() == true)
     {
         var model    = new LcComputation(MapDataManager.LatestMap, Demo.CaculateType);
         var exporter = new Dreambuild.IO.CsvExporter <ComputationUnit>(model.AllUnits, new List <string>
         {
             "Name",
             "Type",
             "GreenField",
             "Area",
             "Floor",
             "Populations",
             "CarbonProduction.Material",
             "CarbonProduction.Construction",
             "CarbonProduction.Maintenance",
             "CarbonProduction.Maintenance.AirConditioning",
             "CarbonProduction.Maintenance.Lighting",
             "CarbonProduction.Maintenance.Equipment",
             "CarbonProduction.Maintenance.Heating",
             "CarbonProduction.Recycle",
             "GreenFieldConsumption"
         });
         exporter.Headers.AddRange(new List <string>
         {
             "名称",
             "类型",
             "绿地类型",
             "面积",
             "建筑面积",
             "人口",
             "建材准备",
             "建造过程",
             "运行维护",
             "空调",
             "照明",
             "设备",
             "供暖",
             "拆毁回收",
             "绿地碳汇"
         });
         exporter.ShowHeaders = true;
         exporter.Export(sfd.FileName);
         MainDemo.TryOpenFile(sfd.FileName);
     }
 }
Exemplo n.º 2
0
        private void OK_Button_Click(object sender, RoutedEventArgs e)
        {
            int sum = baseParams.NaturalGasRatio + baseParams.CoalElectricityRatio + baseParams.OtherCleanEnergyRatio;

            if (sum != 100)
            {
                MessageBox.Show("比例之和必须为100");
            }
            else
            {
                this.DialogResult = true;

                if (originalEnergySavingRatio != baseParams.Standard)
                {
                    var model = new LcComputation(MapDataManager.LatestMap, Demo.CaculateType);
                    model.SetEnergySavingRatio(baseParams.Standard);
                }
                (MainWindow.DemoInstance as Demo).RefreshComputation();
            }
        }
        private void OK_Button_Click(object sender, RoutedEventArgs e)
        {
            var model = new LcComputation(MapDataManager.LatestMap, Demo.CaculateType);

            if (backup.PerCapitaIndustry != Parameter.Trip.PerCapitaIndustry)
            {
                model.SetPerCapitaIndustry(Parameter.Trip);
            }
            if (backup.PerCapitaOffice != Parameter.Trip.PerCapitaOffice)
            {
                model.SetPerCapitaOffice(Parameter.Trip);
            }
            if (backup.PerCapitaResidencial != Parameter.Trip.PerCapitaResidencial)
            {
                model.SetPerCapitaResidencial(Parameter.Trip);
            }
            (MainWindow.DemoInstance as Demo).RefreshComputation();

            this.Close();
        }
        private void Button_Result(object sender, RoutedEventArgs e)
        {
            try
            {
                var model  = new LcComputation(MapDataManager.LatestMap, Demo.CaculateType);
                var result = new ResultSummary
                {
                    Count    = model.AllUnits.Count,
                    Area     = model.AllUnits.Sum(x => x.Area),
                    Green    = model.GetGreenCarbonConsumption(),
                    Building = model.GetBuildingCarbonProduction(),
                    Trip     = model.GetTripCarbonProduction()
                };

                string SumResult = LocalizationHelper.GetString("RS:SumResult");
                Gui.PropertyWindow(SumResult, result, 300, 400);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR");
            }
        }
        private void Button_Visualization(object sender, RoutedEventArgs e)
        {
            var dict = new Dictionary <string, string>();

            dict["1. 建材准备"] = "CarbonProduction.Material";
            dict["2. 建造过程"] = "CarbonProduction.Construction";
            dict["3. 运行维护"] = "CarbonProduction.Maintenance";
            dict["3.1 空调"]  = "CarbonProduction.Maintenance.AirConditioning";
            dict["3.2 照明"]  = "CarbonProduction.Maintenance.Lighting";
            dict["3.3 设备"]  = "CarbonProduction.Maintenance.Equipment";
            dict["3.4 供暖"]  = "CarbonProduction.Maintenance.Heating";
            dict["4. 拆毁回收"] = "CarbonProduction.Recycle";
            dict["5. 绿地碳汇"] = "GreenFieldConsumption";
            dict["6. 功能类型"] = "Type";
            var options  = dict.Keys.ToArray();
            var optionsE = dict.Values.ToArray();
            Tuple <string, int> opt;
            bool   isDensity = false;
            string caption;
            string title;
            string url = GetFileUrl("Web/legend.html");

            if (LocalizationHelper.CurrentLocale == Locales.ZH_CN)
            {
                opt     = GetOption2("选择项目", options);
                caption = "图例";
                title   = "图例";
            }
            else
            {
                opt     = GetOption2("Choose project", optionsE);
                caption = "Legend";
                title   = "Legend";
            }
            if (opt.Item1 == "Cancel")
            {
                return;
            }
            if (opt.Item1 == "B")
            {
                isDensity = true;
                title    += " (kg/m2)";
            }
            else
            {
                if (opt.Item2 != 9)
                {
                    title += " (kg)";
                }
            }
            var model = new LcComputation(MapDataManager.LatestMap, Demo.CaculateType);
            var path  = dict[options[opt.Item2]];

            if (path == "Type")
            {
                var theme = new LcTypeTheme();
                MapControl.Current.Layers.ForEach(x => x.ApplyColorTheme(theme));
                var items = theme.BuildLegend().Select(x => new { text = x.Item1, color = x.Item2 }).ToArray();
                var data  = new { title, items };
                System.IO.File.WriteAllText("Web/data/legend.json", Newtonsoft.Json.JsonConvert.SerializeObject(data));
            }
            else
            {
                var theme = isDensity ? new LcColorTheme(path, (x, cu) => x / cu.Area) : new LcColorTheme(path);
                theme.DetermineValueRange(model.AllUnits);
                MapControl.Current.Layers
                .Where(l => l.LayerData.GeoType == VectorLayer.GEOTYPE_REGION)
                .ForEach(x => x.ApplyColorTheme(theme));
                var items = theme.BuildLegend(5, opt.Item2 == 7).Select(x => new { text = x.Item1, color = x.Item2 }).ToArray();
                var data  = new { title, items };
                System.IO.File.WriteAllText("Web/data/legend.json", Newtonsoft.Json.JsonConvert.SerializeObject(data));
            }
            Gui.WebBrowser(caption, url, 450, 400);
        }
Exemplo n.º 6
0
 public void UpdateResult()
 {
     LcComputation.GetBuildingCarbonProduction(this);
     LcComputation.GetGreenCarbonConsumption(this);
 }