/// <summary> /// Constructor for the KryptonDataGridViewMaskedTextBoxCell cell type /// </summary> public KryptonDataGridViewMaskedTextBoxCell() { // Create a thread specific KryptonMaskedTextBox control used for the painting of the non-edited cells if (_paintingMaskedTextBox == null) { _paintingMaskedTextBox = new KryptonMaskedTextBox(); _paintingMaskedTextBox.SetLayoutDisplayPadding(new Padding(0, 0, 1, -1)); _paintingMaskedTextBox.StateCommon.Border.Width = 0; _paintingMaskedTextBox.StateCommon.Border.Draw = InheritBool.False; _paintingMaskedTextBox.StateCommon.Back.Color1 = Color.Empty; } // Set the default values of the properties: _promptChar = '_'; _allowPromptAsInput = true; _asciiOnly = false; _beepOnError = false; _cutCopyMaskFormat = MaskFormat.IncludeLiterals; _hidePromptOnLeave = false; _hideSelection = true; _insertKeyMode = InsertKeyMode.Default; _mask = string.Empty; _passwordChar = '\0'; _rejectInputOnFirstFailure = false; _resetOnPrompt = true; _resetOnSpace = true; _skipLiterals = true; _textMaskFormat = MaskFormat.IncludeLiterals; _useSystemPasswordChar = false; }
/// <summary> /// Initializes the designer with the specified component. /// </summary> /// <param name="component">The IComponent to associate the designer with.</param> public override void Initialize(IComponent component) { // Let base class do standard stuff base.Initialize(component); // The resizing handles around the control need to change depending on the // value of the AutoSize and AutoSizeMode properties. When in AutoSize you // do not get the resizing handles, otherwise you do. AutoResizeHandles = true; // Cast to correct type _maskedTextBox = component as KryptonMaskedTextBox; if (_maskedTextBox != null) { // Hook into masked textbox events _maskedTextBox.GetViewManager().MouseUpProcessed += OnMaskedTextBoxMouseUp; _maskedTextBox.GetViewManager().DoubleClickProcessed += OnMaskedTextBoxDoubleClick; } // Get access to the design services _designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); _selectionService = (ISelectionService)GetService(typeof(ISelectionService)); // We need to know when we are being removed _changeService.ComponentRemoving += OnComponentRemoving; }
private void UnmonitorControl(KryptonMaskedTextBox c) { c.MouseEnter -= new EventHandler(OnControlEnter); c.MouseLeave -= new EventHandler(OnControlLeave); c.TrackMouseEnter -= new EventHandler(OnControlEnter); c.TrackMouseLeave -= new EventHandler(OnControlLeave); }
/// <summary> /// Initialize a new instance of the KryptonMaskedTextBoxActionList class. /// </summary> /// <param name="owner">Designer that owns this action list instance.</param> public KryptonMaskedTextBoxActionList(KryptonMaskedTextBoxDesigner owner) : base(owner.Component) { // Remember the text box instance _maskedTextBox = owner.Component as KryptonMaskedTextBox; // Cache service used to notify when a property has changed _service = (IComponentChangeService)GetService(typeof(IComponentChangeService)); }
/// <summary> /// Initialize a new instance of the KryptonMaskedTextBoxActionList class. /// </summary> /// <param name="owner">Designer that owns this action list instance.</param> public KryptonMaskedTextBoxActionList(KryptonMaskedTextBoxDesigner owner) : base(owner.Component) { // Remember the text box instance _maskedTextBox = owner.Component as KryptonMaskedTextBox; // Cache service used to notify when a property has changed _service = (IComponentChangeService)GetService(typeof(IComponentChangeService)); }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { if (_maskedTextBox != null) { UnmonitorControl(_maskedTextBox); _maskedTextBox.Dispose(); _maskedTextBox = null; } } base.Dispose(disposing); }
private void UpdateParent(Control parentControl) { // Is there a change in the masked textbox or a change in // the parent control that is hosting the control... if ((parentControl != LastParentControl) || (LastMaskedTextBox != _ribbonMaskedTextBox.MaskedTextBox)) { // We only modify the parent and visible state if processing for correct container if ((_ribbonMaskedTextBox.RibbonContainer.RibbonGroup.ShowingAsPopup && (parentControl is VisualPopupGroup)) || (!_ribbonMaskedTextBox.RibbonContainer.RibbonGroup.ShowingAsPopup && !(parentControl is VisualPopupGroup))) { // If we have added the custrom control to a parent before if ((LastMaskedTextBox != null) && (LastParentControl != null)) { // If that control is still a child of the old parent if (LastParentControl.Controls.Contains(LastMaskedTextBox)) { // Check for a collection that is based on the read only class LastParentControl.Controls.Remove(LastMaskedTextBox); } } // Remember the current control and new parent LastMaskedTextBox = _ribbonMaskedTextBox.MaskedTextBox; LastParentControl = parentControl; // If we have a new masked textbox and parent if ((LastMaskedTextBox != null) && (LastParentControl != null)) { // Ensure the control is not in the display area when first added LastMaskedTextBox.Location = new Point(-LastMaskedTextBox.Width, -LastMaskedTextBox.Height); // Check for the correct visible state of the masked textbox UpdateVisible(LastMaskedTextBox); UpdateEnabled(LastMaskedTextBox); // Check for a collection that is based on the read only class LastParentControl.Controls.Add(LastMaskedTextBox); } } } }
/// <summary> /// Initialise a new instance of the KryptonRibbonGroupMaskedTextBox class. /// </summary> public KryptonRibbonGroupMaskedTextBox() { // Default fields _visible = true; _enabled = true; _itemSizeCurrent = GroupItemSize.Medium; ShortcutKeys = Keys.None; _keyTip = "X"; // Create the actual masked text box control and set initial settings MaskedTextBox = new KryptonMaskedTextBox { InputControlStyle = InputControlStyle.Ribbon, AlwaysActive = false, MinimumSize = new Size(121, 0), MaximumSize = new Size(121, 0), TabStop = false }; // Hook into events to expose via our container MaskedTextBox.TextAlignChanged += OnMaskedTextBoxTextAlignChanged; MaskedTextBox.TextChanged += OnMaskedTextBoxTextChanged; MaskedTextBox.HideSelectionChanged += OnMaskedTextBoxHideSelectionChanged; MaskedTextBox.ModifiedChanged += OnMaskedTextBoxModifiedChanged; MaskedTextBox.ReadOnlyChanged += OnMaskedTextBoxReadOnlyChanged; MaskedTextBox.MaskChanged += OnMaskedMaskChanged; MaskedTextBox.IsOverwriteModeChanged += OnMaskedIsOverwriteModeChanged; MaskedTextBox.MaskInputRejected += OnMaskedMaskInputRejected; MaskedTextBox.TypeValidationCompleted += OnMaskedTypeValidationCompleted; MaskedTextBox.GotFocus += OnMaskedTextBoxGotFocus; MaskedTextBox.LostFocus += OnMaskedTextBoxLostFocus; MaskedTextBox.KeyDown += OnMaskedTextBoxKeyDown; MaskedTextBox.KeyUp += OnMaskedTextBoxKeyUp; MaskedTextBox.KeyPress += OnMaskedTextBoxKeyPress; MaskedTextBox.PreviewKeyDown += OnMaskedTextBoxPreviewKeyDown; // Ensure we can track mouse events on the masked text box MonitorControl(MaskedTextBox); }
public KryptonRibbonGroupMaskedTextBox() { // Default fields _visible = true; _enabled = true; _itemSizeCurrent = GroupItemSize.Medium; _shortcutKeys = Keys.None; _keyTip = "X"; // Create the actual masked text box control and set initial settings _maskedTextBox = new KryptonMaskedTextBox(); _maskedTextBox.InputControlStyle = InputControlStyle.Ribbon; _maskedTextBox.AlwaysActive = false; _maskedTextBox.MinimumSize = new Size(121, 0); _maskedTextBox.MaximumSize = new Size(121, 0); _maskedTextBox.TabStop = false; // Hook into events to expose via our container _maskedTextBox.TextAlignChanged += new EventHandler(OnMaskedTextBoxTextAlignChanged); _maskedTextBox.TextChanged += new EventHandler(OnMaskedTextBoxTextChanged); _maskedTextBox.HideSelectionChanged += new EventHandler(OnMaskedTextBoxHideSelectionChanged); _maskedTextBox.ModifiedChanged += new EventHandler(OnMaskedTextBoxModifiedChanged); _maskedTextBox.ReadOnlyChanged += new EventHandler(OnMaskedTextBoxReadOnlyChanged); _maskedTextBox.MaskChanged += new EventHandler(OnMaskedMaskChanged); _maskedTextBox.IsOverwriteModeChanged += new EventHandler(OnMaskedIsOverwriteModeChanged); _maskedTextBox.MaskInputRejected += new MaskInputRejectedEventHandler(OnMaskedMaskInputRejected); _maskedTextBox.TypeValidationCompleted += new TypeValidationEventHandler(OnMaskedTypeValidationCompleted); _maskedTextBox.GotFocus += new EventHandler(OnMaskedTextBoxGotFocus); _maskedTextBox.LostFocus += new EventHandler(OnMaskedTextBoxLostFocus); _maskedTextBox.KeyDown += new KeyEventHandler(OnMaskedTextBoxKeyDown); _maskedTextBox.KeyUp += new KeyEventHandler(OnMaskedTextBoxKeyUp); _maskedTextBox.KeyPress += new KeyPressEventHandler(OnMaskedTextBoxKeyPress); _maskedTextBox.PreviewKeyDown += new PreviewKeyDownEventHandler(OnMaskedTextBoxPreviewKeyDown); // Ensure we can track mouse events on the masked text box MonitorControl(_maskedTextBox); }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { if (_maskedTextBox != null) { UnmonitorControl(_maskedTextBox); _maskedTextBox.Dispose(); _maskedTextBox = null; } } base.Dispose(disposing); }
private void UnmonitorControl(KryptonMaskedTextBox c) { c.MouseEnter -= new EventHandler(OnControlEnter); c.MouseLeave -= new EventHandler(OnControlLeave); c.TrackMouseEnter -= new EventHandler(OnControlEnter); c.TrackMouseLeave -= new EventHandler(OnControlLeave); }
public KryptonMaskedTextBoxProxy(KryptonMaskedTextBox maskedTextBox) { _maskedTextBox = maskedTextBox; }
/// <summary> /// 设置错误 /// </summary> /// <param name="textBox">TxtBox对象</param> /// <returns>错误返回false;否则为true</returns> private bool SetError(KryptonMaskedTextBox textBox) { if (!regexIp.IsMatch(textBox.Text.Trim())) { textBox.StateCommon.Border.Color1 = Color.Red; return false; } textBox.StateCommon.Border.Color1 = Color.LimeGreen; return true; }
/// <summary> /// Initializes the designer with the specified component. /// </summary> /// <param name="component">The IComponent to associate the designer with.</param> public override void Initialize(IComponent component) { // Let base class do standard stuff base.Initialize(component); // The resizing handles around the control need to change depending on the // value of the AutoSize and AutoSizeMode properties. When in AutoSize you // do not get the resizing handles, otherwise you do. AutoResizeHandles = true; // Cast to correct type _maskedTextBox = component as KryptonMaskedTextBox; if (_maskedTextBox != null) { // Hook into masked textbox events _maskedTextBox.GetViewManager().MouseUpProcessed += new MouseEventHandler(OnMaskedTextBoxMouseUp); _maskedTextBox.GetViewManager().DoubleClickProcessed += new PointHandler(OnMaskedTextBoxDoubleClick); } // Get access to the design services _designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); _selectionService = (ISelectionService)GetService(typeof(ISelectionService)); // We need to know when we are being removed _changeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); }