运行暂停按钮功能

This commit is contained in:
sc committed 2025-05-07 23:35:19 +08:00
commit 87bec34e0a
9 files changed
+147 -27

No files matched your search

+25 -8
View File
@@ -10,17 +10,24 @@
mc:Ignorable="d" Loaded="UserControl_Loaded"
KeyDown="UserControl_KeyDown"
d:DesignHeight="630" d:DesignWidth="1280">
<Grid Focusable="True">
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged"
<Grid>
<DataGrid x:Name="GridSTEP" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged"
Margin="630,40,0,0" d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
ItemsSource="{Binding Path=TechnologicalProcess_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="{x:Null}"
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" AllowDrop="False"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
CanUserAddRows="True" CanUserDeleteRows="False" HeadersVisibility ="Column"
Background="White" SelectionMode="Single" FontSize="15" MinHeight="632" TabIndex="1" Focusable="True">
Background="White" SelectionMode="Single" FontSize="15" MinHeight="632" TabIndex="1" Focusable="True" >
<DataGrid.Resources>
<Style TargetType="ScrollViewer">
<Setter Property="PanningMode" Value="VerticalOnly"/>
</Style>
</DataGrid.Resources>
<DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="IsHitTestVisible" Value="{Binding DataContext.IsInteractive,
RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<Setter Property="Height" Value="30" />
<Setter Property="FontSize" Value="25" />
<Style.Triggers>
@@ -77,7 +84,10 @@
<DataGridTextColumn Binding="{Binding DYELOT}" Width="0" MinWidth="0" MaxWidth="0"/>
</DataGrid.Columns>
</DataGrid>
<TextBlock x:Name="log" HorizontalAlignment="Left" TextWrapping="Wrap" Width="600" FontSize="25" Background="White" Text="{Binding Sys_log}" Margin="0,40,0,0"/>
<ScrollViewer HorizontalAlignment="Left" Width="600" Margin="0,40,0,0" VerticalScrollBarVisibility="Auto"
PanningMode="VerticalOnly">
<TextBlock x:Name="log" TextWrapping="Wrap" FontSize="25" Background="White" Text="{Binding Sys_log}" />
</ScrollViewer>
<TextBlock x:Name="name" HorizontalAlignment="Left" Margin="600,0,0,0" TextWrapping="Wrap" FontSize="24" Background="#FFD0D0D0" Text="{Binding Program_Name}" Height="30" Block.TextAlignment="Center">
<TextBlock.LayoutTransform>
<!--文字同样旋转90度-->
@@ -89,10 +99,17 @@
<Button Content="{x:Static lang:Resources.Receipt}" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="Receipt_Click"/>
<Button Content="{x:Static lang:Resources.ParameterSet}" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="ParameterSet_Click"/>
</WrapPanel>
<WrapPanel Orientation="Horizontal" Background="#FFCCCCCC" VerticalAlignment="Top" Margin="630,0,0,0">
<Button Content="{x:Static lang:Resources.edit}" x:Name="ProgramgroupView_edit" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_edit_Click"/>
<Button Content="{x:Static lang:Resources.Delete}" x:Name="ProgramgroupView_del" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_del_Click"/>
<Button Content="{x:Static lang:Resources.Insert}" x:Name="ProgramgroupView_Insert" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Insert_Click"/>
<WrapPanel Orientation="Horizontal" Background="#FFCCCCCC" VerticalAlignment="Top" Margin="630,0,0,0">
<Button Content="{x:Static lang:Resources.edit}" x:Name="ProgramgroupView_edit" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White"
Click="ProgramgroupView_edit_Click" IsEnabled="{Binding UserButton}"/>
<Button Content="{x:Static lang:Resources.Delete}" x:Name="ProgramgroupView_del" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White"
Click="ProgramgroupView_del_Click" IsEnabled="{Binding UserButton}"/>
<Button Content="{x:Static lang:Resources.Insert}" x:Name="ProgramgroupView_Insert" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White"
Click="ProgramgroupView_Insert_Click" IsEnabled="{Binding UserButton}"/>
<Button Content="{x:Static lang:Resources.R_P}" x:Name="ProgramgroupView_run" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White"
Click="ProgramgroupView_run_Click" Command="{Binding ProgramgroupView_run}"/>
<Button Content="{x:Static lang:Resources.StopProcess}" x:Name="ProgramgroupView_stop" FontSize="20" HorizontalAlignment="Left" Height="40" VerticalAlignment="Top" Width="200" Background="White"
Click="ProgramgroupView_stop_Click" IsEnabled="{Binding UserButton}"/>
</WrapPanel>
</Grid>
</UserControl>
+51 -17
View File
@@ -33,11 +33,28 @@ namespace DyeingComputer.View
/// </summary>
public partial class TechnologicalProcessView : UserControl
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public void RaisePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
if (propertyName != null)
{
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
public TechnologicalProcessView()
{
InitializeComponent();
//Grid.DataContext = new MainWindowViewModel();
FocusManager.SetFocusedElement(Grid, Grid);
// FocusManager.SetFocusedElement(Grid, Grid);
// if (workName != null)
// {
// TechnologicalProcess_Import();
@@ -45,7 +62,11 @@ namespace DyeingComputer.View
// else
// {
TechnologicalProcess_sql();
// }
// }
// ProgramgroupView_edit.IsEnabled = false;
// ProgramgroupView_del.IsEnabled = false;
// ProgramgroupView_Insert.IsEnabled = false;
}
public static object workName;
@@ -108,11 +129,11 @@ namespace DyeingComputer.View
// Grid.DataContext = new MainWindowViewModel();
if (workName != null)
{
Grid.SelectedIndex = 0;
GridSTEP.SelectedIndex = 0;
}
else
{
if (MainWindowViewModel.WORK_RUN != 0) Grid.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
if (MainWindowViewModel.WORK_RUN != 0) GridSTEP.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
}
CountDown();
}
@@ -166,7 +187,7 @@ namespace DyeingComputer.View
dr.EndEdit();
dt_TP = sql.Tables[0];
Grid.SelectedIndex = -1;
GridSTEP.SelectedIndex = -1;
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
@@ -208,7 +229,7 @@ namespace DyeingComputer.View
dt_TP.Rows.RemoveAt(d - 1);
Dat();
Grid.SelectedIndex = -1;
GridSTEP.SelectedIndex = -1;
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
@@ -275,7 +296,16 @@ namespace DyeingComputer.View
{
}
private void ProgramgroupView_run_Click(object sender, RoutedEventArgs e)//运行/暂停
{
}
private void ProgramgroupView_stop_Click(object sender, RoutedEventArgs e)//结束工艺
{
}
private void ParameterSet_Click(object sender, RoutedEventArgs e)
{
@@ -284,20 +314,24 @@ namespace DyeingComputer.View
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (MainWindowViewModel.WORK_RUN == 2) Grid.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
if (MainWindowViewModel.WORK_RUN == 2) GridSTEP.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
int rownum = GridSTEP.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
ID = (Grid.Columns[2].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
Numder = (Grid.Columns[3].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
P1 = (Grid.Columns[6].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第6列,
P2 = (Grid.Columns[7].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第7列,
P3 = (Grid.Columns[8].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第8列,
P4 = (Grid.Columns[9].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第9列,
P5 = (Grid.Columns[10].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第10列,
ID = (GridSTEP.Columns[2].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第0列,
Numder = (GridSTEP.Columns[3].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第1列,
P1 = (GridSTEP.Columns[6].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第6列,
P2 = (GridSTEP.Columns[7].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第7列,
P3 = (GridSTEP.Columns[8].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第8列,
P4 = (GridSTEP.Columns[9].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第9列,
P5 = (GridSTEP.Columns[10].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第10列,
ProgramgroupView_edit.IsEnabled = true;
ProgramgroupView_del.IsEnabled = true;
ProgramgroupView_Insert.IsEnabled = true;
}
}
public void CountDown()
{
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
@@ -309,7 +343,7 @@ namespace DyeingComputer.View
}
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
{
if (MainWindowViewModel.WORK_RUN == 2) Grid.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
if (MainWindowViewModel.WORK_RUN == 2) GridSTEP.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
if (sql != null)
{
dt_TP= sql.Tables[0];