添加项目文件。
This commit is contained in:
314
CapMachine.Wpf/Views/DialogChartRtConfigView.xaml
Normal file
314
CapMachine.Wpf/Views/DialogChartRtConfigView.xaml
Normal file
@@ -0,0 +1,314 @@
|
||||
<UserControl
|
||||
x:Class="CapMachine.Wpf.Views.DialogChartRtConfigView"
|
||||
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:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:local="clr-namespace:CapMachine.Wpf.Views"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
Width="1500"
|
||||
Height="900"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
|
||||
<Setter Property="FontSize" Value="24" />
|
||||
<Setter Property="Width" Value="218" />
|
||||
</Style>
|
||||
<Style x:Key="myHeaderStyle1" TargetType="{x:Type GridViewColumnHeader}">
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
</Style>
|
||||
<Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="0.25*" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="0.25*" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="60" />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- 最左侧 曲线数据源头 -->
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<materialDesign:Card Margin="3" materialDesign:ElevationAssist.Elevation="Dp2">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock
|
||||
Margin="10,3"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="30"
|
||||
Foreground="Blue"
|
||||
Text="曲线数据源" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="26"
|
||||
Foreground="Gray"
|
||||
Text="{Binding SelectedChartSrcData.Name}" />
|
||||
</StackPanel>
|
||||
|
||||
</materialDesign:Card>
|
||||
|
||||
<materialDesign:Card
|
||||
Grid.Row="1"
|
||||
Margin="3"
|
||||
materialDesign:ElevationAssist.Elevation="Dp2">
|
||||
<Border BorderBrush="Black" BorderThickness="1">
|
||||
<ListView
|
||||
x:Name="LvChartSource"
|
||||
Foreground="Black"
|
||||
ItemsSource="{Binding ChartSrcDataListViewItems}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<prism:InvokeCommandAction Command="{Binding SelectionChartSourceCmd}" CommandParameter="{Binding ElementName=LvChartSource, Path=SelectedItem}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<ListView.View>
|
||||
<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle1}">
|
||||
<GridViewColumn
|
||||
Width="50"
|
||||
DisplayMemberBinding="{Binding Index}"
|
||||
Header="序号" />
|
||||
<GridViewColumn
|
||||
Width="220"
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
Header="名称">
|
||||
<!--<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}" TextAlignment="Center" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>-->
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Width="100" Header="状态">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox IsChecked="{Binding Selected}" IsEnabled="False" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<!-- 设置ListViewItem的背景色,模拟网格效果 -->
|
||||
<!--<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Background" Value="LightGray" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>-->
|
||||
</ListView>
|
||||
</Border>
|
||||
</materialDesign:Card>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- 曲线选择操作 -->
|
||||
<materialDesign:Card
|
||||
Grid.Column="1"
|
||||
Margin="5,3"
|
||||
materialDesign:ElevationAssist.Elevation="Dp2">
|
||||
<StackPanel VerticalAlignment="Center" Orientation="Vertical">
|
||||
<StackPanel.Resources>
|
||||
<Style x:Key="btnStyle" TargetType="Button" />
|
||||
</StackPanel.Resources>
|
||||
<Button
|
||||
Margin="5"
|
||||
Command="{Binding ChartSourceCmd}"
|
||||
CommandParameter="Selected"
|
||||
Content="选中>>"
|
||||
Foreground="White" />
|
||||
<Button
|
||||
Margin="5"
|
||||
Command="{Binding ChartSourceCmd}"
|
||||
CommandParameter="Delete"
|
||||
Content=">> 删除"
|
||||
Foreground="White" />
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
|
||||
<!-- 中间 已经选择曲线 -->
|
||||
<Grid Grid.Row="0" Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<materialDesign:Card
|
||||
Margin="3"
|
||||
materialDesign:ElevationAssist.Elevation="Dp2"
|
||||
Background="SkyBlue">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock
|
||||
Margin="10,3"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="30"
|
||||
Foreground="Green"
|
||||
Text="已选曲线" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="26"
|
||||
Foreground="Gray"
|
||||
Text="{Binding SelectedChartSelectData.Name}" />
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</materialDesign:Card>
|
||||
|
||||
<materialDesign:Card
|
||||
Grid.Row="1"
|
||||
Margin="3"
|
||||
materialDesign:ElevationAssist.Elevation="Dp2">
|
||||
<Border BorderBrush="Black" BorderThickness="1">
|
||||
<ListView
|
||||
x:Name="LvChartConfig"
|
||||
Foreground="Black"
|
||||
ItemsSource="{Binding ChartSelectDataListViewItems}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<prism:InvokeCommandAction Command="{Binding SelectedChartConfigCmd}" CommandParameter="{Binding ElementName=LvChartConfig, Path=SelectedItem}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<ListView.View>
|
||||
<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle1}">
|
||||
<GridViewColumn
|
||||
Width="50"
|
||||
DisplayMemberBinding="{Binding Index}"
|
||||
Header="序号" />
|
||||
<GridViewColumn
|
||||
Width="220"
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
Header="名称" />
|
||||
<GridViewColumn
|
||||
Width="100"
|
||||
DisplayMemberBinding="{Binding YAxis.Unit}"
|
||||
Header="Y标尺" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<!-- 设置ListViewItem的背景色,模拟网格效果 -->
|
||||
<!--<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Background" Value="LightGray" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>-->
|
||||
</ListView>
|
||||
</Border>
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
<!-- Y标尺选择操作 -->
|
||||
<materialDesign:Card
|
||||
Grid.Column="3"
|
||||
Margin="5,3"
|
||||
materialDesign:ElevationAssist.Elevation="Dp2">
|
||||
<StackPanel VerticalAlignment="Center" Orientation="Vertical">
|
||||
<StackPanel.Resources>
|
||||
<Style x:Key="btnStyle" TargetType="Button" />
|
||||
</StackPanel.Resources>
|
||||
<Button
|
||||
Margin="5"
|
||||
Command="{Binding ChartYAxisSelectCmd}"
|
||||
CommandParameter="Selected"
|
||||
Content=">>选中"
|
||||
Foreground="White" />
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
|
||||
<!-- Y标尺 -->
|
||||
<Grid Grid.Row="0" Grid.Column="4">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<materialDesign:Card Margin="3" materialDesign:ElevationAssist.Elevation="Dp2">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock
|
||||
Margin="10,3"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="30"
|
||||
Foreground="Blue"
|
||||
Text="Y轴标尺" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="26"
|
||||
Foreground="Gray"
|
||||
Text="{Binding SelectedChartYAxisData.Name}" />
|
||||
</StackPanel>
|
||||
|
||||
</materialDesign:Card>
|
||||
|
||||
<materialDesign:Card
|
||||
Grid.Row="1"
|
||||
Margin="3"
|
||||
materialDesign:ElevationAssist.Elevation="Dp2">
|
||||
<Border BorderBrush="Black" BorderThickness="1">
|
||||
<ListView
|
||||
x:Name="LvChartYAxis"
|
||||
Foreground="Black"
|
||||
ItemsSource="{Binding ChartYAxisDataListViewItems}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<prism:InvokeCommandAction Command="{Binding ChartYAxisDataConfigCmd}" CommandParameter="{Binding ElementName=LvChartYAxis, Path=SelectedItem}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<ListView.View>
|
||||
<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle1}">
|
||||
<GridViewColumn
|
||||
Width="50"
|
||||
DisplayMemberBinding="{Binding Index}"
|
||||
Header="序号" />
|
||||
<GridViewColumn
|
||||
Width="100"
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
Header="标尺名称" />
|
||||
<GridViewColumn
|
||||
Width="80"
|
||||
DisplayMemberBinding="{Binding Min}"
|
||||
Header="最小值" />
|
||||
<GridViewColumn
|
||||
Width="80"
|
||||
DisplayMemberBinding="{Binding Max}"
|
||||
Header="最大值" />
|
||||
<GridViewColumn
|
||||
Width="80"
|
||||
DisplayMemberBinding="{Binding Unit}"
|
||||
Header="单位" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<!-- 设置ListViewItem的背景色,模拟网格效果 -->
|
||||
<!--<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Background" Value="LightGray" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>-->
|
||||
</ListView>
|
||||
</Border>
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Grid.Column="4"
|
||||
VerticalAlignment="Center">
|
||||
<Button
|
||||
Height="40"
|
||||
Margin="80,0"
|
||||
Command="{Binding SaveCmd}"
|
||||
Content="关 闭"
|
||||
FontSize="26"
|
||||
Foreground="White" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
CapMachine.Wpf/Views/DialogChartRtConfigView.xaml.cs
Normal file
28
CapMachine.Wpf/Views/DialogChartRtConfigView.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace CapMachine.Wpf.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// DialogChartRtConfigView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DialogChartRtConfigView : UserControl
|
||||
{
|
||||
public DialogChartRtConfigView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
49
CapMachine.Wpf/Views/DialogCreateProView.xaml
Normal file
49
CapMachine.Wpf/Views/DialogCreateProView.xaml
Normal file
@@ -0,0 +1,49 @@
|
||||
<UserControl
|
||||
x:Class="CapMachine.Wpf.Views.DialogCreateProView"
|
||||
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:CapMachine.Wpf.Views"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel
|
||||
Margin="70"
|
||||
HorizontalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="24"
|
||||
Text="程序名称:"
|
||||
TextAlignment="Center" />
|
||||
<TextBox
|
||||
Width="300"
|
||||
VerticalAlignment="Center"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="1"
|
||||
FontSize="24"
|
||||
Text="{Binding Name}" />
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Margin="10,10"
|
||||
Command="{Binding SaveCmd}"
|
||||
Content="确定" />
|
||||
<Button
|
||||
Margin="10,0"
|
||||
Command="{Binding CancelCmd}"
|
||||
Content="取消" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
15
CapMachine.Wpf/Views/DialogCreateProView.xaml.cs
Normal file
15
CapMachine.Wpf/Views/DialogCreateProView.xaml.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace CapMachine.Wpf.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// DialogCreateProView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DialogCreateProView : UserControl
|
||||
{
|
||||
public DialogCreateProView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
49
CapMachine.Wpf/Views/DialogEditProView.xaml
Normal file
49
CapMachine.Wpf/Views/DialogEditProView.xaml
Normal file
@@ -0,0 +1,49 @@
|
||||
<UserControl
|
||||
x:Class="CapMachine.Wpf.Views.DialogEditProView"
|
||||
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:CapMachine.Wpf.Views"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel
|
||||
Margin="70"
|
||||
HorizontalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="24"
|
||||
Text="程序名称:"
|
||||
TextAlignment="Center" />
|
||||
<TextBox
|
||||
Width="300"
|
||||
VerticalAlignment="Center"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="1"
|
||||
FontSize="24"
|
||||
Text="{Binding Name}" />
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Margin="10,10"
|
||||
Command="{Binding SaveCmd}"
|
||||
Content="确定" />
|
||||
<Button
|
||||
Margin="10,0"
|
||||
Command="{Binding CancelCmd}"
|
||||
Content="取消" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
15
CapMachine.Wpf/Views/DialogEditProView.xaml.cs
Normal file
15
CapMachine.Wpf/Views/DialogEditProView.xaml.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace CapMachine.Wpf.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// DialogEditProView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DialogEditProView : UserControl
|
||||
{
|
||||
public DialogEditProView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
164
CapMachine.Wpf/Views/MainView.xaml
Normal file
164
CapMachine.Wpf/Views/MainView.xaml
Normal file
@@ -0,0 +1,164 @@
|
||||
<Window
|
||||
x:Class="CapMachine.Wpf.Views.MainView"
|
||||
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:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:local="clr-namespace:CapMachine.Wpf.Views"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
Title="压缩机耐久测试平台"
|
||||
Width="1920"
|
||||
Height="1080"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<md:ColorZone md:ElevationAssist.Elevation="Dp2" Mode="PrimaryDark">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Margin="15" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="5,0,15,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="22"
|
||||
FontWeight="Bold"
|
||||
Text="压缩机耐久测试软件平台" />
|
||||
</StackPanel>
|
||||
|
||||
<ListBox
|
||||
x:Name="listBox"
|
||||
Grid.Column="1"
|
||||
ItemsSource="{Binding MenuService.MenuItems}"
|
||||
SelectedIndex="{Binding SelectedIndex}">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Grid>
|
||||
<Border x:Name="border" />
|
||||
<Border x:Name="borderheader" Background="{TemplateBinding Background}" />
|
||||
<ContentPresenter
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
TextBlock.Foreground="{TemplateBinding Foreground}" />
|
||||
</Grid>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter TargetName="borderheader" Property="Background" Value="#ffffff" />
|
||||
<Setter TargetName="borderheader" Property="Opacity" Value="0.1" />
|
||||
<Setter TargetName="border" Property="BorderBrush" Value="#ffffff" />
|
||||
<Setter TargetName="border" Property="BorderThickness" Value="0,0,0,3" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter TargetName="borderheader" Property="Background" Value="#ffffff" />
|
||||
<Setter TargetName="borderheader" Property="Opacity" Value="0.1" />
|
||||
<Setter TargetName="border" Property="BorderBrush" Value="#ffffff" />
|
||||
<Setter TargetName="border" Property="BorderThickness" Value="0,0,0,3" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Margin="20,5"
|
||||
FontSize="16"
|
||||
Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<i:InvokeCommandAction Command="{Binding NavigateCommand}" CommandParameter="{Binding ElementName=listBox, Path=SelectedItem}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</md:ColorZone>
|
||||
|
||||
<md:DialogHost Grid.Row="1">
|
||||
<!-- Content="{Binding ElementName=MainViewContentControl, Path=Content, Mode=TwoWay}" IsTopDrawerOpen="{Binding IsTopDrawerOpen}" -->
|
||||
<md:DrawerHost Content="{Binding ElementName=MainViewContentControl, Path=Content, Mode=TwoWay}" IsTopDrawerOpen="{Binding IsTopDrawerOpen}">
|
||||
<md:DrawerHost.TopDrawerContent>
|
||||
<ItemsControl Padding="0,5,0,20" ItemsSource="{Binding MenuService.MenuItems[0].Items}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Margin="15,10" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="5,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
FontWeight="Bold"
|
||||
Foreground="White"
|
||||
Text="{Binding Name}" />
|
||||
</StackPanel>
|
||||
|
||||
<ItemsControl
|
||||
Grid.Row="1"
|
||||
Margin="10,0"
|
||||
VerticalAlignment="Top"
|
||||
ItemsSource="{Binding Items}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid VerticalAlignment="Center" Columns="2" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Button Height="40" Margin="5">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="10,5" Text="{Binding Name}" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</md:DrawerHost.TopDrawerContent>
|
||||
</md:DrawerHost>
|
||||
</md:DialogHost>
|
||||
|
||||
<ContentControl
|
||||
x:Name="MainViewContentControl"
|
||||
prism:RegionManager.RegionName="MainViewContentRegion"
|
||||
Visibility="Collapsed" />
|
||||
</Grid>
|
||||
</Window>
|
||||
15
CapMachine.Wpf/Views/MainView.xaml.cs
Normal file
15
CapMachine.Wpf/Views/MainView.xaml.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace CapMachine.Wpf.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainView : Window
|
||||
{
|
||||
public MainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
43
CapMachine.Wpf/Views/MonitorView.xaml
Normal file
43
CapMachine.Wpf/Views/MonitorView.xaml
Normal file
@@ -0,0 +1,43 @@
|
||||
<UserControl
|
||||
x:Class="CapMachine.Wpf.Views.MonitorView"
|
||||
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:CapMachine.Wpf.Views"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="1000"
|
||||
d:DesignWidth="1920"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="220" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="140" />
|
||||
<RowDefinition Height="120" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0">
|
||||
<TextBlock
|
||||
FontSize="30"
|
||||
Text="调节器操作栏Hey TyroneChong! A third-party OAuth application (BotSharp) with user:email scopes was recently authorized to access your account. Visit https://github.com/settings/connections/applications/a1009924bfc48dbb7360 for more information. To see this and other security events for your account, visit https://github.com/settings/security-log If you run into problems, please contact support by visiting https://github.com/contact Thanks, The GitHub Team"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1">
|
||||
<TextBlock FontSize="30" Text="控制启动区域" />
|
||||
|
||||
</StackPanel>
|
||||
<Canvas Grid.Row="2">
|
||||
<TextBlock FontSize="30" Text="系统流程图" />
|
||||
</Canvas>
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="3"
|
||||
Grid.Column="1">
|
||||
<TextBlock FontSize="30" Text="数据监视" />
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
15
CapMachine.Wpf/Views/MonitorView.xaml.cs
Normal file
15
CapMachine.Wpf/Views/MonitorView.xaml.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace CapMachine.Wpf.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// MonitorView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MonitorView : UserControl
|
||||
{
|
||||
public MonitorView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
551
CapMachine.Wpf/Views/ProConfigView.xaml
Normal file
551
CapMachine.Wpf/Views/ProConfigView.xaml
Normal file
@@ -0,0 +1,551 @@
|
||||
<UserControl
|
||||
x:Class="CapMachine.Wpf.Views.ProConfigView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Controls="clr-namespace:CapMachine.Shared.Controls;assembly=CapMachine.Shared"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:local="clr-namespace:CapMachine.Wpf.Views"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
d:DesignHeight="1000"
|
||||
d:DesignWidth="1920"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
|
||||
<Setter Property="FontSize" Value="24" />
|
||||
<Setter Property="Width" Value="218" />
|
||||
</Style>
|
||||
<Style x:Key="myHeaderStyle1" TargetType="{x:Type GridViewColumnHeader}">
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="220" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="400" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="8*" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0" Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="80" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Border
|
||||
Grid.Row="0"
|
||||
Margin="2"
|
||||
BorderBrush="CadetBlue"
|
||||
BorderThickness="1">
|
||||
<TextBlock
|
||||
Margin="5"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
Text="工况程序库"
|
||||
TextAlignment="Center" />
|
||||
</Border>
|
||||
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Margin="2"
|
||||
BorderBrush="Black"
|
||||
BorderThickness="1">
|
||||
<StackPanel>
|
||||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button
|
||||
Width="60"
|
||||
Margin="5"
|
||||
Command="{Binding ProAddCmd}"
|
||||
Content="增加"
|
||||
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
|
||||
Style="{StaticResource MaterialDesignOutlinedDarkButton}"
|
||||
ToolTip="增加" />
|
||||
<Button
|
||||
Width="60"
|
||||
Margin="5"
|
||||
Command="{Binding ProEditCmd}"
|
||||
Content="修改"
|
||||
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
|
||||
Style="{StaticResource MaterialDesignOutlinedDarkButton}"
|
||||
ToolTip="修改" />
|
||||
<Button
|
||||
Width="60"
|
||||
Margin="5"
|
||||
Command="{Binding ProDeleteCmd}"
|
||||
Content="删除"
|
||||
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
|
||||
Style="{StaticResource MaterialDesignOutlinedDarkButton}"
|
||||
ToolTip="删除" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
Background="LightBlue"
|
||||
FontSize="20"
|
||||
Text="{Binding SelectedProgramSeg.Name}"
|
||||
TextAlignment="Center" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</Border>
|
||||
|
||||
|
||||
<Grid Grid.Row="2" Margin="2">
|
||||
<Border BorderBrush="Black" BorderThickness="1">
|
||||
<ListView
|
||||
x:Name="listviewPro"
|
||||
Foreground="Black"
|
||||
ItemsSource="{Binding ProSegListViewItems}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<prism:InvokeCommandAction Command="{Binding ProSelectedChangedCmd}" CommandParameter="{Binding ElementName=listviewPro, Path=SelectedItem}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<ListView.View>
|
||||
<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle}">
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="程序名称" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<!-- 设置ListViewItem的背景色,模拟网格效果 -->
|
||||
<!--<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Background" Value="LightGray" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>-->
|
||||
</ListView>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Margin="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
FontSize="26"
|
||||
Text="内容区域"
|
||||
TextAlignment="Center" />
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="15,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
Text="当前工况名称:" />
|
||||
<TextBox
|
||||
Width="150"
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Background="DodgerBlue"
|
||||
FontSize="18"
|
||||
Foreground="White"
|
||||
Text="{Binding SelectedProgramSeg.Name}"
|
||||
TextAlignment="Center" />
|
||||
<TextBlock
|
||||
Margin="15,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
Text="总循环次数:" />
|
||||
<TextBox
|
||||
Width="80"
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Background="DodgerBlue"
|
||||
FontSize="18"
|
||||
Foreground="White"
|
||||
Text="{Binding SelectedProgramSeg.ProRepeat}"
|
||||
TextAlignment="Center" />
|
||||
|
||||
<TextBlock
|
||||
Margin="15,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
Text="当前选中步骤序号:" />
|
||||
<TextBox
|
||||
Width="80"
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Background="DodgerBlue"
|
||||
FontSize="18"
|
||||
Foreground="White"
|
||||
Text="{Binding SelectedProStepDto.StepNo}"
|
||||
TextAlignment="Center" />
|
||||
</StackPanel>
|
||||
<DataGrid
|
||||
x:Name="MainDatagrid"
|
||||
Grid.Row="2"
|
||||
AutoGenerateColumns="False"
|
||||
BorderBrush="Black"
|
||||
BorderThickness="1"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding ListProStepDtoItems}"
|
||||
SelectionMode="Extended">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding StepNo}" Header="序号" />
|
||||
<DataGridTextColumn Binding="{Binding StepRepeat}" Header="循环次数" />
|
||||
<DataGridTemplateColumn Width="200" Header="压缩机转速
信息">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding SpeedInfo}" TextWrapping="Wrap" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Binding="{Binding PID}" Header="PID
信息" />
|
||||
<DataGridTextColumn Binding="{Binding PIDOutLimit}" Header="PID输出限幅信息" />
|
||||
<DataGridTextColumn Binding="{Binding Ps}" Header="Ps信息" />
|
||||
<DataGridTextColumn Binding="{Binding PdInfo}" Header="Pd信息" />
|
||||
</DataGrid.Columns>
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<prism:InvokeCommandAction Command="{Binding GridSelectionChangedCmd}" CommandParameter="{Binding ElementName=MainDatagrid, Path=SelectedItem}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
|
||||
<!--<DataGrid.RowStyle>
|
||||
<Style TargetType="{x:Type DataGridRow}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
|
||||
<Setter Property="Background" Value="AliceBlue" />
|
||||
</Trigger>
|
||||
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
|
||||
<Setter Property="Background" Value="#FFF2F2F2" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>-->
|
||||
</DataGrid>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="2"
|
||||
Margin="2">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="50" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border
|
||||
Margin="2"
|
||||
BorderBrush="CadetBlue"
|
||||
BorderThickness="1">
|
||||
<TextBlock
|
||||
Margin="5"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
Text="工况输入"
|
||||
TextAlignment="Center" />
|
||||
</Border>
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Margin="2"
|
||||
BorderBrush="Black"
|
||||
BorderThickness="1">
|
||||
<StackPanel>
|
||||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button
|
||||
Width="60"
|
||||
Margin="5"
|
||||
Command="{Binding ProStepAddCmd}"
|
||||
Content="增加"
|
||||
Style="{StaticResource MaterialDesignOutlinedDarkButton}"
|
||||
ToolTip="增加" />
|
||||
<Button
|
||||
Width="60"
|
||||
Command="{Binding ProStepEditCmd}"
|
||||
Content="修改"
|
||||
Style="{StaticResource MaterialDesignOutlinedDarkButton}"
|
||||
ToolTip="修改" />
|
||||
<Button
|
||||
Width="60"
|
||||
Margin="5"
|
||||
Command="{Binding ProStepDeleteCmd}"
|
||||
Content="删除"
|
||||
Style="{StaticResource MaterialDesignOutlinedDarkButton}"
|
||||
ToolTip="删除" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
Margin="2"
|
||||
BorderBrush="Black"
|
||||
BorderThickness="1">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="5"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="18"
|
||||
Text="单步循环次数"
|
||||
TextAlignment="Center" />
|
||||
|
||||
<TextBox
|
||||
Width="60"
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Background="DeepSkyBlue"
|
||||
BorderThickness="2"
|
||||
FontSize="18"
|
||||
Foreground="White"
|
||||
Text="{Binding ProStepCycleCount}"
|
||||
TextAlignment="Center" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="18"
|
||||
Text="次" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border
|
||||
Grid.Row="3"
|
||||
Margin="2"
|
||||
BorderBrush="Black"
|
||||
BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="300" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- 速度参数设置 -->
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="70" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.ColumnSpan="3" Margin="1">
|
||||
<Border
|
||||
Padding="3"
|
||||
Background="LightSteelBlue"
|
||||
CornerRadius="3">
|
||||
<TextBlock
|
||||
FontSize="18"
|
||||
Foreground="Blue"
|
||||
Text="速度设置" />
|
||||
</Border>
|
||||
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Margin="5,10,0,0">
|
||||
<TextBox
|
||||
Height="55"
|
||||
VerticalAlignment="Top"
|
||||
materialDesign:HintAssist.Hint="起始速度"
|
||||
AcceptsReturn="True"
|
||||
FontSize="18"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||
Text="{Binding SelectedMeterSpeed.StartValue}"
|
||||
TextWrapping="NoWrap"
|
||||
VerticalScrollBarVisibility="Disabled" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Margin="5,10,0,0">
|
||||
<TextBox
|
||||
Height="55"
|
||||
VerticalAlignment="Top"
|
||||
materialDesign:HintAssist.Hint="结束速度"
|
||||
AcceptsReturn="True"
|
||||
FontSize="18"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||
Text="{Binding SelectedMeterSpeed.EndValue}"
|
||||
TextWrapping="NoWrap"
|
||||
VerticalScrollBarVisibility="Disabled" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Margin="5,10,0,0">
|
||||
<TextBox
|
||||
Height="55"
|
||||
VerticalAlignment="Top"
|
||||
materialDesign:HintAssist.Hint="维持时间"
|
||||
AcceptsReturn="True"
|
||||
FontSize="18"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||
Text="{Binding SelectedMeterSpeed.KeepTime}"
|
||||
TextWrapping="NoWrap"
|
||||
VerticalScrollBarVisibility="Disabled" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal">
|
||||
<Button
|
||||
Margin="5,3"
|
||||
Command="{Binding ProStepSpeedAddCmd}"
|
||||
Content="增加"
|
||||
Foreground="White"
|
||||
Style="{StaticResource MaterialDesignRaisedSecondaryLightButton}"
|
||||
ToolTip="增加程序步骤内的速度设置" />
|
||||
<Button
|
||||
Margin="5,3"
|
||||
Command="{Binding ProStepSpeedEditCmd}"
|
||||
Content="修改"
|
||||
Foreground="White"
|
||||
Style="{StaticResource MaterialDesignRaisedSecondaryLightButton}"
|
||||
ToolTip="修改程序步骤内的速度设置,请先选中" />
|
||||
<Button
|
||||
Margin="5,3"
|
||||
Command="{Binding ProStepSpeedDeleteCmd}"
|
||||
Content="删除"
|
||||
Foreground="White"
|
||||
Style="{StaticResource MaterialDesignRaisedSecondaryLightButton}"
|
||||
ToolTip="删除程序步骤内的速度设置,请先选中" />
|
||||
</StackPanel>
|
||||
<Border
|
||||
Grid.Row="3"
|
||||
Margin="3,0"
|
||||
BorderBrush="Black"
|
||||
BorderThickness="1">
|
||||
<ListView
|
||||
x:Name="listviewProStepSpeed"
|
||||
Foreground="Black"
|
||||
ItemsSource="{Binding ListMeterSpeedItems}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<prism:InvokeCommandAction Command="{Binding MeterSpeedSelectedChangedCmd}" CommandParameter="{Binding ElementName=listviewProStepSpeed, Path=SelectedItem}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<ListView.View>
|
||||
<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle1}">
|
||||
<GridViewColumn
|
||||
Width="60"
|
||||
DisplayMemberBinding="{Binding StepNo}"
|
||||
Header="序号" />
|
||||
<GridViewColumn
|
||||
Width="100"
|
||||
DisplayMemberBinding="{Binding StartValue}"
|
||||
Header="起始速度" />
|
||||
<GridViewColumn
|
||||
Width="100"
|
||||
DisplayMemberBinding="{Binding EndValue}"
|
||||
Header="终止速度" />
|
||||
<GridViewColumn
|
||||
Width="100"
|
||||
DisplayMemberBinding="{Binding KeepTime}"
|
||||
Header="持续时间" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<!-- 设置ListViewItem的背景色,模拟网格效果 -->
|
||||
<!--<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Background" Value="LightGray" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>-->
|
||||
</ListView>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
<DockPanel Grid.Row="1">
|
||||
<DockPanel>
|
||||
<TextBlock
|
||||
Margin="3"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
Foreground="Blue"
|
||||
Text="其他仪表配置"
|
||||
TextAlignment="Center" />
|
||||
</DockPanel>
|
||||
<StackPanel
|
||||
HorizontalAlignment="Right"
|
||||
DockPanel.Dock="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Width="40"
|
||||
Height="40"
|
||||
Click="ProStepOtherTapLeft"
|
||||
Style="{StaticResource MaterialDesignIconButton}"
|
||||
ToolTip="向左">
|
||||
<materialDesign:PackIcon Kind="ArrowLeftBox" />
|
||||
</Button>
|
||||
<Button
|
||||
Width="40"
|
||||
Height="40"
|
||||
Click="ProStepOtherTapRight"
|
||||
Command="{Binding ProStepOtherTapRightCmd}"
|
||||
Style="{StaticResource MaterialDesignIconButton}"
|
||||
ToolTip="向右">
|
||||
<materialDesign:PackIcon Kind="ArrowRightBox" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
|
||||
<!-- 其他的参数设置 Grid.Row="1" Margin="3" SelectedIndex="{Binding TabSelectedIndex, RelativeSource={RelativeSource AncestorType={x:Type local:ProConfigView}}}" -->
|
||||
<materialDesign:Card Grid.Row="2" Margin="3">
|
||||
<TabControl x:Name="OtherTabControl" HorizontalContentAlignment="Left">
|
||||
<TabItem Header="Ps配置">
|
||||
<Controls:MeterConfig
|
||||
AddCommand="{Binding ProStepPsAddCmd}"
|
||||
DeleteCommand="{Binding ProStepPsDeleteCmd}"
|
||||
EditCommand="{Binding ProStepPsEditCmd}"
|
||||
ListMeter="{Binding ListMeterPsItems}"
|
||||
MeterName="Ps"
|
||||
MeterSelectedChangedCmd="{Binding MeterPsSelectedChangedCmd}"
|
||||
SelectedMeter="{Binding SelectedPs}" />
|
||||
</TabItem>
|
||||
<TabItem Header="Pd2配置">
|
||||
<TextBlock Margin="8" Text="Not filled, required width, tab 2" />
|
||||
</TabItem>
|
||||
<TabItem Header="Pd3配置">
|
||||
<TextBlock Margin="8" Text="Not filled, required width, tab 3" />
|
||||
</TabItem>
|
||||
<TabItem Header="Pd4配置">
|
||||
<TextBlock Margin="8" Text="Not filled, required width, tab 4" />
|
||||
</TabItem>
|
||||
<TabItem Header="Pd5配置">
|
||||
<TextBlock Margin="8" Text="Not filled, required width, tab 4" />
|
||||
</TabItem>
|
||||
<TabItem Header="Pd6配置">
|
||||
<TextBlock Margin="8" Text="Not filled, required width, tab 4" />
|
||||
</TabItem>
|
||||
<TabItem Header="Pd7配置">
|
||||
<TextBlock Margin="8" Text="Not filled, required width, tab 4" />
|
||||
</TabItem>
|
||||
<TabItem Header="Pd8配置">
|
||||
<TextBlock Margin="8" Text="Not filled, required width, tab 4" />
|
||||
</TabItem>
|
||||
<TabItem Header="Pd9配置">
|
||||
<TextBlock Margin="8" Text="Not filled, required width, tab 4" />
|
||||
</TabItem>
|
||||
<TabItem Header="Pd10配置">
|
||||
<TextBlock Margin="8" Text="Not filled, required width, tab 4" />
|
||||
</TabItem>
|
||||
<TabItem Header="Pd11配置">
|
||||
<TextBlock Margin="8" Text="Not filled, required width, tab 4" />
|
||||
</TabItem>
|
||||
<TabItem Header="Pd12配置">
|
||||
<TextBlock Margin="8" Text="Not filled, required width, tab 4" />
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</materialDesign:Card>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
42
CapMachine.Wpf/Views/ProConfigView.xaml.cs
Normal file
42
CapMachine.Wpf/Views/ProConfigView.xaml.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace CapMachine.Wpf.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// ProConfigView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ProConfigView : UserControl
|
||||
{
|
||||
public ProConfigView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public int TabSelectedIndex { get; set; }
|
||||
private void ProStepOtherTapLeft(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (TabSelectedIndex > 0)
|
||||
{
|
||||
TabSelectedIndex--;
|
||||
OtherTabControl.SelectedIndex = TabSelectedIndex;
|
||||
// 将选定的 TabItem 滚动到可视范围内
|
||||
TabItem selectedItem = OtherTabControl.SelectedItem as TabItem;
|
||||
selectedItem?.BringIntoView();
|
||||
}
|
||||
}
|
||||
|
||||
private void ProStepOtherTapRight(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (TabSelectedIndex < 12)
|
||||
{
|
||||
TabSelectedIndex++;
|
||||
OtherTabControl.SelectedIndex = TabSelectedIndex;
|
||||
// 将选定的 TabItem 滚动到可视范围内
|
||||
TabItem selectedItem = OtherTabControl.SelectedItem as TabItem;
|
||||
selectedItem?.BringIntoView();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
99
CapMachine.Wpf/Views/RealTimeChartView.xaml
Normal file
99
CapMachine.Wpf/Views/RealTimeChartView.xaml
Normal file
@@ -0,0 +1,99 @@
|
||||
<UserControl
|
||||
x:Class="CapMachine.Wpf.Views.RealTimeChartView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:LightChat="http://schemas.arction.com/charting/ultimate/"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:local="clr-namespace:CapMachine.Wpf.Views"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
Width="1920"
|
||||
Height="1000"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
|
||||
<Setter Property="FontSize" Value="24" />
|
||||
<Setter Property="Width" Value="218" />
|
||||
</Style>
|
||||
<Style x:Key="myHeaderStyle1" TargetType="{x:Type GridViewColumnHeader}">
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="240" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Button Background="Red" />
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
Margin="5,0"
|
||||
Command="{Binding ChartConfigCmd}"
|
||||
Content="编辑曲线"
|
||||
Foreground="White" />
|
||||
</Grid>
|
||||
|
||||
<LightChat:LightningChart x:Name="lightningChart1" Grid.Row="1" />
|
||||
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="3,0"
|
||||
BorderBrush="Black"
|
||||
BorderThickness="1">
|
||||
<ListView x:Name="LvChartRtValue" Foreground="Black">
|
||||
<ListView.View>
|
||||
<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle1}">
|
||||
<GridViewColumn
|
||||
Width="120"
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
Header="名称" />
|
||||
<GridViewColumn
|
||||
Width="60"
|
||||
DisplayMemberBinding="{Binding Value}"
|
||||
Header="实时值" />
|
||||
<GridViewColumn
|
||||
Width="50"
|
||||
DisplayMemberBinding="{Binding Unit}"
|
||||
Header="单位" />
|
||||
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<!-- 设置ListViewItem的背景色,模拟网格效果 -->
|
||||
<!--<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Background" Value="LightGray" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>-->
|
||||
</ListView>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
526
CapMachine.Wpf/Views/RealTimeChartView.xaml.cs
Normal file
526
CapMachine.Wpf/Views/RealTimeChartView.xaml.cs
Normal file
@@ -0,0 +1,526 @@
|
||||
using Arction.Wpf.Charting;
|
||||
using Arction.Wpf.Charting.Annotations;
|
||||
using Arction.Wpf.Charting.Axes;
|
||||
using Arction.Wpf.Charting.SeriesXY;
|
||||
using Arction.Wpf.Charting.Views.ViewXY;
|
||||
using CapMachine.Wpf.Models;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using CapMachine.Wpf.ViewModels;
|
||||
using NLog;
|
||||
using Prism.Events;
|
||||
using System.Text;
|
||||
using System.Timers;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace CapMachine.Wpf.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// RealTimeChartView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class RealTimeChartView : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时器
|
||||
/// </summary>
|
||||
static System.Timers.Timer CurTimer { get; set; }
|
||||
|
||||
private IEventAggregator _EventAggregator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 曲线配置
|
||||
/// </summary>
|
||||
public ChartConfig ChartConfigInfo { get; set; }
|
||||
|
||||
|
||||
public RealTimeChartView(IEventAggregator eventAggregator)
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
LoadLighingChart();
|
||||
|
||||
LvChartRtValue.ItemsSource = ListChartRtSeries;
|
||||
|
||||
//事件服务
|
||||
_EventAggregator = eventAggregator;
|
||||
_EventAggregator.GetEvent<ChartRtEvent>().Subscribe(GetChartRtEvent);
|
||||
|
||||
var CreateAxisY = new AxisY();
|
||||
CreateAxisY.Title.Text = Name;
|
||||
CreateAxisY.Title.AllowDragging = false;
|
||||
CreateAxisY.SetRange(0, 100);
|
||||
CreateAxisY.MajorGrid.Visible = false;
|
||||
//取消滚轮缩放
|
||||
CreateAxisY.ZoomingEnabled = false;
|
||||
ListChartRtSeries.Add(new ChartRtSeries(CreateAxisY, lightningChart1, "室温0"));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取曲线的实时值
|
||||
/// 数据是发布过来
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void GetChartRtEvent(List<ChartRtValue> RtData)
|
||||
{
|
||||
ListChartRtValue = RtData;
|
||||
|
||||
//UpdateLightningChartData();
|
||||
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
foreach (var item in ListChartRtValue)
|
||||
{
|
||||
var Data = ListChartRtSeries.Find(a => a.Name == item.Name);
|
||||
if (Data != null)
|
||||
{
|
||||
Data.AddValue(item.Value);
|
||||
Data.Value = item.Value;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void CurTimer2_Elapsed(object? sender, ElapsedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void CurTimer_Elapsed(object? sender, ElapsedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region ListView配置
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 曲线配置
|
||||
|
||||
/// <summary>
|
||||
/// 实时曲线数据集合
|
||||
/// </summary>
|
||||
public List<ChartRtValue> ListChartRtValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 曲线数据系列集合
|
||||
/// </summary>
|
||||
public List<ChartRtSeries> ListChartRtSeries { get; set; } = new List<ChartRtSeries>();
|
||||
|
||||
/// <summary>
|
||||
/// Chart图表X轴的跨度-秒
|
||||
/// </summary>
|
||||
private int ChartXDateTimeRange = 3600;
|
||||
|
||||
/// <summary>
|
||||
/// X轴滚动
|
||||
/// </summary>
|
||||
private bool ScrollEnable = true;
|
||||
|
||||
/// <summary>
|
||||
/// 更新图表信息
|
||||
/// </summary>
|
||||
private void UpdateLightningChartData()
|
||||
{
|
||||
//timeStamp = timeStamp.AddSeconds(-60);
|
||||
foreach (var item in lightningChart1.ViewXY.PointLineSeries)
|
||||
{
|
||||
//Disable updates, to prevent several extra refreshes
|
||||
lightningChart1.BeginUpdate();
|
||||
|
||||
//Array for 1 point
|
||||
SeriesPoint[] points = new SeriesPoint[1];
|
||||
|
||||
//Convert 'Now' to X value
|
||||
var _previousX = lightningChart1.ViewXY.XAxes[0].DateTimeToAxisValue(DateTime.Now);
|
||||
points[0].X = _previousX;
|
||||
points[0].Y = GetChartRtValue(item.Title.Text);
|
||||
//Add the new point into end of first PointLineSeries
|
||||
item.AddPoints(points, false);
|
||||
|
||||
item.DeletePointsBeforeX(_previousX - ChartXDateTimeRange);
|
||||
//item.DeletePointsBeforeX(_previousX - 100);
|
||||
|
||||
if (ScrollEnable)
|
||||
{
|
||||
lightningChart1.ViewXY.XAxes[0].ScrollPosition = _previousX;
|
||||
}
|
||||
|
||||
|
||||
//Allow updates again, and update
|
||||
lightningChart1.EndUpdate();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据名称获取曲线所需的数据
|
||||
/// </summary>
|
||||
private double GetChartRtValue(string Name)
|
||||
{
|
||||
try
|
||||
{
|
||||
var Data = ListChartRtValue.Find(a => a.Name == Name);
|
||||
if (Data != null)
|
||||
{
|
||||
return Data.Value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//logger.Error(String.Format("ErrSource : {0} ErrMsg : {1}", ex.StackTrace.ToString(), ex.Message.ToString()));
|
||||
return 0;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 曲线个数
|
||||
/// </summary>
|
||||
private int MainRealTimeChartSeriesCount = 0;
|
||||
|
||||
/// <summary>
|
||||
/// LightingChart图标的初始化
|
||||
/// </summary>
|
||||
private void LoadLighingChart()
|
||||
{
|
||||
//Disable rendering, strongly recommended before updating chart properties
|
||||
lightningChart1.BeginUpdate();
|
||||
|
||||
//Reduce memory usage and increase performance. Destroys out-scrolled data.
|
||||
lightningChart1.ViewXY.DropOldSeriesData = false;
|
||||
//多个Y曲线摆放形式
|
||||
lightningChart1.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Layered;
|
||||
//网格带
|
||||
lightningChart1.ViewXY.AxisLayout.AxisGridStrips = XYAxisGridStrips.X;
|
||||
//y轴的在左边还是右边
|
||||
lightningChart1.ViewXY.AxisLayout.YAxisAutoPlacement = YAxisAutoPlacement.AllLeft;
|
||||
|
||||
//lightningChart1.Parent = this.panel1;
|
||||
//lightningChart1.Name = "Temperature measurement _chart";
|
||||
lightningChart1.Title.Text = "实时曲线";
|
||||
|
||||
//lightningChart1.ViewXY.
|
||||
//lightningChart1.Dock = DockStyle.Fill;
|
||||
|
||||
//清除Y轴系列
|
||||
//lightningChart1.ViewXY.YAxes.Clear();
|
||||
var InitAxisY = new AxisY(lightningChart1.ViewXY);
|
||||
InitAxisY.Visible = false;
|
||||
InitAxisY.ZoomingEnabled = false;
|
||||
lightningChart1.ViewXY.YAxes.Add(InitAxisY);
|
||||
|
||||
|
||||
|
||||
//Configure x-axis
|
||||
AxisX xAxis = lightningChart1.ViewXY.XAxes[0];
|
||||
xAxis.ValueType = AxisValueType.DateTime;
|
||||
xAxis.Title.Text = "时间";
|
||||
xAxis.AutoFormatLabels = true;
|
||||
xAxis.LabelsTimeFormat = "MM/dd \n HH:mm.ss";
|
||||
//xAxis.LabelsTimeFormat = "dd/MM/yyyy\nHH:mm.ss";
|
||||
xAxis.LabelsAngle = 45;
|
||||
//xAxis.SteppingInterval = 0.1;
|
||||
//xAxis.ScrollingGap = 15;
|
||||
|
||||
//xAxis.AllowScaling = true;
|
||||
|
||||
xAxis.ScrollMode = XAxisScrollMode.Scrolling;
|
||||
xAxis.ZoomingEnabled = true;
|
||||
|
||||
//Convert DateTime values to axis values
|
||||
DateTime now = DateTime.Now;
|
||||
double minX = xAxis.DateTimeToAxisValue(now);
|
||||
double maxX = xAxis.DateTimeToAxisValue(now.AddMinutes(60));
|
||||
xAxis.SetRange(minX, maxX);
|
||||
|
||||
|
||||
//DateTime now = DateTime.Now;
|
||||
|
||||
//xAxis.SetDateTimeRange(now,now.AddMinutes(60));
|
||||
|
||||
|
||||
|
||||
//光标数据
|
||||
//Add an annotation to show the cursor values
|
||||
//AnnotationXY cursorValueDisplay = new AnnotationXY();
|
||||
AnnotationXY cursorValueDisplay = new AnnotationXY(lightningChart1.ViewXY, lightningChart1.ViewXY.XAxes[0], lightningChart1.ViewXY.YAxes[0]);
|
||||
cursorValueDisplay.Style = AnnotationStyle.RoundedCallout;
|
||||
cursorValueDisplay.LocationCoordinateSystem = CoordinateSystem.RelativeCoordinatesToTarget;
|
||||
cursorValueDisplay.LocationRelativeOffset.X = 130;
|
||||
cursorValueDisplay.LocationRelativeOffset.Y = -100;
|
||||
cursorValueDisplay.Sizing = AnnotationXYSizing.Automatic;
|
||||
//cursorValueDisplay.TextStyle.Font = new WpfFont("Lucida console", 10f, FontStyle.Regular);
|
||||
cursorValueDisplay.TextStyle.Color = System.Windows.Media.Color.FromRgb(0, 0, 0);
|
||||
cursorValueDisplay.Text = "";
|
||||
cursorValueDisplay.Fill.Color = System.Windows.Media.Color.FromRgb(255, 255, 255);
|
||||
cursorValueDisplay.Fill.GradientColor = System.Windows.Media.Color.FromRgb(120, 120, 120);
|
||||
cursorValueDisplay.BorderVisible = false;
|
||||
cursorValueDisplay.AllowTargetMove = false;
|
||||
cursorValueDisplay.Visible = false;
|
||||
lightningChart1.ViewXY.Annotations.Add(cursorValueDisplay);
|
||||
|
||||
//Add cursor
|
||||
LineSeriesCursor cursor = new LineSeriesCursor(lightningChart1.ViewXY, lightningChart1.ViewXY.XAxes[0]);
|
||||
lightningChart1.ViewXY.LineSeriesCursors.Add(cursor);
|
||||
cursor.PositionChanged += cursor_PositionChanged;
|
||||
cursor.ValueAtXAxis = lightningChart1.ViewXY.XAxes[0].DateTimeToAxisValue(DateTime.Now.AddMinutes(30));
|
||||
cursor.LineStyle.Color = System.Windows.Media.Color.FromRgb(200, 200, 200);
|
||||
cursor.SnapToPoints = false;
|
||||
cursor.TrackPoint.Color1 = System.Windows.Media.Color.FromRgb(255, 255, 255);
|
||||
cursor.Style = CursorStyle.PointTracking;
|
||||
|
||||
|
||||
|
||||
lightningChart1.Loaded += LightningChart1_Loaded;
|
||||
lightningChart1.SizeChanged += LightningChart1_SizeChanged;
|
||||
//lightningChart1.Resize += new EventHandler(_chart_Resize);
|
||||
|
||||
////清除Y轴系列
|
||||
//lightningChart1.ViewXY.YAxes.Clear();
|
||||
|
||||
//Don't show legendbox
|
||||
lightningChart1.ViewXY.LegendBoxes[0].Visible = true;
|
||||
lightningChart1.ViewXY.LegendBoxes[0].Position = LegendBoxPositionXY.TopCenter;
|
||||
//Allow chart rendering
|
||||
lightningChart1.EndUpdate();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void LightningChart1_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
|
||||
{
|
||||
UpdateCursorResult();
|
||||
}
|
||||
|
||||
private void LightningChart1_Loaded(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
UpdateCursorResult();
|
||||
}
|
||||
|
||||
private void cursor_PositionChanged(object sender, PositionChangedEventArgs e)
|
||||
{
|
||||
e.CancelRendering = true;
|
||||
|
||||
UpdateCursorResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update cursor texts.
|
||||
/// </summary>
|
||||
private void UpdateCursorResult()
|
||||
{
|
||||
bool showNextToCursor = true;
|
||||
|
||||
//Disable rendering, strongly recommended before updating chart properties
|
||||
lightningChart1.BeginUpdate();
|
||||
|
||||
//Get cursor
|
||||
LineSeriesCursor cursor = lightningChart1.ViewXY.LineSeriesCursors[0];
|
||||
|
||||
//Get annotation
|
||||
AnnotationXY cursorValueDisplay = lightningChart1.ViewXY.Annotations[0];
|
||||
|
||||
//Set annotation target. The location is relative to target.
|
||||
//Use graph bottom as target Y value.
|
||||
float targetYCoord = (float)lightningChart1.ViewXY.GetMarginsRect().Bottom;
|
||||
double y;
|
||||
lightningChart1.ViewXY.YAxes[0].CoordToValue(targetYCoord, out y);
|
||||
cursorValueDisplay.TargetAxisValues.X = cursor.ValueAtXAxis;
|
||||
cursorValueDisplay.TargetAxisValues.Y = y;
|
||||
|
||||
double seriesYValue = 0;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int seriesIndex = 1;
|
||||
|
||||
string channelStringFormat = "{0}: {1}";
|
||||
bool labelVisible = false;
|
||||
bool accurateValue = false;
|
||||
string value = "";
|
||||
|
||||
foreach (PointLineSeries pointLineSeries in lightningChart1.ViewXY.PointLineSeries)
|
||||
{
|
||||
//show series titles and cursor values in them, on the right side of the chart,
|
||||
//if cursor values are not shown next to the cursor in an annotation
|
||||
pointLineSeries.Title.Visible = !showNextToCursor;
|
||||
bool resolved = false;
|
||||
value = "";
|
||||
|
||||
if (accurateValue)
|
||||
resolved = SolveValueAccurate(pointLineSeries, cursor.ValueAtXAxis, out seriesYValue);
|
||||
else
|
||||
resolved = SolveValueCoarse(pointLineSeries, cursor.ValueAtXAxis, out seriesYValue);
|
||||
|
||||
AxisY axisY = lightningChart1.ViewXY.YAxes[pointLineSeries.AssignYAxisIndex];
|
||||
|
||||
if (resolved)
|
||||
{
|
||||
labelVisible = true;
|
||||
//value = string.Format(channelStringFormat, seriesIndex, seriesYValue.ToString("0.000"), axisY.Units.Text);
|
||||
value = string.Format(channelStringFormat, pointLineSeries.Title.Text, seriesYValue.ToString("0.000"));
|
||||
}
|
||||
else
|
||||
{
|
||||
//value = string.Format(channelStringFormat, seriesIndex, "---", axisY.Units.Text);
|
||||
value = string.Format(channelStringFormat, pointLineSeries.Title.Text, "---");
|
||||
}
|
||||
sb.AppendLine(value);
|
||||
//这个会改变曲线标题的名称,影响曲线的定位、删除等操作
|
||||
//pointLineSeries.Title.Text = value;
|
||||
seriesIndex++;
|
||||
}
|
||||
|
||||
//sb.AppendLine("");
|
||||
//sb.AppendLine("时间: " + lightningChart1.ViewXY.XAxes[0].TimeString(cursor.ValueAtXAxis, "HH:mm:ss.ffff"));
|
||||
|
||||
////Set text
|
||||
cursorValueDisplay.Text = sb.ToString();
|
||||
|
||||
////Show the label only if it selected to be shown
|
||||
cursorValueDisplay.Visible = labelVisible && showNextToCursor;
|
||||
|
||||
//Allow chart rendering
|
||||
lightningChart1.EndUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Solve value from series data points array. Accurate method, but slower than SolveValueCoarse
|
||||
/// </summary>
|
||||
/// <param name="series">Series</param>
|
||||
/// <param name="xValue">X value</param>
|
||||
/// <param name="yValue">Output Y value</param>
|
||||
/// <returns>Success status</returns>
|
||||
private bool SolveValueAccurate(PointLineSeries series, double xValue, out double yValue)
|
||||
{
|
||||
AxisY axisY = lightningChart1.ViewXY.YAxes[series.AssignYAxisIndex];
|
||||
yValue = 0;
|
||||
|
||||
LineSeriesValueSolveResult result = series.SolveYValueAtXValue(xValue);
|
||||
if (result.SolveStatus == LineSeriesSolveStatus.OK)
|
||||
{
|
||||
//PointLineSeries may have two or more points at same X value. If so, center it between min and max
|
||||
yValue = (result.YMax + result.YMin) / 2.0;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Solve value from screen coordinates. Faster method, but not less accurateValue than SolveValueAccurate
|
||||
/// </summary>
|
||||
/// <param name="series">Series</param>
|
||||
/// <param name="xValue">X value</param>
|
||||
/// <param name="yValue">Output Y value</param>
|
||||
/// <returns>Success status</returns>
|
||||
private bool SolveValueCoarse(PointLineSeries series, double xValue, out double yValue)
|
||||
{
|
||||
AxisY axisY = lightningChart1.ViewXY.YAxes[series.AssignYAxisIndex];
|
||||
float coordX = lightningChart1.ViewXY.XAxes[0].ValueToCoord(xValue);
|
||||
float coordY;
|
||||
yValue = 0;
|
||||
|
||||
LineSeriesCoordinateSolveResult result = series.SolveYCoordAtXCoord(coordX);
|
||||
if (result.SolveStatus == LineSeriesSolveStatus.OK)
|
||||
{
|
||||
coordY = (result.CoordBottom + result.CoordTop) / 2f;
|
||||
if (axisY.CoordToValue((int)Math.Round(coordY), out yValue) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 增加Y轴
|
||||
/// </summary>
|
||||
/// <param name="Name"></param>
|
||||
/// <param name="MaxVal"></param>
|
||||
/// <param name="MinVal"></param>
|
||||
private void AddYAxis(string Name, double MinVal, double MaxVal)
|
||||
{
|
||||
lightningChart1.BeginUpdate();
|
||||
|
||||
var CreateAxisY = new AxisY();
|
||||
CreateAxisY.Title.Text = Name;
|
||||
CreateAxisY.Title.AllowDragging = false;
|
||||
CreateAxisY.SetRange(MinVal, MaxVal);
|
||||
CreateAxisY.MajorGrid.Visible = false;
|
||||
//取消滚轮缩放
|
||||
CreateAxisY.ZoomingEnabled = false;
|
||||
lightningChart1.ViewXY.YAxes.Add(CreateAxisY);
|
||||
|
||||
//Configure and add series to the chart
|
||||
PointLineSeries CreateSeries = new PointLineSeries(lightningChart1.ViewXY, lightningChart1.ViewXY.XAxes[0], CreateAxisY);
|
||||
CreateSeries.Title.Text = Name;
|
||||
CreateSeries.LineStyle.Color = ChartConfigInfo.ListColor[lightningChart1.ViewXY.YAxes.Count + 1];
|
||||
CreateSeries.AllowUserInteraction = false;
|
||||
lightningChart1.ViewXY.PointLineSeries.Add(CreateSeries);
|
||||
|
||||
lightningChart1.EndUpdate();
|
||||
MainRealTimeChartSeriesCount++;
|
||||
}
|
||||
|
||||
private void DeleteYAxis(string Name)
|
||||
{
|
||||
lightningChart1.BeginUpdate();
|
||||
|
||||
for (int i = 0; i < lightningChart1.ViewXY.YAxes.Count; i++)
|
||||
{
|
||||
if (lightningChart1.ViewXY.YAxes[i].Title.Text == Name)
|
||||
{
|
||||
lightningChart1.ViewXY.YAxes.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < lightningChart1.ViewXY.PointLineSeries.Count; i++)
|
||||
{
|
||||
if (lightningChart1.ViewXY.PointLineSeries[i].Title.Text == Name)
|
||||
{
|
||||
lightningChart1.ViewXY.PointLineSeries.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lightningChart1.EndUpdate();
|
||||
if (MainRealTimeChartSeriesCount <= 0)
|
||||
{
|
||||
MainRealTimeChartSeriesCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainRealTimeChartSeriesCount--;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user