/// <include file='doc\QueuePathEditor.uex' path='docs/doc[@for="PropertyBindingEditor.EditValue"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { PropertyBinding binding = value as PropertyBinding; if (binding != null) { PropertyBinding bindingToEdit = new PropertyBinding(binding); SingleBindingDialog bindingUI = new SingleBindingDialog(bindingToEdit); if (edSvc.ShowDialog(bindingUI) == DialogResult.OK) { value = bindingToEdit; ManagedPropertiesService svc = (ManagedPropertiesService)context.GetService(typeof(ManagedPropertiesService)); if (svc != null) { svc.MakeDirty(); try { svc.WriteConfigFile(); } catch { } } } } } } return(value); }
/// <include file='doc\AdvancedPropertyDialog.uex' path='docs/doc[@for="AdvancedPropertyDialog.SaveSelectedProperties"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void SaveSelectedProperties() { PropertyBindingCollection newBindings = Bindings; ManagedPropertiesService svc = (ManagedPropertiesService)component.Site.GetService(typeof(ManagedPropertiesService)); if (svc != null) { for (int i = 0; i < newBindings.Count; i++) { svc.EnsureKey(newBindings[i]); svc.Bindings[component, newBindings[i].Property] = newBindings[i]; } svc.MakeDirty(); } TypeDescriptor.Refresh(component); // now announce that it's changed IComponentChangeService changeService = (IComponentChangeService)component.Site.GetService(typeof(IComponentChangeService)); if (changeService != null) { changeService.OnComponentChanged(component, null, null, null); } }
/// <include file='doc\AdvancedPropertyEditor.uex' path='docs/doc[@for="AdvancedPropertyEditor.EditValue"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { ComponentSettings compSettings = ((AdvancedPropertyDescriptor)value).ComponentSettings; IComponent component = compSettings.Component; // make sure it's OK to change IComponentChangeService changeService = null; if (component.Site != null) { changeService = (IComponentChangeService)component.Site.GetService(typeof(IComponentChangeService)); } if (changeService != null) { try { changeService.OnComponentChanging(component, (PropertyDescriptor)value); } catch (CheckoutException e) { if (e == CheckoutException.Canceled) { return(value); } throw e; } } IWindowsFormsEditorService editorSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); Debug.Assert(editorSvc != null, "Couldn't get IWindowsFormsEditorService"); if (editorSvc != null) { try { using (AdvancedPropertyDialog dlg = new AdvancedPropertyDialog(component)) { DialogResult result = editorSvc.ShowDialog(dlg); if (result == DialogResult.OK) { bool changeMade = false; PropertyBindingCollection newBindings = dlg.Bindings; ManagedPropertiesService svc = (ManagedPropertiesService)context.GetService(typeof(ManagedPropertiesService)); Debug.Assert(svc != null, "Couldn't get ManagedPropertiesService"); if (svc != null) { for (int i = 0; i < newBindings.Count; i++) { svc.EnsureKey(newBindings[i]); PropertyBinding oldBinding = svc.Bindings[component, newBindings[i].Property]; if (oldBinding == null) { if (newBindings[i].Bound) { changeMade = true; } } else if ((oldBinding.Bound != newBindings[i].Bound) || (oldBinding.Key != newBindings[i].Key)) { changeMade = true; } svc.Bindings[component, newBindings[i].Property] = newBindings[i]; } svc.MakeDirty(); if (changeMade) { TypeDescriptor.Refresh(compSettings.Component); if (changeService != null) { changeService.OnComponentChanged(compSettings.Component, null, null, null); } try { svc.WriteConfigFile(); } catch { } } // this fools the properties window into thinking we changed the value, so it refreshes // the owner object. object retval = new AdvancedPropertyDescriptor(compSettings); return(retval); } } } } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message, SR.GetString(SR.ConfigConfiguredProperties)); } } return(value); }