//they asked to pop up the Package Configurations dialog, so replace the Microsoft functionality so we can control the popup form void cmdEvent_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) { if (Enabled) { try { if (this.ApplicationObject.ActiveWindow == null || this.ApplicationObject.ActiveWindow.ProjectItem == null) return; ProjectItem pi = this.ApplicationObject.ActiveWindow.ProjectItem; if (!pi.Name.ToLower().EndsWith(".dtsx")) return; IDesignerHost designer = this.ApplicationObject.ActiveWindow.Object as IDesignerHost; if (designer == null) return; EditorWindow win = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator)); Package package = (Package)win.PropertiesLinkComponent; this.packageForFixButton = package; this.pathForPackageForFixButton = pi.get_FileNames(1); DtsConfigurationsForm form = new DtsConfigurationsForm(package); if (win.SelectedIndex == 0) { //control flow EditorWindow.EditorView view = win.SelectedView; System.Reflection.BindingFlags getflags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance; Control viewControl = (Control)view.GetType().InvokeMember("ViewControl", getflags, null, view, null); IWin32Window parentWin; #if DENALI || SQL2014 parentWin = viewControl; #else DdsDiagramHostControl diagram = viewControl.Controls["panel1"].Controls["ddsDiagramHostControl1"] as DdsDiagramHostControl; if (diagram == null || diagram.DDS == null) return; parentWin = diagram.DDS; #endif Button editSelectedButton = (Button)form.Controls["editSelectedConfiguration"]; Control packageConfigurationsGridControl1 = form.Controls["packageConfigurationsGridControl1"]; Button btnRelativePaths = new Button(); btnRelativePaths.Text = "Fix All Relative Paths"; btnRelativePaths.Width = 140; btnRelativePaths.Left = packageConfigurationsGridControl1.Left; btnRelativePaths.Top = editSelectedButton.Top; btnRelativePaths.Height = editSelectedButton.Height; btnRelativePaths.Anchor = AnchorStyles.Left | AnchorStyles.Bottom; btnRelativePaths.Click += new EventHandler(btnRelativePaths_Click); form.Controls.Add(btnRelativePaths); if (DesignUtils.ShowDialog((Form)form, parentWin, (IServiceProvider)package.Site) == DialogResult.OK) { SSISHelpers.MarkPackageDirty(package); } CancelDefault = true; } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } } }
//they asked to pop up the Package Configurations dialog, so replace the Microsoft functionality so we can control the popup form void cmdEvent_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) { if (Enabled) { try { if (this.ApplicationObject.ActiveWindow == null || this.ApplicationObject.ActiveWindow.ProjectItem == null) { return; } ProjectItem pi = this.ApplicationObject.ActiveWindow.ProjectItem; if (!pi.Name.ToLower().EndsWith(".dtsx")) { return; } IDesignerHost designer = this.ApplicationObject.ActiveWindow.Object as IDesignerHost; if (designer == null) { return; } EditorWindow win = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator)); Package package = (Package)win.PropertiesLinkComponent; this.packageForFixButton = package; this.pathForPackageForFixButton = pi.get_FileNames(1); DtsConfigurationsForm form = new DtsConfigurationsForm(package); if (win.SelectedIndex == 0) { //control flow EditorWindow.EditorView view = win.SelectedView; System.Reflection.BindingFlags getflags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance; Control viewControl = (Control)view.GetType().InvokeMember("ViewControl", getflags, null, view, null); IWin32Window parentWin; #if DENALI || SQL2014 parentWin = viewControl; #else DdsDiagramHostControl diagram = viewControl.Controls["panel1"].Controls["ddsDiagramHostControl1"] as DdsDiagramHostControl; if (diagram == null || diagram.DDS == null) { return; } parentWin = diagram.DDS; #endif Button editSelectedButton = (Button)form.Controls["editSelectedConfiguration"]; Control packageConfigurationsGridControl1 = form.Controls["packageConfigurationsGridControl1"]; Button btnRelativePaths = new Button(); btnRelativePaths.Text = "Fix All Relative Paths"; btnRelativePaths.Width = 140; btnRelativePaths.Left = packageConfigurationsGridControl1.Left; btnRelativePaths.Top = editSelectedButton.Top; btnRelativePaths.Height = editSelectedButton.Height; btnRelativePaths.Anchor = AnchorStyles.Left | AnchorStyles.Bottom; btnRelativePaths.Click += new EventHandler(btnRelativePaths_Click); form.Controls.Add(btnRelativePaths); if (DesignUtils.ShowDialog((Form)form, parentWin, (IServiceProvider)package.Site) == DialogResult.OK) { SSISHelpers.MarkPackageDirty(package); } CancelDefault = true; } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } } }