MainWindow.xaml 4.51 KB
<Window x:Class="HHECS.DAQClient.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:HHECS.DAQClient"
        xmlns:hc="https://handyorg.github.io/handycontrol"
        mc:Ignorable="d"
        WindowStartupLocation="CenterScreen"
        xmlns:viewmodel="clr-namespace:HHECS.DAQClient.ViewModel"
        xmlns:model="clr-namespace:HHECS.DAQClient.Common"
        d:DataContext="{d:DesignInstance Type=viewmodel:MainVM}"
        Title="数据采集_HUAHENG" Height="600" Width="1024" MinWidth="800" MinHeight="450" WindowState="Maximized">
    <Window.Resources>
        <DataTemplate DataType="{x:Type model:LogModel}">
            <TextBlock Foreground="{Binding Path=ForeColor}" TextWrapping="Wrap">
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}[{0:yyyy/MM/dd HH:mm:ss}]{1}">
                        <Binding Path="CreateTime"/>
                        <Binding Path="Messages"/>
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="18"/>
        </Grid.RowDefinitions>
        <ToolBar Grid.Row="0" Grid.Column="0" VerticalAlignment="Stretch">
            <hc:UniformSpacingPanel Spacing="10">
                <Button x:Name="Btn_Start" Content="启动" IsEnabled="{Binding BtnStartEnabled}" Style="{StaticResource ButtonSuccess}" Command="{Binding StartCommand}"/>
                <Button x:Name="Btn_Stop" Content="停止" IsEnabled="{Binding BtnStopEnabled}" Style="{StaticResource ButtonWarning}" Command="{Binding StopCommand}"/>
                <CheckBox Content="自动上传" IsChecked="{Binding AutoCommit}"/>
            </hc:UniformSpacingPanel>
        </ToolBar>

        <TabControl Grid.Row="1" Grid.Column="0" Style="{StaticResource TabControlBaseStyle}">
            <TabItem Header="日志">
                <ItemsControl ItemsSource="{Binding LogModels}">
                    <ItemsControl.Template>
                        <ControlTemplate>
                            <VirtualizingStackPanel x:Name="ScrollViewer">
                                <ItemsPresenter />
                            </VirtualizingStackPanel>
                        </ControlTemplate>
                    </ItemsControl.Template>
                </ItemsControl>
            </TabItem>
            <TabItem Header="通讯配置">
                <Frame Content="{Binding CommunicationPage}" NavigationUIVisibility="Hidden"/>
            </TabItem>
            <TabItem Header="设备信息">
                <Frame Content="{Binding EquipmentPage}" NavigationUIVisibility="Hidden"/>
            </TabItem>
            <TabItem Header="待推送数据">
                <Frame Content="{Binding EquipmentDataQueuePage}" NavigationUIVisibility="Hidden"/>
            </TabItem>
        </TabControl>

        <StackPanel Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{StaticResource DarkDefaultBrush}">
            <TextBlock Text="Copyright © 2024 长沙华恒机器人系统有限公司" Foreground="{StaticResource SecondaryTextBrush}" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="0,1"/>
        </StackPanel>
        <hc:NotifyIcon x:Name="NotifyIconContextContent" 
                   Text="数据采集"
                   Visibility="Visible"
                   Icon="/favicon.ico">
            <hc:NotifyIcon.ContextMenu>
                <ContextMenu Width="140">
                    <MenuItem Command="hc:ControlCommands.PushMainWindow2Top" Header="打开 数据采集"/>
                    <Separator></Separator>
                    <MenuItem Command="hc:ControlCommands.ShutdownApp" Header="退出"/>
                </ContextMenu>
            </hc:NotifyIcon.ContextMenu>
            <hc:Interaction.Triggers>
                <hc:EventTrigger EventName="Click">
                    <hc:EventToCommand Command="hc:ControlCommands.PushMainWindow2Top"/>
                </hc:EventTrigger>
            </hc:Interaction.Triggers>
        </hc:NotifyIcon>
    </Grid>
</Window>