<UserControl x:Class="Txgy.EWS.Client.PageModule.Views.EventListViewBak"
             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:local="clr-namespace:Txgy.EWS.Client.PageModule.Views"
             xmlns:converter="clr-namespace:Txgy.EWS.Client.Common.Converters;assembly=Txgy.EWS.Client.Common"
             xmlns:prism="http://prismlibrary.com/"
             xmlns:hc="https://handyorg.github.io/handycontrol"
             xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:txc="clr-namespace:Txgy.Controls;assembly=Txgy.Controls"
             xmlns:comm="clr-namespace:Txgy.EWS.Client.Common;assembly=Txgy.EWS.Client.Common"
             xmlns:controls="clr-namespace:Txgy.Controls;assembly=Txgy.Controls"
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
             prism:ViewModelLocator.AutoWireViewModel="True"
             d:DesignHeight="1000"
             d:DesignWidth="800"
             Foreground="#FF673Ab7"
             FontSize="14"
             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"
                        BorderBrush="#99EEEEEE"
                        BorderThickness="0"
                        CornerRadius="3"
                        Background="#EEE">
                    <Border.Effect>
                        <BlurEffect Radius="1" />
                    </Border.Effect>
                    <Grid>
                        <TextBlock Margin="8,0"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   Text="停止"
                                   FontSize="16"
                                   Foreground="#667A40F2" />
                        <TextBlock Margin="4,0"
                                   HorizontalAlignment="Right"
                                   VerticalAlignment="Center"
                                   Text="运行中"
                                   FontSize="16"
                                   Foreground="#FF7A40F2" />
                        <Border Width="48"
                                Margin="2,2"
                                HorizontalAlignment="Left"
                                Background="#DDD"
                                CornerRadius="2">
                            <TextBlock HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       Text="||"
                                       FontSize="16"
                                       Foreground="#FF673Ab7" />
                            <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 RepeatBehavior="Forever"
                                                    AutoReverse="True"
                                                    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>
            <!--<Style x:Key="runStateStyle"
                   TargetType="hc:Badge">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=(comm:GlobalData.IsRunning)}"
                                 Value="True">
                        <DataTrigger.EnterActions>
                            <BeginStoryboard >
                                <Storyboard>
                                    <DoubleAnimation To="10"
                                                     RepeatBehavior="Forever"
                                                     AutoReverse="True"
                                                     Duration="0:0:2"
                                                     Storyboard.TargetProperty="hc:Badge.(Effect).(BlurEffect.Radius)">
                                    </DoubleAnimation>
            -->
            <!--<ColorAnimation To="Blue"
                                Duration="0:0:4"
                                Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" />-->
            <!--
                                </Storyboard>
                            </BeginStoryboard>
                        </DataTrigger.EnterActions>
                        <DataTrigger.ExitActions>

                        </DataTrigger.ExitActions>
                    </DataTrigger>
                </Style.Triggers>
            </Style>-->
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="100" MinHeight="100" />
            <RowDefinition Height="100" MinHeight="100" />
            <RowDefinition Height="120" MinHeight="120" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <!-- 时间模块 -->
        <!--<md:Card Margin="5"
                 UniformCornerRadius="5"
                 Background="White">
            <StackPanel Width="440">
                <controls:CalendarClock ForegroundColor="#FF673Ab7" />
            </StackPanel>
        </md:Card>-->
        <!-- 监测模块 -->
        <md:Card Grid.Row="1"
                 Margin="5"
                 UniformCornerRadius="5"
                 Background="White">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="210" MinWidth="210" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="100" MinWidth="100" />
                </Grid.ColumnDefinitions>
                <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
                    <TextBlock VerticalAlignment="Center" Text="运行状态:" />
                    <ToggleButton Margin="10,0,0,0"
                                  HorizontalAlignment="Center"
                                  VerticalAlignment="Center"
                                  IsChecked="{Binding Path=(comm:GlobalData.IsRunning), Mode=TwoWay}"
                                  Command="{Binding StartMonitoringCommand}"
                                  Template="{StaticResource StateButtonTemplate}">
                        <ToggleButton.Effect>
                            <BlurEffect Radius="1" />
                        </ToggleButton.Effect>
                    </ToggleButton>
                </StackPanel>

                <StackPanel Grid.Column="1" VerticalAlignment="Center">
                    <StackPanel Margin="20,5" Orientation="Horizontal">
                        <TextBlock VerticalAlignment="Center"
                                   Text="运行时长："
                                   FontSize="14" />
                        <TextBlock x:Name="tbRunSpan"
                                   VerticalAlignment="Center"
                                   Text="{Binding RunSpan}"
                                   FontSize="14" />
                    </StackPanel>
                    <StackPanel Margin="20,5" Orientation="Horizontal">
                        <TextBlock VerticalAlignment="Center"
                                   Text="事件数量："
                                   FontSize="14" />
                        <TextBlock x:Name="tbEventCount"
                                   VerticalAlignment="Center"
                                   Text="{Binding RunEventCnt}"
                                   FontSize="14" />
                        <Button Content="测试"
                                Command="{Binding ChangeMusicCommand}"
                                Visibility="Hidden">
                        </Button>
                    </StackPanel>
                </StackPanel>

                <StackPanel Grid.Column="2"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Top">
                    <Grid>
                        <Ellipse x:Name="WarningStat"
                                 Width="60"
                                 Height="60"
                                 Margin="0,20,0,0"
                                 d:Fill="Yellow"
                                 Fill="{Binding CurAlarmLevel.ColorStr, Converter={StaticResource s2c}}">
                            <Ellipse.Effect>
                                <BlurEffect Radius="1" />
                            </Ellipse.Effect>
                        </Ellipse>
                        <TextBlock Margin="5,35,0,0"
                                   d:Foreground="Blue"
                                   Text="警告等级"
                                   Foreground="White"
                                   FontSize="12" />
                        <TextBlock Margin="24,50,0,0"
                                   d:Foreground="Blue"
                                   Text="{Binding CurAlarmLevel.Level}"
                                   Foreground="White"
                                   FontSize="20" />
                    </Grid>
                    <!--<hc:Badge hc:BackgroundSwitchElement.MouseHoverBackground="#FF673Ab7"
                              BadgeMargin="0,10,0,0"
                              Style="{StaticResource BadgeDanger}"
                              Foreground="#FF673Ab7"
                              >
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="MouseDoubleClick">
                                <i:InvokeCommandAction Command="{Binding}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <Grid>
                            <Ellipse x:Name="WarningStat"
                                     Width="60"
                                     Height="60"
                                     Margin="0,20,0,0"
                                     d:Fill="Yellow"
                                     Fill="{Binding CurAlarmLevel.ColorStr, Converter={StaticResource s2c}}">
                                <Ellipse.Effect>
                                    <BlurEffect Radius="1" />
                                </Ellipse.Effect>
                            </Ellipse>
                            <TextBlock Margin="5,35,0,0"
                                       d:Foreground="Blue"
                                       Text="警告等级"
                                       Foreground="White"
                                       FontSize="12" />
                            <TextBlock Margin="24,50,0,0"
                                       d:Foreground="Blue"
                                       Text="{Binding CurAlarmLevel.Level}"
                                       Foreground="White"
                                       FontSize="20" />
                        </Grid>

                    </hc:Badge>-->
                </StackPanel>
            </Grid>
        </md:Card>
        <!-- 查询控制 -->
        <md:Card Grid.Row="2"
                 Margin="5"
                 UniformCornerRadius="5"
                 Background="White">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition Width="82" MinWidth="82" />
                    <ColumnDefinition Width="150" MinWidth="150" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="50" />
                    <RowDefinition Height="50" />
                </Grid.RowDefinitions>
                <StackPanel Grid.ColumnSpan="4"
                            Margin="10,0,0,0"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center"
                            Orientation="Horizontal">
                    <TextBlock HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               Text="起始时间:" />
                    <hc:DateTimePicker x:Name="dpStartTime"
                                       Width="164"
                                       Height="40"
                                       Margin="10,0,0,0"
                                       FontSize="12"
                                       Foreground="#FF673Ab7"
                                       SelectedDateTime="{Binding StartTime, Mode=TwoWay}" />

                    <TextBlock Grid.Column="2"
                               Margin="20,0,0,0"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               Text="结束时间:" />
                    <hc:DateTimePicker x:Name="dpEndTime"
                                       Grid.Column="3"
                                       Width="164"
                                       Height="40"
                                       Margin="10,0,0,0"
                                       FontSize="12"
                                       Foreground="#FF673Ab7"
                                       SelectedDateTime="{Binding EndTime, Mode=TwoWay}" />
                </StackPanel>

                <StackPanel Grid.Row="1"
                            Margin="5,0,0,0"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center"
                            Orientation="Horizontal">
                    <TextBlock VerticalAlignment="Center"
                               Text="最大震级:"
                               FontSize="14" />
                    <hc:NumericUpDown Width="78"
                                      Margin="5"
                                      VerticalAlignment="Center"
                                      FontSize="12"
                                      Foreground="#FF673Ab7"
                                      DecimalPlaces="2"
                                      Increment="0.1"
                                      Maximum="0"
                                      Minimum="-3.0"
                                      Value="{Binding SearchMaxML}" />
                </StackPanel>
                <StackPanel Grid.Row="1"
                            Grid.Column="1"
                            Margin="0,0,0,0"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center"
                            Orientation="Horizontal">
                    <TextBlock Margin="5"
                               VerticalAlignment="Center"
                               Text="最小震级:"
                               FontSize="14" />
                    <hc:NumericUpDown Width="78"
                                      Margin="5"
                                      VerticalAlignment="Center"
                                      FontSize="12"
                                      Foreground="#FF673Ab7"
                                      Increment="0.1"
                                      DecimalPlaces="2"
                                      Minimum="-3"
                                      Maximum="0"
                                      Value="{Binding SearchMinML}" />
                </StackPanel>
                <StackPanel Grid.Row="1"
                            Grid.Column="2"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center">
                    <Button x:Name="btnSelect"
                            FontSize="16"
                            Foreground="White"
                            Content="查询"
                            Style="{StaticResource MaterialDesignRaisedDarkButton}"
                            Command="{Binding SearchCommand}" />
                </StackPanel>
                <StackPanel Grid.Row="1"
                            Grid.Column="3"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Orientation="Horizontal">
                    <TextBlock Text="查询结果：" />
                    <TextBlock x:Name="tbSelectCount" Text="{Binding ResultCount}" />
                    <!-- Text="{Binding ResultCount}" -->
                </StackPanel>
            </Grid>
        </md:Card>
        <md:Card Grid.Row="3"
                 Margin="5"
                 UniformCornerRadius="5"
                 Background="White">

            <ListView Name="lvPatientList"
                      Margin="10"
                      ItemsSource="{Binding Path=(comm:GlobalData.SearchEvents)}"
                      SelectedItem="{Binding SelectGirdItem}">
                <!--<i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <prism:InvokeCommandAction Command="{Binding ProcessAlarmCommand}" CommandParameter="{Binding SelectedItems, ElementName=lvPatientList}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>-->
                <ListView.View>
                    <GridView>

                        <!--<GridViewColumn Width="60"
                                            Header="选择">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding IsSelected}" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>-->
                        <GridViewColumn Width="60"
                                        Header="ID"
                                        DisplayMemberBinding="{Binding EventID}" />
                        <GridViewColumn Width="190"
                                        Header="发震时刻"
                                        DisplayMemberBinding="{Binding EventTime}" />
                        <!--<GridViewColumn Width="150"
                                            Header="东"
                                            DisplayMemberBinding="{Binding Y, StringFormat=0.00}" />
                            <GridViewColumn Width="150"
                                            Header="北"
                                            DisplayMemberBinding="{Binding X, StringFormat=0.00}" />
                            <GridViewColumn Width="100"
                                            Header="海拔"
                                            DisplayMemberBinding="{Binding Z, StringFormat=0.00}" />-->
                        <GridViewColumn Width="100"
                                        Header="ML"
                                        DisplayMemberBinding="{Binding ML, StringFormat=0.00}" />
                        <GridViewColumn Width="100"
                                        Header="能量"
                                        DisplayMemberBinding="{Binding Energy}" />

                    </GridView>
                </ListView.View>
            </ListView>

            <!--<DataGrid x:Name="eventDataGrid"
                      HorizontalContentAlignment="Center"
                      hc:DataGridAttach.ShowRowNumber="True"
                      HeadersVisibility="All"
                      ItemsSource="{Binding MmEvents}"
                      AutoGenerateColumns="False">
                <DataGrid.Resources>
                    <comm:BindingProxy x:Key="BindingProxy"
                                       Data="{Binding}" />
                </DataGrid.Resources>
            -->
            <!--<DataGrid.ContextMenu>
                <ContextMenu Name="dgmenu1" StaysOpen="true">
                    <MenuItem Header="导出Excel"
                                      Command="{Binding Data.Output2ExcelCmd, Source={StaticResource BingdingProxy}}" />
                    <MenuItem Header="导出Index"
                                      Command="{Binding Data.Output2IndexCmd, Source={StaticResource BingdingProxy}}" />
                </ContextMenu>
            </DataGrid.ContextMenu>-->
            <!--

                <DataGrid.Columns>
            -->
            <!--<DataGridTemplateColumn Width="50">
                    <DataGridTemplateColumn.HeaderTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding DataContext.IsSelectAll,
                                        RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.HeaderTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding IsSelected, UpdateSourceTrigger=PropertyChanged}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>-->
            <!--

                    <DataGridCheckBoxColumn Binding="{Binding Selected, UpdateSourceTrigger=PropertyChanged}"
                                            EditingElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnEditingStyle}"
                                            ElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnStyle}">
                        <DataGridCheckBoxColumn.Header>
                            <Border Background="Transparent">
                                <CheckBox IsChecked="{Binding DataContext.IsSelectAll, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
                            </Border>
                        </DataGridCheckBoxColumn.Header>
                        <DataGridCheckBoxColumn.HeaderStyle>
                            <Style TargetType="{x:Type DataGridColumnHeader}"
                                   BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
                                <Setter Property="HorizontalContentAlignment"
                                        Value="Center" />
                            </Style>
                        </DataGridCheckBoxColumn.HeaderStyle>
                    </DataGridCheckBoxColumn>

                    <DataGridTemplateColumn Width="150"
                                            Header="发震时刻">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
            -->
            <!--<TextBlock Text="{Binding MmEvent.EventTime,StringFormat='yyyy-MM-dd HH:mm:ss'}" VerticalAlignment="Center"/>-->
            <!--
                                    <Button VerticalAlignment="Center"
                                            Content="{Binding MmEvent.EventTime, Converter={StaticResource time2String}}"
                                            Style="{DynamicResource LinkButton}"
                                            Command="{Binding DataContext.StatCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
                                            CommandParameter="{Binding ElementName=eventDataGrid, Path=SelectedIndex}" />
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Width="120"
                                        Header="X"
                                        Binding="{Binding MmEvent.X, StringFormat='{}{0:F1}'}"
                                        IsReadOnly="True" />
                    <DataGridTextColumn Width="120"
                                        Header="Y"
                                        Binding="{Binding MmEvent.Y, StringFormat='{}{0:F1}'}"
                                        IsReadOnly="True" />
                    <DataGridTextColumn Width="90"
                                        Header="Z"
                                        Binding="{Binding MmEvent.Z, StringFormat='{}{0:F1}'}"
                                        IsReadOnly="True" />
                    <DataGridTextColumn Width="80"
                                        Header="震级"
                                        Binding="{Binding MmEvent.ML, StringFormat='{}{0:F2}'}"
                                        IsReadOnly="True" />
                    <DataGridTextColumn Width="80"
                                        Header="能量"
                                        Binding="{Binding MmEvent.Energy, StringFormat='{}{0:F1}'}"
                                        IsReadOnly="True" />
            -->
            <!--<DataGridTextColumn Width="80" Header="主频" Binding="{Binding MmEvent.ML,StringFormat='{}{0:F1}'}" IsReadOnly="True"/>
                <DataGridTextColumn Width="80" Header="应力降" Binding="{Binding MmEvent.ML,StringFormat='{}{0:F1}'}" IsReadOnly="True"/>-->
            <!--
                </DataGrid.Columns>
            </DataGrid>-->
        </md:Card>
        <!--<Grid Grid.Row="4">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <CheckBox Margin="5"
                      Content="追加"
                      IsChecked="{Binding Path=(comm:GlobalData.AppendEvent), Mode=TwoWay}"
                      FontSize="18" />
            <hc:Pagination Grid.Column="1"
                           Margin="5"
                           HorizontalAlignment="Right"
                           VerticalAlignment="Center"
                           MaxPageCount="{Binding MaxPageCount, Mode=TwoWay, FallbackValue=5}"
                           MaxPageInterval="3"
                           IsJumpEnabled="True"
                           PageIndex="{Binding PageIndex, Mode=TwoWay}" />
        </Grid>-->
    </Grid>
</UserControl>
