/// <summary> /// Publish Dependant Component Changes /// </summary> /// <typeparam name="T">Type of property</typeparam> /// <param name="propertyName">Property Name that has changed</param> /// <param name="value">new value for Property</param> private void PublishDependentComponentChanges <T>(string propertyName, T value) { System.ComponentModel.Design.IComponentChangeService changeService = null; System.ComponentModel.PropertyDescriptor property = null; T currentValue = default(T); if (DesignMode && this.Site != null) { property = System.ComponentModel.TypeDescriptor.GetProperties(this)[propertyName]; changeService = (System.ComponentModel.Design.IComponentChangeService) this.Site.GetService(typeof(System.ComponentModel.Design.IComponentChangeService)); if (changeService != null) { currentValue = (T)property.GetValue(this); if (currentValue == null) { currentValue = default(T); } // Trap any error and ignore it changeService.OnComponentChanging(this, property); // try to set new value property.SetValue(this, value); changeService.OnComponentChanged(this, property, currentValue, value); } } }
protected void FireChanged() { if (!DesignMode || IsLoading) { return; } System.ComponentModel.Design.IComponentChangeService srv = GetService(typeof(System.ComponentModel.Design.IComponentChangeService)) as System.ComponentModel.Design.IComponentChangeService; if (srv == null) { return; } srv.OnComponentChanged(this, null, null, null); }
public override void Exec() { try { UIHierarchy solExplorer = ApplicationObject.ToolWindows.SolutionExplorer; var hierItem = (UIHierarchyItem)((Array)solExplorer.SelectedItems).GetValue(0); var projItem = (ProjectItem)hierItem.Object; var d = (Dimension)projItem.Object; if (d.DataSource == null) { if (d.Source is TimeBinding) { MessageBox.Show("Attribute Relationship Name Fix is not supported on a Server Time dimension."); return; } } else if (d.Source is DimensionBinding) { MessageBox.Show("Attribute Relationship Name Fix is not supported on a linked dimension."); return; } ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy); ApplicationObject.StatusBar.Progress(true, "Fixing Attribute Relationship Names...", 0, d.Attributes.Count); bool bAttributesChanged = FixAttributeRelationshipNames(d); if (bAttributesChanged) { EnvDTE.Window w = projItem.Open(BIDSViewKinds.Designer); //opens the designer System.ComponentModel.Design.IDesignerHost designer = (System.ComponentModel.Design.IDesignerHost)w.Object; System.ComponentModel.Design.IComponentChangeService changesvc = (System.ComponentModel.Design.IComponentChangeService)designer.GetService(typeof(System.ComponentModel.Design.IComponentChangeService)); changesvc.OnComponentChanged(d, null, null, null); //marks the cube designer as dirty } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy); ApplicationObject.StatusBar.Progress(false, "Fixing Attribute Relationship Names...", 2, 2); } }
/// <summary> /// Call the dialog to edit the TableMappings /// </summary> /// <param name="context"></param> /// <param name="provider">Service provider.</param> /// <param name="value">DataTableMappingCollection object.</param> /// <returns></returns> public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) // DataTableMappingCollection object { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService( typeof(IWindowsFormsEditorService)); if (edSvc != null) { System.ComponentModel.Design.IDesignerHost host = provider.GetService( typeof(System.ComponentModel.Design.IDesignerHost)) as System.ComponentModel.Design.IDesignerHost; if (host == null) { System.Windows.Forms.MessageBox.Show( "The IDesignerHost service interface " + "could not be obtained to process the request.", "Table Mappings"); return(value); } System.ComponentModel.Design.IComponentChangeService chgSvc = provider.GetService( typeof(System.ComponentModel.Design.IComponentChangeService)) as System.ComponentModel.Design.IComponentChangeService; if (chgSvc == null) { System.Windows.Forms.MessageBox.Show( "The IComponentChangeService service interface " + "could not be obtained to process the request.", "Table Mappings"); return(value); } if (!context.OnComponentChanging()) { System.Windows.Forms.MessageBox.Show( "The component is not permitted to be changed.", "Table Mappings"); return(value); } System.ComponentModel.Design.DesignerTransaction designerTxn = host.CreateTransaction("TableMapping"); DbDataAdapter adapter = (DbDataAdapter)context.Instance; Form form = new TableMapForm(adapter); chgSvc.OnComponentChanging(adapter, null); using (form) { using (designerTxn) { try { DialogResult result = edSvc.ShowDialog(form); if (result == DialogResult.OK) { designerTxn.Commit(); } else { designerTxn.Cancel(); } } finally { chgSvc.OnComponentChanged(adapter, null, null, null); // context.OnComponentChanged(); } } } } // end if (edSvc != null) } // end if context is OK return(value); }