public void PonerError(Control ControlE, string sError, ErrorIconAlignment AlineacionError) { base.SetIconAlignment(ControlE, AlineacionError); base.SetIconPadding(ControlE, ControlError.PaddingPredefinido); base.SetError(ControlE, sError); this._NumeroDeErrores++; }
public void SetError(Control control, string value, ErrorIconAlignment iconAlignment, bool inside) { SetError(control, value, iconAlignment); if (inside) { base.SetIconPadding(control, -30); } }
// That will replace the SetIconAlignment from the base class when you call it from outside the class public void SetIconAlignment(Control control, ErrorIconAlignment value) { // Will raise an event just before changing the property OnPropertyChanging("IconAlignment"); // Changed the property using the base class base.SetIconAlignment(control, value); // Will raise an event just after the property has changed OnPropertyChanged("IconAlignment"); }
/* disable in Engine dll * private void __Set_ProgressBar(Int32 cnt) * { * flatThreadSafe.Run(this, (Action)(() => * this.FPBMain.Value = * ((cnt >= 0) ? ((cnt > 100) ? 100 : cnt) : 0) * )); * } */ private void __Set_ErrorProvider(object ctrl, int pad, string txterr, ErrorIconAlignment align = ErrorIconAlignment.MiddleRight) { if (ctrl == null) { return; } flatThreadSafe.Run(this, (Action)(() => this.EPMain.SetIconAlignment(((FlatTextBox)ctrl), align))); flatThreadSafe.Run(this, (Action)(() => this.EPMain.SetIconPadding(((FlatTextBox)ctrl), pad))); flatThreadSafe.Run(this, (Action)(() => this.EPMain.SetError(((FlatTextBox)ctrl), txterr))); }
public ErrorProperty(ErrorProvider ep, Control control) { this.ep = ep; this.control = control; alignment = ErrorIconAlignment.MiddleRight; padding = 0; text = string.Empty; blink_count = 0; tick = new EventHandler(window_Tick); window = new ErrorWindow(); window.Visible = false; window.Width = ep.icon.Width; window.Height = ep.icon.Height; #if NET_2_0 // UIA Framework: Associate ErrorProvider with Control ErrorProvider.OnUIAErrorProviderHookUp(ep, new ControlEventArgs(control)); // UIA Framework: Generate event to associate UserControl with ErrorProvider window.VisibleChanged += delegate(object sender, EventArgs args) { if (window.Visible == true) { ErrorProvider.OnUIAControlHookUp(control, new ControlEventArgs(window)); } else { ErrorProvider.OnUIAControlUnhookUp(control, new ControlEventArgs(window)); } }; #endif if (control.Parent != null) { #if NET_2_0 // UIA Framework: Generate event to associate UserControl with ErrorProvider ErrorProvider.OnUIAControlHookUp(control, new ControlEventArgs(window)); #endif control.Parent.Controls.Add(window); control.Parent.Controls.SetChildIndex(window, control.Parent.Controls.IndexOf(control) + 1); } window.Paint += new PaintEventHandler(window_Paint); window.MouseEnter += new EventHandler(window_MouseEnter); window.MouseLeave += new EventHandler(window_MouseLeave); control.SizeChanged += new EventHandler(control_SizeLocationChanged); control.LocationChanged += new EventHandler(control_SizeLocationChanged); control.ParentChanged += new EventHandler(control_ParentChanged); // Do we want to block mouse clicks? if so we need a few more events handled CalculateAlignment(); }
public ControlItem(ErrorProvider provider, Control control, IntPtr id) { _iconAlignment = DefaultIconAlignment; _error = string.Empty; Id = id; _control = control; _provider = provider; _control.HandleCreated += new EventHandler(OnCreateHandle); _control.HandleDestroyed += new EventHandler(OnDestroyHandle); _control.LocationChanged += new EventHandler(OnBoundsChanged); _control.SizeChanged += new EventHandler(OnBoundsChanged); _control.VisibleChanged += new EventHandler(OnParentVisibleChanged); _control.ParentChanged += new EventHandler(OnParentVisibleChanged); Properties = new PropertyStore(); }
/// <summary> /// /// </summary> /// <param name="edit"></param> /// <param name="EmpErrorText">空值时提醒</param> /// <param name="EIA">ErrorIcon显示位置</param> /// <returns>不为空返回Ture,空返回false</returns> public static bool VerificationNotEmpEditValue(BaseEdit edit, string EmpErrorText, ErrorIconAlignment EIA = ErrorIconAlignment.MiddleRight) { if (edit.Visible == false) return true; if (String.IsNullOrEmpty(ConvertEx.ToString(edit.EditValue))) { if (EmpErrorText != "") { edit.ErrorText = EmpErrorText; edit.ErrorIconAlignment = EIA; } return false; } return true; }
public ErrorProperty(ErrorProvider ep, Control control) { this.ep = ep; this.control = control; alignment = ErrorIconAlignment.MiddleRight; padding = 0; text = string.Empty; blink_count = 0; tick = new EventHandler(window_Tick); window = new ErrorWindow (); window.Visible = false; window.Width = ep.icon.Width; window.Height = ep.icon.Height; #if NET_2_0 // UIA Framework: Associate ErrorProvider with Control ErrorProvider.OnUIAErrorProviderHookUp (ep, new ControlEventArgs (control)); // UIA Framework: Generate event to associate UserControl with ErrorProvider window.VisibleChanged += delegate (object sender, EventArgs args) { if (window.Visible == true) ErrorProvider.OnUIAControlHookUp (control, new ControlEventArgs (window)); else ErrorProvider.OnUIAControlUnhookUp (control, new ControlEventArgs (window)); }; #endif if (control.Parent != null) { #if NET_2_0 // UIA Framework: Generate event to associate UserControl with ErrorProvider ErrorProvider.OnUIAControlHookUp (control, new ControlEventArgs (window)); #endif control.Parent.Controls.Add(window); control.Parent.Controls.SetChildIndex(window, control.Parent.Controls.IndexOf (control) + 1); } window.Paint += new PaintEventHandler(window_Paint); window.MouseEnter += new EventHandler(window_MouseEnter); window.MouseLeave += new EventHandler(window_MouseLeave); control.SizeChanged += new EventHandler(control_SizeLocationChanged); control.LocationChanged += new EventHandler(control_SizeLocationChanged); control.ParentChanged += new EventHandler (control_ParentChanged); // Do we want to block mouse clicks? if so we need a few more events handled CalculateAlignment(); }
public void SetIconAlignment_ChangesAlignment_ForValidErrorControl() { Panel tempPanel = new Panel(); TextBox sampleTextBox = new TextBox { Text = "sample" }; tempPanel.Controls.Add(sampleTextBox); this._errorProvider.SetError(sampleTextBox, "error text"); // Sets default alignment (MiddleRight). this._errorProvider.SetIconAlignment(sampleTextBox, ErrorIconAlignment.BottomLeft); ErrorIconAlignment newAlignment = this._errorProvider.GetIconAlignment(sampleTextBox); Assert.AreEqual(ErrorIconAlignment.BottomLeft, newAlignment); }
public void Show(Control parent, ValidationException exception, ErrorIconAlignment alignment) { Control target = null; if (!exception.Tag.IsNullOrEmpty()) { target = FindControl(parent, exception.Tag); } if (target != null) { this.SetError(target, exception.Message, alignment); } else { this.SetError(parent, exception.Message, alignment); } }
/// <summary> /// Sets the alignment for the error icon of a specified control. /// </summary> /// /// <param name="ErrorControl"> /// The control containing an error. /// </param> /// /// <param name="NewErrorLocation"> /// The new alignment for the icon box. /// </param> /// public void SetIconAlignment(Control ErrorControl, ErrorIconAlignment NewErrorLocation) { if (ErrorControl != null) { if (this._dictionary.ContainsKey(ErrorControl)) { ErrorInfo errorInfo = this._dictionary[ErrorControl]; errorInfo.IconAlignment = NewErrorLocation; this.SetIconLocation(errorInfo.IconControl, errorInfo.IconBox, errorInfo.IconAlignment); } else { throw new ArgumentException("Specified control does not have an error instance."); } } else { throw new ArgumentNullException("ErrorControl"); } }
/// <summary> /// Moves a specified picture box displaying an error icon relative to /// the location of an icon control. /// </summary> /// /// <param name="IconControl"> /// The control where the picture box will be displayed next to. /// </param> /// /// <param name="IconBox"> /// The picture box displaying the error icon. /// </param> /// /// <param name="IconAlignment"> /// The alignment type for the error icon. /// </param> /// private void SetIconLocation(Control IconControl, PictureBox IconBox, ErrorIconAlignment IconAlignment) { int xLocation = 0; int yLocation = 0; switch (IconAlignment) { case ErrorIconAlignment.BottomLeft: xLocation = IconControl.Location.X - IconBox.Width - ICON_X_BUFFER; yLocation = IconControl.Location.Y + IconControl.Height - IconBox.Height; break; case ErrorIconAlignment.BottomRight: xLocation = IconControl.Location.X + IconControl.Width + ICON_X_BUFFER; yLocation = IconControl.Location.Y + IconControl.Height - IconBox.Height; break; case ErrorIconAlignment.MiddleLeft: xLocation = IconControl.Location.X - IconBox.Width - ICON_X_BUFFER; yLocation = IconControl.Location.Y + (IconControl.Height / 2) - (IconBox.Height / 2); break; case ErrorIconAlignment.MiddleRight: xLocation = IconControl.Location.X + IconControl.Width + ICON_X_BUFFER; yLocation = IconControl.Location.Y + (IconControl.Height / 2) - (IconBox.Height / 2); break; case ErrorIconAlignment.TopLeft: xLocation = IconControl.Location.X - IconBox.Width - ICON_X_BUFFER; yLocation = IconControl.Location.Y; break; case ErrorIconAlignment.TopRight: xLocation = IconControl.Location.X + IconControl.Width + ICON_X_BUFFER; yLocation = IconControl.Location.Y; break; } IconBox.Location = new Point(xLocation, yLocation); }
/// <summary> /// Retrieves the icon alignment for a specified control. /// </summary> /// /// <param name="ErrorControl"> /// The control containing an error. /// </param> /// /// <returns> /// The ErrorIconAlignment for the specified control. /// </returns> /// public ErrorIconAlignment GetIconAlignment(Control ErrorControl) { ErrorIconAlignment alignment = ErrorIconAlignment.MiddleRight; if (ErrorControl != null) { if (this._dictionary.ContainsKey(ErrorControl)) { alignment = this._dictionary[ErrorControl].IconAlignment; } else { throw new Exception("Specified control does not have an error instance."); } } else { throw new ArgumentNullException("ErrorControl"); } return(alignment); }
public void ErrorProvider_SetIconAlignment_InvalidValue_ThrowsInvalidEnumArgumentException(ErrorIconAlignment value) { var provider = new ErrorProvider(); var control = new Control(); Assert.Throws <InvalidEnumArgumentException>("value", () => provider.SetIconAlignment(control, value)); }
public void ErrorProvider_SetIconAlignment_NullControl_ThrowsArgumentNullException(ErrorIconAlignment value) { var provider = new ErrorProvider(); Assert.Throws <ArgumentNullException>("control", () => provider.SetIconAlignment(null, value)); }
public void ErrorProvider_SetIconAlignment_Invoke_GetIconAlignmentReturnsExpected(ErrorIconAlignment value) { var provider = new ErrorProvider(); var control = new Control(); provider.SetIconAlignment(control, value); Assert.Equal(value, provider.GetIconAlignment(control)); // Call again. provider.SetIconAlignment(control, value); Assert.Equal(value, provider.GetIconAlignment(control)); }
public void SetIconAlignment(Control control, ErrorIconAlignment value) { throw new NotImplementedException("SetIconAlignment"); }
internal ErrorIconAlignment RTLTranslateIconAlignment(ErrorIconAlignment align) { if (this.provider.RightToLeft) { switch (align) { case ErrorIconAlignment.TopLeft: return ErrorIconAlignment.TopRight; case ErrorIconAlignment.TopRight: return ErrorIconAlignment.TopLeft; case ErrorIconAlignment.MiddleLeft: return ErrorIconAlignment.MiddleRight; case ErrorIconAlignment.MiddleRight: return ErrorIconAlignment.MiddleLeft; case ErrorIconAlignment.BottomLeft: return ErrorIconAlignment.BottomRight; case ErrorIconAlignment.BottomRight: return ErrorIconAlignment.BottomLeft; } } return align; }
/// <include file='doc\ErrorProvider.uex' path='docs/doc[@for="ErrorProvider.SetIconAlignment"]/*' /> /// <devdoc> /// Sets where the error icon should be placed relative to the control. /// </devdoc> public void SetIconAlignment(Control control, ErrorIconAlignment value) { EnsureControlItem(control).IconAlignment = value; }
public ErrorInfo(string NewErrorText, Control NewIconControl) { this.ErrorText = NewErrorText; this.IconControl = NewIconControl; this.IconAlignment = ErrorIconAlignment.MiddleRight; }
public void SetIconAlignment(Control control, ErrorIconAlignment value) { GetErrorProperty(control).Alignment = value; }
public void SetIconAlignment(Control control, ErrorIconAlignment value) {}
public void SetError(Control control, string value, ErrorIconAlignment alignment) { base.SetIconAlignment(control, alignment); base.SetError(control, value); }
const int startingBlinkPhase = 10; // cause we want to blink 5 times // // CONSTRUCTORS // /// <include file='doc\ErrorProvider.uex' path='docs/doc[@for="ErrorProvider.ControlItem.ControlItem"]/*' /> /// <devdoc> /// Construct the item with its associated control, provider, and /// a unique ID. The ID is used for the tooltip ID. /// </devdoc> public ControlItem(ErrorProvider provider, Control control, IntPtr id) { this.toolTipShown = false; this.iconAlignment = defaultIconAlignment; this.error = String.Empty; this.id = id; this.control = control; this.provider = provider; this.control.HandleCreated += new EventHandler(OnCreateHandle); this.control.HandleDestroyed += new EventHandler(OnDestroyHandle); this.control.LocationChanged += new EventHandler(OnBoundsChanged); this.control.SizeChanged += new EventHandler(OnBoundsChanged); this.control.VisibleChanged += new EventHandler(OnParentVisibleChanged); this.control.ParentChanged += new EventHandler(OnParentVisibleChanged); }
/// <summary> /// Contains /// </summary> /// <param name="dxProvider"></param> /// <param name="control"></param> /// <param name="value"></param> /// <param name="align"></param> /// <param name="type"></param> /// <param name="errorText"></param> public static void Contains(DXValidationProvider dxProvider, Control control, object value, ErrorIconAlignment align, ErrorType type, string errorText) { ConditionValidationRule rule = new ConditionValidationRule { ConditionOperator = ConditionOperator.Contains, ErrorText = errorText, ErrorType = type, Value1 = value }; dxProvider.SetIconAlignment(control, align); dxProvider.SetValidationRule(control, rule); }
/// <summary> /// Notblank /// </summary> /// <param name="dxProvider"></param> /// <param name="control"></param> /// <param name="align"></param> /// <param name="type"></param> /// <param name="errorText"></param> public static void NotBlank(DXValidationProvider dxProvider, Control control, ErrorIconAlignment align, ErrorType type, string errorText) { ConditionValidationRule rule = new ConditionValidationRule { ConditionOperator = ConditionOperator.IsNotBlank, ErrorText = errorText, ErrorType = type }; dxProvider.SetIconAlignment(control, align); dxProvider.SetValidationRule(control, rule); }
/// <summary> /// Sets an error condition for a specified control. /// </summary> /// /// <param name="ErrorControl"> /// The control that contains an error. /// </param> /// /// <param name="ErrorText"> /// The text explaining the error for the control. /// </param> /// /// <param name="IconAlignment"> /// The alignment type for the error icon. /// </param> /// public void SetError(Control ErrorControl, string ErrorText, ErrorIconAlignment IconAlignment) { this.SetError(ErrorControl, ErrorControl, ErrorText, IconAlignment); }
/// <summary> /// Sets an error condition for a specified control. /// </summary> /// /// <param name="ErrorControl"> /// The control that contains an error. /// </param> /// /// <param name="IconControl"> /// A separate control than the error control that will have the error /// icon associated with it. /// </param> /// /// <remarks> /// Use the IconControl parameter when the icon cannot be shown near the /// actual error control. By default, the IconControl is set to the /// ErrorControl reference. /// </remarks> /// /// <param name="ErrorText"> /// The text explaining the error for the control. /// </param> /// /// <param name="IconAlignment"> /// The alignment type for the error icon. /// </param> /// public void SetError(Control ErrorControl, Control IconControl, string ErrorText, ErrorIconAlignment IconAlignment) { if (ErrorControl != null) { if (IconControl != null) { if (!ErrorText.IsEmpty()) { if (!this._dictionary.ContainsKey(ErrorControl)) { ErrorInfo errorInfo = new ErrorInfo(ErrorText, IconControl); errorInfo.IconAlignment = IconAlignment; // Add the icon image to the current form and dictionary. PictureBox newIcon = this.pictureBoxIcon.Clone(); newIcon.Parent = IconControl.Parent; this.SetIconLocation(IconControl, newIcon, errorInfo.IconAlignment); newIcon.TabIndex = 0; IconControl.Parent.Controls.Add(newIcon); errorInfo.IconBox = newIcon; // Add the error text to the error control's tooltip text. this.ToolTipProvider.SetToolTip(ErrorControl, ErrorText); // Create the error instance. this._dictionary.Add(ErrorControl, errorInfo); } else { throw new ArgumentException("Error exists for control already."); } } else { throw new ArgumentException("No error text specified."); } } else { throw new ArgumentNullException("IconControl"); } } else { throw new ArgumentNullException("ErrorControl"); } }
public new void SetIconAlignment(Control control, ErrorIconAlignment value) { base.SetIconAlignment(control, ErrorIconAlignment.MiddleLeft); }
internal ErrorIconAlignment RTLTranslateIconAlignment(ErrorIconAlignment align) { if (provider.RightToLeft) { switch (align) { case ErrorIconAlignment.TopLeft: return ErrorIconAlignment.TopRight; case ErrorIconAlignment.MiddleLeft: return ErrorIconAlignment.MiddleRight; case ErrorIconAlignment.BottomLeft: return ErrorIconAlignment.BottomRight; case ErrorIconAlignment.TopRight: return ErrorIconAlignment.TopLeft; case ErrorIconAlignment.MiddleRight: return ErrorIconAlignment.MiddleLeft; case ErrorIconAlignment.BottomRight: return ErrorIconAlignment.BottomLeft; default: Debug.Fail("Unknown ErrorIconAlignment value"); return align; } } else { return align; } }
/// <summary> /// Set Error Icon alignment. /// </summary> /// <param name="control"></param> /// <param name="value"></param> public void SetIconAlignment(Control control, ErrorIconAlignment value) { this._ErrorProvider.SetIconAlignment(control, value); }
/// <summary> /// 例外を通知します。 /// </summary> /// <param name="con">例外通知をしたいコントロール</param> /// <param name="resourceKey">対象のリソースキー</param> /// <param name="paramters">プレースフォルダを置換するパラメータ</param> public virtual void RaiseError(Control con, ErrorIconAlignment alignment, string resourceKey, params string[] paramters) { this.SetIconAlignment(con, alignment); this.SetError(con, ResourceManager.Get(resourceKey, paramters)); if (!Keys.Contains(con)) Keys.Add(con); }
public void SetIconAlignment(Control control, ErrorIconAlignment value) { }
private void SetErrorProvider(ErrorProvider activeErrorProvider, Control activeControl, string message, ErrorIconAlignment iconAlignment) { activeErrorProvider.SetIconAlignment(activeControl, iconAlignment); activeErrorProvider.SetError(activeControl, message); var ttPoint = new Point(Convert.ToInt32(activeControl.Width / 2 - 20), -80); IpToolTip.IsBalloon = true; IpToolTip.UseFading = true; IpToolTip.ToolTipTitle = "Validation Error"; IpToolTip.ToolTipIcon = ToolTipIcon.Error; IpToolTip.Show(message, activeControl, ttPoint, 5000); }
public TextBoxWithErrorProvider(string errProviderString, ErrorIconAlignment errIconAllignment) { errProviderStringToShow = errProviderString; errProvider.SetIconAlignment(this, errIconAllignment); errProvider.Tag = this; }
/// <summary> /// /// </summary> /// <param name="edit"></param> /// <param name="EmpErrorText">空值时提醒</param> /// <param name="EIA">ErrorIcon显示位置</param> /// <returns>不为空返回Ture,空返回false</returns> public static bool VerificationNotEmpEditValue(BaseEdit edit, string EmpErrorText, ErrorIconAlignment EIA = ErrorIconAlignment.MiddleRight) { if (edit.Visible == false) { return(true); } if (String.IsNullOrEmpty(ConvertLib.ToString(edit.EditValue))) { if (EmpErrorText != "") { edit.ErrorText = EmpErrorText; edit.ErrorIconAlignment = EIA; } return(false); } return(true); }