Exemple #1
0
 public override void NavigateToInclude()
 {
     if (AbsoluteFilename != null && Path.IsPathRooted(AbsoluteFilename))
     {
         var fileWindow = VSUtils.OpenFileAndShowDocument(AbsoluteFilename);
     }
 }
Exemple #2
0
        public override async Task NavigateToInclude()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            // Want to navigate to origin of this include, not target if possible
            if (includingFileAbsoluteFilename != null && Path.IsPathRooted(includingFileAbsoluteFilename))
            {
                var fileWindow = VSUtils.OpenFileAndShowDocument(includingFileAbsoluteFilename);

                // Try to move to carret if possible.
                if (include.IncludeLine != null)
                {
                    var textDocument = fileWindow.Document.Object() as EnvDTE.TextDocument;

                    if (textDocument != null)
                    {
                        var includeLinePoint = textDocument.StartPoint.CreateEditPoint();
                        includeLinePoint.MoveToLineAndOffset(include.IncludeLine.LineNumber + 1, 1);
                        includeLinePoint.TryToShow();

                        textDocument.Selection.MoveToPoint(includeLinePoint);
                    }
                }
            }
        }
Exemple #3
0
        public override async Task NavigateToInclude()
        {
            if (AbsoluteFilename != null && Path.IsPathRooted(AbsoluteFilename))
            {
                await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                var fileWindow = VSUtils.OpenFileAndShowDocument(AbsoluteFilename);
            }
        }
Exemple #4
0
        protected override void MenuItemCallback(object sender, EventArgs e)
        {
            if (viewModel == null)
            {
                return;
            }

            if (viewModel.NumIncludes <= 0)
            {
                Output.Instance.ErrorMsg("There is no include tree to save!");
                return;
            }

            // Show save dialog.
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName   = ".dgml";
            dlg.DefaultExt = ".dgml";
            dlg.Filter     = "Text documents (.dgml)|*.dgml";
            bool?result = dlg.ShowDialog();

            // Process save file dialog box results
            if (result ?? false)
            {
                var       settings = (ViewerOptionsPage)IncludeToolboxPackage.Instance.GetDialogPage(typeof(ViewerOptionsPage));
                DGMLGraph dgmlGraph;

                try
                {
                    dgmlGraph = viewModel.Graph.ToDGMLGraph(settings.CreateGroupNodesForFolders, settings.ExpandFolderGroupNodes);
                    if (settings.ColorCodeNumTransitiveIncludes)
                    {
                        dgmlGraph.ColorizeByTransitiveChildCount(settings.NoChildrenColor, settings.MaxChildrenColor);
                    }
                }
                catch
                {
                    Output.Instance.ErrorMsg($"Failed to create dgml graph.");
                    return;
                }

                try
                {
                    dgmlGraph.Serialize(dlg.FileName);
                }
                catch
                {
                    Output.Instance.ErrorMsg($"Failed to safe dgml to {dlg.FileName}.");
                    return;
                }

                if (Output.Instance.YesNoMsg("Saved dgml successfully. Do you want to open it in Visual Studio?") == Output.MessageResult.Yes)
                {
                    VSUtils.OpenFileAndShowDocument(dlg.FileName);
                }
            }
        }