예제 #1
0
        private static void OpenFile(string solutionFolder, string filePath, int lineNumber)
        {
            string solutionPath = Path.Combine(solutionFolder, "Boa.sln");
            {
                try
                {
                    EnvDTE80.DTE2 boa = (EnvDTE80.DTE2)Msdev.GetIDEInstance(solutionPath);

                    if (boa == null)
                    {
                        throw new Exception("BOA is not opened in Visual Studio");
                    }

                    boa.ExecuteCommand(FILE_OPENFILE, filePath);

                    ((EnvDTE.TextSelection)boa.ActiveDocument.Selection).GotoLine(lineNumber, true);

                    boa.ActiveWindow.Activate();

                    boa.MainWindow.WindowState   = vsWindowState.vsWindowStateMinimize;
                    boa.ActiveWindow.WindowState = vsWindowState.vsWindowStateMinimize;

                    boa.ActiveWindow.Activate();
                    boa.MainWindow.Activate();
                }
                catch (Exception e)
                {
                    Debug.Write(e.Message);
                }
            }
        }
        public void OpenFileInVisualStudio(string filename, int lineNumber)
        {
            try
            {
                EnvDTE80.DTE2 boa = (EnvDTE80.DTE2)Msdev.GetIDEInstance(_solutionPath);

                if (boa == null)
                {
                    boa = OpenBoaSolution();
                }

                File.WriteAllText(Path.Combine(Environment.CurrentDirectory, "filename.txt"), filename);

                boa.ExecuteCommand("File.OpenFile", filename);

                ((EnvDTE.TextSelection)boa.ActiveDocument.Selection).GotoLine(lineNumber, true);
                boa.ActiveWindow.Activate();

                boa.MainWindow.WindowState   = vsWindowState.vsWindowStateMinimize;
                boa.ActiveWindow.WindowState = vsWindowState.vsWindowStateMinimize;

                boa.ActiveWindow.Activate();
                boa.MainWindow.Activate();
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
        }
        public bool IsBoaOpened()
        {
            var boa = Msdev.GetIDEInstance(_solutionPath);

            return(boa != null);
        }