File: StackTraceExplorer\StackTraceExplorerRoot.xaml.cs
Web Access
Project: src\src\VisualStudio\Core\Def\Microsoft.VisualStudio.LanguageServices_4volmoxl_wpftmp.csproj (Microsoft.VisualStudio.LanguageServices)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
 
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
 
namespace Microsoft.VisualStudio.LanguageServices.StackTraceExplorer;
 
/// <summary>
/// Interaction logic for CallstackExplorerRoot.xaml
/// </summary>
internal partial class StackTraceExplorerRoot : UserControl
{
    public string CloseTab => ServicesVSResources.Close_tab;
    public string Clear_Text => ServicesVSResources.Clear;
    public string StackTrace => ServicesVSResources.Stack_Trace;
 
    public readonly StackTraceExplorerRootViewModel ViewModel;
 
    public StackTraceExplorerRoot(StackTraceExplorerRootViewModel viewModel)
    {
        DataContext = ViewModel = viewModel;
 
        InitializeComponent();
        DataObject.AddPastingHandler(this, OnPaste);
    }
 
    private void CommandBinding_OnPaste(object sender, ExecutedRoutedEventArgs e)
        => ViewModel.DoPasteAsync(default).Start();
 
    internal void OnClear()
    {
        ViewModel.SelectedTab?.Content.OnClear();
    }
 
    private void OnPaste(object sender, DataObjectPastingEventArgs e)
        => ViewModel.DoPasteAsync(default).Start();
 
    private void Close_Click(object sender, RoutedEventArgs e)
    {
        if (sender is StackTraceExplorerTab tab)
        {
            tab.CloseClick.Execute(null);
        }
    }
 
    private void Clear_Click(object sender, RoutedEventArgs e)
        => OnClear();
}