<UserControl x:Class="TeamViewerApi.Views.ContactsView" 
             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:viewModels="clr-namespace:TeamViewerApi.ViewModels" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="500">
    <UserControl.DataContext>
        <viewModels:ContactsViewModel />
    </UserControl.DataContext>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="0" Grid.Column="0" Text="Contact" />
        <ComboBox Grid.Row="0" Grid.Column="1" 
                  Width="200px" 
                  ItemsSource="{Binding Contacts.Items, Mode=OneWay}" 
                  SelectedItem="{Binding SelectedContact, Mode=TwoWay}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Style="{x:Null}" Text="{Binding Name, Mode=OneWay}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
        <DockPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" 
                   Background="AliceBlue" />
        <TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" FontWeight="Bold" Text="Current contact" />

        <TextBlock Grid.Row="2" Grid.Column="0" Text="Id" />
        <TextBlock Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" Text="{Binding SelectedContact.ContactId, Mode=OneWay}" />
        <TextBlock Grid.Row="3" Grid.Column="0" Text="Name" />
        <TextBlock Grid.Row="3" Grid.Column="1" HorizontalAlignment="Left" Text="{Binding SelectedContact.Name, Mode=OneWay}" />
        <TextBlock Grid.Row="4" Grid.Column="0" Text="Email" />
        <TextBlock Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left" Text="{Binding SelectedContact.Email, Mode=OneWay}" />
        <TextBlock Grid.Row="5" Grid.Column="0" Text="Group" />
        <ComboBox Grid.Row="5" Grid.Column="1" 
                  Width="150px" 
                  HorizontalAlignment="Left" 
                  IsHitTestVisible="False" 
                  SelectedValuePath="GroupId" 
                  ItemsSource="{Binding Groups.Items, Mode=OneWay}" 
                  SelectedValue="{Binding SelectedContact.GroupId, Mode=TwoWay}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Style="{x:Null}" Text="{Binding Name, Mode=OneWay}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
        <TextBlock Grid.Row="6" Grid.Column="0" Text="Description" />
        <TextBlock Grid.Row="6" Grid.Column="1" HorizontalAlignment="Left" Text="{Binding SelectedContact.Description, Mode=OneWay}" />
        <TextBlock Grid.Row="7" Grid.Column="0" Text="State" />
        <TextBlock Grid.Row="7" Grid.Column="1" HorizontalAlignment="Left" Text="{Binding SelectedContact.State, Mode=OneWay}" />
        <TextBlock Grid.Row="8" Grid.Column="0" Text="Picture" />
        <TextBlock Grid.Row="8" Grid.Column="1" HorizontalAlignment="Left">
            <Hyperlink Command="{Binding OpenImageUrlCommand, Mode=OneWay}">
                <TextBlock Style="{x:Null}" Text="{Binding SelectedContact.ImageUrl, Mode=OneWay}" />
            </Hyperlink>
        </TextBlock>
        <TextBlock Grid.Row="9" Grid.Column="0" Text="Features" />
        <TextBlock Grid.Row="9" Grid.Column="1" HorizontalAlignment="Left" Text="{Binding SelectedContact.Features, Mode=OneWay}" />

        <DockPanel Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2" LastChildFill="False">
            <Button DockPanel.Dock="Left" 
                    Content="Get contacts" 
                    Command="{Binding GetContactsCommand, Mode=OneWay}" />
        </DockPanel>
        <DockPanel Grid.Row="11" Grid.Column="0" Grid.ColumnSpan="2" LastChildFill="False">
            <Button DockPanel.Dock="Left"
                    Content="Create new contact" 
                    Command="{Binding CreateContactCommand, Mode=OneWay}" />
            <Button DockPanel.Dock="Right" 
                    Content="Delete current contact" 
                    Command="{Binding DeleteContactCommand, Mode=OneWay}" />
        </DockPanel>
    </Grid>
</UserControl>
