/// <summary> /// Handle "Edit ValidationRules..." verb event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditValidationRulesHandler(object sender, EventArgs e) { this.CustomInitialize(); ValidationRuleDesignForm vrdf = new ValidationRuleDesignForm(this._DesignerHost, this.Component as ValidationProvider, null); vrdf.ShowDialog(); }
/// <summary> /// Handle "Edit ValidationRules..." verb event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditValidationRulesHandler(object sender, EventArgs e) { this.CustomInitialize(); ValidationRuleDesignForm vrdf = new ValidationRuleDesignForm(this._DesignerHost, this.Component as ValidationProvider, null); vrdf.ShowDialog(); }
/// <summary> /// Setup to display our ValidationRuleDesignForm /// </summary> /// <param name="context"></param> /// <param name="provider"></param> /// <param name="value"></param> /// <returns></returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((context != null) && (provider != null)) { // get ValidationProvider name - "ValidationRule on validationProvider1" string sValidationProviderName = context.PropertyDescriptor.DisplayName.Split(' ')[2]; // find component matches provider name ValidationProvider valueVP = null; foreach (IComponent c in context.Container.Components) { valueVP = c as ValidationProvider; if ((valueVP != null) && (valueVP.Site.Name == sValidationProviderName)) { break; } } // get component that are selected object[] selectedComponents = context.Instance as object[]; if (selectedComponents == null) { selectedComponents = new object[] { context.Instance }; } // create ValidationRuleDesignForm ValidationRuleDesignForm vrdf = new ValidationRuleDesignForm((IDesignerHost)provider.GetService(typeof(IDesignerHost)), valueVP, selectedComponents); vrdf.ShowDialog(); // reselect the component on the UI ISelectionService selectionService = (ISelectionService)provider.GetService(typeof(ISelectionService)); selectionService.SetSelectedComponents(selectedComponents); } return(base.EditValue(context, provider, value)); }
/// <summary> /// Setup to display our ValidationRuleDesignForm /// </summary> /// <param name="context"></param> /// <param name="provider"></param> /// <param name="value"></param> /// <returns></returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((context != null) && (provider != null)) { // get ValidationProvider name - "ValidationRule on validationProvider1" string sValidationProviderName = context.PropertyDescriptor.DisplayName.Split(' ')[2]; // find component matches provider name ValidationProvider valueVP = null; foreach(IComponent c in context.Container.Components) { valueVP = c as ValidationProvider; if ((valueVP != null) && (valueVP.Site.Name == sValidationProviderName)) break; } // get component that are selected object[] selectedComponents = context.Instance as object[]; if (selectedComponents == null) { selectedComponents = new object[] { context.Instance }; } // create ValidationRuleDesignForm ValidationRuleDesignForm vrdf = new ValidationRuleDesignForm((IDesignerHost) provider.GetService(typeof(IDesignerHost)), valueVP, selectedComponents); vrdf.ShowDialog(); // reselect the component on the UI ISelectionService selectionService = (ISelectionService) provider.GetService(typeof(ISelectionService)); selectionService.SetSelectedComponents(selectedComponents); } return base.EditValue(context, provider, value); }