<UserControl x:Class="Artemis.UI.Screens.Settings.Tabs.Devices.DeviceSettingsView"
             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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:s="https://github.com/canton7/Stylet"
             xmlns:devices="clr-namespace:Artemis.UI.Screens.Settings.Tabs.Devices"
             xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
             d:DataContext="{d:DesignInstance devices:DeviceSettingsViewModel}"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary
                    Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
                <ResourceDictionary
                    Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PopupBox.xaml" />
                <ResourceDictionary
                    Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBlock.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <materialDesign:Card Width="200">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="140" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Rectangle Grid.Row="0" Fill="{DynamicResource MaterialDesignPaper}" />
            <shared:DeviceVisualizer VerticalAlignment="Center"
                                     HorizontalAlignment="Center"
                                     Margin="10"
                                     Device="{Binding Device}"
                                     RenderOptions.BitmapScalingMode="HighQuality"
                                     Grid.Row="0" />
            <Button Grid.Row="0"
                    Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Bottom"
                    Margin="0 0 16 -20"
                    ToolTip="Identify"
                    Command="{s:Action IdentifyDevice}">
                <materialDesign:PackIcon Kind="AlarmLight" />
            </Button>
            <StackPanel Grid.Row="1" Margin="8 24 8 0">
                <TextBlock Style="{StaticResource MaterialDesignTextBlock}" Text="{Binding Device.RgbDevice.DeviceInfo.Model}" />
                <TextBlock TextWrapping="Wrap" Style="{StaticResource MaterialDesignTextBlock}" Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}">
                    <Run Text="{Binding Device.RgbDevice.DeviceInfo.Manufacturer, Mode=OneWay}" />
                    -
                    <Run Text="{Binding Device.DeviceType, Mode=OneWay}" />
                </TextBlock>
            </StackPanel>
            <StackPanel HorizontalAlignment="Right" Grid.Row="2" Orientation="Horizontal" Margin="8">
                <CheckBox Style="{StaticResource MaterialDesignAccentCheckBox}" IsChecked="{Binding IsDeviceEnabled}">
                    Device enabled
                </CheckBox>
                <materialDesign:PopupBox Style="{StaticResource MaterialDesignToolPopupBox}" Padding="2 0 2 0" Foreground="{StaticResource MaterialDesignBody}">
                    <StackPanel>
                        <Button Command="{s:Action OpenPluginDirectory}">
                            <StackPanel Orientation="Horizontal">
                                <materialDesign:PackIcon Kind="FolderOpen" Margin="0 0 10 0 " VerticalAlignment="Center" />
                                <TextBlock VerticalAlignment="Center">Open plugin directory</TextBlock>
                            </StackPanel>
                        </Button>
                        <Separator />
                        <Button Command="{s:Action DetectInput}" ToolTip="Teach Artemis which keypresses and/or button presses belong to this device">
                            <StackPanel Orientation="Horizontal">
                                <materialDesign:PackIcon Kind="GestureDoubleTap" Margin="0 0 10 0 " VerticalAlignment="Center" />
                                <TextBlock VerticalAlignment="Center">Identify input</TextBlock>
                            </StackPanel>
                        </Button>
                        <Button Command="{s:Action ViewProperties}">
                            <StackPanel Orientation="Horizontal">
                                <materialDesign:PackIcon Kind="Gear" Margin="0 0 10 0 " VerticalAlignment="Center" />
                                <TextBlock VerticalAlignment="Center">Device properties</TextBlock>
                            </StackPanel>
                        </Button>
                    </StackPanel>
                </materialDesign:PopupBox>
            </StackPanel>
        </Grid>
    </materialDesign:Card>
</UserControl>