/// <summary> /// Constructor. /// </summary> /// <param name="dcp"> /// Embedded object's character position. /// </param> /// <param name="uiElementIsland"> /// UIElementIsland associated with embedded object. /// </param> /// <param name="para"> /// TextParagraph associated with embedded object. /// </param> internal InlineObject(int dcp, UIElementIsland uiElementIsland, TextParagraph para) : base(dcp) { _para = para; _uiElementIsland = uiElementIsland; _uiElementIsland.DesiredSizeChanged += new DesiredSizeChangedEventHandler(_para.OnUIElementDesiredSizeChanged); }
// Token: 0x06006B6E RID: 27502 RVA: 0x001F0978 File Offset: 0x001EEB78 internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { MbpInfo mbpInfo = MbpInfo.FromElement(base.Paragraph.Element, base.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); PtsHelper.UpdateMirroringTransform(base.PageFlowDirection, base.ThisFlowDirection, this._visual, TextDpi.FromTextDpi(2 * this._rect.u + this._rect.du)); UIElementIsland uielementIsland = ((UIElementParagraph)base.Paragraph).UIElementIsland; if (uielementIsland != null) { if (this._visual.Children.Count != 1 || this._visual.Children[0] != uielementIsland) { Visual visual = VisualTreeHelper.GetParent(uielementIsland) as Visual; if (visual != null) { ContainerVisual containerVisual = visual as ContainerVisual; Invariant.Assert(containerVisual != null, "Parent should always derives from ContainerVisual."); containerVisual.Children.Remove(uielementIsland); } this._visual.Children.Clear(); this._visual.Children.Add(uielementIsland); } uielementIsland.Offset = new PTS.FSVECTOR(this._rect.u + mbpInfo.BPLeft, this._rect.v + mbpInfo.BPTop).FromTextDpi(); } else { this._visual.Children.Clear(); } Brush backgroundBrush = (Brush)base.Paragraph.Element.GetValue(TextElement.BackgroundProperty); this._visual.DrawBackgroundAndBorder(backgroundBrush, mbpInfo.BorderBrush, mbpInfo.Border, this._rect.FromTextDpi(), this.IsFirstChunk, this.IsLastChunk); }
//------------------------------------------------------------------- // // Private methods // //------------------------------------------------------------------- #region Private Methods /// <summary> /// Format UIElement /// </summary> private void FormatUIElement(int durAvailable, out PTS.FSBBOX fsbbox) { MbpInfo mbp = MbpInfo.FromElement(Element, StructuralCache.TextFormatterHost.PixelsPerDip); double elementHeight; double elementWidth = TextDpi.FromTextDpi(Math.Max(1, durAvailable - (mbp.MBPLeft + mbp.MBPRight))); if (SizeToFigureParent) { // Only child of a figure whose height is set. Size to figure's page height less figure's MBP and BlockUIContainer's MBP // NOTE: BlockUIContainer margins are always extracted before formatting, either from Figure height or page height if (StructuralCache.CurrentFormatContext.FinitePage) { elementHeight = StructuralCache.CurrentFormatContext.PageHeight; } else { Figure figure = (Figure)((BlockUIContainer)Element).Parent; Invariant.Assert(figure.Height.IsAbsolute); elementHeight = figure.Height.Value; } elementHeight = Math.Max(TextDpi.FromTextDpi(1), elementHeight - TextDpi.FromTextDpi(mbp.MBPTop + mbp.MBPBottom)); UIElementIsland.DoLayout(new Size(elementWidth, elementHeight), false, false); // Create fsbbox. Set width to available width since we want block ui container to occupy the full column // and UIElement to be algined within it. Set dv to elementHeight. fsbbox.fsrc = new PTS.FSRECT(); fsbbox.fsrc.du = durAvailable; fsbbox.fsrc.dv = TextDpi.ToTextDpi(elementHeight) + mbp.BPTop + mbp.BPBottom; fsbbox.fDefined = PTS.True; } else { // Either BlockUIContainer is not the only child of a figure or the figure's height is unspecified. // In this case, size to height of strcutural cache's current page less page margins and container MBP. // This is consistent with figure's behavior on sizing to content // Always measure at infinity for bottomless, consistent constraint. if (StructuralCache.CurrentFormatContext.FinitePage) { Thickness pageMargin = StructuralCache.CurrentFormatContext.DocumentPageMargin; elementHeight = StructuralCache.CurrentFormatContext.DocumentPageSize.Height - pageMargin.Top - pageMargin.Bottom - TextDpi.FromTextDpi(mbp.MBPTop + mbp.MBPBottom); elementHeight = Math.Max(TextDpi.FromTextDpi(1), elementHeight); } else { elementHeight = Double.PositiveInfinity; } Size uiIslandSize = UIElementIsland.DoLayout(new Size(elementWidth, elementHeight), false, true); // Create fsbbox. Set width to available width since we want block ui container to occupy the full column // and UIElement to be algined within it fsbbox.fsrc = new PTS.FSRECT(); fsbbox.fsrc.du = durAvailable; fsbbox.fsrc.dv = TextDpi.ToTextDpi(uiIslandSize.Height) + mbp.BPTop + mbp.BPBottom; fsbbox.fDefined = PTS.True; } }
/// <summary> /// Create UIElementIsland representing embedded Element Layout island within content world. /// </summary> private void EnsureUIElementIsland() { if (_uiElementIsland == null) { _uiElementIsland = new UIElementIsland(((BlockUIContainer)Element).Child); _uiElementIsland.DesiredSizeChanged += new DesiredSizeChangedEventHandler(OnUIElementDesiredSizeChanged); } }
/// <summary> /// Ensures the _uiElementIsland variable is up to date /// </summary> private void UpdateUIElementIsland() { UIElement childElement = this.Child; if (_uiElementIsland == null || _uiElementIsland.Root != childElement) { if (_uiElementIsland != null) { _uiElementIsland.Dispose(); _uiElementIsland = null; } if (childElement != null) { _uiElementIsland = new UIElementIsland(childElement); } } }
/// <summary> /// Validates visual node associated with paragraph. /// </summary> internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { // Obtain all mbd info MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); // MIRROR entire element to interface with underlying layout tree. // Border/Padding does not need to be mirrored, as it'll be mirrored with the content. PtsHelper.UpdateMirroringTransform(PageFlowDirection, ThisFlowDirection, _visual, TextDpi.FromTextDpi(2 * _rect.u + _rect.du)); // Add UIElementIsland to visual tree and set appropiate offset. UIElementIsland uiElementIsland = ((UIElementParagraph)Paragraph).UIElementIsland; if (uiElementIsland != null) { if (_visual.Children.Count != 1 || _visual.Children[0] != uiElementIsland) { // Disconnect UIElementIsland from its old parent. Visual currentParent = VisualTreeHelper.GetParent(uiElementIsland) as Visual; if (currentParent != null) { ContainerVisual parent = currentParent as ContainerVisual; Invariant.Assert(parent != null, "Parent should always derives from ContainerVisual."); parent.Children.Remove(uiElementIsland); } _visual.Children.Clear(); _visual.Children.Add(uiElementIsland); } uiElementIsland.Offset = new PTS.FSVECTOR(_rect.u + mbp.BPLeft, _rect.v + mbp.BPTop).FromTextDpi(); } else { _visual.Children.Clear(); } // Draw background and borders. Brush backgroundBrush = (Brush)Paragraph.Element.GetValue(TextElement.BackgroundProperty); _visual.DrawBackgroundAndBorder(backgroundBrush, mbp.BorderBrush, mbp.Border, _rect.FromTextDpi(), IsFirstChunk, IsLastChunk); }
// Token: 0x060067C2 RID: 26562 RVA: 0x001D159B File Offset: 0x001CF79B internal InlineObject(int dcp, UIElementIsland uiElementIsland, TextParagraph para) : base(dcp) { this._para = para; this._uiElementIsland = uiElementIsland; this._uiElementIsland.DesiredSizeChanged += this._para.OnUIElementDesiredSizeChanged; }