//	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;
        }
Esempio n. 2
0
        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);
        }
        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);
        }
        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));
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
        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);
        }
Esempio n. 9
0
        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;
        }