RequestImage() private method

private RequestImage ( ImageBinder binder, CssBox requestFrom ) : void
binder ImageBinder
requestFrom CssBox
return void
Exemplo n.º 1
0
        /// <summary>
        /// Assigns words its width and height
        /// </summary>
        /// <param name="g"></param>
        public virtual void MeasureRunsSize(LayoutVisitor lay)
        {
            //measure once !
            if ((this._boxCompactFlags & BoxFlags.LAY_RUNSIZE_MEASURE) != 0)
            {
                return;
            }
            //-------------------------------- 
            if (this.BackgroundImageBinder != null)
            {
                //this has background
                if (this.BackgroundImageBinder.State == ImageBinderState.Unload)
                {
                    lay.RequestImage(this.BackgroundImageBinder, this);
                }
            }
            //-------------------------------- 
            if (this.RunCount > 0)
            {
                //find word spacing  
                float actualWordspacing = this._actualWordSpacing;
                RequestFont actualFont = this.ResolvedFont;


                float fontHeight = (actualFont.AscentInPixels - actualFont.DescentInPixels + actualFont.LineGapInPixels);
                fontHeight += 4;



                var tmpRuns = this.Runs;
                for (int i = tmpRuns.Count - 1; i >= 0; --i)
                {
                    CssRun run = tmpRuns[i];
                    run.Height = fontHeight;
                    //if this is newline then width =0 ***                         
                    switch (run.Kind)
                    {
                        case CssRunKind.Text:
                            {
                                CssTextRun textRun = (CssTextRun)run;
                                //run.Width = lay.MeasureStringWidth(
                                //    CssBox.UnsafeGetTextBuffer(this),
                                //    textRun.TextStartIndex,
                                //    textRun.TextLength,
                                //    actualFont);
                                Size ss = lay.MeasureStringSize(CssBox.UnsafeGetTextBuffer(this),
                                    textRun.TextStartIndex,
                                    textRun.TextLength,
                                    actualFont);
                                run.SetSize(ss.Width, ss.Height);

                            }
                            break;
                        case CssRunKind.SingleSpace:
                            {
                                run.Width = actualWordspacing;
                            }
                            break;
                        case CssRunKind.Space:
                            {
                                //other space size                                     
                                run.Width = actualWordspacing * ((CssTextRun)run).TextLength;
                            }
                            break;
                        case CssRunKind.LineBreak:
                            {
                                run.Width = 0;
                            }
                            break;
                    }
                }
            }
            this._boxCompactFlags |= BoxFlags.LAY_RUNSIZE_MEASURE;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Assigns words its width and height
        /// </summary>
        /// <param name="g"></param>
        public virtual void MeasureRunsSize(LayoutVisitor lay)
        {
            //measure once !
            if ((_boxCompactFlags & BoxFlags.LAY_RUNSIZE_MEASURE) != 0)
            {
                return;
            }
            //--------------------------------
            if (this.BackgroundImageBinder != null)
            {
                //this has background
                if (this.BackgroundImageBinder.State == BinderState.Unload)
                {
                    lay.RequestImage(this.BackgroundImageBinder, this);
                }
            }
            //--------------------------------
            if (this.RunCount > 0)
            {
                //find word spacing
                float       actualWordspacing = _actualWordSpacing;
                RequestFont actualFont        = this.ResolvedFont;


                float fontHeight = (actualFont.AscentInPixels - actualFont.DescentInPixels + actualFont.LineGapInPixels);
                fontHeight += 4; //TODO: why +4 ????***

                List <CssRun> tmpRuns = this.Runs;
                for (int i = tmpRuns.Count - 1; i >= 0; --i)
                {
                    CssRun run = tmpRuns[i];
                    run.Height = fontHeight;
                    //if this is newline then width =0 ***
                    switch (run.Kind)
                    {
                    case CssRunKind.Text:
                    {
                        CssTextRun textRun = (CssTextRun)run;
                        Size       ss      = lay.MeasureStringSize(CssBox.UnsafeGetTextBuffer(this),
                                                                   textRun.TextStartIndex,
                                                                   textRun.TextLength,
                                                                   actualFont);
                        run.SetSize(ss.Width, ss.Height);
                    }
                    break;

                    case CssRunKind.SingleSpace:
                    {
                        run.Width = actualWordspacing;
                    }
                    break;

                    case CssRunKind.Space:
                    {
                        //other space size
                        run.Width = actualWordspacing * ((CssTextRun)run).TextLength;
                    }
                    break;

                    case CssRunKind.LineBreak:
                    {
                        run.Width = 0;
                    }
                    break;
                    }
                }
            }
            _boxCompactFlags |= BoxFlags.LAY_RUNSIZE_MEASURE;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Assigns words its width and height
        /// </summary>
        /// <param name="g"></param>
        public virtual void MeasureRunsSize(LayoutVisitor lay)
        {
            //measure once !
            if ((this._boxCompactFlags & BoxFlags.LAY_RUNSIZE_MEASURE) != 0)
            {
                return;
            }

            //--------------------------------
            if (this.BackgroundImageBinder != null)
            {
                //this has background
                if (this.BackgroundImageBinder.State == ImageBinderState.Unload)
                {
                    lay.RequestImage(this.BackgroundImageBinder, this);
                }
            }

            //--------------------------------
            if (this.RunCount > 0)
            {
                //find word spacing
                float actualWordspacing = this._actualWordSpacing;
                Font  actualFont        = this.ActualFont;
                var   fontInfo          = actualFont.FontInfo;
                float fontHeight        = fontInfo.LineHeight;

                var tmpRuns = this.Runs;
                for (int i = tmpRuns.Count - 1; i >= 0; --i)
                {
                    CssRun run = tmpRuns[i];
                    run.Height = fontHeight;
                    //if this is newline then width =0 ***
                    switch (run.Kind)
                    {
                    case CssRunKind.Text:
                    {
                        CssTextRun textRun = (CssTextRun)run;
                        run.Width = lay.MeasureStringWidth(
                            CssBox.UnsafeGetTextBuffer(this),
                            textRun.TextStartIndex,
                            textRun.TextLength,
                            actualFont);
                    }
                    break;

                    case CssRunKind.SingleSpace:
                    {
                        run.Width = actualWordspacing;
                    }
                    break;

                    case CssRunKind.Space:
                    {
                        //other space size
                        run.Width = actualWordspacing * ((CssTextRun)run).TextLength;
                    }
                    break;

                    case CssRunKind.LineBreak:
                    {
                        run.Width = 0;
                    }
                    break;
                    }
                }
            }
            this._boxCompactFlags |= BoxFlags.LAY_RUNSIZE_MEASURE;
        }