/// <summary> /// Renders the RelativeHorizontal attribute. /// </summary> void RenderRelativeHorizontal() { if (RenderInParagraph()) { RenderNameValuePair("posrelh", "3"); } else { //We need to write both shpbx and posrelh which are almost equivalent. //Translate("RelativeHorizontal", "shpbx", RtfUnit.Undefined, "margin", false); object relHorObj = GetValueAsIntended("RelativeHorizontal"); RelativeHorizontal relHor = relHorObj == null ? RelativeHorizontal.Margin : (RelativeHorizontal)relHorObj; switch (relHor) { case RelativeHorizontal.Character: RenderNameValuePair("posrelh", "3"); break; case RelativeHorizontal.Column: RenderNameValuePair("posrelh", "2"); break; case RelativeHorizontal.Margin: RenderNameValuePair("posrelh", "0"); break; case RelativeHorizontal.Page: RenderNameValuePair("posrelh", "1"); break; } } }
/// <summary> /// Renders (and calculates) the \shpleft and \shpright controls in RTF. /// </summary> private void RenderLeftRight() { Unit width = GetShapeWidth(); Unit left = 0; Unit right = width; if (!RenderInParagraph()) { RelativeHorizontal relHor = (RelativeHorizontal)GetValueOrDefault("RelativeHorizontal", RelativeHorizontal.Margin); LeftPosition leftPos = (LeftPosition)GetValueOrDefault("Left", new LeftPosition()); //REM: Will not work like this in table cells. //=>The shape would have to be put in a paragraph there. Section sec = (Section)DocumentRelations.GetParentOfType(_shape, typeof(Section)); PageSetup pgStp = sec.PageSetup; Unit leftMrg = (Unit)pgStp.GetValue("LeftMargin", GV.ReadOnly); Unit rgtMrg = (Unit)pgStp.GetValue("RightMargin", GV.ReadOnly); Unit pgHeight = pgStp.PageHeight; Unit pgWidth = pgStp.PageWidth; if (leftPos.ShapePosition == ShapePosition.Undefined) { left = leftPos.Position; right = left + width; } else { switch (relHor) { case RelativeHorizontal.Column: case RelativeHorizontal.Character: case RelativeHorizontal.Margin: AlignHorizontally(leftPos.ShapePosition, pgWidth.Point - leftMrg.Point - rgtMrg.Point, out left, out right); break; case RelativeHorizontal.Page: AlignHorizontally(leftPos.ShapePosition, pgWidth, out left, out right); break; } } } RenderUnit("shpleft", left); RenderUnit("shpright", right); }
public MezImage RelativeHorizontal(RelativeHorizontal relativeHorizontal) { Image.RelativeHorizontal = relativeHorizontal; return(this); }