MainWindow.xaml 5.23 KB
<Window
    x:Class="RobotTool.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:hc="https://handyorg.github.io/handycontrol"
    xmlns:local="clr-namespace:RobotTool"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:model="clr-namespace:HHECS.RobotTool.Common"
    xmlns:viewmodel="clr-namespace:HHECS.RobotTool.ViewModel"
    xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
    Title="华恒焊接-坡口自适应"
    Width="800"
    Height="450"
    d:DataContext="{d:DesignInstance Type=viewmodel:MainVM}"
    WindowStartupLocation="CenterScreen"
    WindowState="Maximized"
    mc:Ignorable="d">
    <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="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="18" />
        </Grid.RowDefinitions>
        <Menu Grid.Row="0" ItemsSource="{Binding MenuItems}" />
        <ToolBar
            Grid.Row="1"
            Grid.Column="0"
            VerticalAlignment="Stretch">
            <hc:UniformSpacingPanel Spacing="10">
                <Button
                    x:Name="Btn_Start"
                    Command="{Binding StartCommand}"
                    Content="启动"
                    IsEnabled="{Binding BtnStartEnabled}"
                    Style="{StaticResource ButtonSuccess}" />
                <Button
                    x:Name="Btn_Stop"
                    Command="{Binding StopCommand}"
                    Content="停止"
                    IsEnabled="{Binding BtnStopEnabled}"
                    Style="{StaticResource ButtonWarning}" />
                <StackPanel Orientation="Horizontal">
                    <TextBlock VerticalAlignment="Center" Text="TCP Server端口:" />
                    <hc:TextBox
                        Width="60"
                        IsReadOnly="{Binding BtnStopEnabled}"
                        Text="{Binding TcpPort}" />
                </StackPanel>
            </hc:UniformSpacingPanel>
        </ToolBar>
        <TabControl
            Grid.Row="2"
            Grid.Column="0"
            Style="{StaticResource TabControlBaseStyle}">
            <TabItem Header="日志">
                <ItemsControl ItemsSource="{Binding LogModels}">
                    <ItemsControl.Template>
                        <ControlTemplate>
                            <ScrollViewer VerticalScrollBarVisibility="Auto">
                                <VirtualizingStackPanel x:Name="ScrollViewer">
                                    <ItemsPresenter />
                                </VirtualizingStackPanel>
                            </ScrollViewer>
                        </ControlTemplate>
                    </ItemsControl.Template>
                </ItemsControl>
            </TabItem>
            <TabItem Header="焊接监控">
                <Frame Content="{Binding WeldMonitorPage}" NavigationUIVisibility="Hidden" />
            </TabItem>
            <TabItem Header="计算工具">
                <Frame Content="{Binding GrooveComputerPage}" NavigationUIVisibility="Hidden" />
            </TabItem>
        </TabControl>

        <StackPanel
            Grid.Row="3"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            Background="{StaticResource DarkDefaultBrush}">
            <TextBlock
                Padding="0,1"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Foreground="{StaticResource SecondaryTextBrush}"
                Text="Copyright © 2024 长沙华恒机器人系统有限公司" />
        </StackPanel>
        <hc:NotifyIcon
            x:Name="NotifyIconContextContent"
            Text="华恒焊接-坡口自适应"
            Visibility="Visible">
            <hc:NotifyIcon.ContextMenu>
                <ContextMenu Width="140">
                    <MenuItem Command="{Binding CurrentViewShowCommand}" Header="打开主页" />
                    <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>