public override void Visit(ExportContainer exportContainer) { sectionCanvas = FixedDocumentCreator.CreateContainer(exportContainer); sectionCanvas.Name = exportContainer.Name; CanvasHelper.SetPosition(sectionCanvas, new Point(exportContainer.Location.X, exportContainer.Location.Y)); PerformList(sectionCanvas, exportContainer.ExportedItems); }
public override void Visit(ExportText exportColumn) { /* * var textBlock = FixedDocumentCreator.CreateTextBlock((ExportText)exportColumn,ShouldSetBackcolor(exportColumn)); * CanvasHelper.SetPosition(textBlock,new Point(exportColumn.Location.X,exportColumn.Location.Y)); * UIElement = textBlock; */ var ft = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn); var visual = new DrawingVisual(); var location = new Point(exportColumn.Location.X, exportColumn.Location.Y); using (var dc = visual.RenderOpen()){ if (ShouldSetBackcolor(exportColumn)) { dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportColumn.BackColor), null, new Rect(location, new Size(exportColumn.Size.Width, exportColumn.Size.Height))); } dc.DrawText(ft, location); } var dragingElement = new DrawingElement(visual); UIElement = dragingElement; }
Canvas RenderGraphicsContainer(IExportColumn column) { var graphicsContainer = column as GraphicsContainer; var graphCanvas = FixedDocumentCreator.CreateContainer(graphicsContainer); CanvasHelper.SetPosition(graphCanvas, column.Location.ToWpf()); graphCanvas.Background = FixedDocumentCreator.ConvertBrush(column.BackColor); if (graphicsContainer != null) { var rect = column as ExportRectangle; if (rect != null) { Visit(rect); } var circle = column as ExportCircle; if (circle != null) { Visit(circle); } graphCanvas.Children.Add(UIElement); } return(graphCanvas); }
public override void Visit(ExportRectangle exportRectangle) { Canvas containerCanvas = FixedDocumentCreator.CreateContainer(exportRectangle); Canvas elementCanvas = null; var border = CreateBorder(exportRectangle); border.CornerRadius = new CornerRadius(Convert.ToDouble(exportRectangle.CornerRadius)); CanvasHelper.SetPosition(border, new Point(0, 0)); foreach (var element in exportRectangle.ExportedItems) { if (IsGraphicsContainer(element)) { elementCanvas = RenderGraphicsContainer(element); containerCanvas.Children.Add(elementCanvas); } else { AsAcceptor(element).Accept(this); containerCanvas.Children.Add(UIElement); } containerCanvas.UpdateLayout(); } border.Child = containerCanvas; UIElement = border; }
// http://stackoverflow.com/questions/25308612/vertical-alignment-with-drawingcontext-drawtext public override void Visit(ExportText exportColumn) { var formattedText = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn); var location = new Point(exportColumn.Location.X, exportColumn.Location.Y); var visual = new DrawingVisual(); using (var drawingContext = visual.RenderOpen()){ var bachgroundRect = new Rect(location, new Size(exportColumn.DesiredSize.Width, formattedText.MaxTextHeight)); if (ShouldSetBackcolor(exportColumn)) { drawingContext.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportColumn.BackColor), null, bachgroundRect); } drawingContext.DrawText(formattedText, location); if (HasFrame(exportColumn)) { var frameRect = new Rect(location, new Size(exportColumn.DesiredSize.Width, formattedText.Height)); var pen = FixedDocumentCreator.CreateWpfPen(exportColumn); pen.Thickness = 1; drawingContext.DrawRectangle(null, pen, frameRect); } } var drawingElement = new DrawingElement(visual); UIElement = drawingElement; }
Canvas RenderDataRow(ExportContainer row) { var rowCanvas = FixedDocumentCreator.CreateContainer(row); var childCanvas = CreateItemsInContainer(row.ExportedItems); rowCanvas.Children.Add(childCanvas); return(rowCanvas); }
public override void Visit(ExportPage page) { fixedPage = FixedDocumentCreator.CreateFixedPage(page); FixedPage = fixedPage; foreach (var element in page.ExportedItems) { AsAcceptor(element).Accept(this); fixedPage.Children.Add(sectionCanvas); } }
static Border CreateBorder(IExportColumn exportColumn) { var border = new Border(); border.BorderThickness = Thickness(exportColumn); border.BorderBrush = FixedDocumentCreator.ConvertBrush(exportColumn.ForeColor); border.Background = FixedDocumentCreator.ConvertBrush(exportColumn.BackColor); border.Width = exportColumn.Size.Width + 2; border.Height = exportColumn.Size.Height + 2; return(border); }
public override void Visit(ExportLine exportGraphics) { var pen = FixedDocumentCreator.CreateWpfPen(exportGraphics); var visual = new DrawingVisual(); using (var dc = visual.RenderOpen()){ dc.DrawLine(pen, new Point(exportGraphics.Location.X, exportGraphics.Location.Y), new Point(exportGraphics.Location.X + exportGraphics.Size.Width, exportGraphics.Location.Y)); } var dragingElement = new DrawingElement(visual); UIElement = dragingElement; }
static DrawingElement CreateCircle(GraphicsContainer circle) { var pen = FixedDocumentCreator.CreateWpfPen(circle); var rad = CalcRadius(circle.Size); var visual = new DrawingVisual(); using (var dc = visual.RenderOpen()){ dc.DrawEllipse(FixedDocumentCreator.ConvertBrush(circle.BackColor), pen, new Point(rad.X, rad.Y), rad.X, rad.Y); } return(new DrawingElement(visual)); }
public override void Visit(ExportRectangle exportRectangle) { var pen = FixedDocumentCreator.CreateWpfPen(exportRectangle); var visual = new DrawingVisual(); using (var dc = visual.RenderOpen()){ dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportRectangle.BackColor), pen, new Rect(exportRectangle.Location.X, exportRectangle.Location.Y, exportRectangle.Size.Width, exportRectangle.Size.Height)); } var dragingElement = new DrawingElement(visual); UIElement = dragingElement; }
public override void Visit(ExportCircle exportCircle) { var pen = FixedDocumentCreator.CreateWpfPen(exportCircle); var rad = CalcRad(exportCircle.Size); var visual = new DrawingVisual(); using (var dc = visual.RenderOpen()){ dc.DrawEllipse(FixedDocumentCreator.ConvertBrush(exportCircle.BackColor), pen, new Point(exportCircle.Location.X + rad.X, exportCircle.Location.Y + rad.Y), rad.X, rad.Y); } var dragingElement = new DrawingElement(visual); UIElement = dragingElement; }
Canvas RenderSectionContainer(ExportContainer container) { var canvas = FixedDocumentCreator.CreateContainer(container); foreach (var element in container.ExportedItems) { if (IsContainer(element)) { RenderRow(canvas, (IExportContainer)element); } else { AsAcceptor(element).Accept(this); canvas.Children.Add(UIElement); } } canvas.Background = FixedDocumentCreator.ConvertBrush(container.BackColor); return(canvas); }
void PerformList(Canvas myCanvas, System.Collections.Generic.List <IExportColumn> exportedItems) { foreach (var element in exportedItems) { var container = element as ExportContainer; if (container != null) { var containerCanvas = FixedDocumentCreator.CreateContainer(container); CanvasHelper.SetPosition(containerCanvas, new Point(container.Location.X, container.Location.Y)); myCanvas.Children.Add(containerCanvas); PerformList(containerCanvas, container.ExportedItems); } else { var acceptor = element as IAcceptor; acceptor.Accept(this); myCanvas.Children.Add(UIElement); } } }
/* * static void CreateUnderline(TextBlock textBlock,IExportText exportColumn){ * if (exportColumn == null) * throw new ArgumentNullException("exportColumn"); * if (textBlock == null) * throw new ArgumentNullException("textBlock"); * var underLine = new TextDecoration(); * Pen p = CreateWpfPen(exportColumn); * underLine.Pen = p ; * underLine.PenThicknessUnit = TextDecorationUnit.FontRecommended; * textBlock.TextDecorations.Add(underLine); * } */ public static Pen CreateWpfPen(IReportObject exportColumn) { if (exportColumn == null) { throw new ArgumentNullException("exportColumn"); } var pen = new Pen(); pen.Brush = ConvertBrush(exportColumn.ForeColor); pen.Thickness = 1; var exportGraphics = exportColumn as IExportGraphics; if (exportGraphics != null) { pen.Thickness = exportGraphics.Thickness; pen.DashStyle = FixedDocumentCreator.DashStyle(exportGraphics); pen.StartLineCap = FixedDocumentCreator.LineCap(exportGraphics.StartLineCap); pen.EndLineCap = FixedDocumentCreator.LineCap(exportGraphics.EndLineCap); } return(pen); }
public override void Visit(ExportText exportColumn) { var formattedText = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn); var location = new Point(exportColumn.Location.X, exportColumn.Location.Y); var visual = new DrawingVisual(); using (var drawingContext = visual.RenderOpen()){ if (ShouldSetBackcolor(exportColumn)) { var r = new Rect(location, new Size(exportColumn.Size.Width, exportColumn.Size.Height)); drawingContext.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportColumn.BackColor), null, new Rect(location, new Size(exportColumn.Size.Width, exportColumn.Size.Height))); } drawingContext.DrawText(formattedText, location); } var dragingElement = new DrawingElement(visual); UIElement = dragingElement; }
public override void Visit(ExportContainer exportContainer) { sectionCanvas = FixedDocumentCreator.CreateContainer(exportContainer); sectionCanvas = RenderSectionContainer(exportContainer); }