Example #1
0
        /// <summary>
        /// Removes all of the entries from managedcourses.xml for the given
        /// assignment manager course.
        /// </summary>
        public static bool UnregisterAssignmentManagerCourse(EnvDTE._DTE dte, string guid)
        {
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Constants.KeyName);
            string sAppDataPath             = (string)key.GetValue(Constants.ValueName);
            string sFolderName  = sAppDataPath + Constants.ApplicationPath;
            string sManagedFile = sFolderName + Constants.ManagedCoursesFileName;
            string strURL       = "";

            System.Xml.XmlDocument xmlDoc = null;
            System.Xml.XmlNode     xmlNode = null, xmlPathNode = null;
            System.Xml.XmlNodeList xmlNodes = null;

            xmlDoc = new System.Xml.XmlDocument();
            xmlDoc.Load(sManagedFile);

            if ((xmlNode = xmlDoc.SelectSingleNode("/managedcourses/course[assnmgr/guid='" + EscapeStringForXPath(guid) + "']")) != null)
            {
                if (((xmlPathNode = xmlDoc.SelectSingleNode("/managedcourses/course/assnmgr[guid='" + EscapeStringForXPath(guid) + "']")) != null) &&
                    ((xmlPathNode = xmlPathNode.SelectSingleNode("amurl")) != null))
                {
                    strURL = xmlPathNode.InnerText;
                }

                xmlNode.ParentNode.RemoveChild(xmlNode);
                xmlDoc.PreserveWhitespace = true;
                xmlDoc.Save(sManagedFile);
            }

            // Return true if there are now no more courses.
            return(((xmlNodes = xmlDoc.SelectNodes("/managedcourses/course")) == null) || (xmlNodes.Count == 0));
        }
Example #2
0
        /// <summary>
        /// Given a URL, this will either register or unregister a safe domain with the shell. It
        /// also sets the flag telling the shell to re-read the safedomains key.
        /// </summary>
        /// <param name="url"> String denoting the path to add to the safe domain.</param>
        /// <param name="register"> Boolean flag whether to register or unregister (true == register). </param>
        public static void SetupSafeDomain(EnvDTE._DTE dte, string url, bool register)
        {
            Microsoft.Win32.RegistryKey key = null, newKey = null;
            string strRegistryRoot = "";

            try {
                strRegistryRoot = dte.RegistryRoot;
                key             = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(strRegistryRoot + Constants.VSProtocolSafeHive);
                // Inform the shell that the set of safe domains has changed
                key.SetValue(Constants.SafeDomainChangedValueName, 1);

                if (register)
                {
                    newKey = key.CreateSubKey(url);
                }
                else
                {
                    key.DeleteSubKey(url, false);
                }
            } catch (System.Exception) {
                // Ignore exceptions, as they mean that permission error occurred creating / deleting a key, which
                // is a terminal error for VS anyways (you couldn't use the shell successfully!).
            } finally {
                if (key != null)
                {
                    key.Close();
                }
                if (newKey != null)
                {
                    newKey.Close();
                }
            }
        }
 public CodeExtractor(EnvDTE._DTE dte)
 {
     if (dte == null)
     {
         throw new System.ArgumentNullException("dte");
     }
     m_application = dte;
     //      m_taskWindow = null;
 }
 protected virtual void OnRemoveAttributes(object sender, EventArgs args)
 {
     EnvDTE._DTE         dte       = GetService(typeof(EnvDTE._DTE)) as EnvDTE._DTE;
     EnvDTE80.CodeClass2 codeClass = GetCodeClass(dte.ActiveDocument.ProjectItem.FileCodeModel.CodeElements, "MyForm");
     while (codeClass.Attributes.Count > 0)
     {
         ((EnvDTE80.CodeAttribute2)codeClass.Attributes.Item(1)).Delete();     // Attributes array starts from 1 not 0
     }
 }
Example #5
0
        // Event handling method for the "Generate DataSet..." verb
        public void OnGenerate(object sender, EventArgs e)
        {
            EnvDTE._DTE dte = (EnvDTE._DTE)GetService(typeof(EnvDTE._DTE));

            Form dlg = new GenDataSetForm(
                this.Component.Site,                                   // IServiceProvider
                (DbDataAdapter)this.Component, dte);
            DialogResult result = dlg.ShowDialog();
        }          // OnGenerate
Example #6
0
        /// <summary>
        /// Registers a command and places it onto the context menu for the editor
        /// window.
        /// </summary>
        public void OnConnection(EnvDTE._DTE application, Extensibility.ext_ConnectMode connectMode, EnvDTE.AddIn addIn)
        {
            m_applicationObject = (EnvDTE._DTE)application;
            m_addInInstance     = (EnvDTE.AddIn)addIn;

            m_strCommandName = "MarkCodeForExtraction";
            m_strName        = AMResources.GetLocalizedString("CodeMarkerName");
            m_strItemText    = AMResources.GetLocalizedString("CodeMarkerItemText");

            string description = AMResources.GetLocalizedString("CodeMarkerDescription");

            EnvDTE.Commands commands = null;
            EnvDTE.Command  command  = null;
            Microsoft.Office.Core._CommandBars      officeCommandBars    = null;
            Microsoft.Office.Core.CommandBar        officeCommandBar     = null;
            Microsoft.Office.Core.CommandBarControl officeCommandControl = null;
            Microsoft.Office.Core.CommandBar        officeAcademic       = null;
            object [] contextGuids;
            contextGuids = new object[] { };

            commands = m_applicationObject.Commands;
            try
            {
                command = commands.AddNamedCommand(m_addInInstance, m_strCommandName, m_strName, description,
                                                   true, 12, ref contextGuids, (int)(EnvDTE.vsCommandStatus.vsCommandStatusEnabled | EnvDTE.vsCommandStatus.vsCommandStatusSupported));

                // Add the new command to the top-level context menu for the editor
                // code window, if possible.
                officeCommandBars            = m_applicationObject.CommandBars;
                officeCommandBar             = (CommandBar)officeCommandBars["Code Window"];
                officeCommandControl         = command.AddControl((object)officeCommandBar, 1);
                officeCommandControl.Caption = m_strItemText;

                string amFacultyMenuItem = AMResources.GetLocalizedString("AMFacultyMenuItem");
                // Also attempt to add it to the Tools menu as well, for accessibility.
                try
                {
                    officeAcademic = (CommandBar)officeCommandBars[amFacultyMenuItem];
                }
                catch
                {
                }
                if (officeAcademic == null)
                {
                    officeCommandBar = (CommandBar)officeCommandBars["Tools"];
                    officeAcademic   = (CommandBar)m_applicationObject.Commands.AddCommandBar(amFacultyMenuItem, EnvDTE.vsCommandBarType.vsCommandBarTypeMenu, officeCommandBar, 1);
                }

                officeCommandControl         = command.AddControl((object)officeAcademic, 1);
                officeCommandControl.Caption = AMResources.GetLocalizedString("CodeMarkerToolsMenuItemText");
            }
            catch (System.Exception /*e*/)
            {
                // Falling into this simply means that the command was already registered.
            }
        }
Example #7
0
        /// <summary>
        /// Adds the necessary entries to managedcourses.xml so that the assignment manager-based
        /// course will correctly appear in the environment and the links to 'work with' the course
        /// will point at the correct server.
        /// </summary>
        public static bool RegisterAssignmentManagerCourse(EnvDTE._DTE dte, string courseName, string url, string guid)
        {
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Constants.KeyName);
            string sAppDataPath             = (string)key.GetValue(Constants.ValueName);
            string sFolderName  = sAppDataPath + Constants.ApplicationPath;
            string sManagedFile = sFolderName + Constants.ManagedCoursesFileName;

            System.IO.DirectoryInfo di             = new System.IO.DirectoryInfo(sFolderName);
            System.Xml.XmlDocument  xmlDoc         = null;
            System.Xml.XmlNode      xmlNode        = null;
            System.Xml.XmlElement   xmlCourseElem  = null;
            System.Xml.XmlElement   xmlAssnMgrElem = null;

            if (!di.Exists)
            {
                System.IO.Directory.CreateDirectory(sFolderName);
            }

            xmlDoc = new System.Xml.XmlDocument();
            try {
                xmlDoc.Load(sManagedFile);
            } catch (System.Exception) {
                xmlDoc.LoadXml("<managedcourses></managedcourses>");
            }

            if ((xmlNode = xmlDoc.SelectSingleNode("/managedcourses/course[assnmgr/guid='" + EscapeStringForXPath(guid) + "']")) != null)
            {
                // If it already exists, we're in an update and getting rid of the old data.
                xmlNode.ParentNode.RemoveChild(xmlNode);
            }

            // Create the course node and its name sub-element
            xmlCourseElem = xmlDoc.CreateElement("course");
            CreateCDATAElement(xmlDoc, xmlCourseElem, "name", courseName);

            // Create an populate the noassnmgr node, attaching it to the
            // course node
            xmlAssnMgrElem = xmlDoc.CreateElement("assnmgr");
            CreateCDATAElement(xmlDoc, xmlAssnMgrElem, "amurl", url);
            CreateCDATAElement(xmlDoc, xmlAssnMgrElem, "guid", guid);
            xmlCourseElem.AppendChild(xmlAssnMgrElem);

            // Finally, add the completed course entry to the document
            xmlDoc.DocumentElement.AppendChild(xmlCourseElem);

            xmlDoc.PreserveWhitespace = true;
            xmlDoc.Save(sManagedFile);

            // Assignment manager courses cannot be browsed to without properly registering their URL
            // into the SafeDomains hive.
            SetupSafeDomain(dte, url, true);

            return(true);
        }
 protected virtual void OnEditText(object sender, EventArgs args)
 {
     EnvDTE._DTE             dte           = GetService(typeof(EnvDTE._DTE)) as EnvDTE._DTE;
     EnvDTE80.CodeClass2     codeClass     = GetCodeClass(dte.ActiveDocument.ProjectItem.FileCodeModel.CodeElements, "MyForm");
     EnvDTE80.CodeAttribute2 codeAttribute = GetCodeAttribute(codeClass, "MyCustom");
     if (codeAttribute != null)
     {
         string newValue = Microsoft.VisualBasic.Interaction.InputBox("Current Text", "Edit MyCustomAttribute text", RemoveQuote(codeAttribute.Value), -1, -1);
         codeAttribute.Value = (!string.IsNullOrWhiteSpace(newValue) ? "\"" + newValue + "\"" : "");
     }
 }
        public VsPackageManagerContext(
            SourceRepositoryManager sourceManager,
            SVsServiceProvider serviceProvider,
            ISolutionManager solutionManager,
            IVsPackageManagerFactory packageManagerFactory)
        {
            _sourceManager = sourceManager;
            _solutionManager = solutionManager;
            _packageManagerFactory = packageManagerFactory;

            _dte = (EnvDTE._DTE)serviceProvider.GetService(typeof(EnvDTE._DTE));
        }
Example #10
0
        }          // OnGenerate

        public void OnGenerateIngresDataSet(
            Component component, object sender, EventArgs e)
        {
            IServiceProvider sp = component.Site;

            EnvDTE._DTE dte = (EnvDTE._DTE)sp.GetService(typeof(EnvDTE._DTE));

            Form dlg = new GenDataSetForm(
                component.Site,                                   // IServiceProvider
                (DbDataAdapter)component, dte);
            DialogResult result = dlg.ShowDialog();
        }  // OnGenerate
        public DelayLoadTaskWindow(EnvDTE._DTE dte)
        {
            if (dte == null)
            {
                throw new System.ArgumentNullException("dte");
            }

            this.dte     = dte;
            taskItems    = null;
            mainCategory = "Academic";
            subCategory  = "Code Extraction";
        }
        public VsPackageManagerContext(
            SourceRepositoryManager sourceManager,
            SVsServiceProvider serviceProvider,
            ISolutionManager solutionManager,
            IVsPackageManagerFactory packageManagerFactory)
        {
            _sourceManager         = sourceManager;
            _solutionManager       = solutionManager;
            _packageManagerFactory = packageManagerFactory;

            _dte = (EnvDTE._DTE)serviceProvider.GetService(typeof(EnvDTE._DTE));
        }
Example #13
0
        internal GenDataSetForm(
            IServiceProvider serviceProvider,
            DbDataAdapter dbDataAdapter,
            EnvDTE._DTE dte)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.serviceProvider = serviceProvider;
            this.dbDataAdapter   = dbDataAdapter;
            this.dte             = dte;
        }
Example #14
0
        /// <summary>
        /// Registers a command and places it on the Tools menu.
        /// </summary>
        public void OnConnection(EnvDTE._DTE application, Extensibility.ext_ConnectMode connectMode, EnvDTE.AddIn addIn)
        {
            m_applicationObject = (EnvDTE._DTE)application;
            m_addInInstance     = (EnvDTE.AddIn)addIn;

            m_strCommandName = "AMStudentGotoHomePage";
            m_strName        = AMResources.GetLocalizedString("AMStudentGotoHomePageName");
            m_strItemText    = AMResources.GetLocalizedString("AMStudentGotoHomePageItemText");
            m_strHomePageUrl = "vs:/default.htm?tab=" + AMResources.GetLocalizedString("AMStudentGotoHomePagePageName");

            string strDescription = AMResources.GetLocalizedString("GotoHomePageDescription");

            EnvDTE.Commands commands = null;
            EnvDTE.Command  command  = null;
            Microsoft.Office.Core._CommandBars      officeCommandBars    = null;
            Microsoft.Office.Core.CommandBar        officeCommandBar     = null;
            Microsoft.Office.Core.CommandBarControl officeCommandControl = null;
            Microsoft.Office.Core.CommandBar        officeAcademic       = null;
            object [] contextGuids;
            contextGuids = new object[] { };

            commands = m_applicationObject.Commands;
            try
            {
                command = commands.AddNamedCommand(m_addInInstance, m_strCommandName, m_strName, strDescription,
                                                   false, 108, ref contextGuids, (int)(EnvDTE.vsCommandStatus.vsCommandStatusEnabled | EnvDTE.vsCommandStatus.vsCommandStatusSupported));

                // Add the new command to the tools menu
                officeCommandBars = m_applicationObject.CommandBars;
                string amStudentMenuItem = AMResources.GetLocalizedString("AMStudentMenuItem");
                try
                {
                    officeAcademic = (CommandBar)officeCommandBars[amStudentMenuItem];
                }
                catch
                {
                }
                if (officeAcademic == null)
                {
                    officeCommandBar = (CommandBar)officeCommandBars["Tools"];
                    officeAcademic   = (CommandBar)m_applicationObject.Commands.AddCommandBar(amStudentMenuItem, EnvDTE.vsCommandBarType.vsCommandBarTypeMenu, officeCommandBar, 1);
                }
                officeCommandControl         = command.AddControl((object)officeAcademic, 1);
                officeCommandControl.Caption = m_strItemText;
            }
            catch (System.Exception /*e*/)
            {
                // Falling into this simply means that the command was already registered.
            }
        }
Example #15
0
 public static void AttachDebuggerToProcess(EnvDTE._DTE dte, Process process, string program)
 {
     for (int i = 5; --i >= 0;)
     {
         try {
             var dteProcess = dte.Debugger.LocalProcesses.OfType <EnvDTE80.Process2>().First(p => p.ProcessID == process.Id);
             dteProcess.Attach2(program);
             return;
         } catch {
             Thread.Sleep(200);
         }
     }
     throw new InvalidOperationException();
 }
        private EngineWrapper CreateSharedEngine()
        {
            // Create the engine wrapper.
            EngineWrapper wrapper = new EngineWrapper();

            // Set the default variables for the shared engine.
            if (null != serviceProvider)
            {
                EnvDTE._DTE dte = (EnvDTE._DTE)serviceProvider.GetService(typeof(EnvDTE.DTE));
                wrapper.SetVariable("dte", dte);
            }
            wrapper.SetVariable("engine", wrapper.PythonEngine);

            return(wrapper);
        }
Example #17
0
        /// <summary>
        /// See <see cref="IWizard"/>.
        /// </summary>
        /// <param name="automationObject">See Visual Studio SDK documentation for automationObject.</param>
        /// <param name="replacementsDictionary">See Visual Studio SDK documentation for replacementsDictionary.</param>
        /// <param name="runKind">See Visual Studio SDK documentation for runKind.</param>
        /// <param name="customParams">See Visual Studio SDK documentation for customParameters.</param>
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            if (automationObject == null)
            {
                throw new ArgumentNullException("automationObject");
            }

            if (replacementsDictionary == null)
            {
                throw new ArgumentNullException("replacementsDictionary");
            }

            this.visualStudioAutomationObject = automationObject as EnvDTE._DTE;
            Debug.Assert(this.visualStudioAutomationObject != null, "The automation object should not be null");
            this.forward.RunStarted(replacementsDictionary["$rootname$"]);
        }
        /// <summary>
        /// Takes a source project in one instance of the environment and requests for another instances
        /// to create a copy of the project.
        /// </summary>
        /// <param name="projSource"> Original project to copy from </param>
        /// <param name="dteCreateIn"> Object Model to create it in </param>
        /// <param name="strDestFolder"> Output folder </param>
        /// <param name="strDestName"> Output project name </param>
        private EnvDTE.Project CopyProject(EnvDTE.Project projSource, EnvDTE._DTE dteCreateIn, string strDestFolder, string strDestName)
        {
            EnvDTE.Project projDest = null;

            try
            {
                projDest = dteCreateIn.Solution.AddFromTemplate(projSource.FileName, strDestFolder, strDestName, false);

                return(projDest);
            }
            catch (System.Exception e)
            {
                // In the event of errors, make it seem as if 'nothing happened'.
                if (projDest != null)
                {
                    projDest.Delete();
                }
                return(null);
            }
        }
Example #19
0
        private static bool TryGetVsInstance(int processId, out EnvDTE._DTE instance)
        {
            var numFetched = IntPtr.Zero;
            IRunningObjectTable runningObjectTable;
            IEnumMoniker        monikerEnumerator;
            var monikers = new IMoniker[1];

            GetRunningObjectTable(0, out runningObjectTable);
            runningObjectTable.EnumRunning(out monikerEnumerator);
            monikerEnumerator.Reset();

            while (0 == monikerEnumerator.Next(1, monikers, numFetched))
            {
                IBindCtx ctx;
                CreateBindCtx(0, out ctx);

                string runningObjectName;
                monikers[0].GetDisplayName(ctx, null, out runningObjectName);

                object runningObjectVal;
                runningObjectTable.GetObject(monikers[0], out runningObjectVal);

                if (runningObjectVal is EnvDTE._DTE && runningObjectName.StartsWith("!VisualStudio"))
                {
                    int currentProcessId = int.Parse(runningObjectName.Split(':')[1]);

                    if (currentProcessId == processId)
                    {
                        instance = (EnvDTE._DTE)runningObjectVal;
                        return(true);
                    }
                }
            }

            instance = null;
            return(false);
        }
        /// <summary>
        /// Loops through each of the items in the project, attempting to extract any sections of code
        /// marked.
        /// </summary>
        /// <param name="dte"> Pointer to Object Model in which all actions should be performed </param>
        private bool ExtractItems(EnvDTE.ProjectItems projSourceItems, EnvDTE._DTE dte, EnvDTE.ProjectItems projDestItems)
        {
            EnvDTE.ProjectItem  projItem            = null;
            EnvDTE.TextDocument textDoc             = null;
            EnvDTE.Properties   extractorProperties = null;
            Extensions          extensions          = null;
            CommentPair         comments            = null;

            EnvDTE.Window w = null;

            bool   fSuccess = true;
            int    i, nItems, nLastIndex;
            string strExtension;

            extractorProperties = m_application.get_Properties("Assignment Manager", "Code Extractor");
            if (extractorProperties == null)
            {
                throw new Exception("The Academic Code Extractor is not properly installed and configured.");
            }
            extensions = extractorProperties.Item("Extensions").Object as Extensions;
            if (extensions == null)
            {
                throw new Exception("The Academic Code Extractor is not properly installed and configured.");
            }

            nItems = projDestItems.Count;
            for (i = 1; i <= nItems; i++)
            {
                projItem = projDestItems.Item(i);
                try
                {
                    if (projItem.ProjectItems.Count > 0)
                    {
                        ExtractItems(projSourceItems.Item(i).ProjectItems, dte, projItem.ProjectItems);
                    }
                    // Note that this will *actually* be happening in an invisible
                    // out-of-process instance of VS, so the user will not be
                    // subjected to appearing / disappearing windows.
                    w       = projItem.Open(EnvDTE.Constants.vsViewKindTextView);
                    textDoc = w.Document.Object("TextDocument") as EnvDTE.TextDocument;

                    strExtension = projItem.get_FileNames(1);

                    nLastIndex = strExtension.LastIndexOf('.');
                    if (nLastIndex == -1)
                    {
                        w.Close(EnvDTE.vsSaveChanges.vsSaveChangesNo);
                        continue;                                          // We have no capacity for files with no extension.
                    }
                    strExtension = strExtension.Remove(0, nLastIndex + 1); // Trim off the 'name.' part of 'name.ext'

                    comments = extensions[strExtension];
                    if (comments == null)
                    {
                        w.Close(EnvDTE.vsSaveChanges.vsSaveChangesNo);
                        continue;                         // This file has no associated extension type. Ignore it.
                    }

                    fSuccess &= ExtractText(textDoc, comments.BeginComment, comments.EndComment, projSourceItems);

                    w.Close(EnvDTE.vsSaveChanges.vsSaveChangesYes);
                }
                catch (Exception /*e*/)
                {
                    // If we end up here, that simply means that the file
                    // has no text. Since we obviously don't want to remove the
                    // textual tags from a file with no comments...
                    if (w != null)
                    {
                        w.Close(EnvDTE.vsSaveChanges.vsSaveChangesNo);
                    }
                }
            }

            return(fSuccess);
        }
 public ClientTools(EnvDTE._DTE dte)
 {
     m_applicationObject = dte;
     m_storageTable      = new System.Collections.Hashtable();
 }
        internal void getProjectFileInfo(string fileName, out string name, out string outputFile, out string configurationName, out string buildPath)
        {
            EnvDTE._DTE          dte = null;
            EnvDTE.Configuration config = null;
            string Name, OutputFile, ConfigurationName, BuildPath;

            buildPath         = String.Empty;
            configurationName = String.Empty;
            outputFile        = String.Empty;
            name = String.Empty;

            try
            {
                EnvDTE.Project     proj = null;
                EnvDTE.OutputGroup group = null;
                string             outputURLDir, projectFileDir;
                Object[]           OutputFiles = null;
                Object[]           OutputURLs  = null;
                int nIndex;

                dte = (EnvDTE._DTE) new VisualStudio_DTE_7_1();

                dte.Solution.AddFromFile(fileName, false);
                proj              = dte.Solution.Projects.Item(1);
                Name              = proj.Name;
                config            = proj.ConfigurationManager.ActiveConfiguration;
                ConfigurationName = config.ConfigurationName;

                // Loop through the possibly-many set of output groups, looking for the
                // one that has the build output. If we don't can't locate it, we will
                // attempt to use the first one in the list.
                nIndex = config.OutputGroups.Count;
                do
                {
                    group = config.OutputGroups.Item(nIndex);
                    nIndex--;
                } while ((nIndex > 0) && (group.CanonicalName != "Built"));

                OutputFiles = (Object[])group.FileNames;
                OutputFile  = (string)OutputFiles[0];

                OutputURLs   = (Object[])group.FileURLs;
                outputURLDir = (string)OutputURLs[0];

                // Given a full URL to the file path (file://c:\....) and the base path
                // to the project file (c:\...), determine the set of additional directories
                // into which the build is being performed.
                projectFileDir = getPath(fileName);
                projectFileDir = projectFileDir.ToUpper();
                outputURLDir   = outputURLDir.ToUpper();
                nIndex         = outputURLDir.LastIndexOf(projectFileDir);
                BuildPath      = outputURLDir.Substring(nIndex + projectFileDir.Length);
                BuildPath      = getPath(BuildPath);

                name              = Name;
                outputFile        = OutputFile;
                configurationName = ConfigurationName;
                buildPath         = BuildPath;
            }
            catch (System.Exception)
            {
                throw new System.Exception(SharedSupport.GetLocalizedString("ProjectInfo_ProjFileInvalid"));
            }
            finally
            {
                if (dte != null)
                {
                    try
                    {
                        dte.Solution.Close(false);
                        dte.Quit();
                    }
                    catch (System.Exception)
                    {
                        // Ignore errors when shutting down out-of-process IDE.
                    }
                }
            }
        }
Example #23
0
 /// <summary>
 /// Called when the AddIn is discarded. This method allows each of the commands to
 /// to unregister and close down on exiting.
 /// </summary>
 /// <param name="application"> Root object in the application </param>
 /// <param name="connectMode"> 'Mode' in which the environment is closing the addin </param>
 /// <param name="addIn"> Object representing this AddIn in the Object Model</param>
 public void OnDisconnection(EnvDTE._DTE application, Extensibility.ext_DisconnectMode disconnectMode, EnvDTE.AddIn addIn)
 {
     application.Commands.Item("StudentClient.Connect." + m_strCommandName, 0).Delete();
 }
Example #24
0
 public FacultyTools(EnvDTE._DTE dte)
 {
     m_applicationObject = dte;
     m_studentTools      = new StudentClient.ClientTools(dte);
 }
Example #25
0
        internal GenDataSetForm(
			IServiceProvider serviceProvider,
			DbDataAdapter dbDataAdapter,
			EnvDTE._DTE   dte)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.serviceProvider = serviceProvider;
            this.dbDataAdapter   = dbDataAdapter;
            this.dte             = dte;
        }
 public TaskListEvents(EnvDTE._DTE dte)
 {
     this.dte = dte;
 }
        /// <summary>
        /// Given a source and a destination, this function creates a new project, optionally performing code
        /// extraction upon it. A return of false means that either the project could not be created or
        /// there was an error with the extraction process.
        /// </summary>
        /// <param name="sourceUniqueProjectName"> The 'uniquename' property of the project to retrieve params from</param>
        /// <param name="path"> Output path, UNC / file paths only</param>
        /// <param name="destProjectName"> Name of the project to create </param>
        /// <param name="performExtraction"> Whether or not to extract properly-delimited sections of text from the source</param>
        public bool CreateNewProject(string sourceUniqueProjectName, string path, string destProjectName, bool performExtraction)
        {
            bool fSucceeded = true;

            if (sourceUniqueProjectName == null)
            {
                throw new System.ArgumentNullException("sourceUniqueProjectName");
            }
            if (path == null)
            {
                throw new System.ArgumentNullException("path");
            }
            if (destProjectName == null)
            {
                throw new System.ArgumentNullException("destProjectName");
            }

            string strProjDestUniqueName = null;

            EnvDTE.Project projDest        = null;
            EnvDTE.Project projSource      = null;
            EnvDTE._DTE    dteOutOfProcess = null;

            try
            {
                //        if (m_taskWindow == null) {
                //          m_taskWindow = new TaskWindow.DelayLoadTaskWindow(m_application);
                //        }

                projSource = GetValidProject(sourceUniqueProjectName);
                if (projSource == null)
                {
                    throw new Exception(AMResources.GetLocalizedString("CodeExtractorNoBaseProject"));
                }

                // NOTE: This is a method in the docs, but a property in implementation.
                object ignore = m_application.ItemOperations.PromptToSave;


                dteOutOfProcess = (EnvDTE._DTE) new VisualStudio_DTE_7_1();
                projDest        = CopyProject(projSource, dteOutOfProcess, path, destProjectName);
                if (projDest == null)
                {
                    throw new Exception(AMResources.GetLocalizedString("CodeExtractorInvalidProjectType"));
                }

                strProjDestUniqueName = projDest.UniqueName;
                if (performExtraction)
                {
                    // Perform extraction - on first user error, open handle to task-list. Log all errors to it.
                    if (!ExtractItems(projSource.ProjectItems, dteOutOfProcess, projDest.ProjectItems))
                    {
                        throw new Exception(AMResources.GetLocalizedString("CodeExtractorInvalidMarkedTags"));
                    }
                }
            }
            finally
            {
                if ((dteOutOfProcess != null) &&
                    (dteOutOfProcess != m_application))
                {
                    // The solution has to be closed because if we're out of process, the
                    // application might not close for a little while, leaving around
                    // extant 'file opened exclusively' problems.
                    dteOutOfProcess.Solution.Close(false);

                    dteOutOfProcess.Quit();
                    dteOutOfProcess = null;
                }
            }

            return(fSucceeded);
        }