Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageExport"/> class.
 /// </summary>
 public ImageExport()
 {
     FImageFormat               = ImageExportFormat.Jpeg;
     FSeparateFiles             = true;
     Resolution                 = 96;
     FJpegQuality               = 100;
     FMonochromeTiffCompression = EncoderValue.CompressionCCITT4;
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageExport"/> class.
 /// </summary>
 public ImageExport()
 {
     paddingNonSeparatePages = 10;
     fileSuffix                = String.Empty;
     HasMultipleFiles          = true;
     imageFormat               = ImageExportFormat.Jpeg;
     separateFiles             = true;
     Resolution                = 96;
     jpegQuality               = 100;
     monochromeTiffCompression = EncoderValue.CompressionCCITT4;
 }
Esempio n. 3
0
        private static string ImageFormatToExtension(ImageExportFormat format)
        {
            switch (format)
            {
            case ImageExportFormat.Bmp: return(".bmp");

            case ImageExportFormat.Gif: return(".gif");

            case ImageExportFormat.Jpeg: return(".jpg");

            case ImageExportFormat.Metafile: return(".emf");

            case ImageExportFormat.Png: return(".png");

            case ImageExportFormat.Tiff: return(".tiff");
            }

            return("");
        }
Esempio n. 4
0
        public static ExportFormat ImageExportFormatToExportFormat(ImageExportFormat format)
        {
            Debug.Assert(!EnumHelper.HasDuplicateValues <ExportFormat>());

            return((ExportFormat)(int)format);
        }
Esempio n. 5
0
        private static void CreateGraph(StreamWriter OutputFile, XmlNode N, int NextLevel)
        {
            string InstanceName = XmlHelper.Name(N.OwnerDocument.DocumentElement);
            string GraphName;

            if (N.Name == "XYPairs")
            {
                GraphName = XmlHelper.Name(N.ParentNode.ParentNode) + XmlHelper.Name(N.ParentNode) + "Graph";
            }
            else
            {
                GraphName = XmlHelper.Name(N.ParentNode) + XmlHelper.Name(N) + "Graph";
            }

            Directory.CreateDirectory(InstanceName + "Graphs");
            string GifFileName = InstanceName + "Graphs\\" + GraphName + ".gif";

            // Setup cleanish graph.
            TChart Graph = new TChart();

            Graph.Aspect.View3D                  = false;
            Graph.Legend.Visible                 = false;
            Graph.Axes.Left.AutomaticMinimum     = false;
            Graph.Axes.Left.Minimum              = 0.0000000005;
            Graph.Axes.Left.Grid.Visible         = false;
            Graph.Axes.Left.Labels.ValueFormat   = "###0.###";
            Graph.Axes.Left.MinorTicks.Visible   = false;
            Graph.Axes.Left.MaximumOffset        = 1;
            Graph.Axes.Bottom.AutomaticMinimum   = false;
            Graph.Axes.Bottom.Minimum            = 0;
            Graph.Axes.Bottom.Grid.Visible       = false;
            Graph.Axes.Bottom.Labels.ValueFormat = "###0.###";
            Graph.Axes.Bottom.MinorTicks.Visible = false;
            Graph.Axes.Bottom.MaximumOffset      = 4;
            Graph.Walls.Visible                  = false;
            Graph.Header.Text            = GraphName;
            Graph.Panel.Bevel.Outer      = Steema.TeeChart.Drawing.BevelStyles.None;
            Graph.Panel.Brush.Color      = Color.White;
            Graph.Panel.ImageBevel.Width = 1;
            Graph.Panel.Shadow.Visible   = false;
            Graph.Panel.Gradient.Visible = false;

            // Create a line series.
            Steema.TeeChart.Styles.Line LineSeries = new Steema.TeeChart.Styles.Line();
            Graph.Series.Add(LineSeries);

            // work out x and y variable names.
            string XName = XmlHelper.Value(N.ParentNode, "XProperty");

            if (N.ParentNode.Name == "TemperatureFunction")
            {
                XName = "Temperature (oC)";
            }

            string YName;

            if (N.Name == "XYPairs")
            {
                YName = XmlHelper.Name(N.ParentNode);
            }
            else
            {
                YName = XmlHelper.Name(N);
            }
            if (YName == "Function")
            {
                YName = XmlHelper.Name(N.ParentNode.ParentNode);
            }

            Graph.Axes.Left.Title.Text   = YName;
            Graph.Axes.Bottom.Title.Text = XName;

            // Set up to write a table.
            OutputFile.WriteLine("<table border=\"0\">");
            //   OutputFile.WriteLine("<td></td><td></td>");
            //   OutputFile.WriteLine("<tr>");

            // output xy table as a nested table.
            OutputFile.WriteLine("<td>");
            OutputFile.WriteLine("<table width=\"250\">");
            OutputFile.WriteLine("<td><b>" + XName + "</b></td><td><b>" + YName + "</b></td>");
            List <string> XYs = XmlHelper.Values(N, "xy");

            foreach (string XY in XYs)
            {
                string[] XYValues = XY.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (XYValues.Length == 2)
                {
                    LineSeries.Add(Convert.ToDouble(XYValues[0]), Convert.ToDouble(XYValues[1]));
                }
                if (Convert.ToDouble(XYValues[1]) < 0.05 && Convert.ToDouble(XYValues[1]) > 0)
                {
                    Graph.Axes.Left.Labels.ValueFormat = "#.#######";
                }

                OutputFile.WriteLine("<tr><td>" + XYValues[0] + "</td><td>" + XYValues[1] + "</td></tr>");
            }
            OutputFile.WriteLine("</table>");
            OutputFile.WriteLine("</td>");

            // output chart as a column to the outer table.
            OutputFile.WriteLine("<td>");
            OutputFile.WriteLine("<img src=\"" + GifFileName + "\">");
            OutputFile.WriteLine("</td>");
            OutputFile.WriteLine("</tr>");
            OutputFile.WriteLine("</table>");

            // Export graph to bitmap file.
            Rectangle         Bounds = new Rectangle(0, 0, 300, 200);
            Stream            stream = new FileStream(GifFileName, FileMode.Create);
            ImageExportFormat image  = Graph.Chart.Export.Image.GIF;

            image.Width  = Bounds.Width;
            image.Height = Bounds.Height;
            image.Save(stream);
            stream.Close();
        }