Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <UserControl
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
- xmlns:system="clr-namespace:System;assembly=mscorlib"
- xmlns:vs="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.12.0"
- xmlns:package="clr-namespace:SaveAllTheTabs"
- x:Class="SaveAllTheTabs.SavedTabsToolWindowControl"
- Background="{DynamicResource VsBrush.Window}"
- Foreground="{DynamicResource VsBrush.WindowText}"
- BorderBrush="{DynamicResource VsBrush.ActiveBorderKey}"
- mc:Ignorable="d"
- d:DesignHeight="300" d:DesignWidth="300"
- x:Name="SavedTabsToolWindow">
- <UserControl.Resources>
- <package:BoolVisibilityConverter x:Key="BoolVisibility" />
- <package:WrapTooltipConverter x:Key="WrapTooltip" />
- <Style x:Key="VsGridViewColumnHeaderGripper" TargetType="Thumb">
- <Setter Property="Width" Value="18" />
- <Setter Property="Background" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBorderBrushKey}}"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Thumb}">
- <Border Padding="{TemplateBinding Padding}" Background="Transparent">
- <Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Background}" />
- </Border>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Setter Property="BorderBrush" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBorderBrushKey}}" />
- </Style>
- <Style x:Key="VsGridViewColumnHeader" TargetType="GridViewColumnHeader">
- <Setter Property="HorizontalContentAlignment" Value="Stretch" />
- <Setter Property="VerticalContentAlignment" Value="Stretch" />
- <Setter Property="Foreground" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowTextBrushKey}}" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="GridViewColumnHeader">
- <Grid>
- <VisualStateManager.VisualStateGroups>
- <VisualStateGroup x:Name="CommonStates">
- <VisualState x:Name="Normal" />
- <VisualState x:Name="MouseOver">
- <Storyboard>
- <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="HeaderBorder">
- <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource {x:Static vs:EnvironmentColors.CommandBarHoverColorKey}}" />
- </ColorAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- <VisualState x:Name="Pressed" />
- <VisualState x:Name="Disabled" />
- </VisualStateGroup>
- </VisualStateManager.VisualStateGroups>
- <Border x:Name="HeaderBorder" BorderThickness="0,1,0,1" Padding="2,0,2,0">
- <Border.BorderBrush>
- <SolidColorBrush Color="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBorderColorKey}}"/>
- </Border.BorderBrush>
- <Border.Background>
- <SolidColorBrush Color="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBackgroundColorKey}}"/>
- </Border.Background>
- <ContentPresenter x:Name="HeaderContent" Margin="4,4,4,5" RecognizesAccessKey="True"
- VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
- HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
- SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
- </Border>
- <Thumb x:Name="PART_HeaderGripper" HorizontalAlignment="Right" Margin="0,0,-9,0" Style="{StaticResource VsGridViewColumnHeaderGripper}" />
- </Grid>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Style.Triggers>
- <Trigger Property="Role" Value="Floating">
- <Setter Property="Opacity" Value="0.7" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="GridViewColumnHeader">
- <Canvas Name="PART_FloatingHeaderCanvas">
- <Rectangle Fill="#60000000" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" />
- </Canvas>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Trigger>
- <Trigger Property="Role" Value="Padding">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="GridViewColumnHeader">
- <Border Name="HeaderBorder" BorderThickness="0,1,0,1">
- <Border.Background>
- <SolidColorBrush Color="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBackgroundColorKey}}"/>
- </Border.Background>
- <Border.BorderBrush>
- <SolidColorBrush Color="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBorderColorKey}}"/>
- </Border.BorderBrush>
- </Border>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Trigger>
- </Style.Triggers>
- </Style>
- <Style x:Key="VsListViewItemStyle" TargetType="ListViewItem">
- <Setter Property="AllowDrop" Value="true"/>
- <Setter Property="SnapsToDevicePixels" Value="true" />
- <Setter Property="OverridesDefaultStyle" Value="true" />
- <Setter Property="Padding" Value="5 0 5 0"/>
- <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
- <Setter Property="VerticalContentAlignment" Value="Stretch"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ListBoxItem">
- <Border x:Name="Border" Padding="2" SnapsToDevicePixels="true" Background="Transparent">
- <VisualStateManager.VisualStateGroups>
- <VisualStateGroup x:Name="CommonStates">
- <VisualState x:Name="Normal" />
- <VisualState x:Name="MouseOver" />
- <VisualState x:Name="Disabled" />
- </VisualStateGroup>
- <VisualStateGroup x:Name="SelectionStates">
- <VisualState x:Name="Unselected" />
- <VisualState x:Name="Selected">
- <Storyboard>
- <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
- <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource {x:Static vs:EnvironmentColors.ComboBoxSelectionColorKey}}" />
- </ColorAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- <VisualState x:Name="SelectedUnfocused">
- <Storyboard>
- <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
- <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource {x:Static vs:EnvironmentColors.CommandBarHoverColorKey}}" />
- </ColorAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- </VisualStateGroup>
- </VisualStateManager.VisualStateGroups>
- <GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
- </Border>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <Style x:Key="VsListViewStyle" TargetType="{x:Type ListView}">
- <Style.Resources>
- <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource VsGridViewColumnHeader}" />
- <Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource VsListViewItemStyle}" />
- </Style.Resources>
- <Setter Property="AllowDrop" Value="true"/>
- <Setter Property="Background" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBackgroundBrushKey}}"/>
- <Setter Property="BorderBrush" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBorderBrushKey}}"/>
- <Setter Property="BorderThickness" Value="0"/>
- <Setter Property="Foreground" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowTextBrushKey}}"/>
- <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
- <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
- <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
- <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
- <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
- <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
- <Setter Property="VerticalContentAlignment" Value="Stretch"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ListView}">
- <ListBox x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
- <ScrollViewer Padding="{TemplateBinding Padding}" Style="{DynamicResource {x:Static GridView.GridViewScrollViewerStyleKey}}" ContentTemplate="{DynamicResource DataTemplate1}">
- <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
- </ScrollViewer>
- </ListBox>
- <ControlTemplate.Triggers>
- <Trigger Property="IsEnabled" Value="false">
- <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBackgroundBrushKey}}"/>
- </Trigger>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="IsGrouping" Value="true"/>
- <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
- </MultiTrigger.Conditions>
- <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
- </MultiTrigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <Style x:Key="VsListViewItemTextBlockStyle" TargetType="{x:Type TextBlock}">
- <Setter Property="Visibility" Value="{Binding Path=Content.(package:DocumentGroup.IsEditing),
- RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}},
- Converter={StaticResource BoolVisibility},
- ConverterParameter=invert}" />
- </Style>
- <Style x:Key="VsListViewItemEditBlockStyle" TargetType="{x:Type FrameworkElement}">
- <Setter Property="VerticalAlignment" Value="Top" />
- <Setter Property="HorizontalAlignment" Value="Stretch" />
- <Setter Property="Visibility" Value="{Binding Path=Content.(package:DocumentGroup.IsEditing),
- RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}},
- Converter={StaticResource BoolVisibility}}" />
- </Style>
- <CollectionViewSource x:Key="Groups" Source="{Binding Groups}" />
- </UserControl.Resources>
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width=".10*"/>
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height=".10*"/>
- </Grid.RowDefinitions>
- <Grid.Resources>
- <DataTemplate x:Key="NameColumnTemplate">
- <Grid>
- <TextBlock Text="{Binding Path=Name}" Style="{StaticResource VsListViewItemTextBlockStyle}"/>
- <TextBox Text="{Binding Path=Name}" Style="{StaticResource VsListViewItemEditBlockStyle}" />
- </Grid>
- </DataTemplate>
- <DataTemplate x:Key="SlotColumnTemplate">
- <TextBlock HorizontalAlignment="Center" Text="{Binding Path=Slot}"/>
- </DataTemplate>
- <DataTemplate x:Key="DescriptionColumnTemplate">
- <TextBlock Text="{Binding Path=Description}" TextWrapping="Wrap"/>
- </DataTemplate>
- </Grid.Resources>
- <ListView x:Name="TabsList" SelectionMode="Single" AllowDrop="True" Grid.Column="0" Grid.Row="0" SelectionChanged="OnTabsListSelectionChanged" Style="{DynamicResource VsListViewStyle}">
- <ListView.ItemsSource>
- <Binding Source="{StaticResource Groups}"/>
- </ListView.ItemsSource>
- <ListView.View>
- <GridView AllowsColumnReorder="false">
- <GridViewColumn CellTemplate="{StaticResource NameColumnTemplate}" Header="Name" Width="Auto" />
- <GridViewColumn CellTemplate="{StaticResource SlotColumnTemplate}" Header="Fav #" Width="Auto" />
- <GridViewColumn CellTemplate="{StaticResource DescriptionColumnTemplate}" Header="Tabs" Width="Auto" />
- </GridView>
- </ListView.View>
- <ListView.ItemContainerStyle>
- <Style TargetType="ListViewItem" BasedOn="{StaticResource VsListViewItemStyle}">
- <Setter Property="ToolTip" Value="{Binding Path=Description, Converter={StaticResource WrapTooltip}}"/>
- <EventSetter Event="MouseDoubleClick" Handler="OnTabsListItemMouseDoubleClick" />
- <EventSetter Event="MouseRightButtonUp" Handler="OnTabsListItemMouseRightButtonUp" />
- <EventSetter Event="PreviewKeyDown" Handler="OnTabsListItemPreviewKeyDown" />
- </Style>
- </ListView.ItemContainerStyle>
- </ListView>
- </Grid>
- </UserControl>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement