添加middleware
This commit is contained in:
61
middleware/zdhsys/Popup/AddDeviceFields.xaml
Normal file
61
middleware/zdhsys/Popup/AddDeviceFields.xaml
Normal file
@@ -0,0 +1,61 @@
|
||||
<Window x:Class="zdhsys.Popup.AddDeviceFields"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
ShowInTaskbar="False"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddDeviceFields" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="400" Height="230" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="90"/>
|
||||
<RowDefinition Height="0.5*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="添加设备可操作" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="4*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="字段名称" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_fields" Grid.Column="1" Margin="10,0,0,0" Width="250" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="内容" Grid.Row="1" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_content" Grid.Row="1" Grid.Column="1" Margin="10,0,0,0" Width="250" HorizontalAlignment="Left"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Margin="10,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Close1" Click="Btn_Close_Click" Grid.Column="2" Margin="10,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
55
middleware/zdhsys/Popup/AddDeviceFields.xaml.cs
Normal file
55
middleware/zdhsys/Popup/AddDeviceFields.xaml.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddDeviceFields.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddDeviceFields : Window
|
||||
{
|
||||
public AddDeviceFields(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "确定");
|
||||
Btn_Close1.SetUI("#FFFFFF", "#0066FF", "#0066FF", "取消");
|
||||
|
||||
txt_fields.SetUI("输入字段名称");
|
||||
txt_content.SetUI("输入内容");
|
||||
if (!string.IsNullOrEmpty(fieldsName))
|
||||
{
|
||||
txt_fields.SetText(fieldsName);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(fieldsContent))
|
||||
{
|
||||
txt_content.SetText(fieldsContent);
|
||||
}
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public bool flag_save = false;
|
||||
public string fieldsName = "";
|
||||
public string fieldsContent = "";
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
fieldsName = txt_fields.Text();
|
||||
fieldsContent = txt_content.Text();
|
||||
if (string.IsNullOrEmpty(fieldsName) || string.IsNullOrEmpty(fieldsContent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
flag_save = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
148
middleware/zdhsys/Popup/AddDeviceGroupInfo.xaml
Normal file
148
middleware/zdhsys/Popup/AddDeviceGroupInfo.xaml
Normal file
@@ -0,0 +1,148 @@
|
||||
<Window x:Class="zdhsys.Popup.AddDeviceGroupInfo"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddDeviceInfo" Height="540" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="700" Height="500" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="120"/>
|
||||
<RowDefinition Height="120"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="创建设备组" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="0.2*"/>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Content="设备组ID" Grid.Column="0" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_DeviceID" Grid.Column="1" Margin="10,0,0,0" Width="200" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="标签名称" Grid.Column="3" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_TagName" Grid.Column="4" Margin="10,0,0,0" Width="200" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="设备组名称" Grid.Row="1" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_DeviceName" Grid.Column="1" Grid.Row="1" Margin="10,0,0,0" Width="200" HorizontalAlignment="Left"/>
|
||||
<Label Content="标签单位" Grid.Column="3" Grid.Row="1" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="cbb_Tag" Grid.Column="4" Grid.Row="1" Margin="10,0,0,0" Height="30" Width="200" VerticalContentAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
|
||||
<Label Content="物体种类" Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="cbb_Bottle" Grid.Column="1" Grid.Row="2" Margin="10,0,0,0" Height="30" Width="200" VerticalContentAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
|
||||
<Label Content="设备类别" Grid.Column="3" Grid.Row="2" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="cbb_DeviceType" Grid.Column="4" Grid.Row="2" Margin="10,0,0,0" Height="30" Width="200" VerticalContentAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.4*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
<ColumnDefinition Width="0.8*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
<ColumnDefinition Width="0.4*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
<ColumnDefinition Width="0.8*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="坐标位置" Grid.Column="0" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<Label Content="POS" Grid.Row="0" Grid.Column="1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_x" Grid.Row="0" Grid.Column="2" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="Y坐标" Grid.Row="1" Grid.Column="1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_y" Grid.Row="1" Grid.Column="2" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="Z坐标" Grid.Row="2" Grid.Column="1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_z" Grid.Row="2" Grid.Column="2" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="设备大小" Grid.Column="4" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<Label Content="长" Grid.Row="0" Grid.Column="5" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_len" Grid.Row="0" Grid.Column="6" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="宽" Grid.Row="1" Grid.Column="5" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_w" Grid.Row="1" Grid.Column="6" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="高" Grid.Row="2" Grid.Column="5" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_h" Grid.Row="2" Grid.Column="6" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="2.1*"/>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="0.1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="设备可操作" Grid.Column="0" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevButton0 x:Name="Btn_Add" Grid.Column="2" />
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="12*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="gd_header" Background="#F6F6F6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="字段名称" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="1" Content="内容" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="2" Content="操作" Style="{StaticResource CustomLabelStyle}"/>
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<Grid x:Name="gd_content"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="7">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="3*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Margin="10,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Close1" Click="Btn_Close_Click" Grid.Column="2" Margin="10,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
251
middleware/zdhsys/Popup/AddDeviceGroupInfo.xaml.cs
Normal file
251
middleware/zdhsys/Popup/AddDeviceGroupInfo.xaml.cs
Normal file
@@ -0,0 +1,251 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using zdhsys.Bean;
|
||||
using zdhsys.Control;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddDeviceInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddDeviceGroupInfo : Window
|
||||
{
|
||||
public AddDeviceGroupInfo(double left, double top)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = left;
|
||||
Top = top;
|
||||
|
||||
Btn_Add.Click += Btn_Add_Click;
|
||||
}
|
||||
|
||||
private List<DeviceFieldsModel> vs = new List<DeviceFieldsModel>();
|
||||
|
||||
private void Btn_Add_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left,Top);
|
||||
AddDeviceFields fields = new AddDeviceFields(p)
|
||||
{
|
||||
Width = Width,
|
||||
Height = Height
|
||||
};
|
||||
_ = fields.ShowDialog();
|
||||
if (fields.flag_save)
|
||||
{
|
||||
DeviceFieldsModel df = new DeviceFieldsModel
|
||||
{
|
||||
FieldsContent = fields.fieldsContent,
|
||||
FieldsName = fields.fieldsName
|
||||
};
|
||||
vs.Add(df);
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToUI()
|
||||
{
|
||||
gd_content.Children.Clear();
|
||||
gd_content.RowDefinitions.Clear();
|
||||
gd_content.ColumnDefinitions.Clear();
|
||||
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
DataToGridView(vs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToGridView(DeviceFieldsModel df)
|
||||
{
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_content);
|
||||
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < gd_header.ColumnDefinitions.Count; i++)
|
||||
{
|
||||
//当前行,添加1列 -- 列宽对应表头
|
||||
GridViewUnitls.AddColumn(gd_content, gd_header, i);
|
||||
|
||||
// 添加对应的控件到新的格子中
|
||||
if (i == 0)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.FieldsName);
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.FieldsContent);
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
DevOperation2 dev = new DevOperation2
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
obj = df//绑定对象。用于详情,修改,删除之类的。
|
||||
};
|
||||
dev.Click_Update += Dev_Click_Update;
|
||||
dev.Click_Delete += Dev_Click_Delete;
|
||||
Grid.SetRow(dev, gd_content.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(dev, i);
|
||||
gd_content.Children.Add(dev);
|
||||
}
|
||||
}
|
||||
//每行再加一个分割线
|
||||
GridViewUnitls.AddSpLine(gd_content, gd_header);
|
||||
}
|
||||
|
||||
private void Dev_Click_Delete(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevOperation2 dev = sender as DevOperation2;
|
||||
DeviceFieldsModel df = dev.obj as DeviceFieldsModel;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
if (vs[i].Id == df.Id && vs[i].FieldsName == df.FieldsName && vs[i].FieldsContent == df.FieldsContent)
|
||||
{
|
||||
vs.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DataToUI();
|
||||
}
|
||||
|
||||
private void Dev_Click_Update(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevOperation2 dev = sender as DevOperation2;
|
||||
DeviceFieldsModel df = dev.obj as DeviceFieldsModel;
|
||||
int index = -1;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
if (vs[i].Id == df.Id && vs[i].FieldsName == df.FieldsName && vs[i].FieldsContent == df.FieldsContent)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Point p = new Point(Left, Top);
|
||||
AddDeviceFields fields = new AddDeviceFields(p)
|
||||
{
|
||||
Width = Width,
|
||||
Height = Height,
|
||||
fieldsContent = vs[index].FieldsContent,
|
||||
fieldsName = vs[index].FieldsName
|
||||
};
|
||||
_ = fields.ShowDialog();
|
||||
if (fields.flag_save)
|
||||
{
|
||||
vs[index].FieldsContent = fields.fieldsContent;
|
||||
vs[index].FieldsName = fields.fieldsName;
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "保存");
|
||||
Btn_Add.SetUI("#0066FF", "#0066FF", "#FFFFFF", "添加");
|
||||
Btn_Close1.SetUI("#FFFFFF", "#0066FF", "#0066FF", "取消");
|
||||
|
||||
txt_DeviceID.SetUI("输入设备组ID");
|
||||
txt_DeviceName.SetUI("输入设备组名称");
|
||||
txt_TagName.SetUI("输入标签名称");
|
||||
|
||||
txt_x.SetUI("输入坐标数值");
|
||||
txt_x.SetNumber();
|
||||
txt_y.SetUI("输入坐标数值");
|
||||
txt_y.SetNumber();
|
||||
txt_z.SetUI("输入坐标数值");
|
||||
txt_z.SetNumber();
|
||||
|
||||
txt_len.SetUI("输入长");
|
||||
txt_len.SetNumber();
|
||||
txt_w.SetUI("输入宽");
|
||||
txt_w.SetNumber();
|
||||
txt_h.SetUI("输入高");
|
||||
txt_h.SetNumber();
|
||||
|
||||
|
||||
foreach (GlobalEnum.UnitOfMeasurement unit in Enum.GetValues(typeof(GlobalEnum.UnitOfMeasurement)))
|
||||
{
|
||||
cbb_Tag.Items.Add(unit);
|
||||
}
|
||||
cbb_Tag.SelectedIndex = 0;
|
||||
|
||||
cbb_Bottle.Items.Add(GlobalEnum.UnitBottle.大瓶子);
|
||||
cbb_Bottle.Items.Add(GlobalEnum.UnitBottle.小瓶子);
|
||||
cbb_Bottle.SelectedIndex = 0;
|
||||
|
||||
foreach (GlobalEnum.UnitDeviceType unit in Enum.GetValues(typeof(GlobalEnum.UnitDeviceType)))
|
||||
{
|
||||
cbb_DeviceType.Items.Add(unit);
|
||||
}
|
||||
cbb_DeviceType.SelectedIndex = 0;
|
||||
|
||||
if (isUpdate)
|
||||
{
|
||||
txt_DeviceID.SetText(Dim.DeviceId.ToString());
|
||||
txt_DeviceName.SetText(Dim.DeviceName);
|
||||
txt_TagName.SetText(Dim.TagName);
|
||||
cbb_Tag.Text = Dim.TagUnit;
|
||||
cbb_DeviceType.Text = Dim.Protocol;
|
||||
txt_x.SetText(Dim.X.ToString());
|
||||
txt_y.SetText(Dim.Y.ToString());
|
||||
txt_z.SetText(Dim.Z.ToString());
|
||||
txt_len.SetText(Dim.L.ToString());
|
||||
txt_w.SetText(Dim.W.ToString());
|
||||
txt_h.SetText(Dim.H.ToString());
|
||||
cbb_Bottle.SelectedIndex = Dim.Bottole;
|
||||
vs = Dim.Dfms;
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
public DeviceGroupInfoModel Dim;
|
||||
/// <summary>
|
||||
/// 0反应类设备 1转移类设备
|
||||
/// </summary>
|
||||
public int DeviceType = 0;
|
||||
public bool isUpdate = false;
|
||||
public bool flag_save = false;
|
||||
/// <summary>
|
||||
/// 保存设备信息--区分新增和修改
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//是否新增
|
||||
if (!isUpdate)
|
||||
{
|
||||
Dim = new DeviceGroupInfoModel
|
||||
{
|
||||
DeviceType = DeviceType,
|
||||
CreateTime = GlobalUnitils.GetNowTime(DateTime.Now)
|
||||
};
|
||||
}
|
||||
Dim.DeviceId =txt_DeviceID.Text();
|
||||
Dim.DeviceName = txt_DeviceName.Text();
|
||||
Dim.TagName = txt_TagName.Text();
|
||||
Dim.TagUnit = cbb_Tag.Text;
|
||||
Dim.Bottole = cbb_Bottle.SelectedIndex;
|
||||
Dim.Protocol = cbb_DeviceType.Text;
|
||||
Dim.X = float.Parse(string.IsNullOrEmpty(txt_x.Text()) ? "0" : txt_x.Text());
|
||||
Dim.Y = float.Parse(string.IsNullOrEmpty(txt_y.Text()) ? "0" : txt_y.Text());
|
||||
Dim.Z = float.Parse(string.IsNullOrEmpty(txt_z.Text()) ? "0" : txt_z.Text());
|
||||
Dim.L = float.Parse(string.IsNullOrEmpty(txt_len.Text()) ? "0" : txt_len.Text());
|
||||
Dim.W = float.Parse(string.IsNullOrEmpty(txt_w.Text()) ? "0" : txt_w.Text());
|
||||
Dim.H = float.Parse(string.IsNullOrEmpty(txt_h.Text()) ? "0" : txt_h.Text());
|
||||
Dim.Dfms = vs;
|
||||
flag_save = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
149
middleware/zdhsys/Popup/AddDeviceInfo.xaml
Normal file
149
middleware/zdhsys/Popup/AddDeviceInfo.xaml
Normal file
@@ -0,0 +1,149 @@
|
||||
<Window x:Class="zdhsys.Popup.AddDeviceInfo"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddDeviceInfo" Height="600" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="700" Height="560" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="120"/>
|
||||
<RowDefinition Height="120"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="创建设备" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="0.2*"/>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Content="设备ID" Grid.Column="0" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_DeviceID" Grid.Column="1" Margin="10,0,0,0" Width="200" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="标签名称" Grid.Column="3" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_TagName" Grid.Column="4" Margin="10,0,0,0" Width="200" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="设备名称" Grid.Row="1" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_DeviceName" Grid.Column="1" Grid.Row="1" Margin="10,0,0,0" Width="200" HorizontalAlignment="Left"/>
|
||||
<Label Content="标签单位" Grid.Column="3" Grid.Row="1" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="cbb_Tag" Grid.Column="4" Grid.Row="1" Margin="10,0,0,0" Height="30" Width="200" VerticalContentAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
|
||||
<Label Content="物体种类" Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="cbb_Bottle" Grid.Column="1" Grid.Row="2" Margin="10,0,0,0" Height="30" Width="200" VerticalContentAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
<Label Content="设备类型" Grid.Column="3" Grid.Row="2" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="cbb_Group" Grid.Column="4" Grid.Row="2" Margin="10,0,0,0" Height="30" Width="200" VerticalContentAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.4*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
<ColumnDefinition Width="0.8*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
<ColumnDefinition Width="0.4*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
<ColumnDefinition Width="0.8*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="坐标位置" Grid.Column="0" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<Label Content="POS" Grid.Row="0" Grid.Column="1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_x" Grid.Row="0" Grid.Column="2" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="Y坐标" Grid.Row="1" Grid.Column="1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_y" Grid.Row="1" Grid.Column="2" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="Z坐标" Grid.Row="2" Grid.Column="1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_z" Grid.Row="2" Grid.Column="2" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="设备大小" Grid.Column="4" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<Label Content="长" Grid.Row="0" Grid.Column="5" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_len" Grid.Row="0" Grid.Column="6" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="宽" Grid.Row="1" Grid.Column="5" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_w" Grid.Row="1" Grid.Column="6" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="高" Grid.Row="2" Grid.Column="5" FontSize="12" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}"/>
|
||||
<local1:DevTextBox x:Name="txt_h" Grid.Row="2" Grid.Column="6" Margin="10,0,0,0" Width="152" HorizontalAlignment="Left"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="1.7*"/>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="0.1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="设备可操作" Grid.Column="0" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevButton0 x:Name="Btn_Point" Grid.Column="2" />
|
||||
<local1:DevButton0 x:Name="Btn_Add" Grid.Column="3" />
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="12*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="gd_header" Background="#F6F6F6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="字段名称" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="1" Content="内容" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="2" Content="操作" Style="{StaticResource CustomLabelStyle}"/>
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<Grid x:Name="gd_content"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="7">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="3*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Margin="10,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Close1" Click="Btn_Close_Click" Grid.Column="2" Margin="10,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
315
middleware/zdhsys/Popup/AddDeviceInfo.xaml.cs
Normal file
315
middleware/zdhsys/Popup/AddDeviceInfo.xaml.cs
Normal file
@@ -0,0 +1,315 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using zdhsys.Bean;
|
||||
using zdhsys.Control;
|
||||
using zdhsys.entity;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddDeviceInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddDeviceInfo : Window
|
||||
{
|
||||
public AddDeviceInfo(double left, double top)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = left;
|
||||
Top = top;
|
||||
|
||||
Btn_Add.Click += Btn_Add_Click;
|
||||
cbb_Group.SelectionChanged += Cbb_Group_SelectionChanged;
|
||||
Btn_Point.Click += Btn_Point_Click;
|
||||
}
|
||||
|
||||
private void Btn_Point_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
AddDevicePoint dp = new AddDevicePoint(p)
|
||||
{
|
||||
Width = Width,
|
||||
Height = Height
|
||||
};
|
||||
if (!string.IsNullOrEmpty(Dim.PointJson))
|
||||
{
|
||||
dp.isUpdate = true;
|
||||
dp.dp = JsonConvert.DeserializeObject<DevicePoint>(Dim.PointJson);
|
||||
}
|
||||
_ = dp.ShowDialog();
|
||||
if (dp.flag_Save)
|
||||
{
|
||||
Dim.PointJson = JsonConvert.SerializeObject(dp.dp);
|
||||
Console.WriteLine($"PointJson={Dim.PointJson}");
|
||||
}
|
||||
}
|
||||
|
||||
private void Cbb_Group_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
GlobalEnum.UnitDeviceType ut = (GlobalEnum.UnitDeviceType)cbb_Group.SelectedIndex;
|
||||
if (ut == GlobalEnum.UnitDeviceType.包硅反应设备)
|
||||
{
|
||||
Btn_Point.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
Btn_Point.Visibility = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private List<DeviceFieldsModel> vs = new List<DeviceFieldsModel>();
|
||||
|
||||
private void Btn_Add_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left,Top);
|
||||
AddDeviceFields fields = new AddDeviceFields(p)
|
||||
{
|
||||
Width = Width,
|
||||
Height = Height
|
||||
};
|
||||
_ = fields.ShowDialog();
|
||||
if (fields.flag_save)
|
||||
{
|
||||
DeviceFieldsModel df = new DeviceFieldsModel
|
||||
{
|
||||
FieldsContent = fields.fieldsContent,
|
||||
FieldsName = fields.fieldsName
|
||||
};
|
||||
vs.Add(df);
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToUI()
|
||||
{
|
||||
gd_content.Children.Clear();
|
||||
gd_content.RowDefinitions.Clear();
|
||||
gd_content.ColumnDefinitions.Clear();
|
||||
|
||||
for(int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
DataToGridView(vs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToGridView(DeviceFieldsModel df)
|
||||
{
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_content);
|
||||
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < gd_header.ColumnDefinitions.Count; i++)
|
||||
{
|
||||
//当前行,添加1列 -- 列宽对应表头
|
||||
GridViewUnitls.AddColumn(gd_content, gd_header, i);
|
||||
|
||||
// 添加对应的控件到新的格子中
|
||||
if (i == 0)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.FieldsName);
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.FieldsContent);
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
DevOperation2 dev = new DevOperation2();
|
||||
dev.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
dev.VerticalAlignment = VerticalAlignment.Center;
|
||||
dev.obj = df;//绑定对象。用于详情,修改,删除之类的。
|
||||
dev.Click_Update += Dev_Click_Update;
|
||||
dev.Click_Delete += Dev_Click_Delete;
|
||||
Grid.SetRow(dev, gd_content.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(dev, i);
|
||||
gd_content.Children.Add(dev);
|
||||
}
|
||||
}
|
||||
//每行再加一个分割线
|
||||
GridViewUnitls.AddSpLine(gd_content, gd_header);
|
||||
}
|
||||
|
||||
private void Dev_Click_Delete(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevOperation2 dev = sender as DevOperation2;
|
||||
DeviceFieldsModel df = dev.obj as DeviceFieldsModel;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
if (vs[i].Id == df.Id && vs[i].FieldsName == df.FieldsName && vs[i].FieldsContent == df.FieldsContent)
|
||||
{
|
||||
vs.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DataToUI();
|
||||
}
|
||||
|
||||
private void Dev_Click_Update(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevOperation2 dev = sender as DevOperation2;
|
||||
DeviceFieldsModel df = dev.obj as DeviceFieldsModel;
|
||||
int index = -1;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
if (vs[i].Id == df.Id && vs[i].FieldsName == df.FieldsName && vs[i].FieldsContent == df.FieldsContent)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Point p = new Point(Left, Top);
|
||||
AddDeviceFields fields = new AddDeviceFields(p)
|
||||
{
|
||||
Width = Width,
|
||||
Height = Height,
|
||||
fieldsContent = vs[index].FieldsContent,
|
||||
fieldsName = vs[index].FieldsName
|
||||
};
|
||||
_ = fields.ShowDialog();
|
||||
if (fields.flag_save)
|
||||
{
|
||||
vs[index].FieldsContent = fields.fieldsContent;
|
||||
vs[index].FieldsName = fields.fieldsName;
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "保存");
|
||||
Btn_Add.SetUI("#0066FF", "#0066FF", "#FFFFFF", "添加");
|
||||
Btn_Point.SetUI("#0066FF", "#0066FF", "#FFFFFF", "点位");
|
||||
Btn_Point.Visibility = Visibility.Hidden;
|
||||
Btn_Close1.SetUI("#FFFFFF", "#0066FF", "#0066FF", "取消");
|
||||
|
||||
txt_DeviceID.SetUI("输入设备ID");
|
||||
txt_DeviceName.SetUI("输入设备名称");
|
||||
txt_TagName.SetUI("输入标签名称");
|
||||
|
||||
txt_x.SetUI("输入坐标数值");
|
||||
txt_x.SetNumber();
|
||||
txt_y.SetUI("输入坐标数值");
|
||||
txt_y.SetNumber();
|
||||
txt_z.SetUI("输入坐标数值");
|
||||
txt_z.SetNumber();
|
||||
|
||||
txt_len.SetUI("输入长");
|
||||
txt_len.SetNumber();
|
||||
txt_w.SetUI("输入宽");
|
||||
txt_w.SetNumber();
|
||||
txt_h.SetUI("输入高");
|
||||
txt_h.SetNumber();
|
||||
|
||||
|
||||
foreach (GlobalEnum.UnitOfMeasurement unit in Enum.GetValues(typeof(GlobalEnum.UnitOfMeasurement)))
|
||||
{
|
||||
cbb_Tag.Items.Add(unit);
|
||||
}
|
||||
cbb_Tag.SelectedIndex = 0;
|
||||
|
||||
cbb_Bottle.Items.Add(GlobalEnum.UnitBottle.大瓶子);
|
||||
cbb_Bottle.Items.Add(GlobalEnum.UnitBottle.小瓶子);
|
||||
cbb_Bottle.SelectedIndex = 0;
|
||||
|
||||
foreach (GlobalEnum.UnitDeviceType unit in Enum.GetValues(typeof(GlobalEnum.UnitDeviceType)))
|
||||
{
|
||||
cbb_Group.Items.Add(unit);
|
||||
}
|
||||
cbb_Group.SelectedIndex = 0;
|
||||
|
||||
if (isUpdate)
|
||||
{
|
||||
txt_DeviceID.SetText(Dim.DeviceId.ToString());
|
||||
txt_DeviceName.SetText(Dim.DeviceName);
|
||||
txt_TagName.SetText(Dim.TagName);
|
||||
cbb_Tag.Text = Dim.TagUnit;
|
||||
txt_x.SetText(Dim.X.ToString());
|
||||
txt_y.SetText(Dim.Y.ToString());
|
||||
txt_z.SetText(Dim.Z.ToString());
|
||||
txt_len.SetText(Dim.L.ToString());
|
||||
txt_w.SetText(Dim.W.ToString());
|
||||
txt_h.SetText(Dim.H.ToString());
|
||||
cbb_Bottle.SelectedIndex = Dim.Bottole;
|
||||
if (!string.IsNullOrEmpty(Dim.DeviceGroupId))
|
||||
{
|
||||
cbb_Group.SelectedIndex = int.Parse(Dim.DeviceGroupId);
|
||||
}
|
||||
vs = Dim.Dfms;
|
||||
DataToUI();
|
||||
}
|
||||
else
|
||||
{
|
||||
Dim = new DeviceInfoModel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DeviceInfoModel Dim;
|
||||
/// <summary>
|
||||
/// 0反应类设备 1转移类设备
|
||||
/// </summary>
|
||||
public int DeviceType = 0;
|
||||
public bool isUpdate = false;
|
||||
public bool flag_save = false;
|
||||
/// <summary>
|
||||
/// 保存设备信息--区分新增和修改
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//是否新增
|
||||
if (!isUpdate)
|
||||
{
|
||||
//这里新增最大排序号来。不按记录条数。因为记录会有删除的可能
|
||||
List<DeviceInfoModel> vs = SqlHelper.GetDeviceInfo();
|
||||
int index = 1;
|
||||
if (vs.Count > 0)
|
||||
{
|
||||
index = vs[vs.Count - 1].Sort + 1;
|
||||
}
|
||||
Dim.DeviceType = DeviceType;
|
||||
Dim.CreateTime = GlobalUnitils.GetNowTime(DateTime.Now);
|
||||
Dim.Sort = index;
|
||||
}
|
||||
Dim.DeviceId = txt_DeviceID.Text();
|
||||
Dim.DeviceName = txt_DeviceName.Text();
|
||||
Dim.TagName = txt_TagName.Text();
|
||||
Dim.TagUnit = cbb_Tag.Text;
|
||||
Dim.Bottole = cbb_Bottle.SelectedIndex;
|
||||
Dim.X = float.Parse(string.IsNullOrEmpty(txt_x.Text()) ? "0" : txt_x.Text());
|
||||
Dim.Y = float.Parse(string.IsNullOrEmpty(txt_y.Text()) ? "0" : txt_y.Text());
|
||||
Dim.Z = float.Parse(string.IsNullOrEmpty(txt_z.Text()) ? "0" : txt_z.Text());
|
||||
Dim.L = float.Parse(string.IsNullOrEmpty(txt_len.Text()) ? "0" : txt_len.Text());
|
||||
Dim.W = float.Parse(string.IsNullOrEmpty(txt_w.Text()) ? "0" : txt_w.Text());
|
||||
Dim.H = float.Parse(string.IsNullOrEmpty(txt_h.Text()) ? "0" : txt_h.Text());
|
||||
// 设备类型
|
||||
Dim.DeviceGroupId = cbb_Group.SelectedIndex.ToString();
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
vs[i].Id = i;
|
||||
}
|
||||
Dim.Dfms = vs;
|
||||
Dim.FieldJson = JsonConvert.SerializeObject(vs);
|
||||
flag_save = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
89
middleware/zdhsys/Popup/AddDevicePoint.xaml
Normal file
89
middleware/zdhsys/Popup/AddDevicePoint.xaml
Normal file
@@ -0,0 +1,89 @@
|
||||
<Window x:Class="zdhsys.Popup.AddDevicePoint"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddDevicePoint" Height="400" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="450" Height="400" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="点位地址管理" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="0.2*"/>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Content="1号瓶" Grid.Column="0" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_1" Grid.Column="1" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
<Label Content="2号瓶" Grid.Column="3" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_2" Grid.Column="4" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="3号瓶" Grid.Row="1" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_3" Grid.Column="1" Grid.Row="1" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
<Label Content="4号瓶" Grid.Column="3" Grid.Row="1" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_4" Grid.Column="4" Grid.Row="1" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="5号瓶" Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_5" Grid.Column="1" Grid.Row="2" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
<Label Content="6号瓶" Grid.Column="3" Grid.Row="2" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_6" Grid.Column="4" Grid.Row="2" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="7号瓶" Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_7" Grid.Column="1" Grid.Row="3" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
<Label Content="8号瓶" Grid.Column="3" Grid.Row="3" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_8" Grid.Column="4" Grid.Row="3" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="9号瓶" Grid.Column="0" Grid.Row="4" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_9" Grid.Column="1" Grid.Row="4" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
<Label Content="10号瓶" Grid.Column="3" Grid.Row="4" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_10" Grid.Column="4" Grid.Row="4" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="11号瓶" Grid.Column="0" Grid.Row="5" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_11" Grid.Column="1" Grid.Row="5" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
<Label Content="12号瓶" Grid.Column="3" Grid.Row="5" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_12" Grid.Column="4" Grid.Row="5" Margin="10,0,0,0" Width="100" HorizontalAlignment="Left"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="3*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Margin="10,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Close1" Click="Btn_Close_Click" Grid.Column="2" Margin="10,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
119
middleware/zdhsys/Popup/AddDevicePoint.xaml.cs
Normal file
119
middleware/zdhsys/Popup/AddDevicePoint.xaml.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
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 zdhsys.entity;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddDevicePoint.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddDevicePoint : Window
|
||||
{
|
||||
public AddDevicePoint(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public DevicePoint dp;
|
||||
public bool isUpdate = false;
|
||||
public bool flag_Save = false;
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
txt_1.SetUI("输入坐标");
|
||||
txt_1.SetNumber();
|
||||
|
||||
txt_2.SetUI("输入坐标");
|
||||
txt_2.SetNumber();
|
||||
|
||||
txt_3.SetUI("输入坐标");
|
||||
txt_3.SetNumber();
|
||||
|
||||
txt_4.SetUI("输入坐标");
|
||||
txt_4.SetNumber();
|
||||
|
||||
txt_5.SetUI("输入坐标");
|
||||
txt_5.SetNumber();
|
||||
|
||||
txt_6.SetUI("输入坐标");
|
||||
txt_6.SetNumber();
|
||||
|
||||
txt_7.SetUI("输入坐标");
|
||||
txt_7.SetNumber();
|
||||
|
||||
txt_8.SetUI("输入坐标");
|
||||
txt_8.SetNumber();
|
||||
|
||||
txt_9.SetUI("输入坐标");
|
||||
txt_9.SetNumber();
|
||||
|
||||
txt_10.SetUI("输入坐标");
|
||||
txt_10.SetNumber();
|
||||
|
||||
txt_11.SetUI("输入坐标");
|
||||
txt_11.SetNumber();
|
||||
|
||||
txt_12.SetUI("输入坐标");
|
||||
txt_12.SetNumber();
|
||||
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "保存");
|
||||
Btn_Close1.SetUI("#FFFFFF", "#0066FF", "#0066FF", "取消");
|
||||
|
||||
if (isUpdate)
|
||||
{
|
||||
txt_1.SetText(dp.p1);
|
||||
txt_2.SetText(dp.p2);
|
||||
txt_3.SetText(dp.p3);
|
||||
txt_4.SetText(dp.p4);
|
||||
txt_5.SetText(dp.p5);
|
||||
txt_6.SetText(dp.p6);
|
||||
txt_7.SetText(dp.p7);
|
||||
txt_8.SetText(dp.p8);
|
||||
txt_9.SetText(dp.p9);
|
||||
txt_10.SetText(dp.p10);
|
||||
txt_11.SetText(dp.p11);
|
||||
txt_12.SetText(dp.p12);
|
||||
}
|
||||
}
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isUpdate)
|
||||
{
|
||||
dp = new DevicePoint();
|
||||
}
|
||||
dp.p1 = txt_1.Text();
|
||||
dp.p2 = txt_2.Text();
|
||||
dp.p3 = txt_3.Text();
|
||||
dp.p4 = txt_4.Text();
|
||||
dp.p5 = txt_5.Text();
|
||||
dp.p6 = txt_6.Text();
|
||||
dp.p7 = txt_7.Text();
|
||||
dp.p8 = txt_8.Text();
|
||||
dp.p9 = txt_9.Text();
|
||||
dp.p10 = txt_10.Text();
|
||||
dp.p11 = txt_11.Text();
|
||||
dp.p12 = txt_12.Text();
|
||||
flag_Save = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
69
middleware/zdhsys/Popup/AddFlowData.xaml
Normal file
69
middleware/zdhsys/Popup/AddFlowData.xaml
Normal file
@@ -0,0 +1,69 @@
|
||||
<Window x:Class="zdhsys.Popup.AddFlowData"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOption" Height="600" Width="1000">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="1000" Height="600" Background="White">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" Grid.Column="0" Margin="10,0,0,0" Content="流程管理" FontSize="15" Foreground="#999999" VerticalAlignment="Center" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
<Label Grid.Row="0" Grid.Column="1" Content=">" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
<Label Grid.Row="0" Grid.Column="2" Content="创建流程" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Margin="10,0,0,0" Content="流程名称" FontSize="15" Foreground="#000000" VerticalAlignment="Center"/>
|
||||
<Grid Grid.Row="1" Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="210"/>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="210"/>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevTextBox x:Name="txt_option" Width="210" HorizontalAlignment="Left"/>
|
||||
<Label Grid.Column="1" Content="创建流程" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
<local1:DevTextBox x:Name="txt_no" Grid.Column="2" Width="200" HorizontalAlignment="Left"/>
|
||||
<local1:DevButton1 x:Name="Btn_Add" Grid.Column="3" Width="120" HorizontalAlignment="Left" Height="40"/>
|
||||
<local1:DevButton1 x:Name="Btn_Save" Grid.Column="4" Width="120" HorizontalAlignment="Left" Height="40"/>
|
||||
<local1:DevButton1 x:Name="Btn_Close" Grid.Column="5" Width="120" HorizontalAlignment="Left" Height="40"/>
|
||||
</Grid>
|
||||
<Label Grid.Row="2" Grid.Column="0" Margin="10,10,0,0" Content="选择内容" FontSize="15" Foreground="#000000" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Grid.Column="2" Margin="0,10,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="12*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="gd_header" Background="#F6F6F6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="序号" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="1" Content="配方名称" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="2" Content="操作" Style="{StaticResource CustomLabelStyle}"/>
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<Grid x:Name="gd_content">
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
224
middleware/zdhsys/Popup/AddFlowData.xaml.cs
Normal file
224
middleware/zdhsys/Popup/AddFlowData.xaml.cs
Normal file
@@ -0,0 +1,224 @@
|
||||
using Newtonsoft.Json;
|
||||
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 zdhsys.Bean;
|
||||
using zdhsys.Control;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOption.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddFlowData : Window
|
||||
{
|
||||
public AddFlowData(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
|
||||
Btn_Add.Click += Btn_Add_Click;
|
||||
Btn_Close.Click += Btn_Close_Click;
|
||||
Btn_Save.Click += Btn_Save_Click;
|
||||
}
|
||||
|
||||
public FlowModel fm = null;
|
||||
public bool isUpdate = false;
|
||||
public bool flag_Save = false;
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
if (string.IsNullOrEmpty(txt_option.Text()))
|
||||
{
|
||||
info.SetUI("流程名称不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txt_no.Text()))
|
||||
{
|
||||
info.SetUI("流程编号不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
if (vs.Count == 0)
|
||||
{
|
||||
info.SetUI("流程内容不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isUpdate)
|
||||
{
|
||||
fm.FlowName = txt_option.Text();
|
||||
fm.FlowNO = txt_no.Text();
|
||||
fm.FlowJson = JsonConvert.SerializeObject(vs);
|
||||
}
|
||||
else
|
||||
{
|
||||
fm = new FlowModel
|
||||
{
|
||||
CreateTime = GlobalUnitils.GetNowTime(DateTime.Now),
|
||||
FlowName = txt_option.Text(),
|
||||
FlowNO = txt_no.Text(),
|
||||
Status = 0,
|
||||
FlowJson = JsonConvert.SerializeObject(vs)
|
||||
};
|
||||
}
|
||||
flag_Save = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
private List<Options> vs = new List<Options>();
|
||||
private void Btn_Add_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
AddFlowDataInfo info = new AddFlowDataInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
_ = info.ShowDialog();
|
||||
if (info.flag_Save)
|
||||
{
|
||||
vs.Add(info.ofm);
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToUI()
|
||||
{
|
||||
gd_content.Children.Clear();
|
||||
gd_content.RowDefinitions.Clear();
|
||||
gd_content.ColumnDefinitions.Clear();
|
||||
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
DataToGridView(vs[i], i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToGridView(Options df, int index)
|
||||
{
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_content);
|
||||
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < gd_header.ColumnDefinitions.Count; i++)
|
||||
{
|
||||
//当前行,添加1列 -- 列宽对应表头
|
||||
GridViewUnitls.AddColumn(gd_content, gd_header, i);
|
||||
|
||||
// 添加对应的控件到新的格子中
|
||||
if (i == 0)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, index.ToString());
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.OptionName);
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
DevOperation2 dev = new DevOperation2
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
obj = df//绑定对象。用于详情,修改,删除之类的。
|
||||
};
|
||||
dev.Click_Update += Dev_Click_Update;
|
||||
dev.Click_Delete += Dev_Click_Delete;
|
||||
Grid.SetRow(dev, gd_content.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(dev, i);
|
||||
gd_content.Children.Add(dev);
|
||||
}
|
||||
}
|
||||
//每行再加一个分割线
|
||||
GridViewUnitls.AddSpLine(gd_content, gd_header);
|
||||
}
|
||||
|
||||
private void Dev_Click_Delete(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevOperation2 dev = sender as DevOperation2;
|
||||
Options df = dev.obj as Options;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
if (vs[i].Id == df.Id)
|
||||
{
|
||||
vs.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DataToUI();
|
||||
}
|
||||
|
||||
private void Dev_Click_Update(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevOperation2 dev = sender as DevOperation2;
|
||||
Options df = dev.obj as Options;
|
||||
int index = -1;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
if (vs[i].Id == df.Id)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Point p = new Point(Left, Top);
|
||||
AddFlowDataInfo info = new AddFlowDataInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.isUpdate = true;
|
||||
info.ofm = vs[index];
|
||||
_ = info.ShowDialog();
|
||||
if (info.flag_Save)
|
||||
{
|
||||
vs[index] = info.ofm;
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
txt_option.SetUI("输入流程名称");
|
||||
txt_no.SetUI("输入流程编号");
|
||||
|
||||
Btn_Add.SetUI("#E8F4FF", "#97D4FF", "\\Image\\add.png", "#1990FF", "增加");
|
||||
Btn_Save.SetUI("#E8F4FF", "#97D4FF", "\\Image\\save.png", "#1990FF", "保存");
|
||||
Btn_Close.SetUI("#E8F4FF", "#97D4FF", "\\Image\\语音关闭.png", "#1990FF", "关闭");
|
||||
|
||||
if (isUpdate)
|
||||
{
|
||||
txt_option.SetText(fm.FlowName);
|
||||
vs = JsonConvert.DeserializeObject<List<Options>>(fm.FlowJson);
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
66
middleware/zdhsys/Popup/AddFlowDataInfo.xaml
Normal file
66
middleware/zdhsys/Popup/AddFlowDataInfo.xaml
Normal file
@@ -0,0 +1,66 @@
|
||||
<Window x:Class="zdhsys.Popup.AddFlowDataInfo"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOptionInfo" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="200" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="0"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="添加内容" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="配方" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="cb" Grid.Column="1" VerticalContentAlignment="Center" Margin="10,0,0,0" Height="30" Width="250" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="3" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="数值" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox Grid.Column="1" Margin="10,0,0,0" x:Name="txt_num" Width="250" HorizontalAlignment="Left"/>
|
||||
<Label x:Name="lb" Content="单位:g" Grid.Column="2" VerticalAlignment="Center" Style="{StaticResource CommonStyleLeft}" FontSize="12" FontWeight="Bold"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.7*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1.3*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Margin="15,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Close1" Click="Btn_Close_Click" Grid.Column="3" Margin="15,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
72
middleware/zdhsys/Popup/AddFlowDataInfo.xaml.cs
Normal file
72
middleware/zdhsys/Popup/AddFlowDataInfo.xaml.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using zdhsys.Bean;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOptionInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddFlowDataInfo : Window
|
||||
{
|
||||
public AddFlowDataInfo(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private List<Options> dim = null;
|
||||
public Options ofm = null;
|
||||
public bool isUpdate = false;
|
||||
public bool flag_Save = false;
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "载入");
|
||||
Btn_Close1.SetUI("#FFFFFF", "#0066FF", "#0066FF", "取消");
|
||||
|
||||
dim = SqlHelper.GetOptions();
|
||||
if (dim == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (dim.Count == 0)
|
||||
{
|
||||
Point p = new Point(Left,Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.SetUI("请先添加配方");
|
||||
_ = info.ShowDialog();
|
||||
Close();
|
||||
}
|
||||
int index = 0;
|
||||
for (int i = 0; i < dim.Count; i++)
|
||||
{
|
||||
cb.Items.Add(dim[i].OptionName);
|
||||
if (ofm != null && ofm.Id == dim[i].Id)
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
cb.SelectedIndex = index;
|
||||
}
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ofm = dim[cb.SelectedIndex];
|
||||
flag_Save = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
79
middleware/zdhsys/Popup/AddFlowImg.xaml
Normal file
79
middleware/zdhsys/Popup/AddFlowImg.xaml
Normal file
@@ -0,0 +1,79 @@
|
||||
<Window x:Class="zdhsys.Popup.AddFlowImg"
|
||||
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:zdhsys.Popup" xmlns:control="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddFlowImg" Height="800" Width="1200">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="1200" Height="800" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="150"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="0" Margin="10,0,0,0" Content="流程管理" FontSize="15" Foreground="#999999" VerticalAlignment="Center" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
<Label Grid.Column="1" Content=">" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
<Label Grid.Column="2" Content="创建流程" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
<control:DevButton0 Grid.Column="3" x:Name="Btn_Save" Click="Btn_Save_Click" Margin="10,0,0,0" Height="40" />
|
||||
<control:DevButton0 Grid.Column="4" x:Name="Btn_Close" Click="Btn_Close_Click" Margin="10,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="150"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="设备" FontSize="15" Foreground="#999999" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="流程名称" FontSize="15" Foreground="#999999" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<control:DevTextBox x:Name="txt_z" Grid.Column="1" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="流程编号" Grid.Column="2" FontSize="15" Foreground="#999999" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<control:DevTextBox x:Name="txt_no" Grid.Column="3" Width="152" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="流程状态" Grid.Column="4" FontSize="15" Foreground="#999999" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<ComboBox x:Name="cbb_Status" Grid.Column="5" Margin="10,0,0,0" Height="30" Width="120" VerticalContentAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
</Grid>
|
||||
<Label Grid.Column="2" Content="操作" FontSize="15" Foreground="#999999" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="160"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="150"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Column="0">
|
||||
<Grid x:Name="gdLeft" ></Grid>
|
||||
</ScrollViewer>
|
||||
<Border Grid.Column="1" BorderThickness="1" BorderBrush="Black" Margin="5" CornerRadius="5">
|
||||
<Grid x:Name="gdCenter" >
|
||||
</Grid>
|
||||
</Border>
|
||||
<Grid x:Name="gdRight" Grid.Column="2"></Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
751
middleware/zdhsys/Popup/AddFlowImg.xaml.cs
Normal file
751
middleware/zdhsys/Popup/AddFlowImg.xaml.cs
Normal file
@@ -0,0 +1,751 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using zdhsys.Bean;
|
||||
using zdhsys.Control;
|
||||
using zdhsys.entity;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddFlowImg.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddFlowImg : Window
|
||||
{
|
||||
public AddFlowImg(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
private List<DeviceInfoModel> dims = null;
|
||||
|
||||
public FlowModel Fm = null;
|
||||
public bool isUpdate = false;
|
||||
public bool isSave = false;
|
||||
|
||||
private void DataToUI()
|
||||
{
|
||||
GridViewUnitls.AddRow(gdRight, 80);
|
||||
GridViewUnitls.AddColumn2(gdRight, gdRight.ActualWidth);
|
||||
FlowButton dev = new FlowButton()
|
||||
{
|
||||
Width = 120,
|
||||
Height = 80
|
||||
};
|
||||
dev.SetUI("#FFFFFF", "#0000FF", "#027AFF", "包硅反应");
|
||||
dev.Click += Dev_Click;
|
||||
Grid.SetRow(dev, gdRight.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(dev, 0);
|
||||
_ = gdRight.Children.Add(dev);
|
||||
|
||||
GridViewUnitls.AddRow(gdCenter, gdCenter.ActualHeight);
|
||||
GridViewUnitls.AddColumn2(gdCenter, gdCenter.ActualWidth);
|
||||
|
||||
gdCenter.MouseLeftButtonDown += gdCenter_MouseLeftButtonDown;
|
||||
gdCenter.MouseLeftButtonUp += GdCenter_MouseLeftButtonUp;
|
||||
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "保存");
|
||||
Btn_Close.SetUI("#FFFFFF", "#0066FF", "#0066FF", "取消");
|
||||
txt_z.SetUI("流程名称");
|
||||
txt_no.SetUI("流程编号");
|
||||
_ = cbb_Status.Items.Add("未执行");
|
||||
_ = cbb_Status.Items.Add("执行");
|
||||
cbb_Status.SelectedIndex = 0;
|
||||
|
||||
dims = SqlHelper.GetDeviceInfo();
|
||||
for (int i = 0; i < dims.Count; i++)
|
||||
{
|
||||
AddLeft(dims[i]);
|
||||
}
|
||||
|
||||
// 修改需要把数据重新还原出来
|
||||
if (isUpdate)
|
||||
{
|
||||
txt_z.SetText(Fm.FlowName);
|
||||
txt_no.SetText(Fm.FlowNO);
|
||||
cbb_Status.SelectedIndex = Fm.Status;
|
||||
List<FlowInfo> infos = JsonConvert.DeserializeObject<List<FlowInfo>>(Fm.FlowJson);
|
||||
for (int i = 0; i < infos.Count; i++)
|
||||
{
|
||||
if (i < infos.Count - 1)
|
||||
{
|
||||
DeviceInfoModel dim = dims.Find(x => x.Id == infos[i].DeviceId);
|
||||
FlowButton2 flow = new FlowButton2()
|
||||
{
|
||||
Width = 120,
|
||||
Height = 80,
|
||||
obj = dim,
|
||||
ID = infos[i].FlowId,
|
||||
CMD = infos[i].Cmd
|
||||
};
|
||||
flow.Click += Dev_Click1;
|
||||
flow.SetUI(infos[i].tempHexBG, infos[i].tempHexBG, infos[i].tempHexTxt, infos[i].tempTxt);
|
||||
Grid.SetRow(flow, gdCenter.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(flow, 0);
|
||||
_ = gdCenter.Children.Add(flow);
|
||||
flow.SetTranslateTransform(new Point(infos[i].translateTransformX, infos[i].translateTransformY));
|
||||
}
|
||||
else if (i == infos.Count - 1)
|
||||
{
|
||||
DeviceInfoModel dim = dims.Find(x => x.Id == infos[i].DeviceId);
|
||||
FlowButton2 flow = new FlowButton2()
|
||||
{
|
||||
Width = 120,
|
||||
Height = 80,
|
||||
obj = dim,
|
||||
ID = infos[i].FlowId,
|
||||
CMD = infos[i].Cmd
|
||||
};
|
||||
flow.Click += Dev_Click1;
|
||||
flow.SetUI(infos[i].tempHexBG, infos[i].tempHexBG, infos[i].tempHexTxt, infos[i].tempTxt);
|
||||
Grid.SetRow(flow, gdCenter.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(flow, 0);
|
||||
_ = gdCenter.Children.Add(flow);
|
||||
flow.SetTranslateTransform(new Point(infos[i].translateTransformX, infos[i].translateTransformY));
|
||||
|
||||
DeviceInfoModel dim2 = dims.Find(x => x.Id == infos[i].DeviceId2);
|
||||
FlowButton2 flow2 = new FlowButton2()
|
||||
{
|
||||
Width = 120,
|
||||
Height = 80,
|
||||
obj = dim2,
|
||||
ID = infos[i].FlowId2,
|
||||
CMD = infos[i].Cmd2
|
||||
};
|
||||
flow2.Click += Dev_Click1;
|
||||
flow2.SetUI(infos[i].tempHexBG2, infos[i].tempHexBG2, infos[i].tempHexTxt2, infos[i].tempTxt2);
|
||||
Grid.SetRow(flow2, gdCenter.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(flow2, 0);
|
||||
_ = gdCenter.Children.Add(flow2);
|
||||
flow2.SetTranslateTransform(new Point(infos[i].translateTransformX2, infos[i].translateTransformY2));
|
||||
}
|
||||
}
|
||||
//还原连接线
|
||||
for (int i = 0; i < infos.Count; i++)
|
||||
{
|
||||
FlowLine f = new FlowLine
|
||||
{
|
||||
startFlow = FindFlowById(infos[i].FlowId),
|
||||
startName = infos[i].flowDirName,
|
||||
endFlow = FindFlowById(infos[i].FlowId2),
|
||||
endName = infos[i].flowDirName2,
|
||||
id = GlobalUnitils.GetNowTime(DateTime.Now) + i
|
||||
};
|
||||
fl.Add(f);
|
||||
}
|
||||
DataToUIFlowLine();
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DataToUI();
|
||||
}
|
||||
|
||||
private void AddLeft(DeviceInfoModel dim)
|
||||
{
|
||||
GridViewUnitls.AddRow(gdLeft, 80);
|
||||
GridViewUnitls.AddColumn2(gdLeft, gdLeft.ActualWidth);
|
||||
FlowButton dev = new FlowButton()
|
||||
{
|
||||
Width = 120,
|
||||
Height = 80,
|
||||
obj = dim
|
||||
};
|
||||
dev.SetUI("#FFFFFF", "#027AFF", "#027AFF", dim.DeviceName);
|
||||
dev.Click += Dev_Click;
|
||||
Grid.SetRow(dev, gdLeft.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(dev, 0);
|
||||
_ = gdLeft.Children.Add(dev);
|
||||
}
|
||||
|
||||
private void Dev_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FlowButton dev0 = sender as FlowButton;
|
||||
DeviceInfoModel dim = dev0.obj as DeviceInfoModel;
|
||||
FlowButton2 dev = new FlowButton2()
|
||||
{
|
||||
Width = 120,
|
||||
Height = 80,
|
||||
obj = dim,
|
||||
ID = GlobalUnitils.GetNowTime(DateTime.Now)
|
||||
};
|
||||
dev.Click += Dev_Click1;
|
||||
if (dim != null)
|
||||
{
|
||||
dev.SetUI("#FFFFFF", "#027AFF", "#027AFF", dim.DeviceName);
|
||||
}
|
||||
else
|
||||
{
|
||||
dev.SetUI("#FFFFFF", "#027AFF", "#027AFF", "包硅反应");
|
||||
}
|
||||
Grid.SetRow(dev, gdCenter.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(dev, 0);
|
||||
_ = gdCenter.Children.Add(dev);
|
||||
}
|
||||
|
||||
private void Dev_Click1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
EditFlowButton info = new EditFlowButton(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
FlowButton2 dev = sender as FlowButton2;
|
||||
info.SetUI(dev.tempHexBG, dev.tempHexTxt, dev.CMD, dev.tempTxt);
|
||||
_ = info.ShowDialog();
|
||||
// 这里要显示出来。不然会自动隐藏。有点没搞懂。
|
||||
dev.Visibility = Visibility.Visible;
|
||||
if (info.isSave)
|
||||
{
|
||||
dev.SetBackColor(info.hexColor[info.backIndex]);
|
||||
dev.SetForeColor(info.hexColor[info.foreIndex]);
|
||||
dev.CMD = info.getCmd();
|
||||
}
|
||||
else if (info.isDel)
|
||||
{
|
||||
Console.WriteLine($"删除相关的连线 {dev.tempTxt}");
|
||||
//1.删除相关的连线
|
||||
int index = findFlowIndex(dev, true);
|
||||
if (index != -1)
|
||||
{
|
||||
DeleteLineByName("FL" + fl[index].id.ToString());
|
||||
fl.RemoveAt(index);
|
||||
}
|
||||
index = findFlowIndex(dev, false);
|
||||
if (index != -1)
|
||||
{
|
||||
DeleteLineByName("FL" + fl[index].id.ToString());
|
||||
fl.RemoveAt(index);
|
||||
}
|
||||
//2.从gd里删除这个流程图
|
||||
DeleteFlowByName(dev.ID);
|
||||
}
|
||||
}
|
||||
|
||||
#region 画线
|
||||
|
||||
private bool isDragging = false;
|
||||
private FlowButton2 startFlow = null;
|
||||
private string startName;
|
||||
|
||||
private void gdCenter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Point clickPoint = e.GetPosition(gdCenter);
|
||||
//Console.WriteLine($"flowButton 按下: {clickPoint.X},{clickPoint.Y}");
|
||||
FlowButton2 flowButton = getFlowByPoint(clickPoint);
|
||||
if (flowButton != null)
|
||||
{
|
||||
string name = flowButton.getEllipse();
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
isDragging = true;
|
||||
startFlow = flowButton;
|
||||
startName = name;
|
||||
//Console.WriteLine("按下:" + name);
|
||||
}
|
||||
//在 flowButton 上单击了鼠标左键
|
||||
//Console.WriteLine($"flowButton 按下: {clickPoint.X},{clickPoint.Y}");
|
||||
}
|
||||
}
|
||||
|
||||
private void GdCenter_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (isDragging)
|
||||
{
|
||||
Point clickPoint = e.GetPosition(gdCenter);
|
||||
//Console.WriteLine($"flowButton 松开: {clickPoint.X},{clickPoint.Y}");
|
||||
FlowButton2 flowButton = getFlowByPoint(clickPoint);
|
||||
if (flowButton != null)
|
||||
{
|
||||
string name = flowButton.getEllipse();
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
//Console.WriteLine("松开:" + name);
|
||||
FlowLine f = new FlowLine
|
||||
{
|
||||
startFlow = startFlow,
|
||||
startName = startName,
|
||||
endFlow = flowButton,
|
||||
endName = name,
|
||||
id = GlobalUnitils.GetNowTime(DateTime.Now)
|
||||
};
|
||||
//判断这个点是否已经有连接线。
|
||||
int index = findFlowIndex(startFlow, true);
|
||||
int index2 = findFlowIndex(flowButton, false);
|
||||
if (index == -1 && index2 == -1)
|
||||
{
|
||||
fl.Add(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("连线重复了");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
isDragging = false;
|
||||
DataToUIFlowLine();
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存所有连接线
|
||||
/// </summary>
|
||||
private List<FlowLine> fl = new List<FlowLine>();
|
||||
/// <summary>
|
||||
/// 绘制所有连接线
|
||||
/// </summary>
|
||||
private void DataToUIFlowLine()
|
||||
{
|
||||
for (int i = 0; i < fl.Count; i++)
|
||||
{
|
||||
Point p0 = new Point(0, 0);
|
||||
Point p1 = new Point(0, 0);
|
||||
FlowButton2 end = null;
|
||||
foreach (UIElement child in gdCenter.Children)
|
||||
{
|
||||
if (child is FlowButton2 flow)
|
||||
{
|
||||
if (flow.ID == fl[i].startFlow.ID)
|
||||
{
|
||||
p0 = getFlowButtonLocation2(flow, flow.getStartPointByName(fl[i].startName));
|
||||
}
|
||||
else if (flow.ID == fl[i].endFlow.ID)
|
||||
{
|
||||
p1 = getFlowButtonLocation2(flow, flow.getStartPointByName(fl[i].endName));
|
||||
end = flow;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p0.X == 0 && p0.Y == 0)
|
||||
{
|
||||
fl.RemoveAt(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
if (p1.X == 0 && p1.Y == 0)
|
||||
{
|
||||
fl.RemoveAt(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
if (Math.Abs(p0.X - p1.X) < 10)
|
||||
{
|
||||
double ch = p0.X - p1.X;
|
||||
if (end != null)
|
||||
{
|
||||
end.translateTransform.X += ch;
|
||||
}
|
||||
p1.X = p0.X;
|
||||
}
|
||||
else if (Math.Abs(p0.Y - p1.Y) < 10)
|
||||
{
|
||||
double ch = p0.Y - p1.Y;
|
||||
if (end != null)
|
||||
{
|
||||
end.translateTransform.Y += ch;
|
||||
}
|
||||
p1.Y = p0.Y;
|
||||
}
|
||||
AddArrowLineToGrid(p0, p1, "FL" + fl[i].id.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private Point getFlowButtonLocation(FlowButton2 flowButton2)
|
||||
{
|
||||
Point topLeft = flowButton2.TranslatePoint(new Point(0, 0), gdCenter);
|
||||
Size size = new Size(flowButton2.ActualWidth, flowButton2.ActualHeight);
|
||||
Rect bounds = new Rect(topLeft, size);
|
||||
//Console.WriteLine($"FlowButton2位置:({bounds.X}, {bounds.Y}), 大小:({bounds.Width}, {bounds.Height})");
|
||||
Point p = flowButton2.getPoint();
|
||||
//Console.WriteLine($"flowButton2 getPoint={p.X},{p.Y}");
|
||||
Point p2 = flowButton2.getTranslateTransform();
|
||||
//Console.WriteLine($"flowButton2 getTranslateTransform={p2.X},{p2.Y}");
|
||||
Point p3 = new Point(bounds.X + p.X + p2.X, bounds.Y + p.Y + p2.Y);
|
||||
//Console.WriteLine($"相对于gdCenter的坐标 {p3.X},{p3.Y}");
|
||||
return p3;
|
||||
}
|
||||
|
||||
private Point getFlowButtonLocation2(FlowButton2 flowButton2, Point p)
|
||||
{
|
||||
//Point topLeft = flowButton2.TranslatePoint(new Point(0, 0), gdCenter);
|
||||
Point topLeft = new Point(379, 309);
|
||||
Size size = new Size(120, 80);
|
||||
Rect bounds = new Rect(topLeft, size);
|
||||
//Console.WriteLine($"FlowButton2位置:({bounds.X}, {bounds.Y}), 大小:({bounds.Width}, {bounds.Height})");
|
||||
//Point p0 = flowButton2.getPoint();
|
||||
//Console.WriteLine($"flowButton2 getPoint={p0.X},{p0.Y}");
|
||||
Point p2 = flowButton2.getTranslateTransform();
|
||||
//Console.WriteLine($"flowButton2 getTranslateTransform={p2.X},{p2.Y}");
|
||||
Point p3 = new Point(bounds.X + p.X + p2.X, bounds.Y + p.Y + p2.Y);
|
||||
//Console.WriteLine($"相对于gdCenter的坐标 {p3.X},{p3.Y}");
|
||||
return p3;
|
||||
}
|
||||
|
||||
private FlowButton2 getFlowByPoint(Point p)
|
||||
{
|
||||
UIElement element = gdCenter.InputHitTest(p) as UIElement;
|
||||
while (element != null)
|
||||
{
|
||||
if (element is FlowButton2)
|
||||
{
|
||||
return element as FlowButton2;
|
||||
}
|
||||
element = VisualTreeHelper.GetParent(element) as UIElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 画线:Line
|
||||
/// </summary>
|
||||
/// <param name="p1"></param>
|
||||
/// <param name="p2"></param>
|
||||
/// <param name="name"></param>
|
||||
private void DrawLine(Point p1, Point p2, string name)
|
||||
{
|
||||
DeleteLineByName(name);
|
||||
Line myLine = new Line
|
||||
{
|
||||
Stroke = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0)),
|
||||
StrokeThickness = 2,
|
||||
Name = name
|
||||
};
|
||||
myLine.X1 = p1.X;
|
||||
myLine.Y1 = p1.Y;
|
||||
myLine.X2 = p2.X;
|
||||
myLine.Y2 = p2.Y;
|
||||
Grid.SetRow(myLine, gdRight.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(myLine, 0);
|
||||
_ = gdCenter.Children.Add(myLine);
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加画线,用path
|
||||
/// </summary>
|
||||
/// <param name="p1"></param>
|
||||
/// <param name="p2"></param>
|
||||
/// <param name="name"></param>
|
||||
private void DrawPathLine(Point p1, Point p2, string name)
|
||||
{
|
||||
Path myPath = new Path
|
||||
{
|
||||
Stroke = Brushes.Red,
|
||||
StrokeThickness = 2,
|
||||
Name = name,
|
||||
Data = new LineGeometry(p1, p2)
|
||||
};
|
||||
_ = gdCenter.Children.Add(myPath);
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加画线且带箭头
|
||||
/// </summary>
|
||||
/// <param name="p1"></param>
|
||||
/// <param name="p2"></param>
|
||||
/// <param name="name"></param>
|
||||
private void AddArrowLineToGrid(Point p1, Point p2, string name)
|
||||
{
|
||||
DeleteLineByName(name);
|
||||
double startX = p1.X;
|
||||
double startY = p1.Y;
|
||||
double endX = p2.X;
|
||||
double endY = p2.Y;
|
||||
double arrowLength = 6;
|
||||
//Console.WriteLine($"p1({p1.X},{p1.Y}) p2({p2.X},{p2.Y})");
|
||||
// 计算箭头两个点的坐标
|
||||
double angle = Math.Atan2(endY - startY, endX - startX);
|
||||
double arrowX1 = endX - arrowLength * Math.Cos(angle - Math.PI / 6);
|
||||
double arrowY1 = endY - arrowLength * Math.Sin(angle - Math.PI / 6);
|
||||
double arrowX2 = endX - arrowLength * Math.Cos(angle + Math.PI / 6);
|
||||
double arrowY2 = endY - arrowLength * Math.Sin(angle + Math.PI / 6);
|
||||
|
||||
double arrowX3 = endX - arrowLength * Math.Cos(angle);
|
||||
double arrowY3 = endY - arrowLength * Math.Sin(angle);
|
||||
|
||||
// 创建箭头路径
|
||||
PathFigure pathFigure = new PathFigure
|
||||
{
|
||||
StartPoint = p2
|
||||
};
|
||||
pathFigure.Segments.Add(new LineSegment(new Point(arrowX1, arrowY1), true));
|
||||
pathFigure.Segments.Add(new LineSegment(new Point(arrowX2, arrowY2), true));
|
||||
pathFigure.IsClosed = true;
|
||||
|
||||
PathFigure pathFigure2 = new PathFigure
|
||||
{
|
||||
StartPoint = p1
|
||||
};
|
||||
pathFigure2.Segments.Add(new LineSegment(new Point(arrowX3, arrowY3), true));
|
||||
|
||||
PathGeometry pathGeometry = new PathGeometry();
|
||||
pathGeometry.Figures.Add(pathFigure);
|
||||
pathGeometry.Figures.Add(pathFigure2);
|
||||
|
||||
// 创建 Path
|
||||
Path path = new Path
|
||||
{
|
||||
Stroke = Brushes.Red,
|
||||
StrokeThickness = 2,
|
||||
Fill = Brushes.Red,
|
||||
Data = pathGeometry,
|
||||
Name = name
|
||||
};
|
||||
_ = gdCenter.Children.Add(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按名称删除画线
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
private void DeleteLineByName(string name)
|
||||
{
|
||||
for (int i = 0; i < gdCenter.Children.Count; i++)
|
||||
{
|
||||
UIElement child = gdCenter.Children[i];
|
||||
// 如果该子元素是线条(Line)类型,就将其从 myGrid 中删除
|
||||
if (child is Line)
|
||||
{
|
||||
Line line = child as Line;
|
||||
if (line.Name == name)
|
||||
{
|
||||
gdCenter.Children.Remove(child);
|
||||
i--; // 修改循环索引,因为我们已经从集合中移除了一个元素
|
||||
}
|
||||
}
|
||||
if (child is Path)
|
||||
{
|
||||
Path line = child as Path;
|
||||
if (line.Name == name)
|
||||
{
|
||||
gdCenter.Children.Remove(child);
|
||||
i--; // 修改循环索引,因为我们已经从集合中移除了一个元素
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 按ID删除流程图
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
private void DeleteFlowByName(double Id)
|
||||
{
|
||||
for (int i = 0; i < gdCenter.Children.Count; i++)
|
||||
{
|
||||
UIElement child = gdCenter.Children[i];
|
||||
if (child is FlowButton2)
|
||||
{
|
||||
FlowButton2 line = child as FlowButton2;
|
||||
if (line.ID == Id)
|
||||
{
|
||||
gdCenter.Children.Remove(child);
|
||||
i--; // 修改循环索引,因为我们已经从集合中移除了一个元素
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过ID在grid里查找FlowButton2
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
private FlowButton2 FindFlowById(double Id)
|
||||
{
|
||||
for (int i = 0; i < gdCenter.Children.Count; i++)
|
||||
{
|
||||
UIElement child = gdCenter.Children[i];
|
||||
if (child is FlowButton2)
|
||||
{
|
||||
FlowButton2 flow = child as FlowButton2;
|
||||
if (flow.ID == Id)
|
||||
{
|
||||
return flow;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 保存流程图
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//1.要先对FL数组进行排序,排成一条线
|
||||
FlowButton2 startLine = null;
|
||||
List<FlowButton2> flows = new List<FlowButton2>();
|
||||
//1.1 先把所有连了线的设备拿出来。
|
||||
//1.2 这个设备如果不存在endFlow里面的话,说明它是第一个。
|
||||
for (int i = 0; i < fl.Count; i++)
|
||||
{
|
||||
if (!findFlow(flows, fl[i].startFlow))
|
||||
{
|
||||
flows.Add(fl[i].startFlow);
|
||||
}
|
||||
if (!findFlow(flows, fl[i].endFlow))
|
||||
{
|
||||
flows.Add(fl[i].endFlow);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < flows.Count; i++)
|
||||
{
|
||||
bool flag = true;
|
||||
for (int j = 0; j < fl.Count; j++)
|
||||
{
|
||||
//在线的终点出现,就不是第一个。
|
||||
if (flows[i].ID == fl[j].endFlow.ID)
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
startLine = flows[i];
|
||||
}
|
||||
}
|
||||
//2.找到第一个之后,就按顺序排下来就行了。
|
||||
List<FlowLine> fl2 = new List<FlowLine>();
|
||||
for (int i = 0; i < fl.Count; i++)
|
||||
{
|
||||
int index = findFlowIndex(startLine, true);
|
||||
fl2.Add(fl[index]);
|
||||
startLine = fl2[fl2.Count - 1].endFlow;
|
||||
}
|
||||
//Console.WriteLine("fl2.Count=" + fl2.Count);
|
||||
List<FlowInfo> infos = new List<FlowInfo>();
|
||||
for (int i = 0; i < fl2.Count; i++)
|
||||
{
|
||||
FlowInfo info = new FlowInfo();
|
||||
if (fl2[i].startFlow.obj != null)
|
||||
{
|
||||
DeviceInfoModel dim = fl2[i].startFlow.obj as DeviceInfoModel;
|
||||
info.DeviceId = dim.Id;
|
||||
}
|
||||
info.FlowId = fl2[i].startFlow.ID;
|
||||
info.flowDirName = fl2[i].startName;
|
||||
info.tempHexBd = fl2[i].startFlow.tempHexBd;
|
||||
info.tempHexBG = fl2[i].startFlow.tempHexBG;
|
||||
info.tempHexTxt = fl2[i].startFlow.tempHexTxt;
|
||||
info.tempTxt = fl2[i].startFlow.tempTxt;
|
||||
info.translateTransformX = fl2[i].startFlow.translateTransform.X;
|
||||
info.translateTransformY = fl2[i].startFlow.translateTransform.Y;
|
||||
info.Cmd = fl2[i].startFlow.CMD;
|
||||
|
||||
if (fl2[i].endFlow.obj != null)
|
||||
{
|
||||
DeviceInfoModel dim = fl2[i].endFlow.obj as DeviceInfoModel;
|
||||
info.DeviceId2 = dim.Id;
|
||||
}
|
||||
info.FlowId2 = fl2[i].endFlow.ID;
|
||||
info.flowDirName2 = fl2[i].endName;
|
||||
info.tempHexBd2 = fl2[i].endFlow.tempHexBd;
|
||||
info.tempHexBG2 = fl2[i].endFlow.tempHexBG;
|
||||
info.tempHexTxt2 = fl2[i].endFlow.tempHexTxt;
|
||||
info.tempTxt2 = fl2[i].endFlow.tempTxt;
|
||||
info.translateTransformX2 = fl2[i].endFlow.translateTransform.X;
|
||||
info.translateTransformY2 = fl2[i].endFlow.translateTransform.Y;
|
||||
info.Cmd2 = fl2[i].endFlow.CMD;
|
||||
infos.Add(info);
|
||||
if (i < fl2.Count - 1)
|
||||
{
|
||||
Console.Write($" {fl2[i].startFlow.tempTxt}");
|
||||
}
|
||||
if (i == fl2.Count - 1)
|
||||
{
|
||||
Console.WriteLine($" {fl2[i].startFlow.tempTxt} {fl2[i].endFlow.tempTxt}");
|
||||
}
|
||||
}
|
||||
//打印一下。
|
||||
//for (int i = 0; i < infos.Count; i++)
|
||||
//{
|
||||
// Console.Write($"{infos[i].tempTxt}-{infos[i].flowDirName} 属性:{infos[i].tempHexBd},{infos[i].tempHexTxt},{infos[i].translateTransformX},{infos[i].translateTransformY}");
|
||||
// Console.WriteLine($" {infos[i].tempTxt2}-{infos[i].flowDirName2} 属性:{infos[i].tempHexBd2},{infos[i].tempHexTxt2},{infos[i].translateTransformX2},{infos[i].translateTransformY2}");
|
||||
//}
|
||||
string json = JsonConvert.SerializeObject(infos);
|
||||
Console.WriteLine("json=" + json);
|
||||
|
||||
if (string.IsNullOrEmpty(txt_z.Text()) || string.IsNullOrEmpty(txt_no.Text()))
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.SetUI("流程名称或流程编号不能为空!");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
if (!isUpdate)
|
||||
{
|
||||
Fm = new FlowModel
|
||||
{
|
||||
CreateTime = GlobalUnitils.GetNowTime(DateTime.Now)
|
||||
};
|
||||
}
|
||||
Fm.FlowName = txt_z.Text();
|
||||
Fm.FlowNO = txt_no.Text();
|
||||
Fm.Status = cbb_Status.SelectedIndex;
|
||||
Fm.FlowJson = json;
|
||||
isSave = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private int findFlowIndex(FlowButton2 flow, bool frist)
|
||||
{
|
||||
if (flow == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < fl.Count; i++)
|
||||
{
|
||||
if (frist)
|
||||
{
|
||||
if (fl[i].startFlow.ID == flow.ID)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fl[i].endFlow.ID == flow.ID)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine($"未找到:{flow.tempTxt} frist={frist}");
|
||||
return -1;
|
||||
}
|
||||
|
||||
private bool findFlow(List<FlowButton2> flows, FlowButton2 flow)
|
||||
{
|
||||
for (int i = 0; i < flows.Count; i++)
|
||||
{
|
||||
if (flows[i].ID == flow.ID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
74
middleware/zdhsys/Popup/AddOption.xaml
Normal file
74
middleware/zdhsys/Popup/AddOption.xaml
Normal file
@@ -0,0 +1,74 @@
|
||||
<Window x:Class="zdhsys.Popup.AddOption"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOption" Height="600" Width="1000">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="1000" Height="600" Background="White">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" Grid.Column="0" Margin="10,0,0,0" Content="配方管理" FontSize="15" Foreground="#999999" VerticalAlignment="Center" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
<Label Grid.Row="0" Grid.Column="1" Content=">" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
<Label Grid.Row="0" Grid.Column="2" Content="创建配方" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Margin="10,0,0,0" Content="配方名称" FontSize="15" Foreground="#000000" VerticalAlignment="Center"/>
|
||||
<Grid Grid.Row="1" Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="210"/>
|
||||
<ColumnDefinition Width="40"/>
|
||||
<ColumnDefinition Width="90"/>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevTextBox x:Name="txt_option" Width="200" HorizontalAlignment="Left"/>
|
||||
<Label Grid.Column="1" Content="状态" FontSize="15" Foreground="#000000" HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||
<ComboBox x:Name="cb" Grid.Column="2" VerticalContentAlignment="Center" Height="30" Width="80" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
<local1:DevButton1 x:Name="Btn_Add" Grid.Column="3" Width="130" HorizontalAlignment="Left" Height="40"/>
|
||||
<local1:DevButton x:Name="Btn_Add2" Grid.Column="4" Width="130" HorizontalAlignment="Left" Height="40"/>
|
||||
<local1:DevButton1 x:Name="Btn_Save" Grid.Column="5" Width="130" HorizontalAlignment="Left" Height="40"/>
|
||||
<local1:DevButton1 x:Name="Btn_Close" Grid.Column="6" Width="130" HorizontalAlignment="Left" Height="40"/>
|
||||
</Grid>
|
||||
<Label Grid.Row="2" Grid.Column="0" Margin="10,10,0,0" Content="选择内容" FontSize="15" Foreground="#000000" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Grid.Column="2" Margin="0,10,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="12*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="gd_header" Background="#F6F6F6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="标签" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="1" Content="对应于指定设备编号" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="2" Content="数值" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="3" Content="是否子配方" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="4" Content="操作" Style="{StaticResource CustomLabelStyle}"/>
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<Grid x:Name="gd_content"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
285
middleware/zdhsys/Popup/AddOption.xaml.cs
Normal file
285
middleware/zdhsys/Popup/AddOption.xaml.cs
Normal file
@@ -0,0 +1,285 @@
|
||||
using Newtonsoft.Json;
|
||||
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 zdhsys.Bean;
|
||||
using zdhsys.Control;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOption.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddOption : Window
|
||||
{
|
||||
public AddOption(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
|
||||
Btn_Add.Click += Btn_Add_Click;
|
||||
Btn_Add2.Click += Btn_Add2_Click;
|
||||
Btn_Close.Click += Btn_Close_Click;
|
||||
Btn_Save.Click += Btn_Save_Click;
|
||||
}
|
||||
|
||||
private List<OptionFieldsModel2> vs = new List<OptionFieldsModel2>();
|
||||
public bool isUpdate = false;
|
||||
public bool flag_Save = false;
|
||||
public Options opt = null;
|
||||
|
||||
private void Btn_Add2_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
AddSubOptionInfo info = new AddSubOptionInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
_ = info.ShowDialog();
|
||||
if (info.flag_Save)
|
||||
{
|
||||
vs.Add(info.ofm);
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
//做一些过滤
|
||||
if (string.IsNullOrEmpty(txt_option.Text()))
|
||||
{
|
||||
info.SetUI("配方名称不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
if (vs.Count == 0)
|
||||
{
|
||||
info.SetUI("配方内容不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isUpdate)
|
||||
{
|
||||
opt = new Options
|
||||
{
|
||||
CreateTime = GlobalUnitils.GetNowTime(DateTime.Now)
|
||||
};
|
||||
}
|
||||
opt.OptionJson = JsonConvert.SerializeObject(vs);
|
||||
opt.OptionName = txt_option.Text();
|
||||
opt.Status = cb.SelectedIndex;
|
||||
flag_Save = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Btn_Add_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
AddOptionInfo info = new AddOptionInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
_ = info.ShowDialog();
|
||||
if (info.flag_Save)
|
||||
{
|
||||
OptionFieldsModel2 ofm2 = new OptionFieldsModel2
|
||||
{
|
||||
DeviceId = info.ofm.DeviceId,
|
||||
Id = info.ofm.Id,
|
||||
IsSub = false,
|
||||
TagName = info.ofm.TagName,
|
||||
TagValue = info.ofm.TagValue
|
||||
};
|
||||
vs.Add(ofm2);
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
txt_option.SetUI("输入配方名称");
|
||||
|
||||
Btn_Add.SetUI("#E8F4FF", "#97D4FF", "\\Image\\add.png", "#1990FF", "增加");
|
||||
Btn_Add2.SetUI("#E8F4FF", "#97D4FF", "\\Image\\add.png", "#1990FF", "增加子配方");
|
||||
Btn_Save.SetUI("#E8F4FF", "#97D4FF", "\\Image\\save.png", "#1990FF", "保存");
|
||||
Btn_Close.SetUI("#E8F4FF", "#97D4FF", "\\Image\\语音关闭.png", "#1990FF", "关闭");
|
||||
|
||||
cb.Items.Add("正常");
|
||||
cb.Items.Add("作废");
|
||||
cb.SelectedIndex = 0;
|
||||
|
||||
if (isUpdate)
|
||||
{
|
||||
cb.SelectedIndex = opt.Status;
|
||||
txt_option.SetText(opt.OptionName);
|
||||
vs = JsonConvert.DeserializeObject<List<OptionFieldsModel2>>(opt.OptionJson);
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToUI()
|
||||
{
|
||||
gd_content.Children.Clear();
|
||||
gd_content.RowDefinitions.Clear();
|
||||
gd_content.ColumnDefinitions.Clear();
|
||||
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
DataToGridView(vs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToGridView(OptionFieldsModel2 df)
|
||||
{
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_content);
|
||||
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < gd_header.ColumnDefinitions.Count; i++)
|
||||
{
|
||||
//当前行,添加1列 -- 列宽对应表头
|
||||
GridViewUnitls.AddColumn(gd_content, gd_header, i);
|
||||
|
||||
// 添加对应的控件到新的格子中
|
||||
if (i == 0)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.TagName);
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.DeviceId);
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.TagValue);
|
||||
}
|
||||
else if (i == 3)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.IsSub ? "是" : "否");
|
||||
}
|
||||
else if (i == 4)
|
||||
{
|
||||
DevOperation2 dev = new DevOperation2
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
obj = df//绑定对象。用于详情,修改,删除之类的。
|
||||
};
|
||||
dev.Click_Update += Dev_Click_Update;
|
||||
dev.Click_Delete += Dev_Click_Delete;
|
||||
Grid.SetRow(dev, gd_content.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(dev, i);
|
||||
gd_content.Children.Add(dev);
|
||||
}
|
||||
}
|
||||
//每行再加一个分割线
|
||||
GridViewUnitls.AddSpLine(gd_content, gd_header);
|
||||
}
|
||||
|
||||
private void Dev_Click_Delete(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevOperation2 dev = sender as DevOperation2;
|
||||
OptionFieldsModel2 df = dev.obj as OptionFieldsModel2;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
if (vs[i].Id == df.Id)
|
||||
{
|
||||
vs.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DataToUI();
|
||||
}
|
||||
|
||||
private void Dev_Click_Update(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevOperation2 dev = sender as DevOperation2;
|
||||
OptionFieldsModel2 df = dev.obj as OptionFieldsModel2;
|
||||
int index = -1;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
if (vs[i].Id == df.Id)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Point p = new Point(Left, Top);
|
||||
if (df.IsSub)
|
||||
{
|
||||
AddSubOptionInfo info = new AddSubOptionInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.isUpdate = true;
|
||||
info.ofm = df;
|
||||
_ = info.ShowDialog();
|
||||
if (info.flag_Save)
|
||||
{
|
||||
vs[index] = info.ofm;
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddOptionInfo info = new AddOptionInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.isUpdate = true;
|
||||
OptionFieldsModel ofm = new OptionFieldsModel
|
||||
{
|
||||
DeviceId = df.DeviceId,
|
||||
Id = df.Id,
|
||||
TagName = df.TagName,
|
||||
TagValue = df.TagValue
|
||||
};
|
||||
info.ofm = ofm;
|
||||
_ = info.ShowDialog();
|
||||
if (info.flag_Save)
|
||||
{
|
||||
OptionFieldsModel2 ofm2 = new OptionFieldsModel2
|
||||
{
|
||||
DeviceId = info.ofm.DeviceId,
|
||||
Id = info.ofm.Id,
|
||||
IsSub = false,
|
||||
TagName = info.ofm.TagName,
|
||||
TagValue = info.ofm.TagValue
|
||||
};
|
||||
vs[index] = ofm2;
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
66
middleware/zdhsys/Popup/AddOptionInfo.xaml
Normal file
66
middleware/zdhsys/Popup/AddOptionInfo.xaml
Normal file
@@ -0,0 +1,66 @@
|
||||
<Window x:Class="zdhsys.Popup.AddOptionInfo"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOptionInfo" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="200" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="添加内容" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="标签" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="cb" Grid.Column="1" SelectionChanged="cb_SelectionChanged" VerticalContentAlignment="Center" Margin="10,0,0,0" Height="30" Width="250" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="3" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="数值" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox Grid.Column="1" Margin="10,0,0,0" x:Name="txt_num" Width="250" HorizontalAlignment="Left"/>
|
||||
<Label x:Name="lb" Content="单位:g" Grid.Column="2" VerticalAlignment="Center" Style="{StaticResource CommonStyleLeft}" FontSize="12" FontWeight="Bold"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.7*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1.3*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Margin="15,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Close1" Click="Btn_Close_Click" Grid.Column="3" Margin="15,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
105
middleware/zdhsys/Popup/AddOptionInfo.xaml.cs
Normal file
105
middleware/zdhsys/Popup/AddOptionInfo.xaml.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using zdhsys.Bean;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOptionInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddOptionInfo : Window
|
||||
{
|
||||
public AddOptionInfo(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private List<DeviceInfoModel> dim = null;
|
||||
public OptionFieldsModel ofm = null;
|
||||
public bool isUpdate = false;
|
||||
public bool flag_Save = false;
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//只能输入数字
|
||||
txt_num.SetNumber();
|
||||
txt_num.SetUI("输入数值");
|
||||
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF","#FFFFFF","载入");
|
||||
Btn_Close1.SetUI("#FFFFFF", "#0066FF", "#0066FF","取消");
|
||||
|
||||
dim = SqlHelper.GetDeviceInfo();
|
||||
if (dim == null) return;
|
||||
if (dim.Count == 0)
|
||||
{
|
||||
Point p = new Point(Left,Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.SetUI("请先添加设备");
|
||||
_ = info.ShowDialog();
|
||||
Close();
|
||||
}
|
||||
int index = 0;
|
||||
for (int i = 0; i < dim.Count; i++)
|
||||
{
|
||||
cb.Items.Add(dim[i].TagName);
|
||||
if (ofm != null && ofm.Id == dim[i].Id)
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
cb.SelectedIndex = index;
|
||||
if (ofm != null)
|
||||
{
|
||||
txt_num.SetText(ofm.TagValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(txt_num.Text()))
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.SetUI("数值不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
if (!isUpdate)
|
||||
{
|
||||
ofm = new OptionFieldsModel();
|
||||
}
|
||||
ofm.Id = dim[cb.SelectedIndex].Id;
|
||||
ofm.DeviceId = dim[cb.SelectedIndex].DeviceId;
|
||||
ofm.TagName = dim[cb.SelectedIndex].TagName;
|
||||
ofm.TagValue = txt_num.Text();
|
||||
flag_Save = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void cb_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
if (dim != null && dim.Count > 0)
|
||||
{
|
||||
string unit = dim[cb.SelectedIndex].TagUnit;
|
||||
unit = "单位:" + unit;
|
||||
lb.Content = unit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
61
middleware/zdhsys/Popup/AddOptionNew.xaml
Normal file
61
middleware/zdhsys/Popup/AddOptionNew.xaml
Normal file
@@ -0,0 +1,61 @@
|
||||
<Window x:Class="zdhsys.Popup.AddOptionNew"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOption" Height="750" Width="1300">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="1300" Height="750" Background="White">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="160"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" Grid.Column="0" Margin="10,0,0,0" Content="配方管理" FontSize="15" Foreground="#999999" VerticalAlignment="Center" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
<Label Grid.Row="0" Grid.Column="1" Content=">" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
<Label Grid.Row="0" Grid.Column="2" Content="创建配方" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Margin="10,0,0,0" Content="配方名称" FontSize="15" Foreground="#000000" VerticalAlignment="Center"/>
|
||||
<Grid Grid.Row="1" Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="210"/>
|
||||
<ColumnDefinition Width="40"/>
|
||||
<ColumnDefinition Width="90"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevTextBox x:Name="txt_option" Width="200" HorizontalAlignment="Left"/>
|
||||
<Label Grid.Column="1" Content="状态" FontSize="15" Foreground="#000000" HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||
<ComboBox x:Name="cb" Grid.Column="2" VerticalContentAlignment="Center" Height="30" Width="80" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
|
||||
<!--<Label Grid.Column="3" Content="流程" FontSize="15" Foreground="#000000" HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||
<ComboBox x:Name="cb_flow" Grid.Column="4" VerticalContentAlignment="Center" Height="30" Width="150" HorizontalAlignment="Left" Background="Transparent"/>-->
|
||||
|
||||
<local1:DevButton1 x:Name="Btn_Save" Grid.Column="5" Width="130" HorizontalAlignment="Right" Height="40"/>
|
||||
<local1:DevButton1 x:Name="Btn_Close" Grid.Column="6" Width="130" HorizontalAlignment="Left" Height="40"/>
|
||||
<local1:DevButton x:Name="Btn_See" Grid.Column="7" Width="130" HorizontalAlignment="Left" Height="40"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="2" Grid.ColumnSpan="3" Background="#F6F6F6">
|
||||
<Grid x:Name="gd_header"></Grid>
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Row="3" Grid.ColumnSpan="3">
|
||||
<Grid x:Name="gd_content"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
562
middleware/zdhsys/Popup/AddOptionNew.xaml.cs
Normal file
562
middleware/zdhsys/Popup/AddOptionNew.xaml.cs
Normal file
@@ -0,0 +1,562 @@
|
||||
using Newtonsoft.Json;
|
||||
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 zdhsys.Bean;
|
||||
using zdhsys.Control;
|
||||
using zdhsys.entity;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOption.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddOptionNew : Window
|
||||
{
|
||||
public AddOptionNew(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
|
||||
Btn_Close.Click += Btn_Close_Click;
|
||||
Btn_Save.Click += Btn_Save_Click;
|
||||
Btn_See.Click += Btn_See_Click;
|
||||
}
|
||||
/// <summary>
|
||||
/// 把流程+配方=生成指令JSON
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Btn_See_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SeeJsons sJson = new SeeJsons();
|
||||
List<List<List<PrintCmd>>> pc = sJson.getJson(fm.Id, Log());
|
||||
Point p = new Point(Left, Top);
|
||||
SeeJson see = new SeeJson(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
see.pc = pc;
|
||||
_ = see.ShowDialog();
|
||||
}
|
||||
|
||||
public FlowModel fm = null;
|
||||
private List<string> vs = new List<string>();
|
||||
public bool isUpdate = false;
|
||||
public bool isSee = false;
|
||||
public bool flag_Save = false;
|
||||
public Options opt = null;
|
||||
private List<List<DevInfo>> devList = new List<List<DevInfo>>();
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
//做一些过滤
|
||||
if (string.IsNullOrEmpty(txt_option.Text()))
|
||||
{
|
||||
info.SetUI("配方名称不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
string json = Log();
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
info.SetUI("配方内容不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isUpdate)
|
||||
{
|
||||
opt = new Options
|
||||
{
|
||||
CreateTime = GlobalUnitils.GetNowTime(DateTime.Now)
|
||||
};
|
||||
}
|
||||
opt.OptionJson = json;
|
||||
opt.OptionName = txt_option.Text();
|
||||
opt.Status = cb.SelectedIndex;
|
||||
opt.FlowId = fm.Id;
|
||||
flag_Save = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private string Log()
|
||||
{
|
||||
List<string> vsStr = new List<string>();
|
||||
// 遍历 Grid 中的每一行
|
||||
for (int row = 0; row < gd_content.RowDefinitions.Count; row++)
|
||||
{
|
||||
List<DevInfo> vs = new List<DevInfo>();
|
||||
// 遍历 Grid 中的每一列
|
||||
for (int column = 0; column < gd_content.ColumnDefinitions.Count; column++)
|
||||
{
|
||||
// 获取当前行和列上的子元素
|
||||
UIElement element = gd_content.Children
|
||||
.Cast<UIElement>()
|
||||
.FirstOrDefault(e => Grid.GetRow(e) == row && Grid.GetColumn(e) == column);
|
||||
|
||||
// 检查子元素是否是 TextBox,并获取其值
|
||||
if (element is TextBox textBox)
|
||||
{
|
||||
string text = textBox.Text;
|
||||
DeviceFields dfs = textBox.Tag as DeviceFields;
|
||||
//Console.WriteLine("index=" + dfs.index + " " + dfs.dim.DeviceName + " " + dfs.dfm.FieldsName + ":" + text);
|
||||
//这里要合并同一个设备的各各字段
|
||||
int index = vs.FindIndex(x => x.Index == dfs.index);
|
||||
//如果已经存在,就修改对应的字段属性就好了。
|
||||
if (index >= 0)
|
||||
{
|
||||
//int index2 = vs[index].Dfms.FindIndex(x => x.FieldsName == dfs.dfm.FieldsName);
|
||||
//DeviceFieldsModel dfm = JsonConvert.DeserializeObject<DeviceFieldsModel>(JsonConvert.SerializeObject(vs[index].Dfms[index2]));
|
||||
//dfm.FieldsContent = text;
|
||||
//vs[index].Dfms[index2] = dfm;
|
||||
//DevInfo dd = vs[index];
|
||||
int index2 = vs[index].Dfms.FindIndex(x => x.FieldsName == dfs.dfm.FieldsName);
|
||||
//Console.WriteLine($"vs.index={index}:{index2} {dfs.dfm.FieldsName}:{text}");
|
||||
vs[index].Dfms[index2].FieldsContent = text;
|
||||
//Console.WriteLine("修改: "+ dd.DeviceName + " name="+dd.Dfms[index2].FieldsName + ":"+dd.Dfms[index2].FieldsContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
//DeviceInfoModel dim = dfs.dim;
|
||||
DevInfo dim = new DevInfo
|
||||
{
|
||||
Index = dfs.index,
|
||||
Id = dfs.dim.Id,
|
||||
// 这里不能直接=dfs.dim.Dfms 因为会出现引用问题。到时候修改dfms的值,整个vs里面所有的dfms值都会改变。
|
||||
// 这里做一个深度拷贝的处理。复制并创建一个新的Dfms内存块
|
||||
Dfms = JsonConvert.DeserializeObject<List<DeviceFieldsModel>>(JsonConvert.SerializeObject(dfs.dim.Dfms))
|
||||
// Dfms = dfs.dim.Dfms.ToList()
|
||||
};
|
||||
int index2 = dim.Dfms.FindIndex(x => x.FieldsName == dfs.dfm.FieldsName);
|
||||
DeviceFieldsModel dfm = dim.Dfms[index2];
|
||||
dfm.FieldsContent = text;
|
||||
dim.Dfms[index2] = dfm;
|
||||
vs.Add(dim);
|
||||
//Console.WriteLine("新增: " + dim.DeviceName + " name=" + dim.Dfms[index2].FieldsName + ":" + dim.Dfms[index2].FieldsContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(vs);
|
||||
vsStr.Add(json);
|
||||
}
|
||||
string json2 = JsonConvert.SerializeObject(vsStr);
|
||||
//Console.WriteLine(json2);
|
||||
return json2;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
txt_option.SetUI("输入配方名称");
|
||||
Btn_Save.SetUI("#E8F4FF", "#97D4FF", "\\Image\\save.png", "#1990FF", "保存");
|
||||
Btn_Close.SetUI("#E8F4FF", "#97D4FF", "\\Image\\语音关闭.png", "#1990FF", "关闭");
|
||||
Btn_See.SetUI("#E8F4FF", "#97D4FF", "\\Image\\see.png", "#1990FF", "查看JSON");
|
||||
|
||||
_ = cb.Items.Add("正常");
|
||||
_ = cb.Items.Add("作废");
|
||||
cb.SelectedIndex = 0;
|
||||
|
||||
if (isUpdate)
|
||||
{
|
||||
cb.SelectedIndex = opt.Status;
|
||||
txt_option.SetText(opt.OptionName);
|
||||
List<FlowModel> fl = SqlHelper.GetFlowModelInfo();
|
||||
fm = fl.Find(x => x.Id == opt.FlowId);
|
||||
vs = JsonConvert.DeserializeObject<List<string>>(opt.OptionJson);
|
||||
DataToUI();
|
||||
DataToGridViewHeader2();
|
||||
}
|
||||
else
|
||||
{
|
||||
DataToGridViewHeader();
|
||||
}
|
||||
if (isSee)
|
||||
{
|
||||
Btn_Save.IsEnabled = false;
|
||||
txt_option.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToUI()
|
||||
{
|
||||
gd_content.Children.Clear();
|
||||
gd_content.RowDefinitions.Clear();
|
||||
gd_content.ColumnDefinitions.Clear();
|
||||
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
List<DevInfo> devs = JsonConvert.DeserializeObject<List<DevInfo>>(vs[i]);
|
||||
devList.Add(devs);
|
||||
}
|
||||
}
|
||||
|
||||
List<FlowInfo> infos = null;
|
||||
|
||||
private DeviceInfoModel getBaoGui()
|
||||
{
|
||||
DeviceInfoModel dm = new DeviceInfoModel
|
||||
{
|
||||
Id = 0,
|
||||
DeviceName = "包硅反应",
|
||||
Dfms = new List<DeviceFieldsModel>()
|
||||
};
|
||||
DeviceFieldsModel dmf = new DeviceFieldsModel
|
||||
{
|
||||
FieldsName = "",
|
||||
FieldsContent = ""
|
||||
};
|
||||
dm.Dfms.Add(dmf);
|
||||
return dm;
|
||||
}
|
||||
|
||||
private void DataToGridViewHeader()
|
||||
{
|
||||
infos = JsonConvert.DeserializeObject<List<FlowInfo>>(fm.FlowJson);
|
||||
List<DeviceInfoModel> vs = SqlHelper.GetDeviceInfo();
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
vs[i].Dfms = JsonConvert.DeserializeObject<List<DeviceFieldsModel>>(vs[i].FieldJson);
|
||||
}
|
||||
List<DeviceInfoModel> vs2 = new List<DeviceInfoModel>();
|
||||
for (int i = 0; i < infos.Count; i++)
|
||||
{
|
||||
if (infos[i].tempTxt == "包硅反应")
|
||||
{
|
||||
DeviceInfoModel dm = getBaoGui();
|
||||
vs2.Add(dm);
|
||||
continue;
|
||||
}
|
||||
for (int k = 0; k < vs.Count; k++)
|
||||
{
|
||||
if (i < infos.Count - 1 && infos[i].DeviceId == vs[k].Id)
|
||||
{
|
||||
vs2.Add(vs[k]);
|
||||
break;
|
||||
}
|
||||
if (i == infos.Count - 1)
|
||||
{
|
||||
if (infos[i].DeviceId == vs[k].Id)
|
||||
{
|
||||
vs2.Add(vs[k]);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (i == infos.Count - 1)
|
||||
{
|
||||
for (int k = 0; k < vs.Count; k++)
|
||||
{
|
||||
if (infos[i].DeviceId2 == vs[k].Id)
|
||||
{
|
||||
vs2.Add(vs[k]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vs = vs2;
|
||||
int count = 0;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
count += vs[i].Dfms.Count;
|
||||
}
|
||||
count++;
|
||||
double widthMax = 1300;
|
||||
double width = widthMax / count;
|
||||
int Index = 0;
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "设备ID");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for (int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
Index++;
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
}
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell(gd_header, Index - vs[i].Dfms.Count + 1, vs[i].DeviceId, vs[i].Dfms.Count);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "设备");
|
||||
Index = 0;
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for (int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
Index++;
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
}
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell(gd_header, Index - vs[i].Dfms.Count + 1, vs[i].DeviceName, vs[i].Dfms.Count);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "标签");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
DeviceFieldsModel dfm = GetByIndex(vs, i);
|
||||
//添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell2(gd_header, i, dfm.FieldsName);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "配方模板");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
DeviceFieldsModel dfm = GetByIndex(vs, i);
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell2(gd_header, i, dfm.FieldsContent);
|
||||
}
|
||||
|
||||
for (int k = 0; k < 12; k++)
|
||||
{
|
||||
GridViewUnitls.AddRow(gd_content);
|
||||
GridViewUnitls.AddColumn2(gd_content, width);
|
||||
GridViewUnitls.AddCell2(gd_content, 0, k + 1 + "号瓶");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_content, width);
|
||||
DeviceFields dfm = GetByIndex2(vs, i);
|
||||
string FieldsContent = dfm.dfm.FieldsContent;
|
||||
// 如果是修改的话,就把里面的值取出来。对应显示
|
||||
if (isUpdate)
|
||||
{
|
||||
List<DevInfo> devs = devList[k];
|
||||
foreach (DevInfo dev in devs)
|
||||
{
|
||||
if (dev.Id == dfm.dim.Id)
|
||||
{
|
||||
foreach (DeviceFieldsModel dfml in dev.Dfms)
|
||||
{
|
||||
if (dfml.Id == dfm.dfm.Id)
|
||||
{
|
||||
FieldsContent = dfml.FieldsContent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCellTextBox(gd_content, i, FieldsContent, dfm, !isSee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToGridViewHeader2()
|
||||
{
|
||||
List<DeviceInfoModel> vs = SqlHelper.GetDeviceInfo();
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
vs[i].Dfms = JsonConvert.DeserializeObject<List<DeviceFieldsModel>>(vs[i].FieldJson);
|
||||
}
|
||||
List<DeviceInfoModel> vs2 = new List<DeviceInfoModel>();
|
||||
for (int i = 0; i < devList[0].Count; i++)
|
||||
{
|
||||
DevInfo dif = devList[0][i];
|
||||
if (dif.Id == 0)
|
||||
{
|
||||
DeviceInfoModel dm = getBaoGui();
|
||||
vs2.Add(dm);
|
||||
}
|
||||
else
|
||||
{
|
||||
DeviceInfoModel dm = vs.Find(x => x.Id == dif.Id);
|
||||
if (dm != null)
|
||||
{
|
||||
vs2.Add(dm);
|
||||
}
|
||||
}
|
||||
}
|
||||
vs = vs2;
|
||||
int count = 0;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
count += vs[i].Dfms.Count;
|
||||
}
|
||||
count++;
|
||||
double widthMax = 1300;
|
||||
double width = widthMax / count;
|
||||
int Index = 0;
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "设备ID");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for (int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
Index++;
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
}
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell(gd_header, Index - vs[i].Dfms.Count + 1, vs[i].DeviceId, vs[i].Dfms.Count);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "设备");
|
||||
Index = 0;
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for (int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
Index++;
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
}
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell(gd_header, Index - vs[i].Dfms.Count + 1, vs[i].DeviceName, vs[i].Dfms.Count);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "标签");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
DeviceFieldsModel dfm = GetByIndex(vs, i);
|
||||
//添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell2(gd_header, i, dfm.FieldsName);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "配方模板");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
DeviceFieldsModel dfm = GetByIndex(vs, i);
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell2(gd_header, i, dfm.FieldsContent);
|
||||
}
|
||||
|
||||
for (int k = 0; k < 12; k++)
|
||||
{
|
||||
GridViewUnitls.AddRow(gd_content);
|
||||
GridViewUnitls.AddColumn2(gd_content, width);
|
||||
GridViewUnitls.AddCell2(gd_content, 0, k + 1 + "号瓶");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_content, width);
|
||||
DeviceFields dfm = GetByIndex2(vs, i);
|
||||
string FieldsContent = dfm.dfm.FieldsContent;
|
||||
// 如果是修改的话,就把里面的值取出来。对应显示
|
||||
if (isUpdate)
|
||||
{
|
||||
List<DevInfo> devs = devList[k];
|
||||
foreach (DevInfo dev in devs)
|
||||
{
|
||||
//用下标。不能用设备ID。 设备是可以重复的。
|
||||
if (dev.Index == dfm.index)
|
||||
{
|
||||
foreach (DeviceFieldsModel dfml in dev.Dfms)
|
||||
{
|
||||
if (dfml.Id == dfm.dfm.Id)
|
||||
{
|
||||
FieldsContent = dfml.FieldsContent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCellTextBox(gd_content, i, FieldsContent, dfm, !isSee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DeviceFieldsModel GetByIndex(List<DeviceInfoModel> vs, int index)
|
||||
{
|
||||
int count = 0;
|
||||
for(int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for(int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
count++;
|
||||
if(count == index)
|
||||
{
|
||||
return vs[i].Dfms[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private DeviceFields GetByIndex2(List<DeviceInfoModel> vs, int index)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for (int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
count++;
|
||||
if (count == index)
|
||||
{
|
||||
DeviceFields df = new DeviceFields
|
||||
{
|
||||
dfm = vs[i].Dfms[k],
|
||||
dim = vs[i],
|
||||
index = i
|
||||
};
|
||||
return df;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
67
middleware/zdhsys/Popup/AddSubOption.xaml
Normal file
67
middleware/zdhsys/Popup/AddSubOption.xaml
Normal file
@@ -0,0 +1,67 @@
|
||||
<Window x:Class="zdhsys.Popup.AddSubOption"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOption" Height="600" Width="1000">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="1000" Height="600" Background="White">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" Grid.Column="0" Margin="10,0,0,0" Content="配方管理" FontSize="15" Foreground="#999999" VerticalAlignment="Center" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
<Label Grid.Row="0" Grid.Column="1" Content=">" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
<Label Grid.Row="0" Grid.Column="2" Content="创建子配方" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Margin="10,0,0,0" Content="配方名称" FontSize="15" Foreground="#000000" VerticalAlignment="Center"/>
|
||||
<Grid Grid.Row="1" Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
<ColumnDefinition Width="160"/>
|
||||
<ColumnDefinition Width="160"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevTextBox x:Name="txt_option" Width="250" HorizontalAlignment="Left"/>
|
||||
<local1:DevButton1 x:Name="Btn_Add" Grid.Column="1" Width="150" HorizontalAlignment="Left" Height="40"/>
|
||||
<local1:DevButton1 x:Name="Btn_Save" Grid.Column="2" Width="150" HorizontalAlignment="Left" Height="40"/>
|
||||
<local1:DevButton1 x:Name="Btn_Close" Grid.Column="3" Width="150" HorizontalAlignment="Left" Height="40"/>
|
||||
</Grid>
|
||||
<Label Grid.Row="2" Grid.Column="0" Margin="10,10,0,0" Content="选择内容" FontSize="15" Foreground="#000000" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Grid.Column="2" Margin="0,10,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="12*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="gd_header" Background="#F6F6F6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="标签" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="1" Content="对应于指定设备编号" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="2" Content="数值" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="3" Content="操作" Style="{StaticResource CustomLabelStyle}"/>
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<Grid x:Name="gd_content">
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
219
middleware/zdhsys/Popup/AddSubOption.xaml.cs
Normal file
219
middleware/zdhsys/Popup/AddSubOption.xaml.cs
Normal file
@@ -0,0 +1,219 @@
|
||||
using Newtonsoft.Json;
|
||||
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 zdhsys.Bean;
|
||||
using zdhsys.Control;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOption.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddSubOption : Window
|
||||
{
|
||||
public AddSubOption(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
|
||||
Btn_Add.Click += Btn_Add_Click;
|
||||
Btn_Close.Click += Btn_Close_Click;
|
||||
Btn_Save.Click += Btn_Save_Click;
|
||||
|
||||
}
|
||||
|
||||
public SubOptionModel som = null;
|
||||
public bool isUpdate = false;
|
||||
public bool flag_Save = false;
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
if (string.IsNullOrEmpty(txt_option.Text()))
|
||||
{
|
||||
info.SetUI("配方名称不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
if (vs.Count == 0)
|
||||
{
|
||||
info.SetUI("配方内容不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isUpdate)
|
||||
{
|
||||
som.SubOptionName = txt_option.Text();
|
||||
//som.Tags = JsonConvert.SerializeObject(vs);
|
||||
}
|
||||
else
|
||||
{
|
||||
som = new SubOptionModel
|
||||
{
|
||||
CreateTime = GlobalUnitils.GetNowTime(DateTime.Now),
|
||||
SubOptionName = txt_option.Text(),
|
||||
//Tags = JsonConvert.SerializeObject(vs)
|
||||
};
|
||||
}
|
||||
flag_Save = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
private List<OptionFieldsModel> vs = new List<OptionFieldsModel>();
|
||||
private void Btn_Add_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
AddOptionInfo info = new AddOptionInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
_ = info.ShowDialog();
|
||||
if (info.flag_Save)
|
||||
{
|
||||
vs.Add(info.ofm);
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToUI()
|
||||
{
|
||||
gd_content.Children.Clear();
|
||||
gd_content.RowDefinitions.Clear();
|
||||
gd_content.ColumnDefinitions.Clear();
|
||||
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
DataToGridView(vs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToGridView(OptionFieldsModel df)
|
||||
{
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_content);
|
||||
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < gd_header.ColumnDefinitions.Count; i++)
|
||||
{
|
||||
//当前行,添加1列 -- 列宽对应表头
|
||||
GridViewUnitls.AddColumn(gd_content, gd_header, i);
|
||||
|
||||
// 添加对应的控件到新的格子中
|
||||
if (i == 0)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.TagName);
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.DeviceId);
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.TagValue);
|
||||
}
|
||||
else if (i == 3)
|
||||
{
|
||||
DevOperation2 dev = new DevOperation2
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
obj = df//绑定对象。用于详情,修改,删除之类的。
|
||||
};
|
||||
dev.Click_Update += Dev_Click_Update;
|
||||
dev.Click_Delete += Dev_Click_Delete;
|
||||
Grid.SetRow(dev, gd_content.RowDefinitions.Count - 1);
|
||||
Grid.SetColumn(dev, i);
|
||||
gd_content.Children.Add(dev);
|
||||
}
|
||||
}
|
||||
//每行再加一个分割线
|
||||
GridViewUnitls.AddSpLine(gd_content, gd_header);
|
||||
}
|
||||
|
||||
private void Dev_Click_Delete(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevOperation2 dev = sender as DevOperation2;
|
||||
OptionFieldsModel df = dev.obj as OptionFieldsModel;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
if (vs[i].Id == df.Id)
|
||||
{
|
||||
vs.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DataToUI();
|
||||
}
|
||||
|
||||
private void Dev_Click_Update(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevOperation2 dev = sender as DevOperation2;
|
||||
OptionFieldsModel df = dev.obj as OptionFieldsModel;
|
||||
int index = -1;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
if (vs[i].Id == df.Id)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Point p = new Point(Left, Top);
|
||||
AddOptionInfo info = new AddOptionInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.isUpdate = true;
|
||||
info.ofm = vs[index];
|
||||
_ = info.ShowDialog();
|
||||
if (info.flag_Save)
|
||||
{
|
||||
vs[index] = info.ofm;
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
txt_option.SetUI("输入配方名称");
|
||||
|
||||
Btn_Add.SetUI("#E8F4FF", "#97D4FF", "\\Image\\add.png", "#1990FF", "增加");
|
||||
Btn_Save.SetUI("#E8F4FF", "#97D4FF", "\\Image\\save.png", "#1990FF", "保存");
|
||||
Btn_Close.SetUI("#E8F4FF", "#97D4FF", "\\Image\\语音关闭.png", "#1990FF", "关闭");
|
||||
|
||||
if (isUpdate)
|
||||
{
|
||||
txt_option.SetText(som.SubOptionName);
|
||||
//vs = JsonConvert.DeserializeObject<List<OptionFieldsModel>>(som.Tags);
|
||||
DataToUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
middleware/zdhsys/Popup/AddSubOptionInfo.xaml
Normal file
56
middleware/zdhsys/Popup/AddSubOptionInfo.xaml
Normal file
@@ -0,0 +1,56 @@
|
||||
<Window x:Class="zdhsys.Popup.AddSubOptionInfo"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOptionInfo" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="200" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="添加内容" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="子配方" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="cb" Grid.Column="1" Margin="10,0,0,0" Height="30" Width="250" VerticalContentAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.7*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1.3*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Margin="15,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Close1" Click="Btn_Close_Click" Grid.Column="3" Margin="15,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
79
middleware/zdhsys/Popup/AddSubOptionInfo.xaml.cs
Normal file
79
middleware/zdhsys/Popup/AddSubOptionInfo.xaml.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using zdhsys.Bean;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOptionInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddSubOptionInfo : Window
|
||||
{
|
||||
public AddSubOptionInfo(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private List<SubOptionModel> dim = null;
|
||||
public OptionFieldsModel2 ofm = null;
|
||||
public bool isUpdate = false;
|
||||
public bool flag_Save = false;
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "载入");
|
||||
Btn_Close1.SetUI("#FFFFFF", "#0066FF", "#0066FF", "取消");
|
||||
|
||||
dim = SqlHelper.GetSubOptionModel();
|
||||
if (dim == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (dim.Count == 0)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.SetUI("请先添加子配方");
|
||||
_ = info.ShowDialog();
|
||||
Close();
|
||||
}
|
||||
int index = 0;
|
||||
for (int i = 0; i < dim.Count; i++)
|
||||
{
|
||||
cb.Items.Add(dim[i].SubOptionName);
|
||||
if (ofm != null && ofm.Id == dim[i].Id)
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
cb.SelectedIndex = index;
|
||||
}
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isUpdate)
|
||||
{
|
||||
ofm = new OptionFieldsModel2();
|
||||
}
|
||||
ofm.Id = dim[cb.SelectedIndex].Id;
|
||||
ofm.TagName = dim[cb.SelectedIndex].SubOptionName;
|
||||
ofm.IsSub = true;
|
||||
ofm.SubId = dim[cb.SelectedIndex].Id;
|
||||
flag_Save = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
55
middleware/zdhsys/Popup/AddSubOptionNew.xaml
Normal file
55
middleware/zdhsys/Popup/AddSubOptionNew.xaml
Normal file
@@ -0,0 +1,55 @@
|
||||
<Window x:Class="zdhsys.Popup.AddSubOptionNew"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOption" Height="750" Width="1300">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="1300" Height="750" Background="White">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="160"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" Grid.Column="0" Margin="10,0,0,0" Content="配方管理" FontSize="15" Foreground="#999999" VerticalAlignment="Center" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
<Label Grid.Row="0" Grid.Column="1" Content=">" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
<Label Grid.Row="0" Grid.Column="2" Content="创建配方" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Margin="10,0,0,0" Content="配方名称" FontSize="15" Foreground="#000000" VerticalAlignment="Center"/>
|
||||
<Grid Grid.Row="1" Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="210"/>
|
||||
<ColumnDefinition Width="40"/>
|
||||
<ColumnDefinition Width="90"/>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevTextBox x:Name="txt_option" Width="200" HorizontalAlignment="Left"/>
|
||||
<Label Grid.Column="1" Content="状态" FontSize="15" Foreground="#000000" HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||
<ComboBox x:Name="cb" Grid.Column="2" VerticalContentAlignment="Center" Height="30" Width="80" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
<local1:DevButton1 x:Name="Btn_Save" Grid.Column="5" Width="130" HorizontalAlignment="Left" Height="40"/>
|
||||
<local1:DevButton1 x:Name="Btn_Close" Grid.Column="6" Width="130" HorizontalAlignment="Left" Height="40"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="2" Grid.ColumnSpan="3" Background="#F6F6F6">
|
||||
<Grid x:Name="gd_header"></Grid>
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Row="3" Grid.ColumnSpan="3">
|
||||
<Grid x:Name="gd_content"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
330
middleware/zdhsys/Popup/AddSubOptionNew.xaml.cs
Normal file
330
middleware/zdhsys/Popup/AddSubOptionNew.xaml.cs
Normal file
@@ -0,0 +1,330 @@
|
||||
using Newtonsoft.Json;
|
||||
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 zdhsys.Bean;
|
||||
using zdhsys.Control;
|
||||
using zdhsys.entity;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOption.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddSubOptionNew : Window
|
||||
{
|
||||
public AddSubOptionNew(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
|
||||
Btn_Close.Click += Btn_Close_Click;
|
||||
Btn_Save.Click += Btn_Save_Click;
|
||||
}
|
||||
|
||||
private List<string> vs = new List<string>();
|
||||
public bool isUpdate = false;
|
||||
public bool isSee = false;
|
||||
public bool flag_Save = false;
|
||||
public SubOptionModel opt = null;
|
||||
private List<List<DevInfo>> devList = new List<List<DevInfo>>();
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
//做一些过滤
|
||||
if (string.IsNullOrEmpty(txt_option.Text()))
|
||||
{
|
||||
info.SetUI("配方名称不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
string json = Log();
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
info.SetUI("配方内容不能为空");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isUpdate)
|
||||
{
|
||||
opt = new SubOptionModel
|
||||
{
|
||||
CreateTime = GlobalUnitils.GetNowTime(DateTime.Now)
|
||||
};
|
||||
}
|
||||
opt.OptionJson = json;
|
||||
opt.SubOptionName = txt_option.Text();
|
||||
opt.Status = cb.SelectedIndex;
|
||||
flag_Save = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private string Log()
|
||||
{
|
||||
List<string> vsStr = new List<string>();
|
||||
// 遍历 Grid 中的每一行
|
||||
for (int row = 0; row < gd_content.RowDefinitions.Count; row++)
|
||||
{
|
||||
List<DevInfo> vs = new List<DevInfo>();
|
||||
// 遍历 Grid 中的每一列
|
||||
for (int column = 0; column < gd_content.ColumnDefinitions.Count; column++)
|
||||
{
|
||||
// 获取当前行和列上的子元素
|
||||
UIElement element = gd_content.Children
|
||||
.Cast<UIElement>()
|
||||
.FirstOrDefault(e => Grid.GetRow(e) == row && Grid.GetColumn(e) == column);
|
||||
|
||||
// 检查子元素是否是 TextBox,并获取其值
|
||||
if (element is TextBox textBox)
|
||||
{
|
||||
string text = textBox.Text;
|
||||
DeviceFields dfs = textBox.Tag as DeviceFields;
|
||||
//Console.WriteLine(dfs.dim.DeviceName + " " + dfs.dfm.FieldsName + ":" + text);
|
||||
//这里要合并同一个设备的各各字段
|
||||
int index = vs.FindIndex(x => x.Id == dfs.dim.Id);
|
||||
//如果已经存在,就修改对应的字段属性就好了。
|
||||
if (index >= 0)
|
||||
{
|
||||
DevInfo dd = vs[index];
|
||||
int index2 = dd.Dfms.FindIndex(x => x.FieldsName == dfs.dfm.FieldsName);
|
||||
dd.Dfms[index2].FieldsContent = text;
|
||||
//Console.WriteLine("修改: "+ dd.DeviceName + " name="+dd.Dfms[index2].FieldsName + ":"+dd.Dfms[index2].FieldsContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
//DeviceInfoModel dim = dfs.dim;
|
||||
DevInfo dim = new DevInfo
|
||||
{
|
||||
Id = dfs.dim.Id,
|
||||
Dfms = dfs.dim.Dfms
|
||||
};
|
||||
int index2 = dim.Dfms.FindIndex(x => x.FieldsName == dfs.dfm.FieldsName);
|
||||
DeviceFieldsModel dfm = dim.Dfms[index2];
|
||||
dfm.FieldsContent = text;
|
||||
dim.Dfms[index2] = dfm;
|
||||
vs.Add(dim);
|
||||
//Console.WriteLine("新增: " + dim.DeviceName + " name=" + dim.Dfms[index2].FieldsName + ":" + dim.Dfms[index2].FieldsContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(vs);
|
||||
vsStr.Add(json);
|
||||
}
|
||||
string json2 = JsonConvert.SerializeObject(vsStr);
|
||||
Console.WriteLine(json2);
|
||||
return json2;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
txt_option.SetUI("输入配方名称");
|
||||
Btn_Save.SetUI("#E8F4FF", "#97D4FF", "\\Image\\save.png", "#1990FF", "保存");
|
||||
Btn_Close.SetUI("#E8F4FF", "#97D4FF", "\\Image\\语音关闭.png", "#1990FF", "关闭");
|
||||
|
||||
cb.Items.Add("正常");
|
||||
cb.Items.Add("作废");
|
||||
cb.SelectedIndex = 0;
|
||||
|
||||
if (isUpdate)
|
||||
{
|
||||
cb.SelectedIndex = opt.Status;
|
||||
txt_option.SetText(opt.SubOptionName);
|
||||
vs = JsonConvert.DeserializeObject<List<string>>(opt.OptionJson);
|
||||
DataToUI();
|
||||
}
|
||||
DataToGridViewHeader();
|
||||
if (isSee)
|
||||
{
|
||||
Btn_Save.IsEnabled = false;
|
||||
txt_option.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToUI()
|
||||
{
|
||||
gd_content.Children.Clear();
|
||||
gd_content.RowDefinitions.Clear();
|
||||
gd_content.ColumnDefinitions.Clear();
|
||||
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
List<DevInfo> devs = JsonConvert.DeserializeObject<List<DevInfo>>(vs[i]);
|
||||
devList.Add(devs);
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToGridViewHeader()
|
||||
{
|
||||
List<DeviceInfoModel> vs = SqlHelper.GetDeviceInfo();
|
||||
int count = 0;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
vs[i].Dfms = JsonConvert.DeserializeObject<List<DeviceFieldsModel>>(vs[i].FieldJson);
|
||||
count += vs[i].Dfms.Count;
|
||||
}
|
||||
count++;
|
||||
double widthMax = 1300;
|
||||
double width = widthMax / count;
|
||||
int Index = 0;
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "设备ID");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for (int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
Index++;
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
}
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell(gd_header, Index - vs[i].Dfms.Count + 1, vs[i].DeviceId, vs[i].Dfms.Count);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "设备");
|
||||
Index = 0;
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for (int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
Index++;
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
}
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell(gd_header, Index - vs[i].Dfms.Count + 1, vs[i].DeviceName, vs[i].Dfms.Count);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "标签");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
DeviceFieldsModel dfm = GetByIndex(vs, i);
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell2(gd_header, i, dfm.FieldsName);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "配方模板");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
DeviceFieldsModel dfm = GetByIndex(vs, i);
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell2(gd_header, i, dfm.FieldsContent);
|
||||
}
|
||||
|
||||
//大瓶子
|
||||
GridViewUnitls.AddRow(gd_content);
|
||||
GridViewUnitls.AddColumn2(gd_content, width);
|
||||
GridViewUnitls.AddCell2(gd_content, 0, "大瓶");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_content, width);
|
||||
DeviceFields dfm = GetByIndex2(vs, i);
|
||||
string FieldsContent = dfm.dfm.FieldsContent;
|
||||
// 如果是修改的话,就把里面的值取出来。对应显示
|
||||
if (isUpdate)
|
||||
{
|
||||
List<DevInfo> devs = devList[0];
|
||||
foreach (DevInfo dev in devs)
|
||||
{
|
||||
if (dev.Id == dfm.dim.Id)
|
||||
{
|
||||
foreach (DeviceFieldsModel dfml in dev.Dfms)
|
||||
{
|
||||
if (dfml.Id == dfm.dfm.Id)
|
||||
{
|
||||
FieldsContent = dfml.FieldsContent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCellTextBox(gd_content, i, FieldsContent, dfm, !isSee);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private DeviceFieldsModel GetByIndex(List<DeviceInfoModel> vs, int index)
|
||||
{
|
||||
int count = 0;
|
||||
for(int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for(int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
count++;
|
||||
if(count == index)
|
||||
{
|
||||
return vs[i].Dfms[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private DeviceFields GetByIndex2(List<DeviceInfoModel> vs, int index)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for (int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
count++;
|
||||
if (count == index)
|
||||
{
|
||||
DeviceFields df = new DeviceFields
|
||||
{
|
||||
dfm = vs[i].Dfms[k],
|
||||
dim = vs[i]
|
||||
};
|
||||
return df;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
54
middleware/zdhsys/Popup/DeleteInfo.xaml
Normal file
54
middleware/zdhsys/Popup/DeleteInfo.xaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<Window x:Class="zdhsys.Popup.DeleteInfo"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOptionInfo" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="200" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="删除" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="15"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
<ColumnDefinition Width="15"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label x:Name="lb" Grid.Column="1" Content="标签" VerticalAlignment="Center" Style="{StaticResource CommonStyleNomal}" FontWeight="Bold"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.5*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Margin="10,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Close1" Click="Btn_Close_Click" Grid.Column="2" Margin="10,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
46
middleware/zdhsys/Popup/DeleteInfo.xaml.cs
Normal file
46
middleware/zdhsys/Popup/DeleteInfo.xaml.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOptionInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DeleteInfo : Window
|
||||
{
|
||||
public DeleteInfo(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
InitUI();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
private void InitUI()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public void SetUI(string str)
|
||||
{
|
||||
lb.Content = "是否删除当前" + str + "?";
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "确定");
|
||||
Btn_Close1.SetUI("#FFFFFF", "#0066FF", "#0066FF", "取消");
|
||||
}
|
||||
|
||||
public bool flagDelete = false;
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
flagDelete = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
72
middleware/zdhsys/Popup/EditFlowButton.xaml
Normal file
72
middleware/zdhsys/Popup/EditFlowButton.xaml
Normal file
@@ -0,0 +1,72 @@
|
||||
<Window x:Class="zdhsys.Popup.EditFlowButton"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="EditFlowButton" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="300" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="编辑/删除" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label FontSize="15" VerticalAlignment="Center" Content="背景色" FontWeight="Bold" Margin="20,0,20,0" />
|
||||
<local1:ColorButton x:Name="cb1" Width="20" Height="20" Margin="5" />
|
||||
<local1:ColorButton x:Name="cb2" Width="20" Height="20" Margin="5" />
|
||||
<local1:ColorButton x:Name="cb3" Width="20" Height="20" Margin="5" />
|
||||
<local1:ColorButton x:Name="cb4" Width="20" Height="20" Margin="5" />
|
||||
<local1:ColorButton x:Name="cb5" Width="20" Height="20" Margin="5" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||
<Label FontSize="15" VerticalAlignment="Center" Content="字体颜色" FontWeight="Bold" Margin="20,0,20,0" />
|
||||
<local1:ColorButton x:Name="cb6" Width="20" Height="20" Margin="5" />
|
||||
<Border BorderThickness="1" BorderBrush="Blue" Width="20" Height="20" Margin="5">
|
||||
<local1:ColorButton x:Name="cb7" Width="19" Height="19"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal">
|
||||
<Label FontSize="15" VerticalAlignment="Center" Content="操作指令" FontWeight="Bold" Margin="20,0,20,0" />
|
||||
<ComboBox x:Name="cbb_cmd" Grid.Column="5" Margin="0,0,0,0" Height="30" Width="60" VerticalContentAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
</StackPanel>
|
||||
<local1:FlowButton2 x:Name="btnFlow" Grid.Row="3" Width="120" Height="80"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="120"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Width="120" Margin="10,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Del" Click="Btn_Del_Click" Width="100" Margin="10,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
206
middleware/zdhsys/Popup/EditFlowButton.xaml.cs
Normal file
206
middleware/zdhsys/Popup/EditFlowButton.xaml.cs
Normal file
@@ -0,0 +1,206 @@
|
||||
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 zdhsys.Control;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// EditFlowButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class EditFlowButton : Window
|
||||
{
|
||||
public EditFlowButton(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
DataToUI();
|
||||
}
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
isSave = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public List<string> hexColor = new List<string>();
|
||||
|
||||
private void DataToUI()
|
||||
{
|
||||
hexColor.Add("#944FFD");
|
||||
hexColor.Add("#FFBF16");
|
||||
hexColor.Add("#FF7089");
|
||||
hexColor.Add("#327FFE");
|
||||
hexColor.Add("#24282E");//黑
|
||||
hexColor.Add("#FFFFFF");//白
|
||||
|
||||
_ = cbb_cmd.Items.Add("抓");
|
||||
_ = cbb_cmd.Items.Add("接");
|
||||
_ = cbb_cmd.Items.Add("放");
|
||||
_ = cbb_cmd.Items.Add("放+抓");
|
||||
cbb_cmd.SelectedIndex = 0;
|
||||
|
||||
btnFlow.SetUI(hexColor[0], hexColor[0], hexColor[5], "设备名称");
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "确定");
|
||||
Btn_Del.SetUI("#FFFFFF", "#0066FF", "#0066FF", "删除节点");
|
||||
|
||||
cb1.SetUI(hexColor[0]);
|
||||
cb2.SetUI(hexColor[1]);
|
||||
cb3.SetUI(hexColor[2]);
|
||||
cb4.SetUI(hexColor[3]);
|
||||
cb5.SetUI(hexColor[4]);
|
||||
|
||||
cb6.SetUI(hexColor[4]);
|
||||
cb7.SetUI(hexColor[5]);
|
||||
|
||||
cb1.Click += Cb_Click;
|
||||
cb2.Click += Cb_Click;
|
||||
cb3.Click += Cb_Click;
|
||||
cb4.Click += Cb_Click;
|
||||
cb5.Click += Cb_Click;
|
||||
|
||||
cb6.Click += Cb6_Click;
|
||||
cb7.Click += Cb6_Click;
|
||||
|
||||
}
|
||||
|
||||
public bool isSave = false;
|
||||
public bool isDel = false;
|
||||
public int backIndex = 0;
|
||||
public int foreIndex = 5;
|
||||
|
||||
private void Cb6_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
cb6.SetIsCheck(false);
|
||||
cb7.SetIsCheck(false);
|
||||
ColorButton cb = sender as ColorButton;
|
||||
cb.SetIsCheck(true);
|
||||
|
||||
if (cb.Name == "cb6")
|
||||
{
|
||||
btnFlow.SetForeColor(hexColor[4]);
|
||||
foreIndex = 4;
|
||||
}
|
||||
else if (cb.Name == "cb7")
|
||||
{
|
||||
btnFlow.SetForeColor(hexColor[5]);
|
||||
foreIndex = 5;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetUI(string hex1, string hex2, int index, string txt)
|
||||
{
|
||||
for (int i = 0; i < hexColor.Count; i++)
|
||||
{
|
||||
if (hexColor[i] == hex1)
|
||||
{
|
||||
backIndex = i;
|
||||
btnFlow.SetBackColor(hexColor[i]);
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
cb1.SetIsCheck(true);
|
||||
break;
|
||||
case 1:
|
||||
cb2.SetIsCheck(true);
|
||||
break;
|
||||
case 2:
|
||||
cb3.SetIsCheck(true);
|
||||
break;
|
||||
case 3:
|
||||
cb4.SetIsCheck(true);
|
||||
break;
|
||||
case 4:
|
||||
cb5.SetIsCheck(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hexColor[i] == hex2)
|
||||
{
|
||||
btnFlow.SetForeColor(hexColor[i]);
|
||||
foreIndex = i;
|
||||
if (i == 4)
|
||||
{
|
||||
cb6.SetIsCheck(true);
|
||||
}
|
||||
else if(i == 5)
|
||||
{
|
||||
cb7.SetIsCheck(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
cbb_cmd.SelectedIndex = index;
|
||||
btnFlow.SetText(txt);
|
||||
}
|
||||
|
||||
private void Cb_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
cb1.SetIsCheck(false);
|
||||
cb2.SetIsCheck(false);
|
||||
cb3.SetIsCheck(false);
|
||||
cb4.SetIsCheck(false);
|
||||
cb5.SetIsCheck(false);
|
||||
ColorButton cb = sender as ColorButton;
|
||||
cb.SetIsCheck(true);
|
||||
|
||||
switch (cb.Name)
|
||||
{
|
||||
case "cb1":
|
||||
btnFlow.SetBackColor(hexColor[0]);
|
||||
backIndex = 0;
|
||||
break;
|
||||
case "cb2":
|
||||
btnFlow.SetBackColor(hexColor[1]);
|
||||
backIndex = 1;
|
||||
break;
|
||||
case "cb3":
|
||||
btnFlow.SetBackColor(hexColor[2]);
|
||||
backIndex = 2;
|
||||
break;
|
||||
case "cb4":
|
||||
btnFlow.SetBackColor(hexColor[3]);
|
||||
backIndex = 3;
|
||||
break;
|
||||
case "cb5":
|
||||
btnFlow.SetBackColor(hexColor[4]);
|
||||
backIndex = 4;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void Btn_Del_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
isDel = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
public int getCmd()
|
||||
{
|
||||
return cbb_cmd.SelectedIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
middleware/zdhsys/Popup/HomeDeviceInfo.xaml
Normal file
43
middleware/zdhsys/Popup/HomeDeviceInfo.xaml
Normal file
@@ -0,0 +1,43 @@
|
||||
<Window x:Class="zdhsys.Popup.HomeDeviceInfo"
|
||||
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:zdhsys.Popup"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="White"
|
||||
MouseLeftButtonDown="Window_MouseLeftButtonDown"
|
||||
Title="HomeDeviceInfo" Height="200" Width="250">
|
||||
<Grid >
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="设备数据:" Margin="10,10,0,0" Style="{StaticResource CommonStyleBold}"/>
|
||||
<Border Grid.Row="1" Margin="8" CornerRadius="5" Background="#F8F8F8">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="90"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Row="0" Content="当前设备:" Style="{StaticResource CommonStyleRight}"/>
|
||||
<Label Grid.Row="1" Content="设备状态:" Style="{StaticResource CommonStyleRight}"/>
|
||||
<Label Grid.Row="2" Content="设备数据:" Style="{StaticResource CommonStyleRight}"/>
|
||||
<Label Grid.Row="3" Content="执行指令:" Style="{StaticResource CommonStyleRight}"/>
|
||||
|
||||
<Label x:Name="lbName" Grid.Column="1" Grid.Row="0" Content="机械臂" Style="{StaticResource CommonStyleLeft}" Foreground="#FF0000"/>
|
||||
<Label x:Name="lbStatus" Grid.Column="1" Grid.Row="1" Content="故障" Style="{StaticResource CommonStyleLeft}" Foreground="#FF0000" />
|
||||
<Label x:Name="lbLocation" Grid.Column="1" Grid.Row="2" Content="位置(01)" Style="{StaticResource CommonStyleLeft}" />
|
||||
<Label x:Name="lbCmd" Grid.Column="1" Grid.Row="3" Content="转到位置01处" Style="{StaticResource CommonStyleLeft}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
42
middleware/zdhsys/Popup/HomeDeviceInfo.xaml.cs
Normal file
42
middleware/zdhsys/Popup/HomeDeviceInfo.xaml.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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 zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// HomeDeviceInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class HomeDeviceInfo : Window
|
||||
{
|
||||
public HomeDeviceInfo(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y - Height;
|
||||
}
|
||||
|
||||
public void SetUI(string name,string status,string location,string cmd)
|
||||
{
|
||||
lbCmd.Content = cmd;
|
||||
lbLocation.Content = location;
|
||||
lbName.Content = name;
|
||||
lbStatus.Content = status;
|
||||
}
|
||||
|
||||
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
54
middleware/zdhsys/Popup/MessageInfo.xaml
Normal file
54
middleware/zdhsys/Popup/MessageInfo.xaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<Window x:Class="zdhsys.Popup.MessageInfo"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
MouseLeftButtonDown="Window_MouseLeftButtonDown"
|
||||
Title="AddOptionInfo" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="200" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="系统提示" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="15"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
<ColumnDefinition Width="15"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label x:Name="lb" Grid.Column="1" Content="标签" VerticalAlignment="Center" Style="{StaticResource CommonStyleNomal}" FontWeight="Bold"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="2" Margin="10,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
42
middleware/zdhsys/Popup/MessageInfo.xaml.cs
Normal file
42
middleware/zdhsys/Popup/MessageInfo.xaml.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOptionInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MessageInfo : Window
|
||||
{
|
||||
public MessageInfo(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public void SetUI(string str)
|
||||
{
|
||||
lb.Content = str;
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "确定");
|
||||
}
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Window_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
54
middleware/zdhsys/Popup/MessageInfo2.xaml
Normal file
54
middleware/zdhsys/Popup/MessageInfo2.xaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<Window x:Class="zdhsys.Popup.MessageInfo2"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
MouseLeftButtonDown="Window_MouseLeftButtonDown"
|
||||
Title="AddOptionInfo" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="200" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="配方模板字符串" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="15"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
<ColumnDefinition Width="15"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="lb" TextWrapping="Wrap" AcceptsReturn="True" MinLines="1" MaxLines="5" BorderThickness="0" Background="Transparent" IsReadOnly="True" Grid.Column="1" Text="标签" VerticalAlignment="Center" Style="{StaticResource CommonStyleNomal}"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="2" Margin="10,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
42
middleware/zdhsys/Popup/MessageInfo2.xaml.cs
Normal file
42
middleware/zdhsys/Popup/MessageInfo2.xaml.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOptionInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MessageInfo2 : Window
|
||||
{
|
||||
public MessageInfo2(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public void SetUI(string str)
|
||||
{
|
||||
lb.Text = str;
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "确定");
|
||||
}
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Window_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
//Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
54
middleware/zdhsys/Popup/MessageInfo3.xaml
Normal file
54
middleware/zdhsys/Popup/MessageInfo3.xaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<Window x:Class="zdhsys.Popup.MessageInfo3"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOptionInfo" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="200" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="系统提示" FontWeight="Bold" />
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="15"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
<ColumnDefinition Width="15"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label x:Name="lb" Grid.Column="1" Content="标签" VerticalAlignment="Center" Style="{StaticResource CommonStyleNomal}" FontWeight="Bold"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Margin="10,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Over" Click="Btn_Over_Click" Grid.Column="3" Margin="10,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
41
middleware/zdhsys/Popup/MessageInfo3.xaml.cs
Normal file
41
middleware/zdhsys/Popup/MessageInfo3.xaml.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOptionInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MessageInfo3 : Window
|
||||
{
|
||||
public MessageInfo3(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
public void SetUI(string str)
|
||||
{
|
||||
lb.Content = str;
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "继续执行");
|
||||
Btn_Over.SetUI("#0066FF", "#0066FF", "#FFFFFF", "结束执行");
|
||||
}
|
||||
|
||||
public bool flag = false;
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
flag = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Btn_Over_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
64
middleware/zdhsys/Popup/OptionDetails.xaml
Normal file
64
middleware/zdhsys/Popup/OptionDetails.xaml
Normal file
@@ -0,0 +1,64 @@
|
||||
<Window x:Class="zdhsys.Popup.OptionDetails"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
MouseLeftButtonDown="Window_MouseLeftButtonDown"
|
||||
Title="AddOption" Height="600" Width="1000">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="1000" Height="600" Background="White">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" Grid.Column="0" Margin="10,0,0,0" Content="配方管理" FontSize="15" Foreground="#999999" VerticalAlignment="Center" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
<Label Grid.Row="0" Grid.Column="1" Content=">" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
<Grid Grid.Row="0" Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="配方详情" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
<local1:ImageButton x:Name="imgClose" Grid.Column="1" VerticalAlignment="Center" Width="40" Height="40" HorizontalAlignment="Right" Margin="0,0,20,0"/>
|
||||
</Grid>
|
||||
<Label Grid.Row="1" Grid.Column="0" Margin="10,0,0,0" Content="配方名称" FontSize="15" Foreground="#000000" VerticalAlignment="Center"/>
|
||||
<Label x:Name="lb_Name" Grid.Row="1" Grid.Column="2" Content="状态" FontSize="15" Foreground="#000000" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<Label Grid.Row="2" Grid.Column="0" Margin="10,10,0,0" Content="选择内容" FontSize="15" Foreground="#000000" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Grid.Column="2" Margin="0,10,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="12*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="gd_header" Background="#F6F6F6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="标签" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="1" Content="对应于指定设备编号" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="2" Content="数值" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="3" Content="是否子配方" Style="{StaticResource CustomLabelStyle}"/>
|
||||
<Label Grid.Column="4" Content="子配方名称" Style="{StaticResource CustomLabelStyle}"/>
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<Grid x:Name="gd_content"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
128
middleware/zdhsys/Popup/OptionDetails.xaml.cs
Normal file
128
middleware/zdhsys/Popup/OptionDetails.xaml.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using Newtonsoft.Json;
|
||||
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 zdhsys.Bean;
|
||||
using zdhsys.Control;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOption.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class OptionDetails : Window
|
||||
{
|
||||
public OptionDetails(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
imgClose.Click += ImgClose_Click;
|
||||
}
|
||||
|
||||
private void ImgClose_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private List<OptionFieldsModel2> vs = new List<OptionFieldsModel2>();
|
||||
public Options opt = null;
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
imgClose.SetUI("\\Image\\语音关闭.png");
|
||||
lb_Name.Content = opt.OptionName;
|
||||
vs = JsonConvert.DeserializeObject<List<OptionFieldsModel2>>(opt.OptionJson);
|
||||
DataToUI();
|
||||
}
|
||||
|
||||
private void DataToUI()
|
||||
{
|
||||
gd_content.Children.Clear();
|
||||
gd_content.RowDefinitions.Clear();
|
||||
gd_content.ColumnDefinitions.Clear();
|
||||
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
if (vs[i].IsSub)
|
||||
{
|
||||
List<SubOptionModel> som = SqlHelper.GetSubOptionModelById(vs[i].SubId);
|
||||
if (som != null && som.Count > 0)
|
||||
{
|
||||
//List<OptionFieldsModel> ofm = JsonConvert.DeserializeObject<List<OptionFieldsModel>>(som[0].Tags);
|
||||
//for (int k = 0; k < ofm.Count; k++)
|
||||
//{
|
||||
// OptionFieldsModel2 df = new OptionFieldsModel2
|
||||
// {
|
||||
// DeviceId = ofm[k].DeviceId,
|
||||
// Id = ofm[k].Id,
|
||||
// TagName = ofm[k].TagName,
|
||||
// TagValue = ofm[k].TagValue,
|
||||
// IsSub = true,
|
||||
// SubId = ofm[k].Id
|
||||
// };
|
||||
// DataToGridView(df, som[0].SubOptionName);
|
||||
//}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DataToGridView(vs[i], "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DataToGridView(OptionFieldsModel2 df, string subName)
|
||||
{
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_content);
|
||||
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < gd_header.ColumnDefinitions.Count; i++)
|
||||
{
|
||||
//当前行,添加1列 -- 列宽对应表头
|
||||
GridViewUnitls.AddColumn(gd_content, gd_header, i);
|
||||
|
||||
// 添加对应的控件到新的格子中
|
||||
if (i == 0)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.TagName);
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.DeviceId);
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.TagValue);
|
||||
}
|
||||
else if (i == 3)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, df.IsSub ? "是" : "否", df.IsSub ? GridViewUnitls.ColorHexNormal : GridViewUnitls.ColorHexBreak);
|
||||
}
|
||||
else if (i == 4)
|
||||
{
|
||||
GridViewUnitls.AddCell(gd_content, i, subName);
|
||||
}
|
||||
}
|
||||
//每行再加一个分割线
|
||||
GridViewUnitls.AddSpLine(gd_content, gd_header);
|
||||
}
|
||||
|
||||
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
52
middleware/zdhsys/Popup/OptionNewModel.xaml
Normal file
52
middleware/zdhsys/Popup/OptionNewModel.xaml
Normal file
@@ -0,0 +1,52 @@
|
||||
<Window x:Class="zdhsys.Popup.OptionNewModel"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOption" Height="750" Width="1300">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="1300" Height="750" Background="White">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="10*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="160"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" Grid.Column="0" Margin="10,0,0,0" Content="配方管理" FontSize="15" Foreground="#999999" VerticalAlignment="Center" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
<Label Grid.Row="0" Grid.Column="1" Content=">" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
<Label Grid.Row="0" Grid.Column="2" Content="配方模板" FontSize="15" Foreground="#999999" VerticalAlignment="Center"/>
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="210"/>
|
||||
<ColumnDefinition Width="40"/>
|
||||
<ColumnDefinition Width="90"/>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton x:Name="Btn_See" Grid.Column="4" Width="130" HorizontalAlignment="Left" Height="40"/>
|
||||
<local1:DevButton1 x:Name="Btn_Save" Grid.Column="5" Width="130" HorizontalAlignment="Left" Height="40"/>
|
||||
<local1:DevButton1 x:Name="Btn_Close" Grid.Column="6" Width="130" HorizontalAlignment="Left" Height="40"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="2" Grid.ColumnSpan="3" Background="#F6F6F6">
|
||||
<Grid x:Name="gd_header"></Grid>
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Row="3" Grid.ColumnSpan="3">
|
||||
<Grid x:Name="gd_content"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
340
middleware/zdhsys/Popup/OptionNewModel.xaml.cs
Normal file
340
middleware/zdhsys/Popup/OptionNewModel.xaml.cs
Normal file
@@ -0,0 +1,340 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using zdhsys.Bean;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOption.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class OptionNewModel : Window
|
||||
{
|
||||
public OptionNewModel(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
|
||||
Btn_Close.Click += Btn_Close_Click;
|
||||
Btn_Save.Click += Btn_Save_Click;
|
||||
Btn_See.Click += Btn_See_Click;
|
||||
}
|
||||
|
||||
public string jsonOption = "";
|
||||
public bool isUpdate = false;
|
||||
|
||||
private void Btn_See_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string ret = Log();
|
||||
Point p = new Point(Left, Top);
|
||||
if (SqlHelper.CountDeviceGroupInfo() == 0)
|
||||
{
|
||||
MessageInfo2 msg = new MessageInfo2(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
msg.SetUI(ret);
|
||||
_ = msg.ShowDialog();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public SubOptionModel opt = null;
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
UpdateDevice();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void UpdateDevice()
|
||||
{
|
||||
List<DeviceFields> df = new List<DeviceFields>();
|
||||
// 遍历 Grid 中的每一行
|
||||
for (int row = 0; row < gd_content.RowDefinitions.Count; row++)
|
||||
{
|
||||
// 遍历 Grid 中的每一列
|
||||
for (int column = 0; column < gd_content.ColumnDefinitions.Count; column++)
|
||||
{
|
||||
// 获取当前行和列上的子元素
|
||||
UIElement element = gd_content.Children
|
||||
.Cast<UIElement>()
|
||||
.FirstOrDefault(e => Grid.GetRow(e) == row && Grid.GetColumn(e) == column);
|
||||
|
||||
// 检查子元素是否是 TextBox,并获取其值
|
||||
if (element is TextBox textBox)
|
||||
{
|
||||
string text = textBox.Text;
|
||||
DeviceFields dfs = textBox.Tag as DeviceFields;
|
||||
Console.WriteLine(dfs.dim.DeviceName + " " + dfs.dfm.FieldsName + ":" + text);
|
||||
|
||||
int index1 = df.FindIndex(x => x.dim.Id == dfs.dim.Id);
|
||||
if (index1 >= 0)
|
||||
{
|
||||
int index2 = df[index1].dim.Dfms.FindIndex(x => x.Id == dfs.dfm.Id);
|
||||
df[index1].dim.Dfms[index2].FieldsContent = text;
|
||||
}
|
||||
else
|
||||
{
|
||||
int index2 = dfs.dim.Dfms.FindIndex(x => x.Id == dfs.dfm.Id);
|
||||
dfs.dim.Dfms[index2].FieldsContent = text;
|
||||
df.Add(dfs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < df.Count; i++)
|
||||
{
|
||||
DeviceInfoModel dim = df[i].dim;
|
||||
string json = JsonConvert.SerializeObject(dim);
|
||||
//Console.WriteLine(json);
|
||||
//Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++++");
|
||||
dim.FieldJson = JsonConvert.SerializeObject(dim.Dfms);
|
||||
SqlHelper.Update(dim);
|
||||
}
|
||||
}
|
||||
|
||||
private string Log()
|
||||
{
|
||||
string ret = "";
|
||||
List<DeviceFields> df = new List<DeviceFields>();
|
||||
// 遍历 Grid 中的每一行
|
||||
for (int row = 0; row < gd_content.RowDefinitions.Count; row++)
|
||||
{
|
||||
// 遍历 Grid 中的每一列
|
||||
for (int column = 0; column < gd_content.ColumnDefinitions.Count; column++)
|
||||
{
|
||||
// 获取当前行和列上的子元素
|
||||
UIElement element = gd_content.Children
|
||||
.Cast<UIElement>()
|
||||
.FirstOrDefault(e => Grid.GetRow(e) == row && Grid.GetColumn(e) == column);
|
||||
|
||||
// 检查子元素是否是 TextBox,并获取其值
|
||||
if (element is TextBox textBox)
|
||||
{
|
||||
string text = textBox.Text;
|
||||
DeviceFields dfs = textBox.Tag as DeviceFields;
|
||||
Console.WriteLine(dfs.dim.DeviceName + " " + dfs.dfm.FieldsName + ":" + text);
|
||||
|
||||
int index1 = df.FindIndex(x => x.dim.Id == dfs.dim.Id);
|
||||
if (index1 >= 0)
|
||||
{
|
||||
int index2 = df[index1].dim.Dfms.FindIndex(x => x.Id == dfs.dfm.Id);
|
||||
df[index1].dim.Dfms[index2].FieldsContent = text;
|
||||
}
|
||||
else
|
||||
{
|
||||
int index2 = dfs.dim.Dfms.FindIndex(x => x.Id == dfs.dfm.Id);
|
||||
dfs.dim.Dfms[index2].FieldsContent = text;
|
||||
df.Add(dfs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < df.Count; i++)
|
||||
{
|
||||
DeviceInfoModel dim = df[i].dim;
|
||||
ret += dim.DeviceId + "(";
|
||||
for(int k = 0; k < dim.Dfms.Count; k++)
|
||||
{
|
||||
if (k == dim.Dfms.Count - 1)
|
||||
{
|
||||
ret += dim.Dfms[k].FieldsContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += dim.Dfms[k].FieldsContent + ",";
|
||||
}
|
||||
}
|
||||
if (i == df.Count - 1)
|
||||
{
|
||||
ret += ");";
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += "),";
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_See.SetUI("#E8F4FF", "#97D4FF", "\\Image\\see.png", "#1990FF", "查看字符");
|
||||
Btn_Save.SetUI("#E8F4FF", "#97D4FF", "\\Image\\save.png", "#1990FF", "保存");
|
||||
Btn_Close.SetUI("#E8F4FF", "#97D4FF", "\\Image\\语音关闭.png", "#1990FF", "关闭");
|
||||
|
||||
DataToGridViewHeader();
|
||||
}
|
||||
|
||||
private void DataToGridViewHeader()
|
||||
{
|
||||
List<DeviceInfoModel> vs = SqlHelper.GetDeviceInfo();
|
||||
int count = 0;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
vs[i].Dfms = JsonConvert.DeserializeObject<List<DeviceFieldsModel>>(vs[i].FieldJson);
|
||||
count += vs[i].Dfms.Count;
|
||||
}
|
||||
count++;
|
||||
double widthMax = 1300;
|
||||
double width = widthMax / count;
|
||||
int Index = 0;
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "设备ID");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for (int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
Index++;
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
}
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell(gd_header, Index - vs[i].Dfms.Count + 1, vs[i].DeviceId, vs[i].Dfms.Count);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "设备");
|
||||
Index = 0;
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for (int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
Index++;
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
}
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell(gd_header, Index - vs[i].Dfms.Count + 1, vs[i].DeviceName, vs[i].Dfms.Count);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_header);
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
GridViewUnitls.AddCell2(gd_header, 0, "标签");
|
||||
// 创建并添加新的列到新行
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_header, width);
|
||||
DeviceFieldsModel dfm = GetByIndex(vs, i);
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCell2(gd_header, i, dfm.FieldsName);
|
||||
}
|
||||
GridViewUnitls.AddSpLine2(gd_header, count, width);
|
||||
// 创建新的行- 固定行高:40
|
||||
GridViewUnitls.AddRow(gd_content);
|
||||
GridViewUnitls.AddColumn2(gd_content, width);
|
||||
GridViewUnitls.AddCell2(gd_content, 0, "配方模板");
|
||||
// 创建并添加新的列到新行
|
||||
if (!isUpdate)
|
||||
{
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_content, width);
|
||||
//DeviceFieldsModel dfm = GetByIndex(vs, i);
|
||||
DeviceFields dfm = GetByIndex2(vs, i);
|
||||
// 添加对应的控件到新的格子中
|
||||
GridViewUnitls.AddCellTextBox(gd_content, i, dfm.dfm.FieldsContent, dfm, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
GridViewUnitls.AddColumn2(gd_content, width);
|
||||
//DeviceFieldsModel dfm = GetByIndex(vs, i);
|
||||
DeviceFields dfm = GetByIndex2(vs, i);
|
||||
// 添加对应的控件到新的格子中
|
||||
string ret = GetOptionValue(dfm);
|
||||
GridViewUnitls.AddCellTextBox(gd_content, i, ret, dfm, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetOptionValue(DeviceFields dfm)
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonOption))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
jsonOption = jsonOption.Replace(";", "");
|
||||
MatchCollection matches = Regex.Matches(jsonOption, @"(\w+)\(([^)]+)\)");
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
string id = match.Groups[1].Value;
|
||||
string value = match.Groups[2].Value;
|
||||
Console.WriteLine($"id={id} value={value}");
|
||||
string[] vs = value.Split(',');
|
||||
if (dfm.dim.DeviceId == id)
|
||||
{
|
||||
int index = dfm.dim.Dfms.FindIndex(x => x.Id == dfm.dfm.Id);
|
||||
if (vs.Length > index)
|
||||
{
|
||||
return vs[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private DeviceFieldsModel GetByIndex(List<DeviceInfoModel> vs, int index)
|
||||
{
|
||||
int count = 0;
|
||||
for(int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for(int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
count++;
|
||||
if(count == index)
|
||||
{
|
||||
return vs[i].Dfms[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private DeviceFields GetByIndex2(List<DeviceInfoModel> vs, int index)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < vs.Count; i++)
|
||||
{
|
||||
for (int k = 0; k < vs[i].Dfms.Count; k++)
|
||||
{
|
||||
count++;
|
||||
if (count == index)
|
||||
{
|
||||
DeviceFields df = new DeviceFields
|
||||
{
|
||||
dfm = vs[i].Dfms[k],
|
||||
dim = vs[i]
|
||||
};
|
||||
return df;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
64
middleware/zdhsys/Popup/RobotInfo.xaml
Normal file
64
middleware/zdhsys/Popup/RobotInfo.xaml
Normal file
@@ -0,0 +1,64 @@
|
||||
<Window x:Class="zdhsys.Popup.RobotInfo"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOptionInfo" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="200" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="机器人信息" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="IP地址" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox x:Name="txt_IP" Grid.Column="1" Margin="10,0,0,0" Width="250" HorizontalAlignment="Left"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="3" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="端口" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<local1:DevTextBox Grid.Column="1" Margin="10,0,0,0" x:Name="txt_Port" Width="250" HorizontalAlignment="Left"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.5*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.5*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Connect" Click="Btn_Connect_Click" Grid.Column="1" Margin="10,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="2" Margin="10,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Close1" Click="Btn_Close_Click" Grid.Column="3" Margin="10,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
108
middleware/zdhsys/Popup/RobotInfo.xaml.cs
Normal file
108
middleware/zdhsys/Popup/RobotInfo.xaml.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using zdhsys.Bean;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOptionInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class RobotInfo : Window
|
||||
{
|
||||
public RobotInfo(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//只能输入数字
|
||||
txt_Port.SetNumber();
|
||||
txt_Port.SetUI("输入数值");
|
||||
txt_IP.SetUI("输入IP地址");
|
||||
|
||||
Btn_Connect.SetUI("#0066FF", "#0066FF", "#FFFFFF", "测试连接");
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "保存");
|
||||
Btn_Close1.SetUI("#FFFFFF", "#0066FF", "#0066FF", "取消");
|
||||
|
||||
InitUI();
|
||||
}
|
||||
|
||||
private List<RobotInfoModel> vs = null;
|
||||
|
||||
private void InitUI()
|
||||
{
|
||||
//加载数据进来,目前机械臂只有一个
|
||||
vs = SqlHelper.GetRobotInfo();
|
||||
if (vs.Count > 0)
|
||||
{
|
||||
txt_Port.SetText(vs[0].RobotPort);
|
||||
txt_IP.SetText(vs[0].RobotIP);
|
||||
}
|
||||
}
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
RobotInfoModel robot = null;
|
||||
if (vs.Count > 0)
|
||||
{
|
||||
robot = vs[0];
|
||||
}
|
||||
else if (vs.Count == 0)
|
||||
{
|
||||
robot = new RobotInfoModel();
|
||||
}
|
||||
robot.RobotIP = txt_IP.Text();
|
||||
robot.RobotPort = txt_Port.Text();
|
||||
int ret = 0;
|
||||
if (!int.TryParse(robot.RobotPort, out ret))
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.SetUI("端口不是整型");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
if (vs.Count == 0)
|
||||
{
|
||||
SqlHelper.Add(robot);
|
||||
}
|
||||
else
|
||||
{
|
||||
SqlHelper.Update(robot);
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Btn_Connect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p);
|
||||
if (string.IsNullOrEmpty(txt_IP.Text()) || string.IsNullOrEmpty(txt_Port.Text()))
|
||||
{
|
||||
info.SetUI("IP和端口不能为空!!");
|
||||
_ = info.ShowDialog();
|
||||
return;
|
||||
}
|
||||
if (RoborUnitils.ConnectRobot(txt_IP.Text(), int.Parse(txt_Port.Text())))
|
||||
{
|
||||
info.SetUI("TCP连接成功!!");
|
||||
_ = info.ShowDialog();
|
||||
}
|
||||
//RoborUnitils.robot.Send("welcome robot");
|
||||
}
|
||||
}
|
||||
}
|
||||
27
middleware/zdhsys/Popup/SeeJson.xaml
Normal file
27
middleware/zdhsys/Popup/SeeJson.xaml
Normal file
@@ -0,0 +1,27 @@
|
||||
<Window x:Class="zdhsys.Popup.SeeJson"
|
||||
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:zdhsys.Popup"
|
||||
xmlns:view="clr-namespace:JsonTool.Views" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
x:Name="MainWin"
|
||||
Loaded="MainWin_Loaded"
|
||||
Title="SeeJson" Height="450" Width="600">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="600" Height="700" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid>
|
||||
<local1:DevButton1 x:Name="Btn_Close" Width="130" HorizontalAlignment="Center" Height="35"/>
|
||||
</Grid>
|
||||
<view:JsonView x:Name="jv" Grid.Row="1" Margin="0,0,0,0" DataContext="{Binding ElementName=MainWin,Path=JsonViewDataContext}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
56
middleware/zdhsys/Popup/SeeJson.xaml.cs
Normal file
56
middleware/zdhsys/Popup/SeeJson.xaml.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using JsonTool.ViewModel;
|
||||
using Newtonsoft.Json;
|
||||
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 zdhsys.entity;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// SeeJson.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SeeJson : Window
|
||||
{
|
||||
public JsonViewModel JsonViewDataContext
|
||||
{
|
||||
get { return (JsonViewModel)GetValue(JsonViewDataContextProperty); }
|
||||
set { SetValue(JsonViewDataContextProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for JsonViewDataContext. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty JsonViewDataContextProperty =
|
||||
DependencyProperty.Register("JsonViewDataContext", typeof(JsonViewModel), typeof(MainWindow), new PropertyMetadata(new JsonViewModel()));
|
||||
public SeeJson(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
Btn_Close.Click += Btn_Close_Click;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public List<List<List<PrintCmd>>> pc;
|
||||
|
||||
private void MainWin_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Close.SetUI("#E8F4FF", "#97D4FF", "\\Image\\语音关闭.png", "#1990FF", "关闭");
|
||||
string json = JsonConvert.SerializeObject(pc);
|
||||
jv.SetText(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
56
middleware/zdhsys/Popup/SelectFlowData.xaml
Normal file
56
middleware/zdhsys/Popup/SelectFlowData.xaml
Normal file
@@ -0,0 +1,56 @@
|
||||
<Window x:Class="zdhsys.Popup.SelectFlowData"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOptionInfo" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="200" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="选择流程" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="流程名称" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="cb" Grid.Column="1" Margin="10,0,0,0" Height="30" Width="250" VerticalContentAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.7*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1.3*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Margin="15,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Close1" Click="Btn_Close_Click" Grid.Column="3" Margin="15,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
72
middleware/zdhsys/Popup/SelectFlowData.xaml.cs
Normal file
72
middleware/zdhsys/Popup/SelectFlowData.xaml.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using zdhsys.Bean;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOptionInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SelectFlowData : Window
|
||||
{
|
||||
public SelectFlowData(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private List<Options> dim = null;
|
||||
public Options ofm = null;
|
||||
public bool isUpdate = false;
|
||||
public bool flag_Save = false;
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "载入");
|
||||
Btn_Close1.SetUI("#FFFFFF", "#0066FF", "#0066FF", "取消");
|
||||
|
||||
dim = SqlHelper.GetOptions();
|
||||
if (dim == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (dim.Count == 0)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.SetUI("请先添加子配方");
|
||||
_ = info.ShowDialog();
|
||||
Close();
|
||||
}
|
||||
int index = 0;
|
||||
for (int i = 0; i < dim.Count; i++)
|
||||
{
|
||||
cb.Items.Add(dim[i].OptionName);
|
||||
if (ofm != null && ofm.Id == dim[i].Id)
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
cb.SelectedIndex = index;
|
||||
}
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ofm = dim[cb.SelectedIndex];
|
||||
flag_Save = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
56
middleware/zdhsys/Popup/SelectFlowData2.xaml
Normal file
56
middleware/zdhsys/Popup/SelectFlowData2.xaml
Normal file
@@ -0,0 +1,56 @@
|
||||
<Window x:Class="zdhsys.Popup.SelectFlowData2"
|
||||
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:zdhsys.Popup" xmlns:local1="clr-namespace:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded"
|
||||
Title="AddOptionInfo" Height="450" Width="800">
|
||||
<Grid Background="#80000000">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="200" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Width="5" Height="25" Fill="#0066FF" />
|
||||
<Label Grid.Column="1" VerticalAlignment="Center" FontSize="15" Content="选择流程" FontWeight="Bold" />
|
||||
<Button x:Name="Btn_Close" Click="Btn_Close_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Grid.Column="2" Width="25" Height="25" Content="X" Foreground="White" Background="Red" Style="{StaticResource NoBorderButtonStyle0}"/>
|
||||
</Grid>
|
||||
<Rectangle Grid.Row="1" Height="2" Fill="#E1E1E1" Margin="15,0,15,0" VerticalAlignment="Top"/>
|
||||
<Grid Grid.Row="2" Margin="15,0,15,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="流程名称" VerticalAlignment="Center" Style="{StaticResource CommonStyleRight}" FontWeight="Bold"/>
|
||||
<ComboBox x:Name="cb" Grid.Column="1" Margin="10,0,0,0" Height="30" Width="250" VerticalContentAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="0.7*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1.3*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local1:DevButton0 x:Name="Btn_Save" Click="Btn_Save_Click" Grid.Column="1" Margin="15,0,0,0" Height="40" />
|
||||
<local1:DevButton0 x:Name="Btn_Close1" Click="Btn_Close_Click" Grid.Column="3" Margin="15,0,0,0" Height="40" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
72
middleware/zdhsys/Popup/SelectFlowData2.xaml.cs
Normal file
72
middleware/zdhsys/Popup/SelectFlowData2.xaml.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using zdhsys.Bean;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Popup
|
||||
{
|
||||
/// <summary>
|
||||
/// AddOptionInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SelectFlowData2 : Window
|
||||
{
|
||||
public SelectFlowData2(Point p)
|
||||
{
|
||||
InitializeComponent();
|
||||
Left = p.X;
|
||||
Top = p.Y;
|
||||
}
|
||||
|
||||
private void Btn_Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private List<FlowModel> dim = null;
|
||||
public FlowModel fm = null;
|
||||
public bool isUpdate = false;
|
||||
public bool flag_Save = false;
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Btn_Save.SetUI("#0066FF", "#0066FF", "#FFFFFF", "载入");
|
||||
Btn_Close1.SetUI("#FFFFFF", "#0066FF", "#0066FF", "取消");
|
||||
|
||||
dim = SqlHelper.GetFlowModelInfo();
|
||||
if (dim == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (dim.Count == 0)
|
||||
{
|
||||
Point p = new Point(Left, Top);
|
||||
MessageInfo info = new MessageInfo(p)
|
||||
{
|
||||
Width = ActualWidth,
|
||||
Height = ActualHeight
|
||||
};
|
||||
info.SetUI("请先添加子配方");
|
||||
_ = info.ShowDialog();
|
||||
Close();
|
||||
}
|
||||
int index = 0;
|
||||
for (int i = 0; i < dim.Count; i++)
|
||||
{
|
||||
cb.Items.Add(dim[i].FlowName);
|
||||
if (fm != null && fm.Id == dim[i].Id)
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
cb.SelectedIndex = index;
|
||||
}
|
||||
|
||||
private void Btn_Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
fm = dim[cb.SelectedIndex];
|
||||
flag_Save = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user