<UserControl x:Class="StartServerWPF.Modules.Main.Views.SetParamView"
             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:i="http://schemas.microsoft.com/xaml/behaviors"
             xmlns:prism="http://prismlibrary.com/" 
             xmlns:hc="https://handyorg.github.io/handycontrol"
             prism:ViewModelLocator.AutoWireViewModel="True"
             mc:Ignorable="d" Background="#FFEEF1F3"
             d:DesignHeight="600" d:DesignWidth="900">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>

            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="60"/>
            <RowDefinition Height="4*"/>
        </Grid.RowDefinitions>
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Loaded">
                <i:InvokeCommandAction Command="{Binding Path=LoadedCommand}"/>
            </i:EventTrigger>
            <!--<i:EventTrigger EventName="Unloaded">
                <i:InvokeCommandAction Command="{Binding Path=UnloadedCommand}"/>
            </i:EventTrigger>-->
        </i:Interaction.Triggers>
        <Border Background="White">
            <TextBlock Text="{Binding Title}" FontSize="16" FontWeight="Bold" VerticalAlignment="Center"  Margin="10,0,10,0"/>
        </Border>
        <Border Background="White"  Grid.Row="1" CornerRadius="5" Margin="10">
            <Grid Margin="10">
                <Grid.RowDefinitions>
                    <RowDefinition  Height="1*" />
                    <RowDefinition  Height="auto" />
                    <RowDefinition  Height="150" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="10"/>
                    <ColumnDefinition />
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Border  Grid.Row="0">
                    <UniformGrid Columns="1">
                        <TextBlock Text="实时处理配置" Background="Black" Foreground="White" VerticalAlignment="Top" Height="30" FontSize="18"/>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="工区名称:" Width="65" VerticalAlignment="Center"/>
                            <Button Content="删除" Background="#FFA6783E" Foreground="White" Command="{Binding DeleteItemCommand}" DockPanel.Dock="Right"/>
                            <ComboBox  ItemsSource="{Binding WorkareaNameSource}" SelectedIndex="{Binding WareaSelectedIndex}" DockPanel.Dock="Right"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="工区路径:"  Width="65" VerticalAlignment="Center"/>
                            <Button Content="..." DockPanel.Dock="Right" Command="{Binding FilePathSaveCommand}" CommandParameter="savepath" Background="#FF0ABEFF"/>
                            <TextBox DockPanel.Dock="Left" Text="{Binding  WareaModel.savepath}" IsReadOnly="True"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="station:"  Width="65" VerticalAlignment="Center"/>
                            <Button Content="..." DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="apmsStation" Background="#FF0ABEFF"/>
                            <TextBox DockPanel.Dock="Left" Text="{Binding  WareaModel.apmModel.station}" IsReadOnly="True"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="ttime2d:"  Width="65" VerticalAlignment="Center"/>
                            <Button Content="..." DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="apmsttime2d" Background="#FF0ABEFF"/>
                            <TextBox DockPanel.Dock="Left" Text="{Binding WareaModel.apmModel.ttime[0].ttime2d}" IsReadOnly="True"/>
                        </DockPanel>
                        <StackPanel VerticalAlignment="Center" Orientation="Horizontal">
                            <TextBlock Text="波形路径:" Width="65" VerticalAlignment="Center"/>
                            <TextBox  Width="100" Text="{Binding  WareaModel.chartsavepath}"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal"  VerticalAlignment="Center">
                            <TextBlock Text="实时路径:    "   VerticalAlignment="Center"/>
                            <TextBox  Width="100" Text="{Binding  WareaModel.apmsavepath}"/>
                            <TextBlock Text="实时微信通知:"  Width="90" VerticalAlignment="Center"/>
                            <CheckBox IsChecked="{Binding WareaModel.apmpush2wx}"/>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                            <TextBlock Text="后处理路径:"   Width="65" VerticalAlignment="Center"/>
                            <TextBox DockPanel.Dock="Left" Width="100" Text="{Binding  WareaModel.toolsavepath}"/>
                            <TextBlock Text="后得理微信通知:" Width="90" VerticalAlignment="Center"/>
                            <CheckBox IsChecked="{Binding WareaModel.toolpush2wx}"/>
                        </StackPanel>

                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="延时时间(min):"  VerticalAlignment="Center"/>
                            <hc:NumericUpDown  Value="{Binding WareaModel.delayTime}" Width="70" HorizontalAlignment="Left"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="network:" VerticalAlignment="Center"/>
                            <TextBox Text="{Binding WareaModel.StationConfig.Network}" IsReadOnly="True"/>
                            <TextBlock Text="location:" VerticalAlignment="Center"/>
                            <TextBox Text="{Binding WareaModel.StationConfig.Location}" IsReadOnly="True"/>
                            <TextBlock Text="channels:" VerticalAlignment="Center"/>
                            <TextBox Text="{Binding WareaModel.StationConfig.Channels}" IsReadOnly="True"/>
                        </DockPanel>
                    </UniformGrid>
                </Border>
                <GroupBox Grid.Row="1" Grid.Column="0" Header="台站配置" Style="{StaticResource  BaseStyle}">
                    <ListBox ItemsSource="{Binding WareaModel.StationConfig.Stations}">
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel>
                                </WrapPanel>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Border CornerRadius="5"
                                        BorderThickness="1">
                                    <Grid>
                                        <CheckBox IsChecked="{Binding IsEnable}" Content="{Binding Name}"/>
                                    </Grid>
                                </Border>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </GroupBox>
                <GroupBox Grid.Row="2" Grid.Column="0" Header="工区配置" Style="{StaticResource  BaseStyle}">
                    <UniformGrid Columns="2">
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="xmin: " VerticalAlignment="Center"/>
                            <TextBox Text="{Binding WareaModel.apmModel.xmin}"/>
                        </DockPanel>
                        <DockPanel Margin="10,0,0,0" VerticalAlignment="Center">
                            <TextBlock Text="xmax: " VerticalAlignment="Center"/>
                            <TextBox Text="{Binding WareaModel.apmModel.xmax}"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="ymin: " VerticalAlignment="Center"/>
                            <TextBox Text="{Binding WareaModel.apmModel.ymin}"/>
                        </DockPanel>
                        <DockPanel Margin="10,0,0,0" VerticalAlignment="Center">
                            <TextBlock Text="ymax: " VerticalAlignment="Center"/>
                            <TextBox Text="{Binding WareaModel.apmModel.ymax}"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="zmin: " VerticalAlignment="Center"/>
                            <TextBox Text="{Binding WareaModel.apmModel.zmin}"/>
                        </DockPanel>
                        <DockPanel Margin="10,0,0,0" VerticalAlignment="Center">
                            <TextBlock Text="zmax: " VerticalAlignment="Center"/>
                            <TextBox Text="{Binding WareaModel.apmModel.zmax}"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text=" zref: " VerticalAlignment="Center" />
                            <TextBox Text="{Binding WareaModel.apmModel.zref}"/>
                        </DockPanel>
                        <DockPanel Margin="10,0,0,0" VerticalAlignment="Center">
                            <TextBlock Text=" step: " VerticalAlignment="Center"/>
                            <TextBox Text="{Binding WareaModel.apmModel.minstep}"/>
                        </DockPanel>
                    </UniformGrid>
                </GroupBox>

                <Border  Grid.Row="0" Grid.Column="2" Margin="20,0,10,0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="1*"/>
                            <RowDefinition Height="1*"/>
                            <RowDefinition Height="1*"/>
                            <RowDefinition Height="1*"/>
                            <RowDefinition Height="1*"/>
                            <RowDefinition Height="1*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="70"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="30"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="系统配置" Background="Black" Foreground="White" VerticalAlignment="Top" Height="30" FontSize="18" Grid.ColumnSpan="3" />
                        <TextBlock Text="IP地址："  Grid.Row="1" Grid.Column="0" VerticalAlignment="Top" Margin="0,14,0,0" />
                        <TextBox Text="{Binding MainModel.VpnIP}"  Grid.Row="1" Grid.Column="1" VerticalAlignment="Top" Margin="0,7,0,0" />
                        <TextBlock Text="VPN名称：" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" />
                        <TextBox Text="{Binding MainModel.VpnName}" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center"  />
                        <TextBlock Text="用户名：" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" />
                        <TextBox Text="{Binding MainModel.VpnPsw}" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" />
                        <TextBlock Text="密码："   Grid.Row="4" Grid.Column="0"  VerticalAlignment="Center" />
                        <TextBox Text="{Binding MainModel.VpnPsw}"  Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" />

                        <TextBlock Text="日志路径："  Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" />
                        <TextBox Text="{Binding MainModel.SystemLogPath}"  IsReadOnly="True"  Grid.Row="5" Grid.Column="1" VerticalAlignment="Center" />
                        <Button Content="..." Command="{Binding LogPathSaveCommand}"  Grid.Row="5" Grid.Column="2" Background="#FF0ABEFF"/>
                    </Grid>
                </Border>
                <StackPanel Grid.Row="3" Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" Visibility="Collapsed">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
                        <!--<TextBlock>
                        <Run Text="监控日期："/>
                        <Run Text="{Binding MoniTime,StringFormat=yyyy-MM-dd HH:mm:ss}"/>
                        </TextBlock>-->
                        <Image Name="tb_calendar_img" Source="/Images/calendar.png" Grid.Column="1" Width="18" Height="18" Margin="0,0,0,0"  PreviewMouseLeftButtonUp="tb_calendar_img_MouseLeftButtonUp"/>
                    </StackPanel>
                    <!--<Popup x:Name="Pop" PopupAnimation="None"  Width="200" Height="210" PlacementTarget="{Binding ElementName=tb_calendar}" Placement="Bottom"  AllowsTransparency="True" StaysOpen="False" VerticalAlignment="Top" Margin="-200,0,0,0">
                        <Calendar Name="calendar" SelectedDate="{Binding MoniTime}" HorizontalAlignment="Left" Margin="0,44,0,0" VerticalAlignment="Top" />
                    </Popup>-->
                </StackPanel>
                <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center" Grid.Row="3"  Grid.Column="2" Margin="0,0,0,30">
                    <Button Content="添加工区" Width="80" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding AddItemCommand}"/>
                    <Button Content="导入工区" Width="80" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding ImportCommand}" Margin="20,0,20,0"/>
                    <Button Content="保存"  Width="80" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding ConfirmCommand}"/>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</UserControl>
