|
| 1 | +<UserControl xmlns="https://github.com/avaloniaui" |
| 2 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 3 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 4 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 5 | + xmlns:vm="using:SourceGit.ViewModels" |
| 6 | + xmlns:v="using:SourceGit.Views" |
| 7 | + mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
| 8 | + x:Class="SourceGit.Views.WorkspaceSwitcher" |
| 9 | + x:DataType="vm:WorkspaceSwitcher"> |
| 10 | + <Grid RowDefinitions="28,Auto,Auto"> |
| 11 | + <TextBlock Grid.Row="0" |
| 12 | + Text="{DynamicResource Text.Repository.WorkspaceSwitcher}" |
| 13 | + FontWeight="Bold" |
| 14 | + HorizontalAlignment="Center" VerticalAlignment="Top"/> |
| 15 | + |
| 16 | + <TextBox Grid.Row="1" |
| 17 | + Height="24" |
| 18 | + Margin="4,0" |
| 19 | + BorderThickness="1" |
| 20 | + CornerRadius="12" |
| 21 | + Text="{Binding SearchFilter, Mode=TwoWay}" |
| 22 | + KeyDown="OnSearchBoxKeyDown" |
| 23 | + BorderBrush="{DynamicResource Brush.Border2}" |
| 24 | + VerticalContentAlignment="Center" |
| 25 | + v:AutoFocusBehaviour.IsEnabled="True"> |
| 26 | + <TextBox.InnerLeftContent> |
| 27 | + <Path Width="14" Height="14" |
| 28 | + Margin="6,0,0,0" |
| 29 | + Fill="{DynamicResource Brush.FG2}" |
| 30 | + Data="{StaticResource Icons.Search}"/> |
| 31 | + </TextBox.InnerLeftContent> |
| 32 | + |
| 33 | + <TextBox.InnerRightContent> |
| 34 | + <Button Classes="icon_button" |
| 35 | + Width="16" |
| 36 | + Margin="0,0,6,0" |
| 37 | + Command="{Binding ClearFilter}" |
| 38 | + IsVisible="{Binding SearchFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" |
| 39 | + HorizontalAlignment="Right"> |
| 40 | + <Path Width="14" Height="14" |
| 41 | + Margin="0,1,0,0" |
| 42 | + Fill="{DynamicResource Brush.FG1}" |
| 43 | + Data="{StaticResource Icons.Clear}"/> |
| 44 | + </Button> |
| 45 | + </TextBox.InnerRightContent> |
| 46 | + </TextBox> |
| 47 | + |
| 48 | + <ListBox Grid.Row="2" |
| 49 | + x:Name="WorkspaceListBox" |
| 50 | + Width="300" |
| 51 | + MaxHeight="400" |
| 52 | + Margin="0,8,0,0" |
| 53 | + BorderThickness="0" |
| 54 | + SelectionMode="Single" |
| 55 | + Background="Transparent" |
| 56 | + Focusable="True" |
| 57 | + ScrollViewer.HorizontalScrollBarVisibility="Disabled" |
| 58 | + ScrollViewer.VerticalScrollBarVisibility="Auto" |
| 59 | + ItemsSource="{Binding VisibleWorkspaces, Mode=OneWay}" |
| 60 | + SelectedItem="{Binding SelectedWorkspace, Mode=TwoWay}"> |
| 61 | + <ListBox.Styles> |
| 62 | + <Style Selector="ListBoxItem"> |
| 63 | + <Setter Property="Padding" Value="8,0"/> |
| 64 | + <Setter Property="MinHeight" Value="26"/> |
| 65 | + <Setter Property="CornerRadius" Value="4"/> |
| 66 | + </Style> |
| 67 | + |
| 68 | + <Style Selector="ListBox"> |
| 69 | + <Setter Property="FocusAdorner"> |
| 70 | + <FocusAdornerTemplate> |
| 71 | + <Grid/> |
| 72 | + </FocusAdornerTemplate> |
| 73 | + </Setter> |
| 74 | + </Style> |
| 75 | + </ListBox.Styles> |
| 76 | + |
| 77 | + <ListBox.ItemsPanel> |
| 78 | + <ItemsPanelTemplate> |
| 79 | + <StackPanel Orientation="Vertical"/> |
| 80 | + </ItemsPanelTemplate> |
| 81 | + </ListBox.ItemsPanel> |
| 82 | + |
| 83 | + <ListBox.ItemTemplate> |
| 84 | + <DataTemplate DataType="vm:Workspace"> |
| 85 | + <Grid ColumnDefinitions="Auto,*" VerticalAlignment="Center" Background="Transparent" DoubleTapped="OnItemDoubleTapped"> |
| 86 | + <Path Grid.Column="0" |
| 87 | + Width="12" Height="12" |
| 88 | + Fill="{Binding Brush}" |
| 89 | + Data="{StaticResource Icons.Workspace}" |
| 90 | + IsVisible="{Binding !IsActive}" |
| 91 | + IsHitTestVisible="False"/> |
| 92 | + <Path Grid.Column="0" |
| 93 | + Width="12" Height="12" |
| 94 | + Fill="{Binding Brush}" |
| 95 | + Data="{StaticResource Icons.Check}" |
| 96 | + IsVisible="{Binding IsActive}" |
| 97 | + IsHitTestVisible="False"/> |
| 98 | + <TextBlock Grid.Column="1" |
| 99 | + Margin="8,0,0,0" |
| 100 | + Classes="primary" |
| 101 | + VerticalAlignment="Center" |
| 102 | + Text="{Binding Name}" |
| 103 | + IsHitTestVisible="False" |
| 104 | + TextTrimming="CharacterEllipsis"/> |
| 105 | + </Grid> |
| 106 | + </DataTemplate> |
| 107 | + </ListBox.ItemTemplate> |
| 108 | + </ListBox> |
| 109 | + </Grid> |
| 110 | +</UserControl> |
| 111 | + |
0 commit comments