/// <summary> /// Converts TextBox ContentAlignment to String Alignment /// </summary> /// <returns></returns> public static StringAlignment ContentAlignmentToStringAlignment(MgTextBox control) { AlignmentInfo alignmentInfo = GetAlignmentInfo(control.TextAlign); switch (alignmentInfo.HorAlign) { case AlignmentTypeHori.Center: return(StringAlignment.Center); case AlignmentTypeHori.Left: if (control.RightToLeft == RightToLeft.Yes) { return(StringAlignment.Far); } else { return(StringAlignment.Near); } case AlignmentTypeHori.Right: if (control.RightToLeft == RightToLeft.Yes) { return(StringAlignment.Near); } else { return(StringAlignment.Far); } default: return(StringAlignment.Near); } }
/// <summary> /// Sets hint text color to MgTextBox (edit control) /// </summary> /// <param name="hintTextBox"></param> /// <param name="hintColor"></param> public static void SetHintColor(MgTextBox hintTextBox, Color hintFgColor) { if (hintTextBox != null) { hintTextBox.TextBoxStrategy.HintFgColor = hintFgColor; } }
/// <summary> /// Sets hint text to MgTextBox (edit control) /// </summary> /// <param name="control"></param> /// <param name="hint"></param> public static void SetHint(MgTextBox hintTextBox, string hint) { //Set hint text and change strategy bool setHint = hint != null && hint.Trim() != ""; if (setHint) { hintTextBox.EnableHintStrategy(hint); } else {//remove strategy when hint text is removed hintTextBox.DisableHintStrategy(); hintTextBox.Refresh(); } }
/// <summary> /// Constructor /// </summary> /// <param name="mgTextBox"></param> public TextBoxHintStrategyBase(MgTextBox mgTextBox) { this.mgTextBox = mgTextBox; }
/// <summary> /// apply text properties to editor control /// </summary> /// <param name = "control"> /// </param> /// <param name = "text"> /// </param> protected internal void setTextProperties(TextBox textbox, String text) { if (textbox.Multiline != _multiLine) { ControlUtils.SetMultiLine(textbox, MultiLine); } if (_showVerticalScroll != ((textbox.ScrollBars & ScrollBars.Vertical) == ScrollBars.Vertical)) { GuiUtilsBase.setMultilineVerticalScroll(textbox, _showVerticalScroll); } // Check if we need to call setMultilineWordWrapScroll - will it really change the textbox property bool shouldSetHS = false; switch (HorizontalScrollBar) { case MultilineHorizontalScrollBar.Yes: if (textbox.WordWrap) { shouldSetHS = true; } break; case MultilineHorizontalScrollBar.No: if (textbox.WordWrap) { shouldSetHS = true; } break; case MultilineHorizontalScrollBar.WordWrap: if (!textbox.WordWrap) { shouldSetHS = true; } break; } if (shouldSetHS) { GuiUtilsBase.setMultilineWordWrapScroll(textbox, HorizontalScrollBar); } if (textbox.AcceptsReturn != _multiLineAllowCR) { GuiUtilsBase.setMultilineAllowCR(textbox, MultiLineAllowCR); } ((TagData)textbox.Tag).CheckAutoWide = AutoWide; if (text != null) { // 0 is illegal and will cause a crash. if (TextSizeLimit > 0 && textbox.MaxLength != _textSizeLimit) { GuiUtilsBase.setTextLimit(textbox, TextSizeLimit); } // QCR #922740, setText unselects the text, we should not perfrom it if not nessesary if (!textbox.Text.Equals(text)) { GuiUtilsBase.setText(textbox, text); } if (textbox.ReadOnly == _modifable) { GuiUtilsBase.setReadOnly(textbox, !_modifable); } } }
/// <summary> /// Constructor /// </summary> /// <param name="mgTextBox"></param> public TextBoxWithHintStrategy(MgTextBox mgTextBox) : base(mgTextBox) { RegisterEvents(); }
/// <summary> /// Sets the Password property /// </summary> public static void SetPasswordEdit(MgTextBox textBox, bool isPasswordEdit) { textBox.UseSystemPasswordChar = isPasswordEdit; }