-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLaunchyBarControl.xaml
More file actions
130 lines (121 loc) · 5.63 KB
/
LaunchyBarControl.xaml
File metadata and controls
130 lines (121 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<UserControl x:Class="CodingWithCalvin.LaunchyBar.UI.LaunchyBarControl"
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:vs="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.15.0"
xmlns:imaging="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.Imaging"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="48"
Background="{DynamicResource {x:Static vs:VsBrushes.ToolWindowBackgroundKey}}">
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/>
<Style x:Key="LaunchyBarButtonStyle" TargetType="Button">
<Setter Property="Width" Value="44"/>
<Setter Property="Height" Value="40"/>
<Setter Property="Margin" Value="0,4"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static vs:VsBrushes.CommandBarTextActiveKey}}"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Active indicator bar on the left edge -->
<Rectangle x:Name="ActiveIndicator"
Grid.Column="0"
Fill="{DynamicResource {x:Static vs:VsBrushes.AccentMediumKey}}"
RadiusX="1" RadiusY="1"
Margin="0,6"
Visibility="Collapsed"/>
<Border x:Name="Border"
Grid.Column="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
Padding="8">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="Background"
Value="{DynamicResource {x:Static vs:VsBrushes.CommandBarHoverKey}}"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="Border" Property="Background"
Value="{DynamicResource {x:Static vs:VsBrushes.CommandBarSelectedKey}}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.5"/>
</Trigger>
<DataTrigger Binding="{Binding IsActive}" Value="True">
<Setter TargetName="ActiveIndicator" Property="Visibility" Value="Visible"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- LaunchyBar Logo -->
<Image Grid.Row="0"
Source="pack://application:,,,/CodingWithCalvin.LaunchyBar;component/Resources/logo-32.png"
Width="32" Height="32"
HorizontalAlignment="Center"
Margin="0,8,0,12"
ToolTip="LaunchyBar"/>
<!-- Separator -->
<Rectangle Grid.Row="1"
Height="1"
Margin="8,0,8,8"
Fill="{DynamicResource {x:Static vs:VsBrushes.CommandBarMenuSeparatorKey}}"/>
<!-- Top Items (flow down) -->
<ItemsControl Grid.Row="2"
ItemsSource="{Binding TopItems}"
VerticalAlignment="Top">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Style="{StaticResource LaunchyBarButtonStyle}"
Command="{Binding DataContext.LaunchCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
CommandParameter="{Binding}"
ToolTip="{Binding Name}">
<imaging:CrispImage Width="24" Height="24"
Moniker="{Binding IconMoniker}" />
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<!-- Bottom Items (flow up) -->
<ItemsControl Grid.Row="3"
ItemsSource="{Binding BottomItems}"
VerticalAlignment="Bottom">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Style="{StaticResource LaunchyBarButtonStyle}"
Command="{Binding DataContext.LaunchCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
CommandParameter="{Binding}"
ToolTip="{Binding Name}">
<imaging:CrispImage Width="24" Height="24"
Moniker="{Binding IconMoniker}" />
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>