コード例 #1
0
        public async Task OnSettingsSaveAsync()
        {
            var generalOptions = await GeneralOptions.GetLiveInstanceAsync();

            if (_stackDataDumpControl == null)
            {
                var window = await package.FindToolWindowAsync(typeof(StackDataDump), 0, true, package.DisposalToken);

                var stackDataDump = window as StackDataDump;
                _stackDataDumpControl = stackDataDump?.Content as StackDataDumpControl;
            }

            _stackDataDumpControl.MaxDepth.Text = generalOptions.MaxObjectDepth.ToString();
            _stackDataDumpControl.AutomaticallyRefresh.IsChecked = generalOptions.AutomaticallyRefresh;
        }
コード例 #2
0
        public async void Execute(object sender, EventArgs e)
        {
            try
            {
                if (_stackDataDumpControl == null)
                {
                    await package.JoinableTaskFactory.RunAsync(async() =>
                    {
                        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                        var window      = await package.FindToolWindowAsync(typeof(StackDataDump), 0, true, package.DisposalToken);
                        var windowFrame = (IVsWindowFrame)window.Frame;
                        if (windowFrame.IsVisible() != 0)
                        {
                            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
                        }

                        var stackDataDump     = window as StackDataDump;
                        _stackDataDumpControl = stackDataDump?.Content as StackDataDumpControl;
                    });
                }
                _stackDataDumpControl.MainTabControl.SelectedIndex = StackDataDumpControl.LocalsTabIndex;
            }
            catch (Exception)
            {
            }
        }
コード例 #3
0
        private void GetFilesAndRunMutations()
        {
            _package.JoinableTaskFactory.RunAsync(async() =>
            {
                await _package.JoinableTaskFactory.SwitchToMainThreadAsync();

                var dte = await ServiceProvider.GetServiceAsync(typeof(DTE)) as DTE;

                if (dte == null)
                {
                    throw new NotSupportedException("Cannot create tool window");
                }

                var selectedItems = dte.SelectedItems;

                if (selectedItems != null)
                {
                    var files = new List <string>();

                    foreach (SelectedItem selectedItem in selectedItems)
                    {
                        if (selectedItem.ProjectItem is ProjectItem projectItem)
                        {
                            // If it have project items it must be a directory
                            if (projectItem.ProjectItems.Count > 0)
                            {
                                files.Add($"{projectItem.FileNames[0]}*");
                                continue;
                            }

                            files.Add(projectItem.FileNames[0]);
                            continue;
                        }

                        if (selectedItem.Project is Project project)
                        {
                            files.Add($"{Path.GetDirectoryName(project.FileName)}/*");
                        }
                    }

                    if (!files.Any())
                    {
                        return;
                    }

                    var window =
                        await _package.FindToolWindowAsync(typeof(MutationExplorerWindow), 0, true, _package.DisposalToken) as
                        MutationExplorerWindow;
                    if (window?.Frame == null)
                    {
                        throw new NotSupportedException("Cannot create tool window");
                    }

                    var windowFrame = (IVsWindowFrame)window.Frame;
                    Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

                    window.InitializeWindow(_mutationFilterItemCreatorService.CreateFilterFromFilePaths(files));
                }
            });
        }
コード例 #4
0
        /// <summary>
        /// Shows the tool window when the menu item is clicked.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            _package.JoinableTaskFactory.RunAsync(async() =>
            {
                try
                {
                    var window = await _package.FindToolWindowAsync(typeof(MutationExplorerWindow), 0, true, _package.DisposalToken) as MutationExplorerWindow;

                    if (window?.Frame == null)
                    {
                        throw new NotSupportedException("Cannot create tool window");
                    }

                    await _package.JoinableTaskFactory.SwitchToMainThreadAsync();

                    var windowFrame = (IVsWindowFrame)window.Frame;
                    Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

                    window.InitializeWindow();
                }
                catch (Exception ex)
                {
                    _userNotificationService.ShowError($"Failed to open config window. Make sure that you have the latest visual studio update. \n Exception: \n {ex.Message}");
                    throw;
                }
            });
        }
コード例 #5
0
 public async Task <IVsWindowFrame> GetWindowFrameAsync()
 {
     return(await package.JoinableTaskFactory.RunAsync(async delegate {
         // Get the instance number 0 of this tool window. This window is single instance so this
         // instance is actually the only one. The last flag is set to true so that if the tool
         // window does not exists it will be created.
         var window = await package.FindToolWindowAsync(typeof(SquirrelPackager), 0, true, package.DisposalToken);
         if ((window == null) || (window.Frame == null))
         {
             throw new NotSupportedException("Cannot create tool window");
         }
         await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);
         return (IVsWindowFrame)window.Frame;
     }));
 }
コード例 #6
0
        public ToolWindowPane FindToolWindow()
        {
            ToolWindowPane window = null;

            package.JoinableTaskFactory.RunAsync(async delegate
            {
                window = await package.FindToolWindowAsync(typeof(OutputToolWindow), 0, true, package.DisposalToken);

                if ((null == window) || (null == window.Frame))
                {
                    throw new NotSupportedException($"Cannot create '{Vsix.Name}' output window");
                }
            });

            return(window);
        }
コード例 #7
0
 /// <summary>
 /// Is hit when user selects Tools > Windows > Football
 /// </summary>
 private async void CommandEventHandler(object sender, EventArgs e)
 {
     // Get the instance number 0 of this tool window. This window is single instance so this instance is actually the only one.
     // The last flag is set to true so that if the tool window does not exists it will be created.
     await _asyncPackage.JoinableTaskFactory.RunAsync(async delegate
     {
         var window = await _asyncPackage.FindToolWindowAsync(typeof(VsixToolWindowPane), 0, true, _asyncPackage.DisposalToken);
         if (window?.Frame == null)
         {
             throw new NotSupportedException("Cannot create tool window");
         }
         await _asyncPackage.JoinableTaskFactory.SwitchToMainThreadAsync();
         var windowFrame = (IVsWindowFrame)window.Frame;
         Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
     });
 }
コード例 #8
0
        public void ShowInfoBar <T>(string text)
        {
            _joinableTaskFactory.Run(async() =>
            {
                await _joinableTaskFactory.SwitchToMainThreadAsync();

                var window = await _asyncPackage.FindToolWindowAsync(typeof(T), 0, true, _asyncPackage.DisposalToken);

                if (window?.Frame == null)
                {
                    throw new NotSupportedException("Cannot create tool window");
                }

                window.AddInfoBar(new InfoBarModel(text));
            });
        }
コード例 #9
0
        /// <summary>
        /// Shows the tool window when the menu item is clicked.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        private async void ShowToolWindowAsync(object sender, EventArgs e)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            var window = await _package.FindToolWindowAsync(typeof(SvgConverterToolWindow), 0, true, CancellationToken.None);

            if (window?.Frame == null)
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            var windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
コード例 #10
0
        public T OpenWindow <T>()
            where T : ToolWindowPane
        {
            return(JoinableTaskFactory.Run(async() =>
            {
                var window = await _asyncPackage.FindToolWindowAsync(typeof(T), 0, true, _asyncPackage.DisposalToken) as T;

                if (window?.Frame == null)
                {
                    throw new NotSupportedException("Cannot create tool window");
                }

                await _asyncPackage.JoinableTaskFactory.SwitchToMainThreadAsync();

                var windowFrame = (IVsWindowFrame)window.Frame;
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

                return window;
            }));
        }
コード例 #11
0
        private void RunMutationsForSelectedLines()
        {
            _package.JoinableTaskFactory.Run(async() =>
            {
                await _package.JoinableTaskFactory.SwitchToMainThreadAsync();

                var service     = await ServiceProvider.GetServiceAsync(typeof(SVsTextManager));
                var textManager = service as IVsTextManager2;
                textManager.GetActiveView2(1, null, (uint)_VIEWFRAMETYPE.vftCodeWindow, out var view);

                view.GetSelection(out int startLine, out var startColumn, out var endLine, out var endColumn);

                var dte = await ServiceProvider.GetServiceAsync(typeof(DTE)) as DTE;

                if (dte == null)
                {
                    return;
                }

                var file = dte.ActiveDocument.FullName;

                var window =
                    await _package.FindToolWindowAsync(typeof(MutationExplorerWindow), 0, true, _package.DisposalToken) as
                    MutationExplorerWindow;
                if (window?.Frame == null)
                {
                    throw new NotSupportedException("Cannot create tool window");
                }

                var windowFrame = (IVsWindowFrame)window.Frame;
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

                window.InitializeWindow(
                    _mutationFilterItemCreatorService.CreateFilterFromLines(file, startLine + 1, endLine + 1));
            });
        }
コード例 #12
0
        public async Task <ToolWindowPane> FindToolWindowAsync()
        {
            ToolWindowPane window = await package.FindToolWindowAsync(typeof(OutputToolWindow), 0, true, package.DisposalToken);

            return(ReturnOrThrowIfCannotCreateToolWindow(window));
        }