コード例 #1
0
        public static void OpenFileInPreviewTab(string file)
        {
            IVsNewDocumentStateContext newDocumentStateContext = null;

            try
            {
                IVsUIShellOpenDocument3 openDoc3 =
                    Package.GetGlobalService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument3;

                Guid reason = VSConstants.NewDocumentStateReason.Navigation;
                newDocumentStateContext = openDoc3.SetNewDocumentState(
                    (uint)__VSNEWDOCUMENTSTATE.NDS_Provisional,
                    ref reason);

                VSFoldersPackage.DTE.ItemOperations.OpenFile(file);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (newDocumentStateContext != null)
                {
                    newDocumentStateContext.Restore();
                }
            }
        }
コード例 #2
0
        public static void OpenFileInPreviewTab(string file)
        {
            IVsNewDocumentStateContext newDocumentStateContext = null;
            bool failedToOpen = false;

            try
            {
                var openDoc3 = Package.GetGlobalService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument3;

                Guid reason = VSConstants.NewDocumentStateReason.Navigation;
                newDocumentStateContext = openDoc3.SetNewDocumentState((uint)__VSNEWDOCUMENTSTATE.NDS_Provisional, ref reason);

                DTE.ItemOperations.OpenFile(file);
            }
            catch (COMException ex)
            {
                // Not sure why, but it's failing to open the documents in the preview tab when links are clicked
                // in the HTML view.  All we get is an E_ABORT COM exception.  They do open successfully in their
                // own tab though which we'll do below after restoring the state.
                System.Diagnostics.Debug.WriteLine(ex);
                failedToOpen = true;
            }
            finally
            {
                if (newDocumentStateContext != null)
                {
                    newDocumentStateContext.Restore();
                }

                if (failedToOpen)
                {
                    DTE.ItemOperations.OpenFile(file);
                }
            }
        }
コード例 #3
0
ファイル: DTEExtensions.cs プロジェクト: rosieks/TreGoToFile
        public static void OpenFileInPreviewTab(this DTE dte, string file, int?line, int?column)
        {
            IVsNewDocumentStateContext newDocumentStateContext = null;

            try
            {
                var openDoc3 = Package.GetGlobalService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument3;

                Guid reason = VSConstants.NewDocumentStateReason.Navigation;
                newDocumentStateContext = openDoc3.SetNewDocumentState((uint)__VSNEWDOCUMENTSTATE.NDS_Provisional, ref reason);

                file = System.IO.Path.GetFullPath(file);
                dte.ItemOperations.OpenFile(file);
                if (line.HasValue)
                {
                    ((TextSelection)dte.ActiveDocument.Selection).MoveTo(line.Value, column.Value);
                }
            }
            finally
            {
                if (newDocumentStateContext != null)
                {
                    newDocumentStateContext.Restore();
                }
            }
        }
コード例 #4
0
        private NewDocumentStateScope(uint state, Guid reason)
        {
            var doc = Package.GetGlobalService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument3;

            if (doc != null)
            {
                _context = doc.SetNewDocumentState(state, ref reason);
            }
        }
コード例 #5
0
ファイル: Helpers.cs プロジェクト: modulexcite/DartVS
        public static void OpenFileInPreviewTab(IServiceProvider serviceProvider, string file)
        {
            IVsNewDocumentStateContext newDocumentStateContext = null;

            try
            {
                IVsUIShellOpenDocument3 openDoc3 = DartPackage.GetGlobalService <SVsUIShellOpenDocument>() as IVsUIShellOpenDocument3;

                Guid reason = VSConstants.NewDocumentStateReason.Navigation;
                newDocumentStateContext = openDoc3.SetNewDocumentState((uint)__VSNEWDOCUMENTSTATE.NDS_Provisional, ref reason);

                VsShellUtilities.OpenDocument(serviceProvider, file);
            }
            finally
            {
                if (newDocumentStateContext != null)
                {
                    newDocumentStateContext.Restore();
                }
            }
        }
コード例 #6
0
        private void OpenFileInPreviewTab(string file)
        {
            IVsNewDocumentStateContext newDocumentStateContext = null;

            try
            {
                IVsUIShellOpenDocument3 openDoc3 = EditorExtensionsPackage.GetGlobalService <SVsUIShellOpenDocument>() as IVsUIShellOpenDocument3;

                Guid reason = VSConstants.NewDocumentStateReason.Navigation;
                newDocumentStateContext = openDoc3.SetNewDocumentState((uint)__VSNEWDOCUMENTSTATE.NDS_Provisional, ref reason);

                EditorExtensionsPackage.DTE.ItemOperations.OpenFile(file);
            }
            finally
            {
                if (newDocumentStateContext != null)
                {
                    newDocumentStateContext.Restore();
                }
            }
        }
コード例 #7
0
        public static void OpenFileInPreviewTab(string file)
        {
            IVsNewDocumentStateContext context = null;

            try
            {
                IVsUIShellOpenDocument3 shell = SassyStudioPackage.GetGlobalService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument3;

                Guid reason = VSConstants.NewDocumentStateReason.Navigation;
                context = shell.SetNewDocumentState((uint)__VSNEWDOCUMENTSTATE.NDS_Provisional, ref reason);

                SassyStudioPackage.Instance.DTE.ItemOperations.OpenFile(file);
            }
            finally
            {
                if (context != null)
                {
                    context.Restore();
                }
            }
        }