/*public override bool Export(MindMapView view, string filename) * { * XmlDocument dom = Export(null, view.Map); * * dom.Save(filename); * return true; * }*/ protected override bool ExportChartToFile(Document document, ChartPage chart, string filename) { if (chart is MindMap) { /*var dom = Export(document, (MindMap)chart);*/ Size size = chart.GetContentSize(); var dom = new SvgDocument(size.Width, size.Height); dom.Title = chart.Name; // if (!chart.BackColor.IsEmpty) { dom.BackColor = chart.BackColor; } // var graphics = new SvgGraphics(dom); // var args = new RenderArgs(graphics, (MindMap)chart, graphics.Font(ChartBox.DefaultChartFont)); var renderer = new GeneralRender(); renderer.Paint((MindMap)chart, args); // dom.Save(filename); return(true); } return(base.ExportChartToFile(document, chart, filename)); }
void PrintChart(ChartPage chart, PrintPageEventArgs e) { if (chart == null) { throw new ArgumentNullException(); } if (chart is MindMap) { var state = e.Graphics.Save(); var contentSize = chart.GetContentSize(); var zoom = PaintHelper.GetZoom(contentSize, e.PageBounds.Size); var args = new RenderArgs(RenderMode.Print, e.Graphics, (MindMap)chart, ChartBox.DefaultChartFont); e.Graphics.ScaleTransform(zoom, zoom); var renderer = new GeneralRender(); renderer.Paint(args.Chart, args); e.Graphics.Restore(state); // print document title if (Options.Current.GetBool(Blumind.Configuration.OptionNames.PageSettigs.PrintDocumentTitle)) { var ptTitle = e.MarginBounds.Location; var brush = new SolidBrush(Color.Black); e.Graphics.DrawString(chart.Name, ChartBox.DefaultChartFont, brush, ptTitle.X, ptTitle.Y); } } }
protected override bool ExportChartToFile(Document document, ChartPage chart, string filename) { if (chart == null) { throw new ArgumentNullException(); } if (string.IsNullOrEmpty(filename)) { throw new ArgumentException("filename"); } if (!OptionsInitalizated && !GetOptions()) { return(false); } //ChartPage = chart; //chart.EnsureChartLayouted(); Size contentSize = chart.GetContentSize(); if (contentSize.Width <= 0 || contentSize.Height <= 0) { return(false); } Bitmap bmp = new Bitmap(contentSize.Width, contentSize.Height); using (Graphics grf = Graphics.FromImage(bmp)) { PaintHelper.SetHighQualityRender(grf); if (!TransparentBackground) { grf.Clear(chart.BackColor); } var render = new GeneralRender(); var args = new RenderArgs(RenderMode.Export, grf, (MindMap)chart, ChartBox.DefaultChartFont); render.Paint((MindMap)chart, args); } SaveImage(bmp, filename); return(true); }
void ExportPage(PdfDocument doc, ChartPage chart) { // Create an empty page var page = doc.AddPage(); if (ExportOptions.Orientation == PageOrientation.Landscape) { page.Orientation = PdfSharp.PageOrientation.Landscape; } // Get an XGraphics object for drawing var graphics = XGraphics.FromPdfPage(page); // if (ExportOptions.WithBackground && !chart.BackColor.IsEmpty) { graphics.Clear(chart.BackColor); } // var contentSize = chart.GetContentSize(); var pageSize = new Size((int)page.Width.Point, (int)page.Height.Point); var zoom = PaintHelper.GetZoom(contentSize, pageSize); var zoomedSize = PaintHelper.Zoom(contentSize, zoom); if (zoomedSize.Width < pageSize.Width || zoomedSize.Height < pageSize.Height) { graphics.TranslateTransform( Math.Max(0, (pageSize.Width - zoomedSize.Width) / 2), Math.Max(0, (pageSize.Height - zoomedSize.Height) / 2)); } graphics.ScaleTransform(zoom); // if (chart is MindMap) { var grf = new PdfGraphics(graphics); var args = new RenderArgs(grf, (MindMap)chart, grf.Font(ChartBox.DefaultChartFont)); var renderer = new GeneralRender(); renderer.Paint((MindMap)chart, args); } }