public static void MakePage([JetBrains.Annotations.NotNull] Document doc, [JetBrains.Annotations.NotNull] string dstdir,
                                    bool requireAll, FileCreationMode fileCreationMode,
                                    [CanBeNull] Section tocSection, [JetBrains.Annotations.NotNull] string csvCharacter)
        {
            string filename = null;

            if (fileCreationMode == FileCreationMode.Settlement && File.Exists(Path.Combine(dstdir, "totals.csv")))
            {
                filename = Path.Combine(dstdir, DirectoryNames.CalculateTargetdirectory(TargetDirectory.Root),
                                        "Totals.csv");
            }

            if (fileCreationMode == FileCreationMode.Household && File.Exists(Path.Combine(dstdir,
                                                                                           DirectoryNames.CalculateTargetdirectory(TargetDirectory.Reports), "TotalsPerLoadtype.csv")))
            {
                filename = Path.Combine(dstdir, DirectoryNames.CalculateTargetdirectory(TargetDirectory.Reports),
                                        "TotalsPerLoadtype.csv");
            }
            if (filename == null)
            {
                if (requireAll)
                {
                    throw new LPGException("Missing totals files.");
                }
                return;
            }

            var sec = doc.AddSection();

            var para = sec.AddParagraph();

            para.Format.Alignment   = ParagraphAlignment.Justify;
            para.Format.Font.Name   = "Times New Roman";
            para.Format.Font.Size   = 20;
            para.Format.Font.Bold   = true;
            para.Format.SpaceAfter  = "0.5cm";
            para.Format.SpaceBefore = "1cm";
            para.Format.Font.Color  = Colors.DarkGray;
            para.AddText("Totals");
            ChartPageBase.MakeTocEntry(tocSection, "Totals");
            para.AddBookmark("Totals");

            switch (fileCreationMode)
            {
            case FileCreationMode.Household:
                var totals = TotalsReader(filename, false, csvCharacter);
                SetHouseholdEntries(totals, doc, sec);
                SetPerDayTable(totals, doc, sec);
                SetMinMaxTable(totals, doc, sec);
                SetPerPersonTable(totals, doc, sec);
                SetPerPersonDayTable(totals, doc, sec);
                return;

            case FileCreationMode.Settlement:
                SetSettlementEntries(doc, sec, filename, csvCharacter);
                return;

            default: throw new LPGException("Forgotten File Creation Mode");
            }
        }
        public void MakePage(Document doc, string dstdir, bool requireAll, List <string> pngFiles, Section tocSection)
        {
            if (MyTargetDirectory == TargetDirectory.Undefined)
            {
                throw new LPGException("Undefined Target Directory in " + SectionTitle);
            }
            var di =
                new DirectoryInfo(Path.Combine(dstdir, DirectoryNames.CalculateTargetdirectory(MyTargetDirectory)));
            var files = di.GetFiles(Pattern);

            if (files.Length == 0)
            {
                if (requireAll)
                {
                    throw new LPGException("Missing files for " + SectionTitle);
                }
                return;
            }
            var sec = MakeDescriptionArea(doc, tocSection);

            foreach (var file in files)
            {
                pngFiles.Remove(file.Name);
                AddImageToSection(sec, file);
                // img.WrapFormat
            }
        }
        public void MakePage([JetBrains.Annotations.NotNull] Document doc, [JetBrains.Annotations.NotNull] string dstdir, bool requireAll, [JetBrains.Annotations.NotNull] Section tocSection)
        {
            var di =
                new DirectoryInfo(
                    Path.Combine(dstdir, DirectoryNames.CalculateTargetdirectory(TargetDirectory.Reports)));
            var fi = di.GetFiles("Thoughts.*.csv");

            if (fi.Length == 0)
            {
                if (requireAll)
                {
                    throw new LPGException("Missing Throughs files");
                }
                return;
            }
            var sec = MakeDescriptionArea(doc, tocSection);

            foreach (var fileInfo in fi)
            {
                var strings = new List <string>();
                using (var sr = new StreamReader(fileInfo.FullName)) {
                    var row = 0;
                    while (!sr.EndOfStream && row < 20)
                    {
                        var s = sr.ReadLine();
                        strings.Add(s);
                        row++;
                    }
                }
                var sb = new StringBuilder();
                foreach (var s in strings)
                {
                    sb.Append(s + Environment.NewLine);
                }
                var para = sec.AddParagraph();
                para.Format.Alignment  = ParagraphAlignment.Justify;
                para.Format.Font.Name  = "Times New Roman";
                para.Format.Font.Size  = 12;
                para.Format.Font.Bold  = false;
                para.Format.SpaceAfter = "0.25cm";
                para.Format.Font.Color = Colors.Black;

                para.AddText(fileInfo.Name);

                para = sec.AddParagraph();
                para.Format.Alignment  = ParagraphAlignment.Left;
                para.Format.Font.Name  = "Times New Roman";
                para.Format.Font.Size  = 10;
                para.Format.Font.Bold  = false;
                para.Format.SpaceAfter = "0.25cm";
                para.Format.Font.Color = Colors.Black;

                para.AddText(sb.ToString());
            }
        }
        private static List <string> GetSettlementStrings([JetBrains.Annotations.NotNull] string destinationDirectory)
        {
            var filename = Path.Combine(destinationDirectory,
                                        DirectoryNames.CalculateTargetdirectory(TargetDirectory.Root), "Information.txt");
            var strings = new List <string>();

            if (!File.Exists(filename))
            {
                return(strings);
            }

            using (var sr = new StreamReader(filename)) {
                while (!sr.EndOfStream)
                {
                    strings.Add(sr.ReadLine());
                }
            }
            return(strings);
        }
Пример #5
0
        public void MakePage([JetBrains.Annotations.NotNull] Document doc, [JetBrains.Annotations.NotNull] string dstdir, bool requireAll, [JetBrains.Annotations.NotNull] Section tocSection)
        {
            var di =
                new DirectoryInfo(Path.Combine(dstdir, DirectoryNames.CalculateTargetdirectory(MyTargetDirectory)));
            var files = di.GetFiles(Pattern);

            if (files.Length == 0)
            {
                if (requireAll)
                {
                    throw new LPGException("Missing Carpet plots");
                }
                return;
            }
            var sec = MakeDescriptionArea(doc, tocSection);

            foreach (var file in files)
            {
                AddImageToSection(sec, file);
                if (file.Name.Contains("Carpetplot."))
                {
                    var legendFileName = file.Name.Replace("Carpetplot.", "CarpetplotLegend.").Replace(".7.", ".");
                    if (file.DirectoryName == null)
                    {
                        throw new LPGException("Directory Name was null");
                    }

                    var legendFile = new FileInfo(Path.Combine(file.DirectoryName, legendFileName));
                    if (legendFile.Exists)
                    {
                        AddImageToSection(sec, legendFile, "Legend for the previous carpet plot");
                    }
                }
                // img.WrapFormat
            }
        }
        public void Run([JetBrains.Annotations.NotNull] CalculationProfiler cp, [JetBrains.Annotations.NotNull] string outputDirectory, [JetBrains.Annotations.NotNull] string source)
        {
            //var cp =  CalculationProfiler.Read(@"C:\work\CalculationBenchmarks.ActionCarpetPlotTest\");

            InitializeDuration2(cp.MainPart);
            MergeAndCompress(cp.MainPart);
            InitPartsList(cp.MainPart);
            const int fontsize = 6;// = GetFontsize(cp.MainPart);
            //const string xaxislabel = "Time Consumption in CPUSeconds";

            OxyPalette p;

            if (_parts.Count > 1)
            {
                p = OxyPalettes.HueDistinct(_parts.Count);
            }
            else
            {
                p = OxyPalettes.Hue64;
            }
            var plotModel1 = new PlotModel
            {
                LegendBorderThickness = 0,
                LegendOrientation     = LegendOrientation.Vertical,
                LegendPlacement       = LegendPlacement.Inside,
                LegendPosition        = LegendPosition.TopLeft,
                PlotAreaBorderColor   = OxyColors.White,
                LegendFontSize        = fontsize,
                LegendSymbolMargin    = 25,
                DefaultFontSize       = fontsize
            };

            var ca = new CategoryAxis
            {
                Position       = AxisPosition.Left,
                GapWidth       = 0,
                MaximumPadding = 0.03,
                MajorTickSize  = 0
            };

            plotModel1.Axes.Add(ca);

            /* var la = new LinearAxis
             * {
             *   Minimum = 0,
             *   MinimumPadding = 0,
             *   Title = ChartLocalizer.Get().GetTranslation(xaxislabel),
             *   Position = AxisPosition.Bottom,
             *   MinorTickSize = 0
             * };*/
            /*  plotModel1.Axes.Add(la);
             * var caSub = new CategoryAxis();
             * caSub.StartPosition = 0.5;
             * caSub.EndPosition = 1;
             * caSub.Position = AxisPosition.Left;
             * caSub.Key = "Sub";
             * caSub.GapWidth = 0.3;
             * caSub.MajorTickSize = 0;
             * caSub.MinorTickSize = 0;
             * plotModel1.Axes.Add(caSub);*/
            //const double runningSum = 0;
            //var row = 0;

            // var allBarSeries = new Dictionary<string, IntervalBarSeries>();
            //var ba = new BarSeries();
            //ba.YAxisKey = "Sub";
            //ba.LabelFormatString = "{0:N1} %";

            /*  foreach (var s in taggingSet.Categories)
             * {
             *    caSub.Labels.Add(ChartLocalizer.Get().GetTranslation(s));
             *    var ibs = new IntervalBarSeries();
             *    // ibs.Title =
             *    var coloridx = taggingSet.GetCategoryIndexOfCategory(s);
             *    ibs.FillColor = p.Colors[coloridx];
             *    ibs.StrokeThickness = 0;
             *    ibs.FontSize = fontsize;
             *    allBarSeries.Add(s, ibs);
             *    double categorysum = 0;
             *    foreach (var tuple in consumption)
             *    {
             *        if (taggingSet.AffordanceToCategories[tuple.Item1] == s)
             *        {
             *            categorysum += tuple.Item2;
             *        }
             *    }
             *    var percent = categorysum / sum * 100;
             *    var bai = new BarItem(percent);
             *    bai.Color = p.Colors[coloridx];
             *    ba.Items.Add(bai);
             * }*/
            //   plotModel1.Series.Add(ba);

            var itemsByLevel = new Dictionary <int, IntervalBarSeries>();

            _textOffsets.Clear();
            AddBars(cp.MainPart, 0, 0, fontsize, itemsByLevel, p, plotModel1);
            //        foreach (IntervalBarSeries series in itemsByLevel.Values) {
            //          plotModel1.Series.Add(series);
            //    }
            string dstFileName = Path.Combine(outputDirectory,
                                              DirectoryNames.CalculateTargetdirectory(TargetDirectory.Charts), "CalculationDurationFlameChart." + source + ".Png");

            PngExporter.Export(plotModel1, dstFileName, 3200, 2000, OxyColor.FromArgb(255, 255, 255, 255),
                               144);
            //Save(plotModel1, plotName, srcEntry.FullFileName + newFileNameSuffix, basisPath); // ".interval"
        }
        private string GetFullPathForTargetdirectry(TargetDirectory targetDirectory)
        {
            var newdirname = DirectoryNames.CalculateTargetdirectory(targetDirectory);

            return(Path.Combine(_baseResultpath, newdirname));
        }