/// <summary> /// * 함 수 명 : TxtText_KeyPress /// * 작 성 자 : 황지희 /// * 개 요 : key 이벤트 영어(대문자), 숫자만 입력받도록 valid 체크 /// </summary> private void TxtText_KeyPress(object sender, KeyPressEventArgs e) { TextBox txt = (TextBox)sender; Control temp = txt.Parent; MaskTextBox mtb = null; while (temp.Parent != null) { if (temp is MaskTextBox) { mtb = temp as MaskTextBox; break; } temp = temp.Parent; } if (mtb == null) { return; } switch (mtb.Name) { case "txt_MaskNum": case "txt_EqpId": CommonFuction.TypingOnlyEngNum(sender, e, mtb); break; } }
/// <summary> /// 2019-05-29 황지희 복사하기 추가 /// </summary> private void UserTabPageControl_KeyDown(object sender, KeyEventArgs e) { TextBox txt = (TextBox)sender; Control temp = txt.Parent; MaskTextBox mtb = null; while (temp.Parent != null) { if (temp is MaskTextBox) { mtb = temp as MaskTextBox; break; } temp = temp.Parent; } if (mtb == null) { return; } if (e.Control && e.KeyCode == Keys.C) { //복사하기 Clipboard.SetText(mtb.ucValue); } }
private void MaskTextBox_OnTextChanged(object sender, TextChangedEventArgs e) { bool isMaskValid = false; try { // Usinig color converter is not a good solution because in case of an invalid text it throws an exception // and this moves focus from sample application into Visual Studio //if (_colorConverter == null) // _colorConverter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Color)); // //CurrentMaskColor = (Color)_colorConverter.ConvertFromString(MaskTextBox.Text); var maskText = MaskTextBox.Text.Trim(); if (maskText.Length == 6) { int red = HexToByte(maskText, 0); int green = HexToByte(maskText, 2); int blue = HexToByte(maskText, 4); if (red != -1 && green != -1 && blue != -1) { CurrentMaskColor = Color.FromRgb((byte)red, (byte)green, (byte)blue); MaskColorRectangle.Fill = new SolidColorBrush(CurrentMaskColor); isMaskValid = true; } } } catch (Exception ex) { isMaskValid = false; } if (isMaskValid) { MaskTextBox.ClearValue(ForegroundProperty); if (_physicallyBasedMaterial != null) { if (TextureMapType == TextureMapTypes.Albedo || TextureMapType == TextureMapTypes.BaseColor || TextureMapType == TextureMapTypes.DiffuseColor) { _physicallyBasedMaterial.BaseColor = CurrentMaskColor.ToColor4(); } OnMapSettingsChanged(); } OnMapSettingsChanged(); } else { MaskTextBox.Foreground = Brushes.Red; } }
/// <summary> /// 텍스트박스 입력 키 제한,엔터키 입력시 TAB키 반환 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TextBox_KeyPress(object sender, KeyPressEventArgs e) { TextBox txt = (TextBox)sender; Control temp = txt.Parent; MaskTextBox mtb = null; while (temp.Parent != null) { if (temp is MaskTextBox) { mtb = temp as MaskTextBox; break; } temp = temp.Parent; } if (mtb == null) { return; } switch (mtb.Name) { case "txtVenderID": CommonFuction.TypingOnlyEngNum(sender, e, txtVenderID); if (e.KeyChar == (char)Keys.Enter) { SendKeys.Send("{TAB}"); } break; case "txtVenderName": if (Char.IsLetter(e.KeyChar) == false && Char.IsDigit(e.KeyChar) == false && e.KeyChar != 8 && e.KeyChar == ',') { e.Handled = true; } if (e.KeyChar == (char)Keys.Enter) { SendKeys.Send("{TAB}"); } break; } }
public static void SetSelectAllTextOnFocus(MaskTextBox textBox, bool value) { textBox.SetValue(SelectAllTextOnFocusProperty, value); }
public static bool GetSelectAllTextOnFocus(MaskTextBox textBox) { return((bool)textBox.GetValue(SelectAllTextOnFocusProperty)); }