<UserControl
    x:Class="Txgy.EWS.Client.PageModule.Views.TitleView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:comm="clr-namespace:Txgy.EWS.Client.Common;assembly=Txgy.EWS.Client.Common"
    xmlns:controls="clr-namespace:Txgy.Controls;assembly=Txgy.Controls"
    xmlns:converter="clr-namespace:Txgy.EWS.Client.Common.Converters;assembly=Txgy.EWS.Client.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:global="clr-namespace:Txgy.EWS.Client.Common;assembly=Txgy.EWS.Client.Common"
    xmlns:local="clr-namespace:Txgy.EWS.Client.PageModule.Views"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="http://prismlibrary.com/"
    d:DesignHeight="100"
    d:DesignWidth="1530"
    prism:ViewModelLocator.AutoWireViewModel="True"
    mc:Ignorable="d">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.DataGrid.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <converter:DateTime2StringConverter x:Key="time2String" />
            <converter:String2ColorConverter x:Key="s2c" />
            <Style x:Key="LinkButton" TargetType="Button">
                <Setter Property="Width" Value="Auto" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <ContentPresenter
                                VerticalAlignment="Center"
                                Content="{TemplateBinding Content}"
                                ContentTemplate="{TemplateBinding ContentTemplate}">
                                <ContentPresenter.Resources>
                                    <Style TargetType="{x:Type TextBlock}">
                                        <Setter Property="TextDecorations" Value="Underline" />
                                    </Style>
                                </ContentPresenter.Resources>
                            </ContentPresenter>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="Foreground" Value="Blue" />
                <Setter Property="Cursor" Value="Hand" />
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter Property="Foreground" Value="Red" />
                    </Trigger>
                </Style.Triggers>
            </Style>
            <Style x:Key="blueText" TargetType="TextBlock">
                <Setter Property="Foreground" Value="#FF7A40F2" />
            </Style>
            <ControlTemplate x:Key="StateButtonTemplate" TargetType="ToggleButton">
                <Border
                    Name="back"
                    Width="102"
                    Height="30"
                    Background="#EEE"
                    BorderBrush="#99EEEEEE"
                    BorderThickness="0"
                    CornerRadius="3">
                    <Border.Effect>
                        <BlurEffect Radius="1" />
                    </Border.Effect>
                    <Grid>
                        <TextBlock
                            Margin="8,0"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center"
                            FontSize="16"
                            Foreground="#667A40F2"
                            Text="停止" />
                        <TextBlock
                            Margin="4,0"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            FontSize="16"
                            Foreground="#FF7A40F2"
                            Text="运行中" />
                        <Border
                            Width="48"
                            Margin="2,2"
                            HorizontalAlignment="Left"
                            Background="#DDD"
                            CornerRadius="2">
                            <TextBlock
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                FontSize="16"
                                Foreground="#FF673Ab7"
                                Text="||" />
                            <Border.RenderTransform>
                                <TranslateTransform x:Name="tt" X="48" />
                            </Border.RenderTransform>
                        </Border>
                    </Grid>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsChecked" Value="True">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="tt"
                                        Storyboard.TargetProperty="X"
                                        To="0"
                                        Duration="0:0:0.2" />
                                </Storyboard>
                            </BeginStoryboard>
                            <BeginStoryboard>
                                <Storyboard>
                                    <ColorAnimation
                                        AutoReverse="True"
                                        RepeatBehavior="Forever"
                                        Storyboard.TargetName="back"
                                        Storyboard.TargetProperty="Background.(SolidColorBrush.Color)"
                                        To="Orange"
                                        Duration="0:0:2" />
                                    <!--<DoubleAnimation To="10"
                                    RepeatBehavior="Forever"
                                    AutoReverse="True"
                                    Duration="0:0:2"
                                    Storyboard.TargetName="back"
                                    Storyboard.TargetProperty="Effect.(BlurEffect.Radius)" />-->
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                        <Trigger.ExitActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="tt"
                                        Storyboard.TargetProperty="X"
                                        Duration="0:0:0.2" />
                                    <ColorAnimation
                                        Storyboard.TargetName="back"
                                        Storyboard.TargetProperty="Background.(SolidColorBrush.Color)"
                                        Duration="0:0:0.2" />
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.ExitActions>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
            <DataTrigger
                x:Key="newAlarm"
                Binding="{Binding RunEventCnt}"
                Value="2">
                <DataTrigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <MediaTimeline Source="" />

                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.EnterActions>
            </DataTrigger>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="350" MinWidth="350" />
            <ColumnDefinition MinWidth="160" />
            <ColumnDefinition Width="480" MinWidth="480" />
        </Grid.ColumnDefinitions>
        <controls:CalendarClock2row
            Height="68"
            HorizontalAlignment="Center"
            ForegroundColor="Black" />
        <StackPanel
            Grid.Column="1"
            HorizontalAlignment="Center"
            VerticalAlignment="Center">
            <TextBlock
                d:Text="煤矿动力灾害微地震实时预警系统"
                FontSize="34"
                Text="{Binding Path=(global:GlobalConfig.SystemNameCN)}" />
            <TextBlock
                HorizontalAlignment="Center"
                d:Text="Microseismic Real-time Monitoring System"
                FontSize="24"
                Text="{Binding Path=(global:GlobalConfig.SystemNameEN)}" />
        </StackPanel>
        <Grid Grid.Column="2" Height="68">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal">
                <TextBlock
                    VerticalAlignment="Center"
                    FontSize="18"
                    Text="运行时长：" />
                <TextBlock
                    VerticalAlignment="Center"
                    d:Text="1天22小时15分20秒"
                    FontSize="18"
                    Text="{Binding RunSpan}" />
            </StackPanel>
            <StackPanel Grid.Row="1" Orientation="Horizontal">
                <StackPanel Orientation="Horizontal">
                    <TextBlock
                        VerticalAlignment="Center"
                        FontSize="14"
                        Text="事件数量：" />
                    <TextBlock
                        VerticalAlignment="Center"
                        d:Text="10000"
                        FontSize="18"
                        FontWeight="Bold"
                        Foreground="Blue"
                        Text="{Binding ReceivedEventCount}" />
                </StackPanel>
                <StackPanel Margin="10,0,0,0" Orientation="Horizontal">
                    <TextBlock
                        VerticalAlignment="Center"
                        FontSize="14"
                        Text="预警数量：" />
                    <TextBlock
                        VerticalAlignment="Center"
                        d:Text="10000"
                        FontSize="18"
                        FontWeight="Bold"
                        Foreground="Blue"
                        Text="{Binding AlarmedEventCount}" />
                </StackPanel>
                <StackPanel Margin="10,0,0,0" Orientation="Horizontal">
                    <TextBlock
                        VerticalAlignment="Center"
                        FontSize="14"
                        Text="数据时长：" />
                    <TextBlock
                        VerticalAlignment="Center"
                        d:Text="24小时"
                        FontSize="18"
                        FontWeight="Bold"
                        Foreground="Blue"
                        Text="{Binding Path=(comm:GlobalConfig.DataLookbackHours), StringFormat={}{0:0.##}小时}" />
                </StackPanel>
            </StackPanel>
            <Button
                Grid.Column="1"
                Margin="0,0,5,0"
                HorizontalAlignment="Right"
                Content="设置"
                Visibility="Collapsed" />
            <!--<ToggleButton Grid.Row="1"
            Grid.Column="1"
            Width="80" />-->
            <StackPanel
                Grid.Row="1"
                Grid.Column="1"
                Margin="0,0,20,0"
                HorizontalAlignment="Right"
                Orientation="Horizontal">
                <!--<TextBlock VerticalAlignment="Center"
                Text="运行状态:" />-->
                <ToggleButton
                    Margin="10,0,0,0"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Command="{Binding StartMonitoringCommand}"
                    IsChecked="{Binding Path=(comm:GlobalData.IsRunning), Mode=TwoWay}"
                    Template="{StaticResource StateButtonTemplate}">
                    <ToggleButton.Effect>
                        <BlurEffect Radius="1" />
                    </ToggleButton.Effect>
                </ToggleButton>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
