<Window x:Class="BeWo.View.ChatView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:view="clr-namespace:BeWo.View"
        Title="Chat View" Height="800" Width="800" WindowStartupLocation="CenterScreen" WindowStyle="None" 
		AllowsTransparency="True"
        Background="Transparent"
        ResizeMode="NoResize">
    <Grid>
        <GroupBox Header="Chat" x:Name="rootGroupBox" Style="{DynamicResource MainContentGroupBoxWithoutMaximizeBtnStyle}" MouseLeftButtonDown="RootGroupBox_OnMouseLeftButtonDown">
            <Grid Background="{StaticResource ObjectEditBackgroundBrush}">

                <TextBox x:Name="ServerStats" Height="23" Margin="539,13,7,0" TextWrapping="Wrap" VerticalAlignment="Top" ToolTip="Server Info" IsEnabled="False"/>

                <TextBox x:Name="Chatbox" HorizontalAlignment="Left" Margin="174,719,0,11" TextWrapping="Wrap" 
                         VerticalContentAlignment="Center" Width="462" Height="25" ToolTip="Schreiben Sie hier eine Nachricht hinein" KeyDown="OnKeyDownHandler" GotFocus="OnFocus" LostFocus="OnDefocus" Text="Nachricht schreiben" Foreground="DarkGray" >
                    <TextBox.Resources>
                        <Style TargetType="{x:Type Border}">
                            <Setter Property="CornerRadius" Value="3"/>
                            <Setter Property="Padding" Value="10,0,0,0" />                     
                        </Style>
                    </TextBox.Resources>
                </TextBox>

                <ListBox x:Name="Chat" HorizontalAlignment="Left" Height="630" Margin="170,64,0,0" VerticalAlignment="Top" Width="615" >
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <!--<Setter Property="IsEnabled" Value="False" />
                            <Setter Property="Foreground" Value="Black" />-->
                            <Setter Property="Focusable" Value="False"/>                      
                        </Style>
                    </ListBox.ItemContainerStyle>
                    <ListBox.Resources>
                      <Style TargetType="Border">
                        <Setter Property="CornerRadius" Value="3"/>
                        <Setter Property="Padding" Value="10,0,0,0" />
                      </Style>
                    </ListBox.Resources>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Border BorderBrush="Fuchsia" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8">
                                <WrapPanel MinHeight="15" Margin="5" >
                                    <TextBlock Text="{Binding Username}" FontWeight="Bold" VerticalAlignment="Center" />
                                    <TextBlock Text=": " FontWeight="Bold" VerticalAlignment="Center"/>
                                    <TextBlock Text="{Binding UserMessage}" Width="350" TextWrapping="Wrap" VerticalAlignment="Center"/>
                                    <TextBlock Text="{Binding SendTime}" Margin="2" Width="115"  VerticalAlignment="Top" HorizontalAlignment="Right" TextAlignment="Right"/>

                                </WrapPanel>
                            </Border>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <!--  <ListBox.ItemsPanel> falls der Text von unten kommen soll 
                        <ItemsPanelTemplate>
                            <StackPanel VerticalAlignment="Bottom"/> 
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>-->
                </ListBox>



                <ListBox x:Name="Clientlist" HorizontalAlignment="Left" Height="680" Margin="10,64,0,0" VerticalAlignment="Top" Width="157" SelectionChanged="ListBoxSelectedIndexChanged" Style="{DynamicResource ResourceKey=styleListBox}" ItemTemplate="{DynamicResource DataTemplate1}">
                    <ListBox.Resources>
                        <DataTemplate x:Key="DataTemplate1">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="50"/>
                                    <ColumnDefinition Width="90"/>
                                    <ColumnDefinition Width="20"/>
                                </Grid.ColumnDefinitions>
                               <!-- <Border Margin="2" BorderBrush="Black" BorderThickness="1" CornerRadius="30"  Width="30" Height="30"> -->
                                    <Ellipse Width='30' Height='30'>               
                                        <Ellipse.Fill>
                                            <ImageBrush ImageSource='{Binding Image}'  Stretch='Fill' />
                                        </Ellipse.Fill>
                                    </Ellipse>
                                   <!-- <Image Source="{Binding Path=Image}" Stretch="Fill" Width="30" Height="30" >
                                        <Image.Clip>
                                            <EllipseGeometry Center="150,160" RadiusX="120" RadiusY="120" />
                                        </Image.Clip>
                                    </Image>-->
                               <!-- </Border>-->
                                <StackPanel Grid.Column="1" Margin="5">
                                    <StackPanel Orientation="Horizontal" TextBlock.FontWeight="Bold" >
                                        <TextBlock Text="{Binding Path=Name, FallbackValue=FirstName}" />
                                    </StackPanel>
                                    <TextBlock Text="{Binding Path=Lastms, FallbackValue=Message}" />
                                </StackPanel>

                              <!--Für die anzeige der anzahl ungelesener Nachrichten -->
                              <StackPanel Grid.Column="2" Margin="5">
                                <TextBlock Text="{Binding Path=Receivems}" FontWeight="Bold" Foreground="DarkRed"/>
                              </StackPanel>
                              
                            </Grid>
                        </DataTemplate>
                    </ListBox.Resources>
                </ListBox>

                <Button x:Name="SendButton" Content="Senden" HorizontalAlignment="Left" Margin="670,718,0,0" VerticalAlignment="Top" Width="111" Click="SendButton_Click" Height="25"/>
                <Label Content="Aktuelle Liste:" HorizontalAlignment="Left" Margin="10,41,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.622,0.045" Width="132"/>

            </Grid>
        </GroupBox>
        <ComboBox x:Name="chatSettingControll" HorizontalAlignment="Left" Margin="17,53,0,0" VerticalAlignment="Top" Width="136" SelectionChanged="ComboBox_SelectionChanged"/>
        
        <ListBox x:Name="AktChatUser" HorizontalAlignment="Left" Background="Transparent" BorderBrush="Transparent" Height="50" Margin="175,52,0,0" VerticalAlignment="Top" Width="365" ItemTemplate="{DynamicResource DataTemplate2}">
            <ListBox.Resources>
                <DataTemplate x:Key="DataTemplate2">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="50"/>
                            <ColumnDefinition Width="100"/>
                        </Grid.ColumnDefinitions>
                       <!-- <Border Margin="5" BorderBrush="DarkGray" BorderThickness="1"> -->
                            <Ellipse Width='30' Height='30'>
                                <Ellipse.Fill>
                                    <ImageBrush ImageSource='{Binding Image}'  Stretch='Fill' />
                                </Ellipse.Fill>
                            </Ellipse>
                           <!-- <Image Source="{Binding Path=Image}" Stretch="Fill" Width="30" Height="30" />-->
                      <!--  </Border> -->
                        <StackPanel Grid.Column="1" Margin="5">
                            <StackPanel Orientation="Horizontal" TextBlock.FontWeight="Bold" >
                                <TextBlock Text="{Binding Path=Name, FallbackValue=FirstName}" />
                            </StackPanel>
                            <TextBlock Text="{Binding Path=Lastms, FallbackValue=Message}" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListBox.Resources>
        </ListBox>
    </Grid>
</Window>
