Browse Source

步骤编辑相关修改

master
sc 1 month ago
parent
commit
4f9195c552
  1. 132
      KEY/TouchKeyboard.xaml
  2. 116
      KEY/TouchKeyboard.xaml.cs
  3. 100
      KEY/TouchKeyboardNumeral.xaml
  4. 215
      KEY/TouchKeyboardNumeral.xaml.cs
  5. 14
      SunlightCentralizedControlManagement_SCCM_.csproj
  6. 26
      UserClass/AsyncSerialPortClient.cs
  7. 54
      View/DyeingPlanView.xaml.cs
  8. 137
      View/MonitorView.xaml.cs
  9. 35
      View/ProductionPlanningEdit.xaml.cs
  10. 129
      View/ProgramstepsView .xaml
  11. 154
      View/ProgramstepsView .xaml.cs
  12. 163
      WindowsView/ViewStep.xaml
  13. 1410
      WindowsView/ViewStep.xaml.cs

132
KEY/TouchKeyboard.xaml

@ -0,0 +1,132 @@
<Window x:Class="SunlightCentralizedControlManagement_SCCM_.KEY.TouchKeyboard"
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:SunlightCentralizedControlManagement_SCCM_.WindowsView"
mc:Ignorable="d" WindowStyle="None" ResizeMode="NoResize" Topmost="True"
WindowStartupLocation="CenterScreen"
Title="TouchKeyboard" Height="500" Width="750">
<Window.Resources>
<Style x:Key="KeyButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#FFF0F0F0"/>
<Setter Property="BorderBrush" Value="#FFCCCCCC"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="MinWidth" Value="60"/>
<Setter Property="MinHeight" Value="40"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#FFDDDDDD"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SpecialKeyButtonStyle" BasedOn="{StaticResource KeyButtonStyle}" TargetType="Button">
<Setter Property="Background" Value="#FFE0E0E0"/>
<Setter Property="FontSize" Value="16"/>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 预览区域 -->
<TextBox x:Name="PreviewTextBox" Grid.Row="0" Height="60" Margin="10"
FontSize="24" VerticalContentAlignment="Center" IsReadOnly="False"/>
<!-- 键盘主体区域 -->
<Grid Grid.Row="1" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 数字行 -->
<StackPanel Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Center">
<Button Content="1" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="2" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="3" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="4" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="5" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="6" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="7" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="8" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="9" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="0" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="DEL" Style="{StaticResource SpecialKeyButtonStyle}" Click="Backspace_Click" Width="60"/>
</StackPanel>
<!-- 第一行字母 -->
<StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center">
<Button Content="Q" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="W" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="E" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="R" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="T" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="Y" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="U" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="I" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="O" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="P" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
</StackPanel>
<!-- 第二行字母 -->
<StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Center">
<Button Content="A" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="S" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="D" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="F" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="G" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="H" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="J" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="K" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="L" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="/" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="HIDE" Style="{StaticResource SpecialKeyButtonStyle}" Click="Hide_Click" Width="60"/>
</StackPanel>
<!-- 第三行字母 -->
<StackPanel Orientation="Horizontal" Grid.Row="3" HorizontalAlignment="Center">
<Button x:Name="ShiftButton" Content="⇧" Style="{StaticResource SpecialKeyButtonStyle}" Click="Shift_Click" Width="60"/>
<Button Content="Z" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="X" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="C" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="V" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="B" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="N" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="M" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="." Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="ENTER" Style="{StaticResource SpecialKeyButtonStyle}" Click="Enter_Click" Width="120"/>
</StackPanel>
</Grid>
<!-- 状态栏 -->
<StatusBar Grid.Row="2">
<StatusBarItem>
<TextBlock x:Name="StatusTextBlock" Text="就绪"/>
</StatusBarItem>
</StatusBar>
</Grid>
</Window>

116
KEY/TouchKeyboard.xaml.cs

@ -0,0 +1,116 @@
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.Shapes;
using static SunlightCentralizedControlManagement_SCCM_.KEY.TouchKeyboardNumeral;
namespace SunlightCentralizedControlManagement_SCCM_.KEY
{
/// <summary>
/// TouchKeyboard.xaml 的交互逻辑
/// </summary>
public partial class TouchKeyboard : Window
{
private bool isShiftActive = false;
public string KeyValue;
public event EventHandler<KeyPressedEventArgs> KeyPressed;
public TouchKeyboard()
{
InitializeComponent();
}
private void KeyButton_Click(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
if (button != null)
{
string key = button.Content.ToString();
if (key.Length == 1 && char.IsLetter(key[0]))
{
key = isShiftActive ? key.ToUpper() : key.ToLower();
}
PreviewTextBox.Text += key;
// 输入后关闭Shift状态
if (isShiftActive)
{
isShiftActive = false;
UpdateButtonAppearance();
}
}
}
private void Shift_Click(object sender, RoutedEventArgs e)
{
isShiftActive = !isShiftActive;
UpdateButtonAppearance();
}
private void Backspace_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(PreviewTextBox.Text))
{
PreviewTextBox.Text = PreviewTextBox.Text.Substring(0, PreviewTextBox.Text.Length - 1);
}
}
private void Enter_Click(object sender, RoutedEventArgs e)
{
// 触发回车事件
KeyPressed?.Invoke(this, new KeyPressedEventArgs(KeyType.Enter, PreviewTextBox.Text));
this.Close();
// PreviewTextBox.Text += Environment.NewLine;
}
private void Hide_Click(object sender, RoutedEventArgs e)
{
KeyPressed?.Invoke(this, new KeyPressedEventArgs(KeyType.Hide, ""));
this.Close();
}
private void UpdateButtonAppearance()
{
// 更新Shift按钮的外观以反映当前状态
if (isShiftActive)
{
ShiftButton.Background = new SolidColorBrush(Colors.LightBlue);
}
else
{
ShiftButton.Background = new SolidColorBrush(Color.FromRgb(224, 224, 224));
}
}
public class KeyPressedEventArgs : EventArgs
{
public KeyType KeyType { get; }
public string KeyValue { get; }
public KeyPressedEventArgs(KeyType keyType, string keyValue)
{
KeyType = keyType;
KeyValue = keyValue;
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// 初始化为默认模式
// SetKeyboardMode(KeyboardMode.Default);
PreviewTextBox.Text = null;
}
}
}

100
KEY/TouchKeyboardNumeral.xaml

@ -0,0 +1,100 @@
<Window x:Class="SunlightCentralizedControlManagement_SCCM_.KEY.TouchKeyboardNumeral"
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:SunlightCentralizedControlManagement_SCCM_.WindowsView"
mc:Ignorable="d"
WindowStyle="None"
ResizeMode="NoResize"
Topmost="True"
WindowStartupLocation="CenterScreen"
Title="TouchKeyboardNumeral"
Loaded="Window_Loaded"
Height="500" Width="550">
<Window.Resources>
<Style x:Key="KeyButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#FFF0F0F0"/>
<Setter Property="BorderBrush" Value="#FFCCCCCC"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="MinWidth" Value="100"/>
<Setter Property="MinHeight" Value="40"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#FFDDDDDD"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="#FFBBBBBB"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SpecialKeyButtonStyle" BasedOn="{StaticResource KeyButtonStyle}" TargetType="Button">
<Setter Property="Background" Value="#FFE0E0E0"/>
<Setter Property="FontSize" Value="16"/>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 预览区域 -->
<TextBox x:Name="PreviewTextBox" Grid.Row="0" Height="60" Margin="10"
FontSize="24" VerticalContentAlignment="Center" IsReadOnly="False"/>
<!-- 键盘主体区域 -->
<Grid Grid.Row="1" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 数字行 -->
<StackPanel x:Name="FirstRow" Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Center">
<Button Content="7" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="8" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="9" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="0" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="DEL" Style="{StaticResource SpecialKeyButtonStyle}" Click="Backspace_Click" Width="60"/>
</StackPanel>
<!-- 数字行 -->
<StackPanel x:Name="SecondRow" Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center">
<Button Content="4" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="5" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="6" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="." Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="HIDE" Style="{StaticResource SpecialKeyButtonStyle}" Click="Hide_Click" Width="60"/>
</StackPanel>
<!-- 数字行 -->
<StackPanel x:Name="ThirdRow" Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Center">
<Button Content="1" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="2" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="3" Style="{StaticResource KeyButtonStyle}" Click="KeyButton_Click"/>
<Button Content="ENTER" Style="{StaticResource SpecialKeyButtonStyle}" Click="Enter_Click" Width="200"/>
</StackPanel>
</Grid>
</Grid>
</Window>

215
KEY/TouchKeyboardNumeral.xaml.cs

@ -0,0 +1,215 @@
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.Shapes;
namespace SunlightCentralizedControlManagement_SCCM_.KEY
{
/// <summary>
/// TouchKeyboard.xaml 的交互逻辑
/// </summary>
public partial class TouchKeyboardNumeral : Window
{
private bool mode = false;
public string KeyValue;
public event EventHandler<KeyPressedEventArgs> KeyPressed;
private KeyboardMode currentMode = KeyboardMode.Default;
private int minValue = 0;
private int maxValue = 9;
private TextBox targetTextBox;
// 定义键盘模式枚举
public enum KeyboardMode
{
Default, // 默认模式,所有键可用
NumericOnly, // 只允许数字
DecimalOnly, // 允许数字和小数点
LimitedRange // 限制数字范围
}
public TouchKeyboardNumeral()
{
InitializeComponent();
}
public void SetKeyboardMode(KeyboardMode mode, TextBox target = null, int min = 0, int max = 9)
{
currentMode = mode;
targetTextBox = target;
minValue = min;
maxValue = max;
UpdateKeyboardLayout();
}
private void UpdateKeyboardLayout()
{
switch (currentMode)
{
case KeyboardMode.NumericOnly:
// 只允许数字,禁用小数点
SetButtonEnabled(".", false);
break;
case KeyboardMode.DecimalOnly:
// 允许数字和小数点
SetButtonEnabled(".", true);
break;
case KeyboardMode.LimitedRange:
// 根据范围启用/禁用数字键
for (int i = 0; i <= 9; i++)
{
SetButtonEnabled(i.ToString(), i >= minValue && i <= maxValue);
}
mode = true;
break;
case KeyboardMode.Default:
default:
// 启用所有键
foreach (var element in FirstRow.Children)
{
if (element is Button button && char.IsDigit(button.Content.ToString()[0]))
button.IsEnabled = true;
}
foreach (var element in SecondRow.Children)
{
if (element is Button button && (char.IsDigit(button.Content.ToString()[0]) || button.Content.ToString() == "."))
button.IsEnabled = true;
}
foreach (var element in ThirdRow.Children)
{
if (element is Button button && char.IsDigit(button.Content.ToString()[0]))
button.IsEnabled = true;
}
break;
}
}
// 设置按钮启用状态
private void SetButtonEnabled(string content, bool enabled)
{
// 在第一行查找
foreach (var element in FirstRow.Children)
{
if (element is Button button && button.Content.ToString() == content)
{
button.IsEnabled = enabled;
return;
}
}
// 在第二行查找
foreach (var element in SecondRow.Children)
{
if (element is Button button && button.Content.ToString() == content)
{
button.IsEnabled = enabled;
return;
}
}
// 在第三行查找
foreach (var element in ThirdRow.Children)
{
if (element is Button button && button.Content.ToString() == content)
{
button.IsEnabled = enabled;
return;
}
}
}
// 数字键点击事件
private void KeyButton_Click(object sender, RoutedEventArgs e)
{
if (mode && PreviewTextBox.Text.Length > 0) return;
Button button = sender as Button;
if (button != null && button.IsEnabled)
{
string keyValue = button.Content.ToString();
PreviewTextBox.Text += keyValue;
// 触发按键事件
// KeyPressed?.Invoke(this, new KeyPressedEventArgs(KeyType.Character, keyValue));
}
}
// 退格键点击事件
private void Backspace_Click(object sender, RoutedEventArgs e)
{
if (PreviewTextBox.Text.Length > 0)
{
PreviewTextBox.Text = PreviewTextBox.Text.Substring(0, PreviewTextBox.Text.Length - 1);
// 触发退格事件
// KeyPressed?.Invoke(this, new KeyPressedEventArgs(KeyType.Backspace, ""));
}
}
// 回车键点击事件
private void Enter_Click(object sender, RoutedEventArgs e)
{
// 触发回车事件
KeyPressed?.Invoke(this, new KeyPressedEventArgs(KeyType.Enter, PreviewTextBox.Text));
// 隐藏键盘
this.Hide();
}
// 隐藏键点击事件
private void Hide_Click(object sender, RoutedEventArgs e)
{
KeyPressed?.Invoke(this, new KeyPressedEventArgs(KeyType.Hide, ""));
// 隐藏键盘
this.Hide();
}
public class KeyPressedEventArgs : EventArgs
{
public KeyType KeyType { get; }
public string KeyValue { get; }
public KeyPressedEventArgs(KeyType keyType, string keyValue)
{
KeyType = keyType;
KeyValue = keyValue;
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// 初始化为默认模式
// SetKeyboardMode(KeyboardMode.Default);
PreviewTextBox.Text = null;
mode = false;
}
}
// 按键类型枚举
public enum KeyType
{
Character,
Backspace,
Enter,
Hide
}
// 按键事件参数
public class KeyPressedEventArgs : EventArgs
{
public KeyType KeyType { get; }
public string KeyValue { get; }
public KeyPressedEventArgs(KeyType keyType, string keyValue)
{
KeyType = keyType;
KeyValue = keyValue;
}
}
}

14
SunlightCentralizedControlManagement_SCCM_.csproj

@ -110,6 +110,12 @@
<DependentUpon>DispenseState.xaml</DependentUpon>
</Compile>
<Compile Include="EX\Exchange\BDC_SQL.cs" />
<Compile Include="KEY\TouchKeyboard.xaml.cs">
<DependentUpon>TouchKeyboard.xaml</DependentUpon>
</Compile>
<Compile Include="KEY\TouchKeyboardNumeral.xaml.cs">
<DependentUpon>TouchKeyboardNumeral.xaml</DependentUpon>
</Compile>
<Compile Include="EX\ManualDyelot.xaml.cs">
<DependentUpon>ManualDyelot.xaml</DependentUpon>
</Compile>
@ -241,6 +247,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="KEY\TouchKeyboard.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="KEY\TouchKeyboardNumeral.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="EX\ManualDyelot.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

26
UserClass/AsyncSerialPortClient.cs

@ -129,7 +129,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{
try
{
return EasyTask.CompletedTask; ;
// return EasyTask.CompletedTask; ;
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
@ -275,7 +275,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{
//a.Add<MyPlugin>();
}));
await portclient.ConnectAsync();
try
{
await portclient.ConnectAsync();
}
catch (Exception ex) { LogGing.ERRDATA(ex); }
}
public static async Task PortClient2(SerialPortClient portclient, string com, int BAUD)
{
@ -308,7 +312,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{
//a.Add<MyPlugin>();
}));
await portclient.ConnectAsync();
try
{
await portclient.ConnectAsync();
}
catch (Exception ex) { LogGing.ERRDATA(ex); }
}
public static async Task PortClient3(SerialPortClient portclient, string com, int BAUD)
{
@ -341,7 +349,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{
//a.Add<MyPlugin>();
}));
await portclient.ConnectAsync();
try
{
await portclient.ConnectAsync();
}
catch (Exception ex) { LogGing.ERRDATA(ex); }
}
public static async Task PortClient4(SerialPortClient portclient, string com, int BAUD)
{
@ -374,7 +386,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{
//a.Add<MyPlugin>();
}));
await portclient.ConnectAsync();
try
{
await portclient.ConnectAsync();
}
catch (Exception ex) { LogGing.ERRDATA(ex); }
}
public static readonly ManualResetEventSlim _responseEvent = new ManualResetEventSlim(false);

54
View/DyeingPlanView.xaml.cs

@ -33,8 +33,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
/// ProductionPlanningEdit.xaml 的交互逻辑
/// </summary>
public partial class DyeingPlanView : UserControl
{
DataTable ProgramName = new DataTable();
{
DataTable ProgramName = new DataTable();
DataTable WorkOrder =new DataTable();
DataTable dat = new DataTable();
DataTable TEMPTable = new DataTable();
@ -310,7 +310,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
if (ID == null) ID = dat.Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
ViewStep viewstop = new ViewStep(Numder, dat.Select("STEP = " + ID).First());
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();
@ -335,8 +335,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DatSteps(dat);
Grid_data.ItemsSource = dat.DefaultView;
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
if (ID == null) ID = dat.Rows.Count.ToString();
ViewStep viewstop = new ViewStep(null, "0", "0", "0", "0", "0");
ViewStep viewstop = new ViewStep(Numder, dat.Select("STEP = " + ID).First());
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();
@ -369,7 +370,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
if (ID == null) ID = dat.Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
ViewStep viewstop = new ViewStep(Numder, dat.Select("STEP = " + ID).First());
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();
@ -377,27 +378,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}
private void Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
{
int i = dat.Rows.Count;
int n = StrToInt.To16Convert10(ID);
if (e.Mode)
int n = Convert.ToInt16(ID);
ID = null;
if (e.PNAME != "")
{
DataRow dr = dat.Rows[n - 1];
dr.BeginEdit();
dr["StepID"] = e.StepID;
dr["StepName"] = e.StepNAME;
dr["ParameterName"] = e.PNAME;
dr["Parameter1"] = e.P1;
dr["Parameter2"] = e.P2;
dr["Parameter3"] = e.P3;
dr["Parameter4"] = e.P4;
dr["Parameter5"] = e.P5;
dr["Parameter1"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter2"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter3"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter4"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter5"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter1_S1"] = e.Row_DAT.Field<double>("Parameter1_S1");
dr["Parameter2_S1"] = e.Row_DAT.Field<double>("Parameter2_S1");
dr["Parameter3_S1"] = e.Row_DAT.Field<double>("Parameter3_S1");
dr["Parameter4_S1"] = e.Row_DAT.Field<double>("Parameter4_S1");
dr["Parameter5_S1"] = e.Row_DAT.Field<double>("Parameter5_S1");
dr["Parameter1_S2"] = e.Row_DAT.Field<double>("Parameter1_S2");
dr["Parameter2_S2"] = e.Row_DAT.Field<double>("Parameter2_S2");
dr["Parameter3_S2"] = e.Row_DAT.Field<double>("Parameter3_S2");
dr["Parameter4_S2"] = e.Row_DAT.Field<double>("Parameter4_S2");
dr["Parameter5_S2"] = e.Row_DAT.Field<double>("Parameter5_S2");
dr["Parameter1_S3"] = e.Row_DAT.Field<double>("Parameter1_S3");
dr["Parameter2_S3"] = e.Row_DAT.Field<double>("Parameter2_S3");
dr["Parameter3_S3"] = e.Row_DAT.Field<double>("Parameter3_S3");
dr["Parameter4_S3"] = e.Row_DAT.Field<double>("Parameter4_S3");
dr["Parameter5_S3"] = e.Row_DAT.Field<double>("Parameter5_S3");
dr["StepName_S1"] = e.Row_DAT.Field<string>("StepName_S1");
dr["StepName_S2"] = e.Row_DAT.Field<string>("StepName_S2");
dr["StepName_S3"] = e.Row_DAT.Field<string>("StepName_S3");
dr["StepID_S1"] = e.Row_DAT.Field<string>("StepID_S1");
dr["StepID_S2"] = e.Row_DAT.Field<string>("StepID_S2");
dr["StepID_S3"] = e.Row_DAT.Field<string>("StepID_S3");
dr.EndEdit();
Grid_data.SelectedIndex = -1;
}
else
{
dat.Rows.RemoveAt(Convert.ToInt32(ID) - 1);
MainWindowViewModel.dt_TP.Rows.RemoveAt(n - 1);
DatSteps(dat);
}
Grid_data.SelectedIndex = -1;
}
Grid_data.ItemsSource = dat.DefaultView;
}
private void TEMP()

137
View/MonitorView.xaml.cs

@ -362,26 +362,55 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}//停止
private void ListViewItem_edit(object sender, MouseButtonEventArgs e)
{
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
viewstop.data = ID;
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
if (ID == null) ID = MainWindowViewModel.dt_TP.Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, MainWindowViewModel.dt_TP.Select("STEP = " + ID).First());
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(edit_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();
}//编辑
private void edit_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
{
DataRow dataRow = MainWindowViewModel.dt_TP.NewRow();
dataRow.BeginEdit();
dataRow.ItemArray = e.Row_DAT.ItemArray;
dataRow.EndEdit();
MainWindowViewModel.dt_TP.Rows.InsertAt(dataRow, Convert.ToInt16(ID) - 1);
DatSteps(MainWindowViewModel.dt_TP);
TechnologicalProcess_View = ToObservableCollection<TechnologicalP>(MainWindowViewModel.dt_TP);
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
dat_821.Clear();
dat_821.Add("INSTRUCTION", "EDIT");
dat_821.Add("StepID", e.StepID);
dat_821.Add("StepName", e.StepNAME);
dat_821.Add("ParameterName", e.PNAME);
dat_821.Add("Parameter1", e.P1);
dat_821.Add("Parameter2", e.P2);
dat_821.Add("Parameter3", e.P3);
dat_821.Add("Parameter4", e.P4);
dat_821.Add("Parameter5", e.P5);
dat_821.Add("Parameter1", e.Row_DAT.Field<double>("Parameter1"));
dat_821.Add("Parameter2", e.Row_DAT.Field<double>("Parameter2"));
dat_821.Add("Parameter3", e.Row_DAT.Field<double>("Parameter3"));
dat_821.Add("Parameter4", e.Row_DAT.Field<double>("Parameter4"));
dat_821.Add("Parameter5", e.Row_DAT.Field<double>("Parameter5"));
dat_821.Add("Parameter1_S1", e.Row_DAT.Field<double>("Parameter1_S1"));
dat_821.Add("Parameter2_S1", e.Row_DAT.Field<double>("Parameter2_S1"));
dat_821.Add("Parameter3_S1", e.Row_DAT.Field<double>("Parameter3_S1"));
dat_821.Add("Parameter4_S1", e.Row_DAT.Field<double>("Parameter4_S1"));
dat_821.Add("Parameter5_S1", e.Row_DAT.Field<double>("Parameter5_S1"));
dat_821.Add("Parameter1_S2", e.Row_DAT.Field<double>("Parameter1_S2"));
dat_821.Add("Parameter2_S2", e.Row_DAT.Field<double>("Parameter2_S2"));
dat_821.Add("Parameter3_S2", e.Row_DAT.Field<double>("Parameter3_S2"));
dat_821.Add("Parameter4_S2", e.Row_DAT.Field<double>("Parameter4_S2"));
dat_821.Add("Parameter5_S2", e.Row_DAT.Field<double>("Parameter5_S2"));
dat_821.Add("Parameter1_S3", e.Row_DAT.Field<double>("Parameter1_S3"));
dat_821.Add("Parameter2_S3", e.Row_DAT.Field<double>("Parameter2_S3"));
dat_821.Add("Parameter3_S3", e.Row_DAT.Field<double>("Parameter3_S3"));
dat_821.Add("Parameter4_S3", e.Row_DAT.Field<double>("Parameter4_S3"));
dat_821.Add("Parameter5_S3", e.Row_DAT.Field<double>("Parameter5_S3"));
dat_821.Add("StepName_S1", e.Row_DAT.Field<string>("StepName_S1"));
dat_821.Add("StepName_S2", e.Row_DAT.Field<string>("StepName_S2"));
dat_821.Add("StepName_S3", e.Row_DAT.Field<string>("StepName_S3"));
dat_821.Add("StepID_S1", e.Row_DAT.Field<string>("StepID_S1"));
dat_821.Add("StepID_S2", e.Row_DAT.Field<string>("StepID_S2"));
dat_821.Add("StepID_S3", e.Row_DAT.Field<string>("StepID_S3"));
dat_821.Add("ID", ID);
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
@ -391,7 +420,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
});
TechnologicalProcess_bool = true;
}
private void ListViewItem_Jump(object sender, MouseButtonEventArgs e)
@ -425,25 +453,55 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}//跳步
private void ListViewItem_Insert(object sender, MouseButtonEventArgs e)
{
ViewStep viewstop = new ViewStep(null, "0", "0", "0", "0", "0");
viewstop.data = ID;
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
if (ID == null) ID = MainWindowViewModel.dt_TP.Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, MainWindowViewModel.dt_TP.Select("STEP = " + ID).First());
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Insert_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();
}//插入
private void Insert_ButtonClicked(object sender, AddressUpdateEventArgs e)//cr返回结果
private void Insert_ButtonClicked(object sender, AddressUpdateEventArgs e)//插入返回结果
{
TechnologicalProcess_bool = true;
DataRow dataRow = MainWindowViewModel.dt_TP.NewRow();
dataRow.BeginEdit();
dataRow.ItemArray = e.Row_DAT.ItemArray;
dataRow.EndEdit();
MainWindowViewModel.dt_TP.Rows.InsertAt(dataRow, Convert.ToInt16( ID )- 1);
DatSteps(MainWindowViewModel.dt_TP);
TechnologicalProcess_View = ToObservableCollection<TechnologicalP>(MainWindowViewModel.dt_TP);
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
dat_821.Clear();
dat_821.Add("INSTRUCTION", "INSERT");
dat_821.Add("StepID", e.StepID);
dat_821.Add("StepName", e.StepNAME);
dat_821.Add("ParameterName", e.PNAME);
dat_821.Add("Parameter1", e.P1);
dat_821.Add("Parameter2", e.P2);
dat_821.Add("Parameter3", e.P3);
dat_821.Add("Parameter4", e.P4);
dat_821.Add("Parameter5", e.P5);
dat_821.Add("Parameter1", e.Row_DAT.Field<double>("Parameter1"));
dat_821.Add("Parameter2", e.Row_DAT.Field<double>("Parameter2"));
dat_821.Add("Parameter3", e.Row_DAT.Field<double>("Parameter3"));
dat_821.Add("Parameter4", e.Row_DAT.Field<double>("Parameter4"));
dat_821.Add("Parameter5", e.Row_DAT.Field<double>("Parameter5"));
dat_821.Add("Parameter1_S1", e.Row_DAT.Field<double>("Parameter1_S1"));
dat_821.Add("Parameter2_S1", e.Row_DAT.Field<double>("Parameter2_S1"));
dat_821.Add("Parameter3_S1", e.Row_DAT.Field<double>("Parameter3_S1"));
dat_821.Add("Parameter4_S1", e.Row_DAT.Field<double>("Parameter4_S1"));
dat_821.Add("Parameter5_S1", e.Row_DAT.Field<double>("Parameter5_S1"));
dat_821.Add("Parameter1_S2", e.Row_DAT.Field<double>("Parameter1_S2"));
dat_821.Add("Parameter2_S2", e.Row_DAT.Field<double>("Parameter2_S2"));
dat_821.Add("Parameter3_S2", e.Row_DAT.Field<double>("Parameter3_S2"));
dat_821.Add("Parameter4_S2", e.Row_DAT.Field<double>("Parameter4_S2"));
dat_821.Add("Parameter5_S2", e.Row_DAT.Field<double>("Parameter5_S2"));
dat_821.Add("Parameter1_S3", e.Row_DAT.Field<double>("Parameter1_S3"));
dat_821.Add("Parameter2_S3", e.Row_DAT.Field<double>("Parameter2_S3"));
dat_821.Add("Parameter3_S3", e.Row_DAT.Field<double>("Parameter3_S3"));
dat_821.Add("Parameter4_S3", e.Row_DAT.Field<double>("Parameter4_S3"));
dat_821.Add("Parameter5_S3", e.Row_DAT.Field<double>("Parameter5_S3"));
dat_821.Add("StepName_S1", e.Row_DAT.Field<string>("StepName_S1"));
dat_821.Add("StepName_S2", e.Row_DAT.Field<string>("StepName_S2"));
dat_821.Add("StepName_S3", e.Row_DAT.Field<string>("StepName_S3"));
dat_821.Add("StepID_S1", e.Row_DAT.Field<string>("StepID_S1"));
dat_821.Add("StepID_S2", e.Row_DAT.Field<string>("StepID_S2"));
dat_821.Add("StepID_S3", e.Row_DAT.Field<string>("StepID_S3"));
dat_821.Add("ID", ID);
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
@ -453,6 +511,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
});
}
private void ListViewItem_Delete(object sender, MouseButtonEventArgs e)
{
@ -470,7 +529,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
});
TechnologicalProcess_bool = true;
MainWindowViewModel.dt_TP.Select("Step="+ID).First().Delete();
MainWindowViewModel.dt_TP.AcceptChanges();
DatSteps(MainWindowViewModel.dt_TP);
TechnologicalProcess_View = ToObservableCollection<TechnologicalP>(MainWindowViewModel.dt_TP);
}
}//删除
string Numder = null;
@ -484,15 +546,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{
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列,
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
viewstop.data = ID;
if (ID == null) ID = MainWindowViewModel.dt_TP.Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, MainWindowViewModel.dt_TP.Select("STEP = " + ID).First());
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(edit_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();
}
}
@ -503,9 +561,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{
ID = (Gridstep.Columns[2].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位列,
ViewStep viewstop = new ViewStep(null, "0", "0", "0", "0", "0");
viewstop.data = ID;
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
if (ID == null) ID = MainWindowViewModel.dt_TP.Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, MainWindowViewModel.dt_TP.Select("STEP = " + ID).First());
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Insert_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();
}
}
@ -529,7 +589,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
});
TechnologicalProcess_bool = true;
MainWindowViewModel.dt_TP.Select("Step=" + ID).First().Delete();
MainWindowViewModel.dt_TP.AcceptChanges();
DatSteps(MainWindowViewModel.dt_TP);
TechnologicalProcess_View = ToObservableCollection<TechnologicalP>(MainWindowViewModel.dt_TP);
}
}
}
@ -716,7 +779,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
public string DYELOT { get; set; }
public string Remark { get; set; }
}
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new()
{
try
@ -768,6 +830,17 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}
catch (Exception) { return null; }
}
public void DatSteps(DataTable db)//行号刷新
{
int a = db.Rows.Count;
for (int i = 0; i < a; i++)
{
DataRow dr = db.Rows[i];
dr.BeginEdit();
dr["Step"] = i + 1;
dr.EndEdit();
}
}
}
}

35
View/ProductionPlanningEdit.xaml.cs

@ -422,7 +422,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
if (ID == null) ID = dat.Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
ViewStep viewstop = new ViewStep(Numder, dat.Select("STEP = " + ID).First());
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();
@ -434,15 +434,36 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
int n = StrToInt.To16Convert10(ID);
DataRow dr = dat.Rows[n - 1];
dr.BeginEdit();
dr.BeginEdit();
dr["StepID"] = e.StepID;
dr["StepName"] = e.StepNAME;
dr["ParameterName"] = e.PNAME;
dr["Parameter1"] = e.P1;
dr["Parameter2"] = e.P2;
dr["Parameter3"] = e.P3;
dr["Parameter4"] = e.P4;
dr["Parameter5"] = e.P5;
dr["Parameter1"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter2"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter3"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter4"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter5"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter1_S1"] = e.Row_DAT.Field<double>("Parameter1_S1");
dr["Parameter2_S1"] = e.Row_DAT.Field<double>("Parameter2_S1");
dr["Parameter3_S1"] = e.Row_DAT.Field<double>("Parameter3_S1");
dr["Parameter4_S1"] = e.Row_DAT.Field<double>("Parameter4_S1");
dr["Parameter5_S1"] = e.Row_DAT.Field<double>("Parameter5_S1");
dr["Parameter1_S2"] = e.Row_DAT.Field<double>("Parameter1_S2");
dr["Parameter2_S2"] = e.Row_DAT.Field<double>("Parameter2_S2");
dr["Parameter3_S2"] = e.Row_DAT.Field<double>("Parameter3_S2");
dr["Parameter4_S2"] = e.Row_DAT.Field<double>("Parameter4_S2");
dr["Parameter5_S2"] = e.Row_DAT.Field<double>("Parameter5_S2");
dr["Parameter1_S3"] = e.Row_DAT.Field<double>("Parameter1_S3");
dr["Parameter2_S3"] = e.Row_DAT.Field<double>("Parameter2_S3");
dr["Parameter3_S3"] = e.Row_DAT.Field<double>("Parameter3_S3");
dr["Parameter4_S3"] = e.Row_DAT.Field<double>("Parameter4_S3");
dr["Parameter5_S3"] = e.Row_DAT.Field<double>("Parameter5_S3");
dr["StepName_S1"] = e.Row_DAT.Field<string>("StepName_S1");
dr["StepName_S2"] = e.Row_DAT.Field<string>("StepName_S2");
dr["StepName_S3"] = e.Row_DAT.Field<string>("StepName_S3");
dr["StepID_S1"] = e.Row_DAT.Field<string>("StepID_S1");
dr["StepID_S2"] = e.Row_DAT.Field<string>("StepID_S2");
dr["StepID_S3"] = e.Row_DAT.Field<string>("StepID_S3");
dr.EndEdit();
Grid_data.ItemsSource = dat.DefaultView;

129
View/ProgramstepsView .xaml

@ -11,18 +11,24 @@
d:DesignHeight="630" d:DesignWidth="1280">
<UserControl.Resources>
<ConvertMoels:RowToIndexConverter x:Key="RowToIndexConverter"/>
</UserControl.Resources>
<Grid>
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" d:ItemsSource="{d:SampleData ItemCount=90}"
PreviewMouseLeftButtonUp="Grid_PreviewMouseLeftButtonUp" MouseDoubleClick="Grid_MouseDoubleClick"
Background="White" HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9"
GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" FontSize="15"
Grid.ColumnSpan="2" CanUserResizeRows="False" AutoGenerateColumns="False" MinColumnWidth="30"
CanUserAddRows="False" CanUserDeleteRows="False" HeadersVisibility ="Column" SelectionMode="Single"
Margin="0,0,0,60">
<ConvertMoels:StatexmlConvert x:Key="StatexmlConvert"/>
<ConvertMoels:StateToColorConvert x:Key="StateToColorConvert"/>
<ConvertMoels:BoolToVisidilityConvert x:Key="BoolToVisidilityConvert"/>
<ConvertMoels:StatenToImageConvert x:Key="StatenToImageConvert"/>
</UserControl.Resources>
<Grid>
<DataGrid x:Name="Grid_step" AlternationCount="2" MouseDoubleClick="Grid_MouseDoubleClick"
MouseLeftButtonUp="Grid_PreviewMouseLeftButtonUp"
d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" Background="White"
GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" BorderBrush="{x:Null}"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" CanUserAddRows="True">
<DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Height" Value="30" />
<Setter Property="IsHitTestVisible" Value="{Binding DataContext.IsInteractive,
RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<Setter Property="Height" Value="100" />
<Setter Property="FontSize" Value="25" />
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
@ -32,42 +38,115 @@
<Setter Property="Background" Value="#FFF0F0F0" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False"/>
<DataTrigger Binding="{Binding RUN}" Value="1">
<Setter Property="Background" Value="#FF00D6FF"/>
</DataTrigger>
<DataTrigger Binding="{Binding RUN}" Value="2">
<Setter Property="Background" Value="Yellow"/>
</DataTrigger>
<DataTrigger Binding="{Binding RUN}" Value="9">
<Setter Property="Background" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="MinWidth" Value="20"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFC0C0C0"/>
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
<Setter Property="Background" Value="#FF00D6FF"/>
<Setter Property="BorderBrush" Value="#FF00D6FF"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
<DataGrid.Columns>
<!--列信息绑定-->
<DataGridTextColumn Binding="{Binding ProgramID}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Binding="{Binding Program}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Step}" Binding="{Binding Step}" Width="60" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Code}" Width="100" Binding="{Binding StepID}" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Directives}" Width="300" Binding="{Binding StepName}" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.ParameterSet}" Width="*" Binding="{Binding ParameterName}" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Step}" Binding="{Binding Step}"
Width="80" IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static lang:Resources.Code}" Width="0" MinWidth="0"
MaxWidth="0" Binding="{Binding StepID}" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Directives}" Width="0" MinWidth="0"
MaxWidth="0" Binding="{Binding StepName}" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.ParameterSet}" Width="0" MinWidth="0"
MaxWidth="0" Binding="{Binding ParameterName}" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Parameter1}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Binding="{Binding Parameter2}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Binding="{Binding Parameter3}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Binding="{Binding Parameter4}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Binding="{Binding Parameter5}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Binding="{Binding Parameter6}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Binding="{Binding Parameter7}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Binding="{Binding Parameter8}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Binding="{Binding Parameter9}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Binding="{Binding Parameter10}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Binding="{Binding StepTime}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTemplateColumn Header="{x:Static lang:Resources.Directives}" Width="100" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Path=StepID,Converter={StaticResource StatenToImageConvert}}" Height="100" Width="100"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="{x:Static lang:Resources.Directives}" Width="600" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<Border BorderBrush="#FFC9C9C9" BorderThickness="0,0,0,0.5">
<TextBlock Height="50" >
<Run Text="{x:Static lang:Resources.Function}"/>
<Run Text=":"/>
<Run Text="{Binding StepName}"/>
</TextBlock>
</Border>
<Border BorderBrush="#FFC9C9C9" BorderThickness="0,0.5,0,0">
<TextBlock Height="50" >
<Run Text="{x:Static lang:Resources.ParameterSet}"/>
<Run Text=":"/>
<Run Text="{Binding ParameterName}"/>
</TextBlock>
</Border>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="{x:Static lang:Resources.Subroutine}" Width="100" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Path=StepID_S1,Converter={StaticResource StatenToImageConvert}}" Height="100" Width="100"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="{x:Static lang:Resources.Subroutine}" Width="100" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Path=StepID_S2,Converter={StaticResource StatenToImageConvert}}" Height="100" Width="100"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="{x:Static lang:Resources.Subroutine}" Width="100" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Path=StepID_S3 ,Converter={StaticResource StatenToImageConvert}}" Height="100" Width="100"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="{x:Static lang:Resources.Remark}" Binding="{Binding Remark}"
Width="*" IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="TextTrimming" Value="CharacterEllipsis"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
<StackPanel x:Name="scr" VerticalAlignment="Bottom" Height="60" Background="#FF00204E" Orientation="Horizontal" Margin="0,0,400,0">

154
View/ProgramstepsView .xaml.cs

@ -47,8 +47,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Programgroup_sql();
}
DataSet sql; //内存数据缓存
// DataSet sql; //内存数据缓存
DataTable Step;
string ProgramID;
string ProgramNAME;
string Numder = null;
@ -58,34 +58,25 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
public void Programgroup_sql()
{
string sql_script = "select * from ProgramSteps where ProgramID='" + ProgramID + "' order by Step asc";
if (sql != null) sql.Clear(); //清空缓存
sql = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表写入缓存
//sql.Tables[0].Rows.Add(datatable_t);
DataRow dr = sql.Tables[0].NewRow();//添加表数据
dr["ProgramID"] = ProgramID;
dr["Program"] = ProgramNAME;
sql.Tables[0].Rows.Add(dr);
Dat();
if (sql != null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
Step = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet(sql_script, null).Tables[0]; //读取计划表写入缓存
Grid_step.ItemsSource = Step.DefaultView; //转换显示计划表
}
public void Dat()//行号刷新
public void Dat(DataTable dat)//行号刷新
{
int a = sql.Tables[0].Rows.Count;
int a = dat.Rows.Count;
for (int i = 0; i < a; i++)
{
DataRow dr = sql.Tables[0].Rows[i];
DataRow dr = dat.Rows[i];
dr.BeginEdit();
dr["Step"] = i + 1;
dr.EndEdit();
}
dat.AcceptChanges();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)//打开页面时的操作
{
if (ID == null) ID = sql.Tables[0].Rows.Count.ToString();
Grid.SelectedIndex = Convert.ToInt32(ID)-1;
}
public static T GetVisualChild<T>(Visual parent) where T : Visual
{
@ -112,17 +103,17 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
edit.IsEnabled = true;
Insert.IsEnabled = true;
Delete.IsEnabled = true;
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
int rownum = Grid_step.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列,
StepTime = (Grid.Columns[16].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//
ID = (Grid_step.Columns[2].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第0列,
Numder = (Grid_step.Columns[3].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第1列,
P1 = (Grid_step.Columns[6].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第6列,
P2 = (Grid_step.Columns[7].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第7列,
P3 = (Grid_step.Columns[8].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第8列,
P4 = (Grid_step.Columns[9].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第9列,
P5 = (Grid_step.Columns[10].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第10列,
StepTime = (Grid_step.Columns[16].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//
}
}
@ -131,21 +122,21 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
edit.IsEnabled = true;
Insert.IsEnabled = true;
Delete.IsEnabled = true;
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
int rownum = Grid_step.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列,
StepTime = (Grid.Columns[16].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//
ID = (Grid_step.Columns[2].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第0列,
Numder = (Grid_step.Columns[3].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第1列,
P1 = (Grid_step.Columns[6].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第6列,
P2 = (Grid_step.Columns[7].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第7列,
P3 = (Grid_step.Columns[8].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第8列,
P4 = (Grid_step.Columns[9].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第9列,
P5 = (Grid_step.Columns[10].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//定位第10列,
StepTime = (Grid_step.Columns[16].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;//
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
if (ID == null) ID = sql.Tables[0].Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
if (ID == null) ID = Step.Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, Step.Select("STEP = " + ID).First());
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();
@ -163,42 +154,41 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Insert.IsEnabled = false;
Delete.IsEnabled = false;
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
if (ID == null) ID = sql.Tables[0].Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
if (ID == null) ID = Step.Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, Step.Select("STEP = " + ID).First());
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();
}
private void Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
{
int i = sql.Tables[0].Rows.Count;
int i = Step.Rows.Count;
int n = StrToInt.To16Convert10(ID);
if (i == n)
{
DataRow dr_ = sql.Tables[0].NewRow();//添加表数据
DataRow dr_ = Step.NewRow();//添加表数据
dr_["ProgramID"] = ProgramID;
dr_["Program"] = ProgramNAME;
sql.Tables[0].Rows.Add(dr_);
Dat();
Step.Rows.Add(dr_);
Dat(Step);
ID = (n + 1).ToString();
}
int steptime=0;//时间秒
int steptime = 0;//时间秒
string[] time_D = { "001", "013", "015", "017", "065" };
string[] time_J = { "031", "093" };
string[] time_T = { "054", "055","056" };
foreach (var item in time_D)
string[] time_T = { "054", "055", "056" };
foreach (var item in time_D)
{
if (item == e.StepID)
{
steptime = Convert.ToUInt16(e.P3)*60;
steptime = Convert.ToUInt16(e.Row_DAT.Field<double>("Parameter3")) * 60;
}
}
foreach (var item in time_J)
{
if (item == e.StepID)
{
steptime = Convert.ToUInt16(e.P1) * 60;
steptime = Convert.ToUInt16(e.Row_DAT.Field<double>("Parameter1")) * 60;
}
}
foreach (var item in time_T)
@ -208,25 +198,46 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
steptime = 5;
}
}
if (steptime==0)
if (steptime == 0)
{
steptime = 300;
}
DataRow dr = sql.Tables[0].Rows[n - 1];
DataRow dr = Step.Rows[n - 1];
dr.BeginEdit();
dr["StepID"] = e.StepID;
dr["StepName"] = e.StepNAME;
dr["ParameterName"] = e.PNAME;
dr["Parameter1"] = e.P1;
dr["Parameter2"] = e.P2;
dr["Parameter3"] = e.P3;
dr["Parameter4"] = e.P4;
dr["Parameter5"] = e.P5;
dr["StepTime"] =steptime;//
dr["Parameter1"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter2"] = e.Row_DAT.Field<double>("Parameter2");
dr["Parameter3"] = e.Row_DAT.Field<double>("Parameter3");
dr["Parameter4"] = e.Row_DAT.Field<double>("Parameter4");
dr["Parameter5"] = e.Row_DAT.Field<double>("Parameter5");
dr["Parameter1_S1"] = e.Row_DAT.Field<double>("Parameter1_S1");
dr["Parameter2_S1"] = e.Row_DAT.Field<double>("Parameter2_S1");
dr["Parameter3_S1"] = e.Row_DAT.Field<double>("Parameter3_S1");
dr["Parameter4_S1"] = e.Row_DAT.Field<double>("Parameter4_S1");
dr["Parameter5_S1"] = e.Row_DAT.Field<double>("Parameter5_S1");
dr["Parameter1_S2"] = e.Row_DAT.Field<double>("Parameter1_S2");
dr["Parameter2_S2"] = e.Row_DAT.Field<double>("Parameter2_S2");
dr["Parameter3_S2"] = e.Row_DAT.Field<double>("Parameter3_S2");
dr["Parameter4_S2"] = e.Row_DAT.Field<double>("Parameter4_S2");
dr["Parameter5_S2"] = e.Row_DAT.Field<double>("Parameter5_S2");
dr["Parameter1_S3"] = e.Row_DAT.Field<double>("Parameter1_S3");
dr["Parameter2_S3"] = e.Row_DAT.Field<double>("Parameter2_S3");
dr["Parameter3_S3"] = e.Row_DAT.Field<double>("Parameter3_S3");
dr["Parameter4_S3"] = e.Row_DAT.Field<double>("Parameter4_S3");
dr["Parameter5_S3"] = e.Row_DAT.Field<double>("Parameter5_S3");
dr["StepName_S1"] = e.Row_DAT.Field<string>("StepName_S1");
dr["StepName_S2"] = e.Row_DAT.Field<string>("StepName_S2");
dr["StepName_S3"] = e.Row_DAT.Field<string>("StepName_S3");
dr["StepID_S1"] = e.Row_DAT.Field<string>("StepID_S1");
dr["StepID_S2"] = e.Row_DAT.Field<string>("StepID_S2");
dr["StepID_S3"] = e.Row_DAT.Field<string>("StepID_S3");
dr["StepTime"] = steptime;//
dr.EndEdit();
Grid.ItemsSource = sql.Tables[0].DefaultView;
Grid_step.ItemsSource = Step.DefaultView;
}
private void ListViewItem_Insert(object sender, System.Windows.Input.MouseButtonEventArgs e)//插入事件
@ -235,14 +246,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Insert.IsEnabled = false;
Delete.IsEnabled = false; int d = 0;
if (ID != null) { d = Convert.ToInt32(ID); } else { return; }
DataRow dr = sql.Tables[0].NewRow();//添加表数据
DataRow dr = Step.NewRow();//添加表数据
dr["ProgramID"] = ProgramID;
dr["Program"] = ProgramNAME;
sql.Tables[0].Rows.InsertAt(dr, d - 1);
Step.Rows.InsertAt(dr, d - 1);
ID = null;
Dat();
Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
Dat(Step);
Grid_step.ItemsSource = Step.DefaultView; //转换显示计划表
}
private void ListViewItem_Save(object sender, System.Windows.Input.MouseButtonEventArgs e)//保存事件
@ -253,14 +264,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
int r = 0;
MainWindowViewModel.SQLiteHelpers.Delete("ProgramSteps", "ProgramID = '" + ProgramID + "'", null);
DataTable data_t = new DataTable();
data_t = sql.Tables[0].Clone();
data_t = Step.Clone();
int a = sql.Tables[0].Rows.Count;
int a = Step.Rows.Count;
for (int i = 0; i < a - 1; i++)
{
data_t.Clear();//清空
DataRow dt = sql.Tables[0].Rows[i];//行转换
DataRow dt = Step.Rows[i];//行转换
DataRow dr = data_t.NewRow();
dr.ItemArray = dt.ItemArray;
data_t.Rows.InsertAt(dr, 0);
@ -268,7 +279,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
r = MainWindowViewModel.SQLiteHelpers.InsertData("ProgramSteps", MainWindowViewModel.SQLiteHelpers.DataTableToDictionary(data_t));//行插入
}
int time =Convert.ToUInt16( sql.Tables[0].Compute("sum(StepTime)", ""))/60;
int time =Convert.ToUInt16( Step.Compute("sum(StepTime)", ""))/60;
string time_ =DateTime.Parse( TimeSpan.FromMinutes(time).ToString()).ToString("HH:mm");// DateTime.Parse(time.ToString()).ToString("HH:mm");
Dictionary<string, object> Program_Step = new Dictionary<string, object>();//缓存函数
Program_Step.Add("Step", a - 1);
@ -289,15 +300,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Delete.IsEnabled = false;
int d = 0;
int a = sql.Tables[0].Rows.Count;
int a = Step.Rows.Count;
if (ID != null) { d = Convert.ToInt32(ID); } else { return; }
if (a != d)//如果删除不是最后一行执行
{
sql.Tables[0].Rows.RemoveAt(d - 1);
Dat();
Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
Step.Rows.RemoveAt(d - 1);
Dat(Step);
Grid_step.ItemsSource = Step.DefaultView; //转换显示计划表
}
}

163
WindowsView/ViewStep.xaml

@ -5,36 +5,149 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.WindowsView"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize"
Title="SUNLIGHT 800" Height="400" Width="400">
<Grid FocusManager.FocusedElement="{Binding ElementName=boxNAME}">
<TextBlock Text="{x:Static lang:Resources.Code}" HorizontalAlignment="Left" Height="30" Margin="10,20,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="130" FontSize="20" Background="#FFEFEEEE"/>
<TextBlock Text="{x:Static lang:Resources.Function}" HorizontalAlignment="Left" Height="30" Margin="10,60,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="130" FontSize="20" Background="#FFEFEEEE"/>
<ComboBox x:Name="boxID" HorizontalAlignment="Right" Height="30" Margin="0,60,10,0" VerticalAlignment="Top" Width="230" FontSize="18" SelectionChanged="BoxID_SelectionChanged" BorderBrush="#FF5100E0"/>
<TextBox x:Name="boxNAME" HorizontalAlignment="Right" Height="30" Margin="0,20,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True" ToolTip="code"
TextChanged="TextBox_TextChanged" PreviewTextInput="Tb_KeyPress" InputMethod.IsInputMethodEnabled="False" FontSize="18" HorizontalContentAlignment="Left" MaxLength="3" CaretBrush="#FF5100E0" BorderBrush="#FF5100E0"/>
WindowStyle="None"
Title="SUNLIGHT 800" Height="800" Width="600">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="300"/>
<RowDefinition/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Border Grid.Row="1" BorderThickness="5,5,5,5" BorderBrush="#FFABABAB"/>
<Grid Grid.Row="0">
<TextBlock Text="{x:Static lang:Resources.Code}" HorizontalAlignment="Left" Height="30"
Margin="210,20,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150"
FontSize="20" Background="#FFEFEEEE"/>
<TextBlock Text="{x:Static lang:Resources.Function}" HorizontalAlignment="Left" Height="30"
Margin="210,60,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150"
FontSize="20" Background="#FFEFEEEE"/>
<ComboBox x:Name="boxID" HorizontalAlignment="Right" Height="30" Margin="0,60,10,0"
VerticalAlignment="Top" Width="230" FontSize="20" SelectionChanged="BoxID_SelectionChanged"/>
<TextBox x:Name="boxNAME" HorizontalAlignment="Right" Height="30" Margin="0,20,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
TextChanged="TextBox_TextChanged" PreviewTextInput="Tb_KeyPress"
InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" MaxLength="3"/>
<Image x:Name="imageP" HorizontalAlignment="Left" Height="200" Margin="10,20,0,0" VerticalAlignment="Top" Width="200">
<Image.OpacityMask>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
</Image.OpacityMask>
</Image>
<TextBlock x:Name="P1N" HorizontalAlignment="Left" Height="30" Margin="210,120,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P1" HorizontalAlignment="Right" Height="30" Margin="0,120,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP1" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" TextChanged="P1_TextChanged"/>
<TextBlock x:Name="P2N" HorizontalAlignment="Left" Height="30" Margin="210,155,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P2" HorizontalAlignment="Right" Height="30" Margin="0,155,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP2" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" TextChanged="P2_TextChanged"/>
<TextBlock x:Name="P3N" HorizontalAlignment="Left" Height="30" Margin="210,190,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P3" HorizontalAlignment="Right" Height="30" Margin="0,190,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP3" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" TextChanged="P3_TextChanged"/>
<TextBlock x:Name="P4N" HorizontalAlignment="Left" Height="30" Margin="210,225,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P4" HorizontalAlignment="Right" Height="30" Margin="0,225,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP4" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" TextChanged="P4_TextChanged"/>
<TextBlock x:Name="P5N" HorizontalAlignment="Left" Height="30" Margin="210,260,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P5" HorizontalAlignment="Right" Height="30" Margin="0,260,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP5" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" TextChanged="P5_TextChanged"/>
</Grid>
<TextBlock x:Name="P1N" HorizontalAlignment="Left" Height="30" Margin="10,120,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="130" FontSize="20" Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P1" HorizontalAlignment="Right" Height="30" Margin="0,120,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP1" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Left" Visibility="Hidden" CaretBrush="#FF5100E0" />
<TextBlock x:Name="P2N" HorizontalAlignment="Left" Height="30" Margin="10,155,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="130" FontSize="20" Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P2" HorizontalAlignment="Right" Height="30" Margin="0,155,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP2" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Left" Visibility="Hidden" CaretBrush="#FF5100E0" />
<TextBlock x:Name="P3N" HorizontalAlignment="Left" Height="30" Margin="10,190,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="130" FontSize="20" Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P3" HorizontalAlignment="Right" Height="30" Margin="0,190,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP3" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Left" Visibility="Hidden" CaretBrush="#FF5100E0" />
<TextBlock x:Name="P4N" HorizontalAlignment="Left" Height="30" Margin="10,225,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="130" FontSize="20" Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P4" HorizontalAlignment="Right" Height="30" Margin="0,225,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP4" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Left" Visibility="Hidden" CaretBrush="#FF5100E0" />
<TextBlock x:Name="P5N" HorizontalAlignment="Left" Height="30" Margin="10,260,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="130" FontSize="20" Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P5" HorizontalAlignment="Right" Height="30" Margin="0,260,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP5" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Left" Visibility="Hidden" CaretBrush="#FF5100E0" />
<Grid Grid.Row="1">
<TextBlock x:Name="Sub" Text="{x:Static lang:Resources.Subroutine}" HorizontalAlignment="Left"
Height="40" Margin="210,20,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="360"
FontSize="25" Background="#FFEFEEEE"/>
<Image x:Name="imageP1" Source="/Lmage/ADD.jpg" HorizontalAlignment="Left" Height="125"
Margin="20,10,0,0" VerticalAlignment="Top" Width="125" Opacity="0.4"
MouseLeftButtonDown="imageP1_MouseLeftButtonDown" MouseLeftButtonUp="imageP1_MouseLeftButtonUp"/>
<Image x:Name="imageP2" Source="/Lmage/ADD.jpg" HorizontalAlignment="Left" Height="125"
Margin="20,145,0,0" VerticalAlignment="Top" Width="125" Opacity="0.4"
MouseLeftButtonDown="imageP2_MouseLeftButtonDown" MouseLeftButtonUp="imageP2_MouseLeftButtonUp"/>
<Image x:Name="imageP3" Source="/Lmage/ADD.jpg" HorizontalAlignment="Left" Height="125"
Margin="20,280,0,0" VerticalAlignment="Top" Width="125" Opacity="0.4"
MouseLeftButtonDown="imageP3_MouseLeftButtonDown" MouseLeftButtonUp="imageP3_MouseLeftButtonUp"/>
<TextBlock Text="{x:Static lang:Resources.Code}" HorizontalAlignment="Left" Height="30"
Margin="210,70,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150"
FontSize="20" Background="#FFEFEEEE"/>
<TextBlock Text="{x:Static lang:Resources.Function}" HorizontalAlignment="Left" Height="30"
Margin="210,110,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150"
FontSize="20" Background="#FFEFEEEE"/>
<ComboBox x:Name="boxIDp" HorizontalAlignment="Right" Height="30" Margin="0,110,10,0"
VerticalAlignment="Top" Width="230" FontSize="20" SelectionChanged="boxIDp_SelectionChanged"/>
<TextBox x:Name="boxNAMEp" HorizontalAlignment="Right" Height="30" Margin="0,70,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
IsReadOnly="True" FontSize="20" HorizontalContentAlignment="Right" MaxLength="3"
TextChanged="TextBoxp_TextChanged" />
<TextBlock x:Name="P1NP" HorizontalAlignment="Left" Height="30" Margin="210,170,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P1P" HorizontalAlignment="Right" Height="30" Margin="0,170,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1"
ClipToBounds="True" Text="0" PreviewTextInput="Tb_KeyP1p"
TextChanged="P1P_TextChanged" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" />
<TextBlock x:Name="P2NP" HorizontalAlignment="Left" Height="30" Margin="210,205,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P2P" HorizontalAlignment="Right" Height="30" Margin="0,205,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1"
ClipToBounds="True" Text="0" PreviewTextInput="Tb_KeyP2p"
TextChanged="P2P_TextChanged" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" />
<TextBlock x:Name="P3NP" HorizontalAlignment="Left" Height="30" Margin="210,240,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P3P" HorizontalAlignment="Right" Height="30" Margin="0,240,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1"
ClipToBounds="True" Text="0" PreviewTextInput="Tb_KeyP3p"
TextChanged="P3P_TextChanged" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" />
<TextBlock x:Name="P4NP" HorizontalAlignment="Left" Height="30" Margin="210,275,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P4P" HorizontalAlignment="Right" Height="30" Margin="0,275,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1"
ClipToBounds="True" Text="0" PreviewTextInput="Tb_KeyP4p"
TextChanged="P4P_TextChanged" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" />
<TextBlock x:Name="P5NP" HorizontalAlignment="Left" Height="30" Margin="210,310,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P5P" HorizontalAlignment="Right" Height="30" Margin="0,310,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1"
ClipToBounds="True" Text="0" PreviewTextInput="Tb_KeyP5p"
TextChanged="P5P_TextChanged" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" />
</Grid>
<Button Content="{x:Static lang:Resources.YES}" HorizontalAlignment="Left" Height="35" Margin="50,70,0,5" VerticalAlignment="Bottom" Width="80" Click="YES_Click" Background="#FF5100E0"/>
<Button Content="{x:Static lang:Resources.NO}" HorizontalAlignment="Right" Height="35" Margin="0,70,50,5" VerticalAlignment="Bottom" Width="80" Click="NO_Click" Background="#FF5100E0"/>
<Button Grid.Row="2" x:Name="yes" Content="{x:Static lang:Resources.YES}"
HorizontalAlignment="Right" Height="35" Margin="0,0,200,5"
VerticalAlignment="Bottom" Width="80" Click="YES_Click"/>
<Button Grid.Row="2" x:Name="no" Content="{x:Static lang:Resources.NO}"
HorizontalAlignment="Right" Height="35" Margin="0,0,50,5"
VerticalAlignment="Bottom" Width="80" Click="NO_Click"/>
</Grid>
</Window>

1410
WindowsView/ViewStep.xaml.cs

File diff suppressed because it is too large
Loading…
Cancel
Save