<styles:WindowChromeBase x:Class="_1RM.View.Utils.AlternateAddressSwitchingView"
                  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:utils="clr-namespace:_1RM.View.Utils"
                  xmlns:styles="clr-namespace:Shawn.Utils.WpfResources.Theme.Styles;assembly=Shawn.Utils.WpfResources"
                  xmlns:attachProperty="clr-namespace:Shawn.Utils.WpfResources.Theme.AttachProperty;assembly=Shawn.Utils.WpfResources"
                  mc:Ignorable="d"
                  d:DataContext="{d:DesignInstance utils:AlternateAddressSwitchingViewModel}"
                  ResizeMode="NoResize"
                  WindowStyle="None"
                  Background="Transparent"
                  AllowsTransparency="True"
                  ShowInTaskbar="False"
                  Topmost="True"
                  Width="250" Height="120">
    <Grid Background="Transparent">
        <Border Margin="1"
                CornerRadius="{StaticResource DefaultCornerRadius}" 
                BorderBrush="{DynamicResource BackgroundTextBrush}"
                BorderThickness="1"
                SnapsToDevicePixels="True"
                ClipToBounds="True"
                Background="{DynamicResource PrimaryMidBrush}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>

                <!-- System Button Area -->
                <Grid Grid.Row="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Grid Background="Transparent" Width="12" Height="12" Margin="2 0">
                            <Image Source="/Resources/Image/Logo/logo32.png"></Image>
                        </Grid>
                    <TextBlock Grid.Column="1" VerticalAlignment="Center" 
                               FontWeight="Bold"
                               TextTrimming="CharacterEllipsis"
                               Foreground="{DynamicResource PrimaryTextBrush}" 
                               Text="{Binding Title}" />
                    <TextBlock Grid.Column="2" VerticalAlignment="Center" Margin="5 0" 
                               Foreground="{DynamicResource PrimaryTextBrush}" 
                               Visibility="{Binding Eta, Converter={StaticResource ConverterEqual2Collapsed}, ConverterParameter=0}"
                               Text="{Binding Eta, StringFormat={}0s}" />

                    <Button Grid.Column="3" Style="{StaticResource ButtonBarPrimaryStyle}"
                            Command="{Binding CmdCloseContinue}"
                            Width="20" Height="20">
                        <Rectangle Width="8" Height="1" Stroke="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" StrokeThickness="0.5" />
                    </Button>

                    <Button Grid.Column="4" Width="20" Height="20"
                            Command="{Binding CmdCloseEnd}"
                            Style="{StaticResource ButtonBarPrimaryStyle}"
                            attachProperty:VisionElement.ForegroundAccent="White"
                            attachProperty:VisionElement.BackgroundAccent="Red"
                            attachProperty:VisionElement.ForegroundOnMouseDown="White"
                            attachProperty:VisionElement.BackgroundOnMouseDown="Red">
                        <Path Margin="7"
                              StrokeThickness="0.5" 
                              VerticalAlignment="Center"
                              HorizontalAlignment="Center"
                              Stroke="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}"
                              Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}"
                              Data="{StaticResource GeometryCloseCross}"
                              Stretch="Uniform">
                        </Path>
                    </Button>
                </Grid>

                <Grid Grid.Row="1"
                      Visibility="{Binding Message, Converter={StaticResource ConverterEqual2Collapsed}, ConverterParameter=''}">
                    <TextBlock VerticalAlignment="Center" 
                               FontSize="{DynamicResource GlobalFontSizeSubtitle}"
                               FontWeight="Bold" HorizontalAlignment="Center" Margin="10 5"
                               TextWrapping="WrapWithOverflow"
                               TextTrimming="CharacterEllipsis"
                               Foreground="Red" 
                               Text="{Binding Message}" >
                    </TextBlock>
                </Grid>

                <ItemsControl Grid.Row="2" ItemsSource="{Binding PingTestItems}">
                    <ItemsControl.Template>
                        <ControlTemplate>
                            <ScrollViewer x:Name="ScrollViewer" Padding="{TemplateBinding Padding}" Grid.IsSharedSizeScope="True">
                                <ItemsPresenter />
                            </ScrollViewer>
                        </ControlTemplate>
                    </ItemsControl.Template>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="0 5 10 0" Background="Transparent">
                                <Grid.Style>
                                    <Style TargetType="Grid">
                                        <Setter Property="Opacity" Value="0.6"></Setter>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Success}">
                                                <Setter Property="Opacity" Value="1"></Setter>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Failed}">
                                                <Setter Property="Opacity" Value="0.8"></Setter>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Canceled}">
                                                <Setter Property="Opacity" Value="0.1"></Setter>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Grid.Style>

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="80"></ColumnDefinition>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                    <ColumnDefinition Width="20"></ColumnDefinition>
                                </Grid.ColumnDefinitions>

                                <TextBlock Text="{Binding Name}"
                                           ToolTip="{Binding Name}"
                                           TextTrimming="CharacterEllipsis"
                                           Margin="5 0 0 0">
                                    <TextBlock.Style>
                                        <Style TargetType="TextBlock" BasedOn="{StaticResource TextBlockBase}">
                                            <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Success}">
                                                    <Setter Property="Foreground" Value="Green"></Setter>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Failed}">
                                                    <Setter Property="Foreground" Value="Red"></Setter>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>

                                <TextBlock Grid.Column="1" Text="{Binding Address}"
                                           TextTrimming="CharacterEllipsis"
                                           ToolTip="{Binding Address}"
                                           Margin="5 0">
                                    <TextBlock.Style>
                                        <Style TargetType="TextBlock" BasedOn="{StaticResource TextBlockBase}">
                                            <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Success}">
                                                    <Setter Property="Foreground" Value="Green"></Setter>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Failed}">
                                                    <Setter Property="Foreground" Value="Red"></Setter>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>

                                <TextBlock Grid.Column="1" Text="{Binding Ping, StringFormat={}  0ms}"
                                           Opacity="0.8" FontSize="{DynamicResource GlobalFontSizeSmall}" 
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Right"
                                           Background="{DynamicResource PrimaryMidBrush}"
                                           Foreground="{DynamicResource PrimaryTextBrush}">
                                    <TextBlock.Style>
                                        <Style TargetType="TextBlock" BasedOn="{StaticResource TextBlockBase}">
                                            <Setter Property="Visibility" Value="Collapsed"></Setter>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Success}">
                                                    <Setter Property="Visibility" Value="Visible"></Setter>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>

                                <Grid Grid.Column="2" Height="16" Width="16" Background="Transparent" ToolTip="{Binding Status}">
                                    <Path Height="12" Width="12" UseLayoutRounding="True" Stretch="Uniform">
                                        <Path.Style>
                                            <Style TargetType="Path">
                                                <Setter Property="Height" Value="12"></Setter>
                                                <Setter Property="Width" Value="12"></Setter>
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.None}">
                                                        <Setter Property="Visibility" Value="Collapsed"></Setter>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Success}">
                                                        <Setter Property="Data" Value="{StaticResource GeometryHook}"></Setter>
                                                        <Setter Property="Fill" Value="Green"></Setter>
                                                        <Setter Property="Stroke" Value="Green"></Setter>
                                                        <Setter Property="ToolTip" Value="Success"></Setter>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Pinging}">
                                                        <Setter Property="Data" Value="{StaticResource GeometrySandClock}"></Setter>
                                                        <Setter Property="Fill" Value="{DynamicResource PrimaryTextBrush}"></Setter>
                                                        <Setter Property="Stroke" Value="{DynamicResource PrimaryTextBrush}"></Setter>
                                                        <Setter Property="Opacity" Value="0.5"></Setter>
                                                        <Setter Property="ToolTip" Value="Pinging"></Setter>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Failed}">
                                                        <Setter Property="Data" Value="{StaticResource GeometryCloseCross}"></Setter>
                                                        <Setter Property="Fill" Value="Red"></Setter>
                                                        <Setter Property="Stroke" Value="Red"></Setter>
                                                        <Setter Property="ToolTip" Value="Failed"></Setter>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Status}" Value="{x:Static utils:PingStatus.Canceled}">
                                                        <Setter Property="Data" Value="{StaticResource GeometrySandClock}"></Setter>
                                                        <Setter Property="Fill" Value="{DynamicResource PrimaryTextBrush}"></Setter>
                                                        <!--<Setter Property="Opacity" Value="0.3"></Setter>-->
                                                        <Setter Property="ToolTip" Value="Canceled"></Setter>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Path.Style>
                                    </Path>
                                </Grid>
                            </Grid>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>
        </Border>
    </Grid>
</styles:WindowChromeBase>