/// <summary> Sets horizontal alignment of the control. </summary> /// <param name="control"></param> /// <param name="verticalAlignment"></param> public static void SetHorizontalAlignment(Control control, AlignmentTypeHori horizontalAlignment) { if (control is MgLinkLabel || control is MgButtonBase || control is Label || control is MgRadioPanel || control is MgCheckBox || control is MgTextBox || control is MgShape) { ContentAlignment contentAlignment = GetContentAligmentForSetHorAligment(control, horizontalAlignment); SetContentAlignment(control, contentAlignment); } }
/// <summary> /// in WebInfo.cpp we send the HorAligement property revers, because the control displays the text according to the RTL Property /// the printText() displays the text according to the send aligment so we need to reverse the org horisontal aligment /// </summary> /// <param name="rightToLeft"></param> /// <param name="AlignmentInfo"></param> /// <param name="TextAlign"></param> /// <returns></returns> public static ContentAlignment GetOrgContentAligment(RightToLeft rightToLeft, ContentAlignment TextAlign) { AlignmentInfo alignmentInfo = GetAlignmentInfo(TextAlign); ContentAlignment NewTextAli = TextAlign; if (rightToLeft == RightToLeft.Yes && alignmentInfo.HorAlign != AlignmentTypeHori.Center) { AlignmentTypeHori newTypeHor = (alignmentInfo.HorAlign == AlignmentTypeHori.Right ? AlignmentTypeHori.Left : AlignmentTypeHori.Right); NewTextAli = GetContentAligmentForHorAligmentAndVerAligment(newTypeHor, alignmentInfo.VerAlign); } return(NewTextAli); }
/// <summary> /// /// </summary> /// <param name="contentAlignment"></param> /// <param name="VerAligment"></param> /// <returns></returns> public static ContentAlignment GetContentAligmentForSetVerAligment(ContentAlignment contentAlignment, AlignmentTypeVert VerAligment) { ContentAlignment RetContentAlignment; //get the Current Content alignment info from the ContentAlignmentTable AlignmentInfo aligmentInfo = _contentAlignmentTable[contentAlignment]; //get the current Horizontal alignment AlignmentTypeHori CurrHorAligment = aligmentInfo.HorAlign; //get the new Contant alignment from the HorVerConversion; RetContentAlignment = _horVerTranslation[(int)(VerAligment - 1), (int)(CurrHorAligment - 1)]; return(RetContentAlignment); }
/// <summary> /// Gets the System.Windows.Forms.HorizontalAlignment corresponding to AlignmentTypeHori /// </summary> /// <param name="alignmentTypeHori"></param> /// <returns></returns> public static HorizontalAlignment HorAlign2HorAlign(AlignmentTypeHori alignmentTypeHori) { HorizontalAlignment horiAlignment = HorizontalAlignment.Left; if (alignmentTypeHori == AlignmentTypeHori.Left) { horiAlignment = HorizontalAlignment.Left; } else if (alignmentTypeHori == AlignmentTypeHori.Center) { horiAlignment = HorizontalAlignment.Center; } else if (alignmentTypeHori == AlignmentTypeHori.Right) { horiAlignment = HorizontalAlignment.Right; } return(horiAlignment); }
/// <summary>return the display rect of the display size according to the contentAlignment</summary> /// <param name="ClientRect"></param> /// <param name="DisplaySize"></param> /// <param name="contentAlignment"></param> /// <returns></returns> public static Rectangle GetFocusRect(Control control, Rectangle displayRect, ContentAlignment contentAlignment, Size textSize) { AlignmentInfo aligmentInfo = GetAlignmentInfo(contentAlignment); //get the current vertical\horizontal aligment AlignmentTypeVert alignmentTypeVert = aligmentInfo.VerAlign; AlignmentTypeHori alignmentTypeHori = aligmentInfo.HorAlign; Rectangle focusRect = new Rectangle(displayRect.X, displayRect.Y, textSize.Width, textSize.Height); switch (alignmentTypeVert) { case AlignmentTypeVert.Top: break; case AlignmentTypeVert.Bottom: focusRect.Y = displayRect.Bottom - textSize.Height; break; case AlignmentTypeVert.Center: focusRect.Y += (displayRect.Height - textSize.Height) / 2; break; } switch (alignmentTypeHori) { case AlignmentTypeHori.Left: break; case AlignmentTypeHori.Right: focusRect.X = displayRect.Right - textSize.Width; break; case AlignmentTypeHori.Center: focusRect.X += (displayRect.Width - textSize.Width) / 2; break; } //check the rect focus that is not out the control focusRect.X = Math.Max(1, focusRect.X); focusRect.Width = Math.Min(focusRect.Width, control.ClientRectangle.Width - focusRect.X); return(focusRect); }
/// <summary> return alignment flags for horizontal and vertical alignment /// </summary> /// <param name="HorAligment"></param> /// <param name="VerAligment"></param> /// <returns></returns> private static ContentAlignment GetContentAligmentForHorAligmentAndVerAligment(AlignmentTypeHori HorAligment, AlignmentTypeVert VerAligment) { ContentAlignment RetContentAlignment = _horVerTranslation[(int)(VerAligment - 1), (int)(HorAligment - 1)]; return(RetContentAlignment); }
/// <summary> /// /// </summary> /// <param name="control"></param> /// <param name="HorAligment"></param> /// <returns></returns> internal static ContentAlignment GetContentAligmentForSetHorAligment(Control control, AlignmentTypeHori HorAligment) { //get the current content alignment of the control ContentAlignment CurrContentAlignment = GetContentAlignment(control); return(GetContentAligmentForSetHorAligment(CurrContentAlignment, HorAligment)); }
public AlignmentTypeVert VerAlign; //(TOP = 1, CENTER = 2,BOTTOM = 3) internal AlignmentInfo(AlignmentTypeVert VerAlign, AlignmentTypeHori HorAlign) { this.HorAlign = HorAlign; this.VerAlign = VerAlign; }