This commit is contained in:
sc committed 2024-12-05 01:09:10 +08:00
commit 6e4c993835
3 files changed
+210 -15

No files matched your search

+4 -1
View File
@@ -6,6 +6,8 @@
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:viewmodel="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ViewModel"
d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}"
mc:Ignorable="d"
d:DesignHeight="1000" d:DesignWidth="1900">
<Grid Cursor="">
@@ -70,7 +72,8 @@
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<DataGrid Grid.Column="2" x:Name="Gridstep" AlternationCount="2" IsReadOnly="True" SelectionChanged="Gridstep_SelectionChanged"
d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
ItemsSource="{Binding Path=TechnologicalProcess_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" Background="White"
GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
+44 -14
View File
@@ -2,9 +2,12 @@
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -21,6 +24,7 @@ using System.Xml.Linq;
using TouchSocket.Core;
using TouchSocket.Sockets;
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
using static System.Net.WebRequestMethods;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
namespace SunlightCentralizedControlManagement_SCCM_.View
@@ -33,6 +37,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
public MonitorView()
{
InitializeComponent();
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
CountDown();
}
@@ -140,13 +145,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
if (ID == null) ID = TechnologicalProcess.Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
viewstop.data = ID;
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(edit_ButtonClicked);
viewstop.ShowDialog();
}//编辑
string Numder = null;
string ID = null;
string P1 = "0", P2 = "0", P3 = "0", P4 = "0", P5 = "0";
private void Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
private void edit_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
{
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
dat_821.Clear();
@@ -172,12 +177,31 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}//跳步
private void ListViewItem_Insert(object sender, MouseButtonEventArgs e)
{
if (ID == null) ID = (TechnologicalProcess.Rows.Count-1).ToString();
if (ID == null) ID = (TechnologicalProcess.Rows.Count).ToString();
ViewStep viewstop = new ViewStep(null, "0", "0", "0", "0", "0");
viewstop.data = ID;
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Insert_ButtonClicked);
viewstop.ShowDialog();
}//插入
private void Insert_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
{
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("ID", ID);
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.MachiensTcpClient[index].SendAsync("SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString());
}
private void ListViewItem_Delete(object sender, MouseButtonEventArgs e)
{
@@ -230,25 +254,31 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
MainWindowViewModel.MachiensTcpClient[index].SendAsync("SC831" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index));
if (TechnologicalProcess.Rows.Count > 0)
{
DataView dataView = TechnologicalProcess.DefaultView;
if (Gridstep.ItemsSource != dataView)
{
Gridstep.ItemsSource = dataView;
}
// Gridstep.ItemsSource = MainWindowViewModel.dt_TP.DefaultView;
// if (!Equals(Gridstep.ItemsSource , TechnologicalProcess.DefaultView))
// {
MainWindowViewModel.dt_TP = TechnologicalProcess;
// }
}
else
{
Gridstep.ItemsSource = null;
// MainWindowViewModel.dt_TP = null;
}
}
else
{
Gridstep.ItemsSource = null;
// MainWindowViewModel.dt_TP = null;
}
}
catch (Exception ) { log.Text = null; Gridstep.ItemsSource = null; }//返回错误为空
}
catch (Exception )
{
log.Text = null;
// MainWindowViewModel.dt_TP = null;
}//返回错误为空
}
}
}
}