plcsharp/PLCSharpWpf/VVMs/MainWindow/MainWindow.xaml

266 lines
14 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<Window x:Class="PLCSharp.VVMs.MainWindow.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:local="clr-namespace:PLCSharp.VVMs.MainWindow"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=local:MainWindowViewModel}"
d:Height="1000" d:Width="1200"
MinWidth="800" MinHeight="600"
ResizeMode="CanResizeWithGrip" WindowStartupLocation="CenterScreen"
WindowState="Normal" WindowStyle="None" Closing="Window_Closing">
<Window.Resources>
<ResourceDictionary>
<Style x:Key="NavigateMenu" TargetType="ListBox">
<Style.Setters>
<Setter Property="FontSize" Value="18" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ListBoxItem">
<Style.Triggers>
<Trigger Property="ListBoxItem.IsSelected" Value="True">
<Setter Property="ListBoxItem.Background" Value="LightGray" />
</Trigger>
</Style.Triggers>
</Style>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
<Style x:Key="DialogMenu" TargetType="ListBox">
<Style.Setters>
<Setter Property="FontSize" Value="12" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ListBoxItem">
<Style.Triggers>
<Trigger Property="ListBoxItem.IsSelected" Value="True">
<Setter Property="ListBoxItem.Background" Value="DeepSkyBlue" />
</Trigger>
</Style.Triggers>
</Style>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
<Style x:Key="ButtonMenu" TargetType="Button">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Opacity" Value="0.8" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" OpacityMask="{TemplateBinding OpacityMask}" />
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.9" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Window.Resources>
<!-- 总 -->
<Grid Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}, AncestorLevel=1}, Path=ActualHeight}" Background="#CCCCCCCC" Opacity="1">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<!-- 标题 -->
<Border Background="Black" Opacity="0.8" PreviewMouseLeftButtonDown="Border_PreviewMouseLeftButtonDown" PreviewMouseMove="Border_PreviewMouseMove" />
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Margin="20,0"
Text="{Binding Title}"
FontSize="22"
VerticalAlignment="Center"
FontStyle="Oblique" Foreground="White" />
</StackPanel>
<!-- 右上角功能区域 -->
<Grid Width="160" HorizontalAlignment="Right" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<!-- 最小化 -->
<Button Grid.Column="1"
Width="40" Height="40" Padding="0"
Background="Transparent" BorderThickness="0" Click="BtnMin"
Foreground="White" ToolTip="最小化">
<TextBlock Text="&#xe650;" FontSize="20" FontFamily="{StaticResource iconfont}" Foreground="LightGray" />
</Button>
<!-- 最大化 -->
<Button Name="btnMaximize" Grid.Column="2"
Width="40" Height="40" Padding="0"
Background="Transparent" BorderThickness="0" Click="BtnMaximize_Click"
Foreground="White" ToolTip="最大化" Visibility="Visible">
<TextBlock Text="&#xe673;" FontSize="20" FontFamily="{StaticResource iconfont}" Foreground="LightGray" />
</Button>
<!-- 关闭 -->
<Button Grid.Column="3"
Width="40" Height="40" Padding="0"
Background="Transparent" BorderThickness="0"
Command="{Binding Exit}"
ToolTip="退出">
<TextBlock Text="&#xeca0;" FontSize="20" FontFamily="{StaticResource iconfont}" Foreground="LightGray" />
</Button>
</Grid>
<!-- 菜单和主题内容 -->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<!-- ToggleButton切换IsChecked,动态更新gridMenu宽度 -->
<ColumnDefinition x:Name="gridMenu" Width="{Binding ElementName=toggle, Path=IsChecked, Converter={StaticResource BoolToValueConverter}, ConverterParameter=180, FallbackValue=60}" />
<ColumnDefinition />
<ColumnDefinition Width="60" />
</Grid.ColumnDefinitions>
<!-- 左侧边 -->
<Grid Background="#FF3B3E41">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ToggleButton x:Name="toggle"
Height="30" Margin="15,0"
HorizontalAlignment="Left" VerticalAlignment="Center"
Background="Transparent" BorderBrush="Transparent" Cursor="Hand"
Foreground="White"
Style="{DynamicResource ToggleButtonCustom}">
<TextBlock Text="{Binding ElementName=toggle, Path=IsChecked, Converter={StaticResource BoolToValueConverter}, ConverterParameter=&#xe618;, FallbackValue=&#xe619;}"
FontSize="30"
FontFamily="{StaticResource iconfont}"
VerticalAlignment="Center"
Foreground="LightGray" />
</ToggleButton>
<!-- 菜单 -->
<ListBox Grid.Row="1"
Margin="-5"
ItemsSource="{Binding Navigate.NavigateListShow}"
SelectedItem="{Binding Navigate.NavigateTarget}"
Style="{StaticResource NavigateMenu}">
<ListBox.Template>
<!-- 控件模板 决定条目布局 -->
<ControlTemplate TargetType="{x:Type ListBox}">
<StackPanel IsItemsHost="True" />
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemTemplate>
<DataTemplate>
<!-- 条目内布局 -->
<Border Width="180" Height="50" Padding="0"
Background="Transparent" Cursor="Hand"
ToolTip="{Binding DisplayName}">
<!-- Hidden Visible Collapsed -->
<Grid Width="180" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Width="120" />
</Grid.ColumnDefinitions>
<Viewbox Height="32" Margin="10">
<TextBlock Text="{Binding IconKind}" FontFamily="{StaticResource iconfont}" Foreground="LightGray" />
</Viewbox>
<TextBlock Grid.Column="1"
Text="{Binding DisplayName}"
HorizontalAlignment="Center" VerticalAlignment="Center"
Foreground="White" />
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<!-- 内容区 -->
<Grid Grid.Column="1" Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=1}, Path=ActualHeight}" Background="White">
<ContentControl prism:RegionManager.RegionName="ContentRegionCore" />
</Grid>
<!-- 右侧边 -->
<StackPanel Grid.Column="2" Background="#FF3B3E41">
<Button Width="50" Height="50" Margin="1" Padding="0"
Background="Transparent"
BorderBrush="{x:Null}"
Command="{Binding ShowDialog}"
CommandParameter="Login" Cursor="Hand" ToolTip="登录">
<Button.Content>
<TextBlock Text="&#xeb6e;" FontSize="30" FontFamily="{StaticResource iconfont}" Foreground="LightGray" />
</Button.Content>
</Button>
<Button Width="50" Height="50" Margin="1" Padding="0"
Background="Transparent"
BorderBrush="{x:Null}"
Command="{Binding ShowDialog}"
CommandParameter="SystemConfig" Cursor="Hand" ToolTip="配置">
<Button.Content>
<TextBlock Text="&#xe8b8;" FontSize="30" FontFamily="{StaticResource iconfont}" Foreground="LightGray" />
</Button.Content>
</Button>
<Button Width="50" Height="50" Margin="1" Padding="0"
Background="Transparent"
BorderBrush="{x:Null}"
Command="{Binding ShowDialog}"
CommandParameter="ErrorLogs" Cursor="Hand" ToolTip="警报记录">
<Button.Content>
<TextBlock Text="&#xe678;" FontSize="30" FontFamily="{StaticResource iconfont}" Foreground="LightGray" />
</Button.Content>
</Button>
</StackPanel>
</Grid>
<!-- 状态栏 -->
<Grid Grid.Row="2" Background="Black" Opacity="0.8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="用户:" FontSize="14" HorizontalAlignment="Center" Foreground="Gray" />
<TextBlock Text="{Binding Login.CurrentUser.Name}" FontSize="14" HorizontalAlignment="Center" Foreground="Gray" />
</StackPanel>
<StackPanel Grid.Column="1" HorizontalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="权限:" FontSize="14" HorizontalAlignment="Center" Foreground="Gray" />
<TextBlock Text="{Binding Login.CurrentUser.Authority}" FontSize="14" HorizontalAlignment="Center" Foreground="Gray" />
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<TextBlock Text="{Binding CpuUsage, StringFormat=CPU:{0:F2} %}" FontSize="14" HorizontalAlignment="Center" Foreground="Gray" />
</StackPanel>
<StackPanel Grid.Column="3" Orientation="Horizontal">
<TextBlock Text="{Binding MemoryUsage, StringFormat=RAM:{0:F2} MB}" FontSize="14" HorizontalAlignment="Center" Foreground="Gray" />
</StackPanel>
</Grid>
</Grid>
</Window>