<Window x:Class="TwitterClient.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:TwitterClient.ViewModel"
		xmlns:local="clr-namespace:TwitterClient"
        xmlns:c="clr-namespace:TwitterClient.Converters"
        Title="TwitterClient" Height="596" Width="408">
    <Window.DataContext>
        <vm:TwitterViewModel/>
    </Window.DataContext>
    <Window.Resources>
        <Color x:Key="ActiveColor" R="38" G="211" B="190"/>
        <c:LenghtToBackgroundConverter x:Key="lenghtToBackgroundConverter"/>
        <c:LengthToDescriptionConverter x:Key="lenghtToDescriptionConverter"/>
        <c:LenghtToIsEnabledConverter x:Key="lenghtToIsEnabledConverter"/>
        <SolidColorBrush x:Key="ItemBrush" Color="Transparent" />
        <SolidColorBrush x:Key="SelectedItemBrush" Color="Red" />
        <SolidColorBrush x:Key="HoverItemBrush" Color="Azure" />
        <SolidColorBrush x:Key="ButtonMouseOverCoross" Color="#FF26D3BE"/>

        <Style x:Key="RoundedItem" TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid Cursor="Hand">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0:0:0.2">
                                            <VisualTransition.GeneratedEasingFunction>
                                                <CubicEase EasingMode="EaseInOut"/>
                                            </VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                        <VisualTransition GeneratedDuration="0:0:0.3" To="Normal">
                                            <VisualTransition.GeneratedEasingFunction>
                                                <CubicEase EasingMode="EaseInOut"/>
                                            </VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                        <VisualTransition GeneratedDuration="0" To="Pressed"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Disabled"/>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bgOver" />
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bg" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed"/>
                                    <VisualState x:Name="Normal"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Rectangle
					x:Name="bg" Fill="Transparent" RadiusX="4" RadiusY="4"/>
                            <Rectangle
					x:Name="bgOver" Fill="#FF26D3BE" RadiusX="4" RadiusY="4" Opacity="0"/>
                            <Border Name="ItemBorder">
                                <ContentPresenter/>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="AddTweetButton" TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Cursor="Hand">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0:0:0.2">
                                            <VisualTransition.GeneratedEasingFunction>
                                                <CubicEase EasingMode="EaseInOut"/>
                                            </VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                        <VisualTransition GeneratedDuration="0:0:0.3" To="Normal">
                                            <VisualTransition.GeneratedEasingFunction>
                                                <CubicEase EasingMode="EaseInOut"/>
                                            </VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                        <VisualTransition GeneratedDuration="0" To="Pressed"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bgOver" />
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bg" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Over1" />
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Over2" />
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Over3" />
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Over4" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bgOver" />
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bg" />
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Over3" />
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Over4" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Normal"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Rectangle  x:Name="bg" Fill="#FF999999" RadiusX="4" RadiusY="4"/>
                            <Rectangle  x:Name="bgOver" Fill="{TemplateBinding Background}" RadiusX="4" RadiusY="4" Opacity="0"/>
                            <Rectangle  x:Name="Over1"
					        Fill="White"   Width="3" Height="11" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            <Rectangle  x:Name="Over2"
					        Fill="White" Width="11" Height="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            <Rectangle x:Name="Over3"
					        Fill="{StaticResource ButtonMouseOverCoross}" Width="3" Height="11" HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="0"/>
                            <Rectangle x:Name="Over4"
					        Fill="{StaticResource ButtonMouseOverCoross}" Width="11" Height="3" HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="0"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="FontFamily" Value="/ProjectManager;Component/Fonts/Fonts.zip#Marke Eigenbau"/>
            <Setter Property="FontSize" Value="8"/>
            <Setter Property="Foreground" Value="Gray"/>
        </Style>
        <Style x:Key="RefreshButton" TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Cursor="Hand" >
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0:0:0.2">
                                            <VisualTransition.GeneratedEasingFunction>
                                                <CubicEase EasingMode="EaseInOut"/>
                                            </VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                        <VisualTransition GeneratedDuration="0:0:0.3" To="Normal">
                                            <VisualTransition.GeneratedEasingFunction>
                                                <CubicEase EasingMode="EaseInOut"/>
                                            </VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                        <VisualTransition GeneratedDuration="0" To="Pressed"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Disabled"/>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bgOver" />
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bg" />
                                            </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bgOver1" />
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bg1" />
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bgOver" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Normal"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Rectangle  x:Name="bgOver1" Fill="{TemplateBinding Background}" RadiusX="4" RadiusY="4" Opacity="0"/>
                            <Rectangle  x:Name="bg1" RadiusX="4" RadiusY="4" Fill="#FF999999">
                            </Rectangle>
                            <Rectangle  x:Name="bg" RadiusX="4" RadiusY="4" Margin="3">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Images/refresh_inactive.png"  Stretch="Uniform"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <Rectangle  x:Name="bgOver" RadiusX="10" RadiusY="10" Opacity="0" Margin="3">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Images/refresh_active.png"  Stretch="Uniform"/>
                                </Rectangle.Fill>
                            </Rectangle>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="FontFamily" Value="/ProjectManager;Component/Fonts/Fonts.zip#Marke Eigenbau"/>
            <Setter Property="FontSize" Value="8"/>
            <Setter Property="Foreground" Value="Gray"/>
        </Style>
    </Window.Resources>
    <Grid >
        <Button Style="{StaticResource ResourceKey=RefreshButton}" Height="28" HorizontalAlignment="Right" Margin="0,37,12,0" Name="button1" VerticalAlignment="Top" Width="41" Click="button1_Click"/>
        <TextBlock Height="19" HorizontalAlignment="Left" Margin="12,12,0,0" Text="{Binding StringFormat={}{0}   element(ów), Path=Tweets.Count}" VerticalAlignment="Top" Width="115" />
        <ListBox Background="Transparent"
			ScrollViewer.CanContentScroll="True"
            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
            ScrollViewer.VerticalScrollBarVisibility="Disabled"
			Margin="12,71,12,113" 
			Name="listBox1" 
			ItemsSource="{Binding Path=Tweets}"
            ItemContainerStyle="{StaticResource RoundedItem}" BorderBrush="{x:Null}">
            <ListBox.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Border CornerRadius="4">
                                <TextBlock FontWeight="Bold" Foreground="#FF999999" Text="{Binding Path=Name}" />
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                        <GradientStop Color="#FF26D3BE" Offset="0" />
                                        <GradientStop Color="#FF999999" Offset="1" />
                                    </LinearGradientBrush>
                                </Border.Background>
                            </Border>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListBox.GroupStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <local:TweetTemplate />
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.ContextMenu>
                <ContextMenu >
                    <MenuItem Header="Sourtuj według">
                        <MenuItem Header="Data" IsCheckable="True" Name="Data" Checked="Data_checked" Unchecked="Data_unchecked" />
                        <MenuItem Header="ScreenName" IsCheckable="True" Name="ScreenName" Checked="ScreenName_checked" Unchecked="ScreenName_unchecked" />
                    </MenuItem>
                    <MenuItem Header="Grupuj według">
                        <MenuItem Header="Użytkownik" IsCheckable="True" Name="Uzytkownik" Checked="Uzytkownik_checked" Unchecked="Uzytkownik_unchecked" />
                    </MenuItem>
                    <MenuItem Header="Time Line">
                        <MenuItem Header="User"  Name="user" Click="user_Click" />
                        <MenuItem Header="Home"  Name="home" Click="home_Click" />
                        <MenuItem Header="Public"  Name="public" Click="public_Click" />
                        <MenuItem Header="Mentions"  Name="mentions" Click="mentions_Click" />
                        <MenuItem Header="RetweetedByMe"  Name="retweetedByMe" Click="retweetByMe_Click" />
                    </MenuItem>
                </ContextMenu>
            </ListBox.ContextMenu>
        </ListBox>
        <TextBox Background="#83FFFFFF" BorderBrush="{x:Null}" TextWrapping="Wrap" Height="80" Margin="12,0,86,27" Name="textBox1" VerticalAlignment="Bottom" MaxLength="140" IsEnabled="True" Text="{Binding Path=TweetText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        <Button  IsEnabled="{Binding Path=Text.Length, ElementName=textBox1,Converter={StaticResource lenghtToIsEnabledConverter} }" Style="{StaticResource ResourceKey=AddTweetButton}"  Height="80" HorizontalAlignment="Right" Margin="0,0,12,27" Name="button2" VerticalAlignment="Bottom" Width="70" Click="button2_Click" />
        <!--<Label  Height="21" Margin="12,0" Name="label1" VerticalAlignment="Bottom" ContentStringFormat="{}{0} znak(ów)" Content="{Binding  Path=Text.Length, ElementName=textBox1,Converter={StaticResource lenghtToDescriptionConverter}}" Foreground="#F0867878" FontSize="10" BorderBrush="Black"
                Background="{Binding Path=Text.Length, ElementName=textBox1,Converter={StaticResource lenghtToBackgroundConverter}}"/>-->
        <Label  Height="21" Margin="12,0" Name="label1" VerticalAlignment="Bottom" Content="{Binding  Path=Text.Length, ElementName=textBox1,Converter={StaticResource lenghtToDescriptionConverter}}" Foreground="#F0867878" FontSize="10" BorderBrush="Black"
                Background="{Binding Path=Text.Length, ElementName=textBox1,Converter={StaticResource lenghtToBackgroundConverter}}"/>
        <TextBox Background="Transparent" Height="28" Margin="12,37,59,0" Name="textBox2" VerticalAlignment="Top" TextChanged="textBox2_TextChanged">
            
        </TextBox>
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                <GradientStop Color="#FFD9D9D9" Offset="0"/>
                <GradientStop Color="White" Offset="1"/>
            </LinearGradientBrush>
        </Grid.Background>
    </Grid>
</Window>
