protected override void DrawBoxContent(Canvas canvas, Rectangle updateArea)
        {
            // canvas.FillRectangle(Color.White, 0, 0, this.Width, this.Height);
            if (needUpdate)
            {
                //default bg => transparent !, 
                //gfx2d.Clear(ColorRGBA.White);//if want opaque bg
                ReleaseUnmanagedResources();
                if (bmp != null)
                {
                    bmp.Dispose();
                }

                this.bmp = this.actualImage;// new Bitmap(this.Width, this.Height, this.actualImage.GetBuffer(), false);
                // canvas.Platform.CreatePlatformBitmap(this.Width, this.Height, this.actualImage.GetBuffer(), false);
                Image.SetCacheInnerImage(bmp, null);
                needUpdate = false;
            }
            //canvas.FillRectangle(this.BackColor, 0, 0, this.Width, this.Height);

            if (bmp != null)
            {
                canvas.DrawImage(this.bmp, new RectangleF(0, 0, this.Width, this.Height));
            }
            //---------------------



#if DEBUG
            //canvasPage.dbug_DrawCrossRect(PixelFarm.Drawing.Color.Black,
            //    new Rectangle(0, 0, this.Width, this.Height));
#endif
        }
        protected override void DrawBoxContent(Canvas canvas, Rectangle updateArea)
        {
            if (this.imageBinder != null)
            {
                switch (imageBinder.State)
                {
                    case ImageBinderState.Loaded:
                        {
                            canvas.DrawImage(imageBinder.Image,
                                new RectangleF(0, 0, this.Width, this.Height));
                        }
                        break;
                    case ImageBinderState.Unload:
                        {
                            if (this.imageBinder.HasLazyFunc)
                            {
                                this.imageBinder.LazyLoadImage();
                            }
                        }
                        break;
                }
            }
            else
            {
                //when no image
                //canvasPage.FillRectangle(BackColor, updateArea._left, updateArea._top, updateArea.Width, updateArea.Height);
            }
#if DEBUG
            //canvasPage.dbug_DrawCrossRect(PixelFarm.Drawing.Color.Black,
            //    new Rectangle(0, 0, this.Width, this.Height));
#endif
        }
Esempio n. 3
0
 public sealed override void CustomDrawToThisCanvas(Canvas canvas, Rectangle updateArea)
 {
     canvas.OffsetCanvasOrigin(-myviewportX, -myviewportY);
     updateArea.Offset(myviewportX, myviewportY);
     this.DrawBoxContent(canvas, updateArea);
     canvas.OffsetCanvasOrigin(myviewportX, myviewportY);
     updateArea.Offset(-myviewportX, -myviewportY);
 }
Esempio n. 4
0
 public void UnBind()
 {
     //clear
     this.canvas = null;
     this.htmlContainer = null;
     this.clipStacks.Clear();
     this.latestClip = new Rectangle(0, 0, CssBoxConstConfig.BOX_MAX_RIGHT, CssBoxConstConfig.BOX_MAX_BOTTOM);
 }
Esempio n. 5
0
 public override void CustomDrawToThisCanvas(Canvas canvas, Rectangle updateArea)
 {
     if (this.textBuffer != null)
     {
         var prevColor = canvas.CurrentTextColor;
         canvas.CurrentTextColor = textColor;
         canvas.DrawText(this.textBuffer, this.X, this.Y);
         canvas.CurrentTextColor = prevColor;
     }
 }
Esempio n. 6
0
        protected override void DrawBoxContent(Canvas canvas, Rectangle updateArea)
        {
            myHtmlCont.CheckDocUpdate();
            var painter = PainterStock.GetSharedPainter(this.myHtmlCont, canvas);
            painter.SetViewportSize(this.Width, this.Height);
#if DEBUG
            painter.dbugDrawDiagonalBox(Color.Blue, this.X, this.Y, this.Width, this.Height);
#endif

            myHtmlCont.PerformPaint(painter);
            PainterStock.ReleaseSharedPainter(painter);
        }
Esempio n. 7
0
        protected override void DrawBoxContent(Canvas canvas, Rectangle updateArea)
        {
            var enterFont = canvas.CurrentFont;
            canvas.CurrentFont = this.CurrentTextSpanStyle.FontInfo;
            if (vscrollableSurface != null)
            {
                vscrollableSurface.DrawToThisPage(canvas, updateArea);
            }
            //1. bg 
            if (BackgroundColor.A > 0)
            {
                //canvas.FillRectangle(BackgroundColor, 0, 0, updateArea.Width, updateArea.Height);
                canvas.FillRectangle(BackgroundColor, 0, 0, this.Width, this.Height);
            }


            //2. sub ground 
            if (internalTextLayerController.SelectionRange != null)
            {
                internalTextLayerController.SelectionRange.Draw(canvas, updateArea);
            }

            //3. each layer
            if (vscrollableSurface != null)
            {
                vscrollableSurface.DrawToThisPage(canvas, updateArea);
            }
            else
            {
                this.textLayer.DrawChildContent(canvas, updateArea);
                if (this.HasDefaultLayer)
                {
                    this.DrawDefaultLayer(canvas, ref updateArea);
                }
            }

#if DEBUG
            //for debug
            canvas.FillRectangle(Color.Red, 0, 0, 5, 5);
#endif  
            //4. caret 
            if (this.stateShowCaret)
            {
                Point textManCaretPos = internalTextLayerController.CaretPos;
                this.myCaret.DrawCaret(canvas, textManCaretPos.X, textManCaretPos.Y);
            }
            else
            {
            }
            canvas.CurrentFont = enterFont;
        }
 protected override void DrawBoxContent(Canvas canvas, Rectangle updateArea)
 {
     //draw this ...
     var penwidth = canvas.StrokeWidth;
     int borderWidth = 5;
     int halfBorder = borderWidth / 2;
     canvas.StrokeWidth = borderWidth;
     canvas.DrawRectangle(
         Color.OrangeRed,
         halfBorder, halfBorder,
         this.Width - borderWidth,
         this.Height - borderWidth);
     canvas.StrokeWidth = penwidth;
 }
Esempio n. 9
0
        internal static PaintVisitor GetSharedPainter(HtmlContainer htmlCont, Canvas canvas)
        {
            PaintVisitor painter = null;
            if (painterStock.Count == 0)
            {
                painter = new PaintVisitor();
            }
            else
            {
                painter = painterStock.Dequeue();
            }

            painter.Bind(htmlCont, canvas);
            return painter;
        }
        /// <summary>
        /// Draw the background image of the given box in the given rectangle.<br/>
        /// Handle background-repeat and background-position values.
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="box">the box to draw its background image</param>
        /// <param name="imageLoadHandler">the handler that loads image to draw</param>
        /// <param name="rectangle">the rectangle to draw image in</param>
        public static void DrawBackgroundImage(Canvas g, CssBox box, ImageBinder imageBinder, RectangleF rectangle)
        {
            var image = imageBinder.Image;
            //temporary comment image scale code 
            var imgSize = image.Size;
            //new Size(imageLoadHandler.Rectangle == Rectangle.Empty ? imageLoadHandler.Image.Width : imageLoadHandler.Rectangle.Width,
            //                 imageLoadHandler.Rectangle == Rectangle.Empty ? imageLoadHandler.Image.Height : imageLoadHandler.Rectangle.Height);

            // get the location by BackgroundPosition value
            var location = GetLocation(box.BackgroundPositionX, box.BackgroundPositionY, rectangle, imgSize);
            //var srcRect = imageLoadHandler.Rectangle == Rectangle.Empty
            //                  ? new Rectangle(0, 0, imgSize.Width, imgSize.Height)
            //                  : new Rectangle(imageLoadHandler.Rectangle.Left, imageLoadHandler.Rectangle.Top, imgSize.Width, imgSize.Height);
            var srcRect = new Rectangle(0, 0, image.Width, image.Height);
            // initial image destination rectangle
            var destRect = new Rectangle(location, imgSize);
            // need to clip so repeated image will be cut on rectangle

            var prevClip = g.CurrentClipRect;
            PixelFarm.Drawing.Rectangle copyRect = new PixelFarm.Drawing.Rectangle(
               (int)rectangle.X,
               (int)rectangle.Y,
               (int)rectangle.Width,
               (int)rectangle.Height);
            copyRect.Intersect(prevClip);
            g.SetClipRect(copyRect);
            switch (box.BackgroundRepeat)
            {
                case CssBackgroundRepeat.NoRepeat:
                    g.DrawImage(image, new RectangleF(location, imgSize), new RectangleF(0, 0, image.Width, image.Height));
                    break;
                case CssBackgroundRepeat.RepeatX:
                    DrawRepeatX(g, image, rectangle, srcRect, destRect, imgSize);
                    break;
                case CssBackgroundRepeat.RepeatY:
                    DrawRepeatY(g, image, rectangle, srcRect, destRect, imgSize);
                    break;
                default:
                    DrawRepeat(g, image, rectangle, srcRect, destRect, imgSize);
                    break;
            }

            g.SetClipRect(prevClip);
        }
        protected override void DrawBoxContent(Canvas canvas, Rectangle updateArea)
        {
#if DEBUG
            if (this.dbugBreak)
            {
            }
#endif
            //sample bg   
            //canvas.FillRectangle(BackColor, updateArea.Left, updateArea.Top, updateArea.Width, updateArea.Height);
            canvas.FillRectangle(BackColor, 0, 0, this.Width, this.Height);
            this.DrawDefaultLayer(canvas, ref updateArea);
#if DEBUG
            //canvas.dbug_DrawCrossRect(PixelFarm.Drawing.Color.Black,
            //    new Rectangle(0, 0, this.Width, this.Height));

            //canvas.dbug_DrawCrossRect(PixelFarm.Drawing.Color.Black,
            //   new Rectangle(updateArea.Left, updateArea.Top, updateArea.Width, updateArea.Height));
#endif
        }
        protected override void DrawBoxContent(Canvas canvas, Rectangle updateArea)
        {
            //if (this.image != null)
            //{
            //    canvas.DrawImage(this.image,
            //        new RectangleF(0, 0, this.Width, this.Height));
            //}
            //else
            //{
            //when no image
            //---------------------

            // canvas.FillRectangle(Color.White, 0, 0, this.Width, this.Height);
            if (needUpdate)
            {
                //default bg => transparent !,

                //gfx2d.Clear(ColorRGBA.White);//if want opaque bg
                ReleaseUnmanagedResources();
                int j = sprites.Count;
                for (int i = 0; i < j; ++i)
                {
                    sprites[i].OnDraw(gfx2d);
                }

                //this.bmp = new Bitmap(this.Width, this.Height, this.actualImage.GetBuffer(), true);
                needUpdate = false;
            }
            canvas.DrawImage(actualImage, new RectangleF(0, 0, this.Width, this.Height));
            //---------------------
            //copy data from actual image to canvas 

            //}
#if DEBUG
            //canvasPage.dbug_DrawCrossRect(PixelFarm.Drawing.Color.Black,
            //    new Rectangle(0, 0, this.Width, this.Height));
#endif
        }
Esempio n. 13
0
        public override void DrawChildContent(Canvas canvasPage, Rectangle updateArea)
        {
            if ((layerFlags & IS_LAYER_HIDDEN) != 0)
            {
                return;
            }

            this.BeginDrawingChildContent();
            foreach (RenderElement child in this.GetDrawingIter())
            {
                if (child.IntersectsWith(ref updateArea))
                {
                    int x = child.X;
                    int y = child.Y;
                    canvasPage.OffsetCanvasOrigin(x, y);
                    updateArea.Offset(-x, -y);
                    child.DrawToThisCanvas(canvasPage, updateArea);
                    canvasPage.OffsetCanvasOrigin(-x, -y);
                    updateArea.Offset(x, y);
                }
            }

            this.FinishDrawingChildContent();
        }
Esempio n. 14
0
        protected void DrawDefaultLayer(Canvas canvas, ref Rectangle updateArea)
        {
            if (this.defaultLayer != null)
            {
#if DEBUG
                if (!debugBreaK1)
                {
                    debugBreaK1 = true;
                }
#endif
                defaultLayer.DrawChildContent(canvas, updateArea);
            }
        }
Esempio n. 15
0
 public override void CustomDrawToThisCanvas(Canvas canvas, Rectangle updateArea)
 {
     int bWidth = this.Width;
     int bHeight = this.Height;
     if (!this.HasStyle)
     {
         canvas.DrawText(this.mybuffer, new Rectangle(0, 0, bWidth, bHeight), 0);
     }
     else
     {
         TextSpanStyle style = this.SpanStyle;
         switch (EvaluateFontAndTextColor(canvas, style))
         {
             case DIFF_FONT_SAME_TEXT_COLOR:
                 {
                     var prevFont = canvas.CurrentFont;
                     canvas.CurrentFont = style.FontInfo;
                     canvas.DrawText(this.mybuffer,
                        new Rectangle(0, 0, bWidth, bHeight),
                        style.ContentHAlign);
                     canvas.CurrentFont = prevFont;
                 }
                 break;
             case DIFF_FONT_DIFF_TEXT_COLOR:
                 {
                     var prevFont = canvas.CurrentFont;
                     var prevColor = canvas.CurrentTextColor;
                     canvas.CurrentFont = style.FontInfo;
                     canvas.CurrentTextColor = style.FontColor;
                     canvas.DrawText(this.mybuffer,
                        new Rectangle(0, 0, bWidth, bHeight),
                        style.ContentHAlign);
                     canvas.CurrentFont = prevFont;
                     canvas.CurrentTextColor = prevColor;
                 }
                 break;
             case SAME_FONT_DIFF_TEXT_COLOR:
                 {
                     var prevColor = canvas.CurrentTextColor;
                     canvas.DrawText(this.mybuffer,
                     new Rectangle(0, 0, bWidth, bHeight),
                     style.ContentHAlign);
                     canvas.CurrentTextColor = prevColor;
                 }
                 break;
             default:
                 {
                     canvas.DrawText(this.mybuffer,
                        new Rectangle(0, 0, bWidth, bHeight),
                        style.ContentHAlign);
                 }
                 break;
         }
     }
 }
Esempio n. 16
0
 static int EvaluateFontAndTextColor(Canvas canvas, TextSpanStyle spanStyle)
 {
     var font = spanStyle.FontInfo;
     var color = spanStyle.FontColor;
     var currentTextFont = canvas.CurrentFont;
     var currentTextColor = canvas.CurrentTextColor;
     if (font != null && font != currentTextFont)
     {
         if (currentTextColor != color)
         {
             return DIFF_FONT_DIFF_TEXT_COLOR;
         }
         else
         {
             return DIFF_FONT_SAME_TEXT_COLOR;
         }
     }
     else
     {
         if (currentTextColor != color)
         {
             return SAME_FONT_DIFF_TEXT_COLOR;
         }
         else
         {
             return SAME_FONT_SAME_TEXT_COLOR;
         }
     }
 }
Esempio n. 17
0
 public static void DrawBorder(CssSide border, PointF[] borderPts, Canvas g, CssBox box, Color solidColor, RectangleF rectangle)
 {
     SetInOutsetRectanglePoints(border, box, rectangle, true, true, borderPts);
     g.FillPolygon(solidColor, borderPts);
 }
Esempio n. 18
0
 protected override void DrawBoxContent(Canvas canvas, Rectangle updateArea)
 {
     canvas.FillRectangle(Color.White, 0, 0, this.Width, this.Height);
     this.DrawDefaultLayer(canvas, ref updateArea);
 }
Esempio n. 19
0
 protected abstract void DrawBoxContent(Canvas canvas, Rectangle updateArea);
Esempio n. 20
0
        ///// <summary>
        ///// Get cached solid brush instance for the given color.
        ///// </summary>
        ///// <param name="color">the color to get brush for</param>
        ///// <returns>brush instance</returns>
        //public static Brush GetSolidBrush(Color color)
        //{

        //    if (color == Color.White)
        //    {
        //        return Brushes.White;
        //    }
        //    else if (color == Color.Black)
        //    {
        //        return Brushes.Black;
        //    }
        //    else if (!IsColorVisible(color))
        //    {
        //        return Brushes.Transparent;
        //    }
        //    else
        //    {
        //        Brush brush;
        //        if (!_brushesCache.TryGetValue(color, out brush))
        //        {

        //            _brushesCache[color] = brush = CurrentGraphicPlatform.CreateSolidBrush(color);

        //        }
        //        return brush;
        //    }
        //}

        ///// <summary>
        ///// Get cached pen instance for the given color.
        ///// </summary>
        ///// <param name="color">the color to get pen for</param>
        ///// <returns>pen instance</returns>
        //public static Pen GetPen(GraphicPlatform p, Color color)
        //{
        //    Pen pen;
        //    if (!_penCache.TryGetValue(color, out pen))
        //    {
        //        pen = p.CreateSolidPen(color); 
        //        _penCache[color] = pen;
        //    }
        //    else
        //    {
        //        pen.Width = 1;
        //    }
        //    return pen;
        //}
        /// <summary>
        /// Draw image loading icon.
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="r">the rectangle to draw icon in</param>
        public static void DrawImageLoadingIcon(Canvas g, RectangleF r)
        {
            g.DrawRectangle(Color.LightGray, r.Left + 3, r.Top + 3, 13, 14);
            var image = GetLoadImage();
            g.DrawImage(image, new RectangleF(r.Left + 4, r.Top + 4, image.Width, image.Height));
        }
        public override void DrawChildContent(Canvas canvas, Rectangle updateArea)
        {
            if ((layerFlags & IS_LAYER_HIDDEN) != 0)
            {
                return;
            }

            this.BeginDrawingChildContent();
            if ((layerFlags & FLOWLAYER_HAS_MULTILINE) != 0)
            {
                List<EditableTextLine> lines = (List<EditableTextLine>)lineCollection;
                int renderAreaTop = updateArea.Top;
                int renderAreaBottom = updateArea.Bottom;
                bool foundFirstLine = false;
                int j = lines.Count;
                for (int i = 0; i < j; ++i)
                {
                    EditableTextLine line = lines[i];
#if DEBUG
                    if (this.OwnerRenderElement is RenderBoxBase)
                    {
                        debug_RecordLineInfo((RenderBoxBase)OwnerRenderElement, line);
                    }
#endif

                    int y = line.Top;
                    LinkedListNode<EditableRun> curNode = line.First;
                    if (!foundFirstLine)
                    {
                        if (y + line.ActualLineHeight < renderAreaTop)
                        {
                            continue;
                        }
                        else
                        {
                            foundFirstLine = true;
                        }
                    }
                    else
                    {
                        if (y > renderAreaBottom)
                        {
                            break;
                        }
                    }

                    updateArea.OffsetY(-y);
                    canvas.OffsetCanvasOriginY(y);
                    while (curNode != null)
                    {
                        EditableRun child = curNode.Value;
                        if (child.IntersectOnHorizontalWith(ref updateArea))
                        {
                            int x = child.X;
                            canvas.OffsetCanvasOriginX(x);
                            updateArea.OffsetX(-x);
                            child.DrawToThisCanvas(canvas, updateArea);
                            canvas.OffsetCanvasOriginX(-x);
                            updateArea.OffsetX(x);
                        }
                        curNode = curNode.Next;
                    }
                    canvas.OffsetCanvasOriginY(-y);
                    updateArea.OffsetY(y);
                }
            }
            else
            {
                EditableTextLine line = (EditableTextLine)lineCollection;
#if DEBUG
                if (OwnerRenderElement is RenderBoxBase)
                {
                    debug_RecordLineInfo((RenderBoxBase)OwnerRenderElement, line);
                }
#endif

                LinkedListNode<EditableRun> curNode = line.First;
                if (curNode != null)
                {
                    int y = line.Top;
                    canvas.OffsetCanvasOriginY(y);
                    updateArea.OffsetY(-y);
                    while (curNode != null)
                    {
                        EditableRun child = curNode.Value;
                        if (child.IntersectOnHorizontalWith(ref updateArea))
                        {
                            int x = child.X;
                            canvas.OffsetCanvasOriginX(x);
                            updateArea.OffsetX(-x);
                            child.DrawToThisCanvas(canvas, updateArea);
                            canvas.OffsetCanvasOriginX(-x);
                            updateArea.OffsetX(x);
                        }
                        curNode = curNode.Next;
                    }
                    canvas.OffsetCanvasOriginY(-y);
                    updateArea.OffsetY(y);
                }
            }
            this.FinishDrawingChildContent();
        }
 public void dbugShowRenderPart(Canvas canvasPage, Rectangle updateArea)
 {
     RootGraphic visualroot = this.dbugVRoot;
     if (visualroot.dbug_ShowRootUpdateArea)
     {
         canvasPage.FillRectangle(Color.FromArgb(50, Color.Black),
              updateArea.Left, updateArea.Top,
                 updateArea.Width - 1, updateArea.Height - 1);
         canvasPage.FillRectangle(Color.White,
              updateArea.Left, updateArea.Top, 5, 5);
         canvasPage.DrawRectangle(Color.Yellow,
                 updateArea.Left, updateArea.Top,
                 updateArea.Width - 1, updateArea.Height - 1);
         Color c_color = canvasPage.CurrentTextColor;
         canvasPage.CurrentTextColor = Color.White;
         canvasPage.DrawText(visualroot.dbug_RootUpdateCounter.ToString().ToCharArray(), updateArea.Left, updateArea.Top);
         if (updateArea.Height > 25)
         {
             canvasPage.DrawText(visualroot.dbug_RootUpdateCounter.ToString().ToCharArray(), updateArea.Left, updateArea.Top + (updateArea.Height - 20));
         }
         canvasPage.CurrentTextColor = c_color;
         visualroot.dbug_RootUpdateCounter++;
     }
 }
 void debug_RecordPostDrawInfo(Canvas canvasPage)
 {
     if (dbugVRoot.dbug_ShowElementOutline)
     {
         canvasPage.DrawRectangle(Color.Red,
             0, 0, this.Width - 1, this.Height - 1);
     }
     if (dbugVRoot.dbug_ForceShowObjectIden)
     {
         var prevColor = canvasPage.CurrentTextColor;
         canvasPage.CurrentTextColor = Color.Blue;
         canvasPage.DrawText(
                 ("<< " + dbug_FullElementDescription()).ToCharArray()
                 , 0, dbug_element_code_y);
         canvasPage.CurrentTextColor = prevColor;
     }
     else if (dbugVRoot.dbug_ShowObjectIden && !dbug_hide_objIden)
     {
         var prevColor = canvasPage.CurrentTextColor;
         canvasPage.CurrentTextColor = Color.Blue;
         canvasPage.DrawText(
                 ("<< " + dbug_FullElementDescription()).ToCharArray()
                 , 0, dbug_element_code_y);
         canvasPage.CurrentTextColor = prevColor;
     }
 }
 public VisualPaintEventArgs(Canvas canvas, Rectangle updateArea)
 {
     this.canvas = canvas;
     this.updateArea = updateArea;
 }
 public abstract void DrawChildContent(Canvas canvasPage, Rectangle updateArea);
Esempio n. 26
0
 /// <summary>
 /// Draw image failed to load icon.
 /// </summary>
 /// <param name="g">the device to draw into</param>
 /// <param name="r">the rectangle to draw icon in</param>
 public static void DrawImageErrorIcon(Canvas g, RectangleF r)
 {
     g.DrawRectangle(Color.LightGray, r.Left + 2, r.Top + 2, 15, 15);
     var image = GetErrorImage();
     g.DrawImage(image, new RectangleF(r.Left + 3, r.Top + 3, image.Width, image.Height));
 }
 public void dbug_AddDrawElement(RenderElement visualElement, Canvas currentCanvas)
 {
     dbug_AddDrawElement(visualElement, currentCanvas, null);
 }
        public void dbug_AddDrawElement(RenderElement visualElement, Canvas currentCanvas, string additionalMsg)
        {
            StringBuilder stBuilder = new StringBuilder();
            stBuilder.Append(new string('.', dbug_drawLevel));
            stBuilder.Append("[" + dbug_drawLevel + "] c_" + currentCanvas.debug_canvas_id + " ");
            stBuilder.Append(visualElement.dbug_FullElementDescription());
            Rectangle r = visualElement.dbugGetGlobalRect();
            stBuilder.Append(" global(" + r.X + "," + r.Y + "," + r.Width + "," + r.Height + ")");
            Rectangle currentClipRect = currentCanvas.CurrentClipRect;
            stBuilder.Append(" clip(" + currentClipRect.X +
                "," + currentClipRect.Y + "," + currentClipRect.Width + "," + currentClipRect.Height + ") ");
            if (visualElement.dbugParentVisualElement != null)
            {
                stBuilder.Append(" of " + visualElement.dbugParentVisualElement.dbug_FullElementDescription());
            }

            dbug_rootDrawingMsg.AddLast(new dbugLayoutMsg(visualElement, stBuilder.ToString()));
            if (additionalMsg != null)
            {
                stBuilder.Length = 0; stBuilder.Append(new string('.', dbug_drawLevel));
                stBuilder.Append("[" + dbug_drawLevel + "] c:" + currentCanvas.debug_canvas_id + " ");
                stBuilder.Append(visualElement.dbug_FullElementDescription());
                dbug_rootDrawingMsg.AddLast(new dbugLayoutMsg(visualElement, stBuilder.ToString()));
            }
        }
Esempio n. 29
0
        internal void PaintDecoration(Canvas g, RectangleF rectangle, bool isFirst, bool isLast)
        {
            float y = 0f;
            switch (this.TextDecoration)
            {
                default:
                    return;
                case Css.CssTextDecoration.Underline:
                    {
                        //TODO: correct this ...
                        //var h = g.MeasureString(" ", ActualFont).Height;
                        //float desc = FontsUtils.GetDescentPx(ActualFont);
                        //y = (float)Math.Round(rectangle.Top + h - desc + 0.5); 

                        RequestFont afont = ResolvedFont;
                        
                            
                        //PixelFarm.Drawing.Fonts.ActualFont ff = afont.ActualFont;
                        var h = afont.SizeInPixels;
                        float desc = (float)afont.DescentInPixels;// fontInfo.DescentPx;
                        y = (float)Math.Round(rectangle.Top + h - desc);
                    }
                    break;
                case Css.CssTextDecoration.LineThrough:
                    {
                        y = rectangle.Top + rectangle.Height / 2f;
                    }
                    break;
                case Css.CssTextDecoration.Overline:
                    {
                        y = rectangle.Top;
                    }
                    break;
            }


            //y -= ActualPaddingBottom - ActualBorderBottomWidth;
            y -= (ActualPaddingBottom + ActualBorderBottomWidth);
            float x1 = rectangle.X;
            if (isFirst)
            {
                x1 += ActualPaddingLeft + ActualBorderLeftWidth;
            }


            float x2 = rectangle.Right;
            if (isLast)
            {
                x2 -= ActualPaddingRight + ActualBorderRightWidth;
            }

            var prevColor = g.StrokeColor;
            g.StrokeColor = ActualColor;
            g.DrawLine(x1, y, x2, y);
            g.StrokeColor = prevColor;
        }
 public void Draw(Canvas destPage, Rectangle updateArea)
 {
     if (IsOnTheSameLine)
     {
         VisualPointInfo topEndPoint = TopEnd;
         VisualPointInfo bottomEndPoint = BottomEnd;
         int linetop = topEndPoint.LineTop;
         destPage.FillRectangle(Color.LightGray, topEndPoint.X, linetop,
             bottomEndPoint.X - topEndPoint.X, topEndPoint.ActualLineHeight);
     }
     else
     {
         EditableVisualPointInfo topEndPoint = TopEnd;
         int lineYPos = topEndPoint.LineTop;
         destPage.FillRectangle(Color.LightGray, topEndPoint.X, lineYPos,
             topEndPoint.CurrentWidth - topEndPoint.X,
             topEndPoint.ActualLineHeight);
         int topLineId = topEndPoint.LineId;
         int bottomLineId = BottomEnd.LineId;
         if (bottomLineId - topLineId > 1)
         {
             EditableTextLine adjacentStartLine = topEndPoint.EditableLine.Next;
             while (adjacentStartLine != BottomEnd.Line)
             {
                 destPage.FillRectangle(Color.LightGray, 0,
                     adjacentStartLine.LineTop,
                     adjacentStartLine.CurrentWidth,
                     adjacentStartLine.ActualLineHeight);
                 adjacentStartLine = adjacentStartLine.Next;
             }
             EditableTextLine adjacentStopLine = BottomEnd.Line.Prev;
         }
         VisualPointInfo bottomEndPoint = BottomEnd;
         lineYPos = bottomEndPoint.LineTop;
         destPage.FillRectangle(Color.LightGray, 0, lineYPos, bottomEndPoint.X,
              bottomEndPoint.ActualLineHeight);
     }
 }