//New KlPo 27.08.07 /// <summary> /// Gets the alignment depending on the currentPage for the alignments "Outside" and "Inside". /// </summary> /// <param name="alignment">The original alignment</param> /// <returns>the alignment depending on the currentPage for the alignments "Outside" and "Inside"</returns> private ElementAlignment GetCurrentAlignment(ElementAlignment alignment) { ElementAlignment align = alignment; if (align == ElementAlignment.Inside) { if (currentPage % 2 == 0) { align = ElementAlignment.Far; } else { align = ElementAlignment.Near; } } else if (align == ElementAlignment.Outside) { if (currentPage % 2 == 0) { align = ElementAlignment.Near; } else { align = ElementAlignment.Far; } } return(align); }
/// <summary> /// Converts content alignment to pivot. /// </summary> public static Vector2 ToPivot(this ElementAlignment alignment) { switch (alignment) { default: case ElementAlignment.Center: return(new Vector2(0.5f, 0.5f)); case ElementAlignment.Left: return(new Vector2(0, 0.5f)); case ElementAlignment.Top: return(new Vector2(0.5f, 1)); case ElementAlignment.Right: return(new Vector2(1, 0.5f)); case ElementAlignment.Bottom: return(new Vector2(0.5f, 0)); case ElementAlignment.TopLeft: return(new Vector2(0, 1)); case ElementAlignment.TopRight: return(new Vector2(1, 1)); case ElementAlignment.BottomLeft: return(new Vector2(0, 0)); case ElementAlignment.BottomRight: return(new Vector2(1, 0)); } }
/// <summary> /// Converts marklight text alignment to text mesh pro text alignment. /// </summary> public static TextAlignmentOptions ToTextAlignmentOptions(this ElementAlignment alignment) { switch (alignment) { case ElementAlignment.Center: return(TextAlignmentOptions.Center); case ElementAlignment.Left: return(TextAlignmentOptions.Left); case ElementAlignment.Top: return(TextAlignmentOptions.Top); case ElementAlignment.Right: return(TextAlignmentOptions.Right); case ElementAlignment.Bottom: return(TextAlignmentOptions.Bottom); case ElementAlignment.TopLeft: return(TextAlignmentOptions.TopLeft); case ElementAlignment.TopRight: return(TextAlignmentOptions.TopRight); case ElementAlignment.BottomLeft: return(TextAlignmentOptions.BottomLeft); case ElementAlignment.BottomRight: return(TextAlignmentOptions.BottomRight); default: return(TextAlignmentOptions.Center); } }
bool PositionHorizontallyToPage(LayoutInfo layoutInfo) { XUnit xPos; ElementAlignment align = GetCurrentAlignment(layoutInfo.HorizontalAlignment); switch (align) { case ElementAlignment.Near: #if true // Attempt to make it compatible with MigraDoc CPP. // Ignore layoutInfo.Left if absolute position is specified in layoutInfo.MarginLeft. // Use layoutInfo.Left if layoutInfo.MarginLeft is 0. // TODO We would need HasValue for XUnit to determine whether a value was assigned. if (layoutInfo.HorizontalReference == HorizontalReference.Page || layoutInfo.HorizontalReference == HorizontalReference.PageMargin) { xPos = layoutInfo.MarginLeft != 0 ? layoutInfo.MarginLeft : layoutInfo.Left; } else { xPos = Math.Max(layoutInfo.MarginLeft, layoutInfo.Left); } #else if (layoutInfo.HorizontalReference == HorizontalReference.Page || layoutInfo.HorizontalReference == HorizontalReference.PageMargin) { xPos = layoutInfo.MarginLeft; // ignore layoutInfo.Left if absolute position is specified } else { xPos = Math.Max(layoutInfo.MarginLeft, layoutInfo.Left); } #endif layoutInfo.ContentArea.X = xPos; break; case ElementAlignment.Far: xPos = _currentSection.PageSetup.EffectivePageWidth.Point; xPos -= layoutInfo.ContentArea.Width; xPos -= layoutInfo.MarginRight; layoutInfo.ContentArea.X = xPos; break; case ElementAlignment.Center: xPos = _currentSection.PageSetup.EffectivePageWidth.Point; xPos -= layoutInfo.ContentArea.Width; xPos /= 2; layoutInfo.ContentArea.X = xPos; break; } return(true); }
private object GetElementAlignment(ElementAlignment alignment) { switch (alignment) { case ElementAlignment.Center: return("justify-content-md-center"); case ElementAlignment.Left: return("justify-content-md-start ml-md-1"); case ElementAlignment.Right: default: return("justify-content-md-end mr-md-1"); } }
bool PositionHorizontallyToPage(LayoutInfo layoutInfo) { XUnit xPos; ElementAlignment align = GetCurrentAlignment(layoutInfo.HorizontalAlignment); switch (align) { case ElementAlignment.Near: #if true //!!!newTHHO 22.10.2008 allow negative offsets (supporting "Anschnitt" for images) //if (layoutInfo.MarginLeft < 0) // layoutInfo.GetType(); if (layoutInfo.HorizontalReference == HorizontalReference.Page || layoutInfo.HorizontalReference == HorizontalReference.PageMargin) { xPos = layoutInfo.MarginLeft; // ignore layoutInfo.Left if absolute position is specified } else { xPos = Math.Max(layoutInfo.MarginLeft, layoutInfo.Left); } #else //!!!delTHHO 22.10.2008 xPos = Math.Max(layoutInfo.MarginLeft, layoutInfo.Left); #endif layoutInfo.ContentArea.X = xPos; break; case ElementAlignment.Far: xPos = this.currentSection.PageSetup.PageWidth.Point; xPos -= layoutInfo.ContentArea.Width; xPos -= layoutInfo.MarginRight; layoutInfo.ContentArea.X = xPos; break; case ElementAlignment.Center: xPos = this.currentSection.PageSetup.PageWidth.Point; xPos -= layoutInfo.ContentArea.Width; xPos /= 2; layoutInfo.ContentArea.X = xPos; break; } return(true); }
/// <summary> /// Sets text alignment. /// </summary> public void SetTextAlignment(ElementAlignment textAlignment) { switch (textAlignment) { case ElementAlignment.Center: TextAlignment = TMPro.TextAlignmentOptions.Center; break; case ElementAlignment.Left: TextAlignment = TMPro.TextAlignmentOptions.Left; break; case ElementAlignment.Top: TextAlignment = TMPro.TextAlignmentOptions.Top; break; case ElementAlignment.Right: TextAlignment = TMPro.TextAlignmentOptions.Right; break; case ElementAlignment.Bottom: TextAlignment = TMPro.TextAlignmentOptions.Left; break; case ElementAlignment.TopLeft: TextAlignment = TMPro.TextAlignmentOptions.TopLeft; break; case ElementAlignment.TopRight: TextAlignment = TMPro.TextAlignmentOptions.TopRight; break; case ElementAlignment.BottomLeft: TextAlignment = TMPro.TextAlignmentOptions.BottomLeft; break; case ElementAlignment.BottomRight: TextAlignment = TMPro.TextAlignmentOptions.BottomRight; break; } }
bool PositionHorizontallyToMargin(LayoutInfo layoutInfo) { Rectangle rect = CalcContentRect(this.currentPage); ElementAlignment align = GetCurrentAlignment(layoutInfo.HorizontalAlignment); switch (align) { case ElementAlignment.Near: if (layoutInfo.Left != 0) { layoutInfo.ContentArea.X += layoutInfo.Left; return(true); } else if (layoutInfo.MarginLeft != 0) { layoutInfo.ContentArea.X += layoutInfo.MarginLeft; return(true); } return(false); case ElementAlignment.Far: XUnit xPos = rect.X + rect.Width; xPos -= layoutInfo.ContentArea.Width; xPos -= layoutInfo.MarginRight; layoutInfo.ContentArea.X = xPos; return(true); case ElementAlignment.Center: xPos = rect.Width; xPos -= layoutInfo.ContentArea.Width; xPos = rect.X + xPos / 2; layoutInfo.ContentArea.X = xPos; return(true); } return(false); }
/// <summary> /// Gets the alignment depending on the currentPage for the alignments "Outside" and "Inside". /// </summary> /// <param name="alignment">The original alignment</param> /// <returns>the alignment depending on the currentPage for the alignments "Outside" and "Inside"</returns> private ElementAlignment GetCurrentAlignment(ElementAlignment alignment) { ElementAlignment align = alignment; if (align == ElementAlignment.Inside) { align = _currentPage % 2 == 0 ? ElementAlignment.Far : ElementAlignment.Near; } else if (align == ElementAlignment.Outside) { align = _currentPage % 2 == 0 ? ElementAlignment.Near : ElementAlignment.Far; } return align; }
/// <summary> /// Sets text alignment. /// </summary> public void SetTextAlignment(ElementAlignment textAlignment) { TextAlignment = textAlignment; }