public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { dte = (EnvDTE.DTE)automationObject; string destinationDirectory = replacementsDictionary["$destinationdirectory$"]; string fullOFRoot = Path.Combine(destinationDirectory, "..\\..\\.."); while (!isOFDirectory(fullOFRoot)) { var ofPathForm = new FormOFRoot(); var resultOFPAth = ofPathForm.ShowDialog(); if (resultOFPAth == DialogResult.Cancel) { throw new WizardBackoutException(); } else { fullOFRoot = ofPathForm.getOFRoot(); ofRoot = fullOFRoot; } } // Display a form to the user. The form collects // input for the custom message. inputForm = new FormAddons(destinationDirectory, ofRoot); var result = inputForm.ShowDialog(); if (result == DialogResult.Cancel) { throw new WizardBackoutException(); } // Add custom parameters. replacementsDictionary.Add("$ofroot$", ofRoot); }
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { dte = (EnvDTE.DTE)automationObject; string destinationDirectory = replacementsDictionary["$destinationdirectory$"]; string fullOFRoot = Path.Combine(destinationDirectory, "..\\..\\.."); while (!isOFDirectory(fullOFRoot)) { var ofPathForm = new FormOFRoot(); var resultOFPAth = ofPathForm.ShowDialog(); if (resultOFPAth == DialogResult.Cancel) { throw new WizardBackoutException(); } else { fullOFRoot = ofPathForm.getOFRoot(); ofRoot = fullOFRoot; } } // Display a form to the user. The form collects // input for the custom message. inputForm = new FormAddons(destinationDirectory, ofRoot); var result = inputForm.ShowDialog(); if(result == DialogResult.Cancel) { throw new WizardBackoutException(); } // Add custom parameters. replacementsDictionary.Add("$ofroot$", ofRoot); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { var monitorSelection = Package.GetGlobalService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection; var solution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution; if (monitorSelection == null || solution == null) { return; } IVsMultiItemSelect multiItemSelect = null; IntPtr hierarchyPtr = IntPtr.Zero; IntPtr selectionContainerPtr = IntPtr.Zero; uint itemid; int hr = VSConstants.S_OK; try { hr = monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemid, out multiItemSelect, out selectionContainerPtr); if (ErrorHandler.Failed(hr) || hierarchyPtr == IntPtr.Zero || itemid == VSConstants.VSITEMID_NIL) { // there is no selection return; } IVsHierarchy hierarchy = Marshal.GetObjectForIUnknown(hierarchyPtr) as IVsHierarchy; if (hierarchy == null) return; string doc; ((IVsProject)hierarchy).GetMkDocument(itemid,out doc); object pvar; hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out pvar); var project = (EnvDTE.Project)pvar; var vcproject = (VCProject)project.Object; string ofRoot = "..\\..\\.."; foreach (VCConfiguration config in vcproject.Configurations) { ofRoot = config.GetEvaluatedPropertyValue("OF_ROOT"); if (ofRoot != "") { break; } } var ofDi = new DirectoryInfo(ofRoot); if (new DirectoryInfo(Path.Combine(vcproject.ProjectDirectory, "..\\..\\..")).Equals(ofDi)) { ofRoot = "..\\..\\.."; } else { ofRoot = Path.GetFullPath(ofRoot); } var inputForm = new FormAddons(Path.GetDirectoryName(doc), ofRoot); var result = inputForm.ShowDialog(); if (result == DialogResult.Cancel) { return; } var addons = inputForm.getAddons(); var currentAddons = inputForm.getProjectCurrentAddons(); var addonsToRemove = currentAddons.Except(addons); var remainingAddons = currentAddons.Except(addonsToRemove); var newAddons = addons.Except(remainingAddons); Wizard.removeAddons(vcproject, ofRoot, addonsToRemove); Wizard.addAddons(vcproject, ofRoot, newAddons); Wizard.saveAddonsMake(vcproject, addons); DTE2 application = project.DTE.Application as DTE2; UIHierarchy solExplorer = application.ToolWindows.SolutionExplorer; Wizard.CollapseAllFolders(solExplorer, project.Name); } finally { if (selectionContainerPtr != IntPtr.Zero) { Marshal.Release(selectionContainerPtr); } if (hierarchyPtr != IntPtr.Zero) { Marshal.Release(hierarchyPtr); } } }