EnvDTE.Document.Activate()

Here are the examples of the csharp api class EnvDTE.Document.Activate() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

13 Examples 7

1. Example

View license
internal void RestoreTrackedDocument()
        {
            if (TrackedDocument != null && Package.ActiveDocument != TrackedDocument)
            {
                TrackedDocument.Activate();
            }
        }

2. Example

Project: codemaid
Source File: TextDocumentHelper.cs
View license
internal static void SelectCodeItem(Document document, BaseCodeItem codeItem)
        {
            var textDocument = document.GetTextDocument();
            if (textDocument == null) return;

            try
            {
                codeItem.RefreshCachedPositionAndName();
                textDocument.Selection.MoveToPoint(codeItem.StartPoint, false);
                textDocument.Selection.MoveToPoint(codeItem.EndPoint, true);

                textDocument.Selection.SwapAnchor();
            }
            catch (Exception)
            {
                // Select operation may fail if element is no longer available.
            }
            finally
            {
                // Always set focus within the code editor window.
                document.Activate();
            }
        }

3. Example

Project: codemaid
Source File: TextDocumentHelper.cs
View license
internal static void MoveToCodeItem(Document document, BaseCodeItem codeItem, bool centerOnWhole)
  /n ..... /n //View Source file for more details /n }

4. Example

Project: codemaid
Source File: ActiveDocumentRestorer.cs
View license
internal void RestoreTrackedDocument()
        {
            if (TrackedDocument != null && Package.ActiveDocument != TrackedDocument)
            {
                TrackedDocument.Activate();
            }
        }

5. Example

View license
public void Format(Document document, IDocumentFilter filter, string command)
        {
            var currentDoc = dte.ActiveDocument;

            document.Activate();

            if (dte.ActiveWindow.Kind == "Document")
            {
                if (string.IsNullOrEmpty(command))
                {
                    command = defaultCommand;
                }
                if (filter.IsAllowed(document))
                    dte.ExecuteCommand(command, string.Empty);
            }

            currentDoc.Activate();
        }

6. Example

Project: codemaid
Source File: TestOperations.cs
View license
public static Document GetActivatedDocument(ProjectItem projectItem)
        {
            projectItem.Open(Constants.vsViewKindTextView);

            var document = projectItem.Document;
            Assert.IsNotNull(projectItem.Document);

            document.Activate();

            return document;
        }

7. Example

View license
internal void Cleanup(Document document, ITextBuffer textBuffer)
        {
            if (!_codeCleanupAvailabilityLogic.ShouldCleanup(document, true)) return;

            // Make sure the document to be cleaned up is active, required for some commands like format document.
            document.Activate();

            if (_package.IDE.ActiveDocument != document)
            {
                OutputWindowHelper.WriteLine(document.Name + " did not complete activation before cleaning started.");
            }

            _undoTransactionHelper.Run(
                delegate
                {
                    _package.IDE.StatusBar.Text = String.Format("EditorConfig is cleaning '{0}'...", document.Name);

                    // Perform the set of configured cleanups based on the language.
                    RunCodeCleanupGeneric(document, textBuffer);

                    _package.IDE.StatusBar.Text = String.Format("EditorConfig cleaned '{0}'.", document.Name);
                },
                delegate(Exception ex)
                {
                    OutputWindowHelper.WriteLine(String.Format("EditorConfig stopped cleaning '{0}': {1}", document.Name, ex));
                    _package.IDE.StatusBar.Text = String.Format("EditorConfig stopped cleaning '{0}'.  See output window for more details.", document.Name);
                });
        }

8. Example

Project: MultiversePlatform
Source File: LuaInterface.cs
View license
private EnvDTE.TextSelection OpenFile()
        {
            if (firstChildItem == null)
                return null;

            if (!firstChildItem.get_IsOpen(null))
            {
                EnvDTE.Window window = firstChildItem.Open(null);
                window.Visible = true;
            }
            else
            {
                firstChildItem.Document.Activate();
            }

            EnvDTE.TextSelection selection = firstChildItem.Document.Selection as EnvDTE.TextSelection;
            selection.StartOfDocument(false);

            return selection;
        }

9. Example

Project: codemaid
Source File: CodeCleanupManager.cs
View license
internal void Cleanup(Document document)
        {
            if (!_codeCleanupAvailabilityLogic.Ca/n ..... /n //View Source file for more details /n }

10. Example

View license
private void ExtractToTvf(object sender, EventArgs e)
        {
            try
            {
                CallWrapper();
                var dte = (DTE) GetService(typeof (DTE));

                if (dte.ActiveDocument == null)
                {
                    return;
                }

                var doc = dte.ActiveDocument;

                var text = GetCurrentText();
                if (String.IsNullOrEmpty(text))
                    return;

                var newText = new CodeExtractor(text).ExtractIntoFunction();

                if (text != newText && !String.IsNullOrEmpty(newText))
                {
                    doc.Activate();
                    SetCurrentText(newText);
                    OutputPane.WriteMessage("Code extracted into an inline table valued function");
                }
            }
            catch (Exception ex)
            {
                OutputPane.WriteMessage("Error extracting code into a TVF: {0}", ex.Message);
            }
        }

11. Example

View license
internal void Execute()
        {
            if (_doc == null || _textDoc == null) return;

       /n ..... /n //View Source file for more details /n }

12. Example

View license
[SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", Message/n ..... /n //View Source file for more details /n }

13. Example

View license
private void ReformatDocuments(IEnumerable<Document> documentsToReformat, bool saveDocumentsAf/n ..... /n //View Source file for more details /n }