Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.55 KB | None | 0 0
  1. <UserControl
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
  7. xmlns:system="clr-namespace:System;assembly=mscorlib"
  8. xmlns:vs="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.12.0"
  9. xmlns:package="clr-namespace:SaveAllTheTabs"
  10. x:Class="SaveAllTheTabs.SavedTabsToolWindowControl"
  11. Background="{DynamicResource VsBrush.Window}"
  12. Foreground="{DynamicResource VsBrush.WindowText}"
  13. BorderBrush="{DynamicResource VsBrush.ActiveBorderKey}"
  14. mc:Ignorable="d"
  15. d:DesignHeight="300" d:DesignWidth="300"
  16. x:Name="SavedTabsToolWindow">
  17.  
  18. <UserControl.Resources>
  19. <package:BoolVisibilityConverter x:Key="BoolVisibility" />
  20. <package:WrapTooltipConverter x:Key="WrapTooltip" />
  21.  
  22. <Style x:Key="VsGridViewColumnHeaderGripper" TargetType="Thumb">
  23. <Setter Property="Width" Value="18" />
  24. <Setter Property="Background" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBorderBrushKey}}"/>
  25. <Setter Property="Template">
  26. <Setter.Value>
  27. <ControlTemplate TargetType="{x:Type Thumb}">
  28. <Border Padding="{TemplateBinding Padding}" Background="Transparent">
  29. <Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Background}" />
  30. </Border>
  31. </ControlTemplate>
  32. </Setter.Value>
  33. </Setter>
  34. <Setter Property="BorderBrush" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBorderBrushKey}}" />
  35. </Style>
  36.  
  37. <Style x:Key="VsGridViewColumnHeader" TargetType="GridViewColumnHeader">
  38. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  39. <Setter Property="VerticalContentAlignment" Value="Stretch" />
  40. <Setter Property="Foreground" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowTextBrushKey}}" />
  41. <Setter Property="Template">
  42. <Setter.Value>
  43. <ControlTemplate TargetType="GridViewColumnHeader">
  44. <Grid>
  45. <VisualStateManager.VisualStateGroups>
  46. <VisualStateGroup x:Name="CommonStates">
  47. <VisualState x:Name="Normal" />
  48. <VisualState x:Name="MouseOver">
  49. <Storyboard>
  50. <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="HeaderBorder">
  51. <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource {x:Static vs:EnvironmentColors.CommandBarHoverColorKey}}" />
  52. </ColorAnimationUsingKeyFrames>
  53. </Storyboard>
  54. </VisualState>
  55. <VisualState x:Name="Pressed" />
  56. <VisualState x:Name="Disabled" />
  57. </VisualStateGroup>
  58. </VisualStateManager.VisualStateGroups>
  59. <Border x:Name="HeaderBorder" BorderThickness="0,1,0,1" Padding="2,0,2,0">
  60. <Border.BorderBrush>
  61. <SolidColorBrush Color="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBorderColorKey}}"/>
  62. </Border.BorderBrush>
  63. <Border.Background>
  64. <SolidColorBrush Color="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBackgroundColorKey}}"/>
  65. </Border.Background>
  66. <ContentPresenter x:Name="HeaderContent" Margin="4,4,4,5" RecognizesAccessKey="True"
  67. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  68. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  69. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  70. </Border>
  71. <Thumb x:Name="PART_HeaderGripper" HorizontalAlignment="Right" Margin="0,0,-9,0" Style="{StaticResource VsGridViewColumnHeaderGripper}" />
  72. </Grid>
  73. </ControlTemplate>
  74. </Setter.Value>
  75. </Setter>
  76. <Style.Triggers>
  77. <Trigger Property="Role" Value="Floating">
  78. <Setter Property="Opacity" Value="0.7" />
  79. <Setter Property="Template">
  80. <Setter.Value>
  81. <ControlTemplate TargetType="GridViewColumnHeader">
  82. <Canvas Name="PART_FloatingHeaderCanvas">
  83. <Rectangle Fill="#60000000" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" />
  84. </Canvas>
  85. </ControlTemplate>
  86. </Setter.Value>
  87. </Setter>
  88. </Trigger>
  89. <Trigger Property="Role" Value="Padding">
  90. <Setter Property="Template">
  91. <Setter.Value>
  92. <ControlTemplate TargetType="GridViewColumnHeader">
  93. <Border Name="HeaderBorder" BorderThickness="0,1,0,1">
  94. <Border.Background>
  95. <SolidColorBrush Color="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBackgroundColorKey}}"/>
  96. </Border.Background>
  97. <Border.BorderBrush>
  98. <SolidColorBrush Color="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBorderColorKey}}"/>
  99. </Border.BorderBrush>
  100. </Border>
  101. </ControlTemplate>
  102. </Setter.Value>
  103. </Setter>
  104. </Trigger>
  105. </Style.Triggers>
  106. </Style>
  107.  
  108. <Style x:Key="VsListViewItemStyle" TargetType="ListViewItem">
  109. <Setter Property="AllowDrop" Value="true"/>
  110. <Setter Property="SnapsToDevicePixels" Value="true" />
  111. <Setter Property="OverridesDefaultStyle" Value="true" />
  112. <Setter Property="Padding" Value="5 0 5 0"/>
  113. <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
  114. <Setter Property="VerticalContentAlignment" Value="Stretch"/>
  115. <Setter Property="Template">
  116. <Setter.Value>
  117. <ControlTemplate TargetType="ListBoxItem">
  118. <Border x:Name="Border" Padding="2" SnapsToDevicePixels="true" Background="Transparent">
  119. <VisualStateManager.VisualStateGroups>
  120. <VisualStateGroup x:Name="CommonStates">
  121. <VisualState x:Name="Normal" />
  122. <VisualState x:Name="MouseOver" />
  123. <VisualState x:Name="Disabled" />
  124. </VisualStateGroup>
  125. <VisualStateGroup x:Name="SelectionStates">
  126. <VisualState x:Name="Unselected" />
  127. <VisualState x:Name="Selected">
  128. <Storyboard>
  129. <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
  130. <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource {x:Static vs:EnvironmentColors.ComboBoxSelectionColorKey}}" />
  131. </ColorAnimationUsingKeyFrames>
  132. </Storyboard>
  133. </VisualState>
  134. <VisualState x:Name="SelectedUnfocused">
  135. <Storyboard>
  136. <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
  137. <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource {x:Static vs:EnvironmentColors.CommandBarHoverColorKey}}" />
  138. </ColorAnimationUsingKeyFrames>
  139. </Storyboard>
  140. </VisualState>
  141. </VisualStateGroup>
  142. </VisualStateManager.VisualStateGroups>
  143. <GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
  144. </Border>
  145. </ControlTemplate>
  146. </Setter.Value>
  147. </Setter>
  148. </Style>
  149.  
  150. <Style x:Key="VsListViewStyle" TargetType="{x:Type ListView}">
  151. <Style.Resources>
  152. <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource VsGridViewColumnHeader}" />
  153. <Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource VsListViewItemStyle}" />
  154. </Style.Resources>
  155.  
  156. <Setter Property="AllowDrop" Value="true"/>
  157. <Setter Property="Background" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBackgroundBrushKey}}"/>
  158. <Setter Property="BorderBrush" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBorderBrushKey}}"/>
  159. <Setter Property="BorderThickness" Value="0"/>
  160. <Setter Property="Foreground" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowTextBrushKey}}"/>
  161. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
  162. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
  163. <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
  164. <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
  165. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  166. <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
  167. <Setter Property="VerticalContentAlignment" Value="Stretch"/>
  168. <Setter Property="Template">
  169. <Setter.Value>
  170. <ControlTemplate TargetType="{x:Type ListView}">
  171. <ListBox x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
  172. <ScrollViewer Padding="{TemplateBinding Padding}" Style="{DynamicResource {x:Static GridView.GridViewScrollViewerStyleKey}}" ContentTemplate="{DynamicResource DataTemplate1}">
  173. <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  174. </ScrollViewer>
  175. </ListBox>
  176. <ControlTemplate.Triggers>
  177. <Trigger Property="IsEnabled" Value="false">
  178. <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBackgroundBrushKey}}"/>
  179. </Trigger>
  180. <MultiTrigger>
  181. <MultiTrigger.Conditions>
  182. <Condition Property="IsGrouping" Value="true"/>
  183. <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
  184. </MultiTrigger.Conditions>
  185. <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  186. </MultiTrigger>
  187. </ControlTemplate.Triggers>
  188. </ControlTemplate>
  189. </Setter.Value>
  190. </Setter>
  191. </Style>
  192.  
  193. <Style x:Key="VsListViewItemTextBlockStyle" TargetType="{x:Type TextBlock}">
  194. <Setter Property="Visibility" Value="{Binding Path=Content.(package:DocumentGroup.IsEditing),
  195. RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}},
  196. Converter={StaticResource BoolVisibility},
  197. ConverterParameter=invert}" />
  198. </Style>
  199.  
  200. <Style x:Key="VsListViewItemEditBlockStyle" TargetType="{x:Type FrameworkElement}">
  201. <Setter Property="VerticalAlignment" Value="Top" />
  202. <Setter Property="HorizontalAlignment" Value="Stretch" />
  203. <Setter Property="Visibility" Value="{Binding Path=Content.(package:DocumentGroup.IsEditing),
  204. RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}},
  205. Converter={StaticResource BoolVisibility}}" />
  206. </Style>
  207.  
  208. <CollectionViewSource x:Key="Groups" Source="{Binding Groups}" />
  209. </UserControl.Resources>
  210.  
  211. <Grid>
  212. <Grid.ColumnDefinitions>
  213. <ColumnDefinition Width=".10*"/>
  214. </Grid.ColumnDefinitions>
  215. <Grid.RowDefinitions>
  216. <RowDefinition Height=".10*"/>
  217. </Grid.RowDefinitions>
  218.  
  219. <Grid.Resources>
  220. <DataTemplate x:Key="NameColumnTemplate">
  221. <Grid>
  222. <TextBlock Text="{Binding Path=Name}" Style="{StaticResource VsListViewItemTextBlockStyle}"/>
  223. <TextBox Text="{Binding Path=Name}" Style="{StaticResource VsListViewItemEditBlockStyle}" />
  224. </Grid>
  225. </DataTemplate>
  226. <DataTemplate x:Key="SlotColumnTemplate">
  227. <TextBlock HorizontalAlignment="Center" Text="{Binding Path=Slot}"/>
  228. </DataTemplate>
  229. <DataTemplate x:Key="DescriptionColumnTemplate">
  230. <TextBlock Text="{Binding Path=Description}" TextWrapping="Wrap"/>
  231. </DataTemplate>
  232. </Grid.Resources>
  233.  
  234. <ListView x:Name="TabsList" SelectionMode="Single" AllowDrop="True" Grid.Column="0" Grid.Row="0" SelectionChanged="OnTabsListSelectionChanged" Style="{DynamicResource VsListViewStyle}">
  235. <ListView.ItemsSource>
  236. <Binding Source="{StaticResource Groups}"/>
  237. </ListView.ItemsSource>
  238.  
  239. <ListView.View>
  240. <GridView AllowsColumnReorder="false">
  241. <GridViewColumn CellTemplate="{StaticResource NameColumnTemplate}" Header="Name" Width="Auto" />
  242. <GridViewColumn CellTemplate="{StaticResource SlotColumnTemplate}" Header="Fav #" Width="Auto" />
  243. <GridViewColumn CellTemplate="{StaticResource DescriptionColumnTemplate}" Header="Tabs" Width="Auto" />
  244. </GridView>
  245. </ListView.View>
  246.  
  247. <ListView.ItemContainerStyle>
  248. <Style TargetType="ListViewItem" BasedOn="{StaticResource VsListViewItemStyle}">
  249. <Setter Property="ToolTip" Value="{Binding Path=Description, Converter={StaticResource WrapTooltip}}"/>
  250. <EventSetter Event="MouseDoubleClick" Handler="OnTabsListItemMouseDoubleClick" />
  251. <EventSetter Event="MouseRightButtonUp" Handler="OnTabsListItemMouseRightButtonUp" />
  252. <EventSetter Event="PreviewKeyDown" Handler="OnTabsListItemPreviewKeyDown" />
  253. </Style>
  254. </ListView.ItemContainerStyle>
  255. </ListView>
  256. </Grid>
  257. </UserControl>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement