sc 1 year ago
parent
commit
51c2aae2e9
  1. 59
      ConvertMoels/ProductTypeSQLConvert.cs
  2. 42
      ConvertMoels/StatenConvert.cs
  3. 3
      DyeingComputer.csproj
  4. 43
      MainWindow.xaml
  5. 2
      MainWindow.xaml.cs
  6. 18
      Properties/Resources.Designer.cs
  7. 10
      Properties/Resources.en-US.resx
  8. 6
      Properties/Resources.resx
  9. 6
      Properties/Resources.zh-CN.resx
  10. 6
      Properties/Resources.zh-TW.resx
  11. 2
      View/WorkOrderView.xaml
  12. 84
      ViewModel/MainWindowViewModel.cs
  13. 28
      ViewModel/ViewModelLocator.cs

59
ConvertMoels/ProductTypeSQLConvert.cs

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace DyeingComputer.ConvertMoels
{
/// <summary>
/// 原料类型数值转换器
/// 将类型数值转换为类型名称返回
/// </summary>
internal class ProductTypeSQLConvert : IValueConverter
{
/// <summary>
/// </summary>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string ProductType = System.Convert.ToString(value);
if (ProductType == "1")//类型0:染料,1:助剂,2:粉体助剂,3:液体染料,其它:未知
{
return "染料";
}
else
{
if (ProductType == "2")
{
return "助剂";
}
else
{
if (ProductType == "3")
{
return "粉体助剂";
}
else
{
if (ProductType == "4")
{
return "液体染料";
}
else
{
return "未知类型";
}
}
}
}
}
/// <summary>
/// </summary>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

42
ConvertMoels/StatenConvert.cs

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace DyeingComputer.ConvertMoels
{
internal class StatenConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
{
return null;
}
else
{
string Staten = null;
string i = value.ToString();
if (i == "101") Staten = "准备就绪";
if (i == "102") Staten = "计量输送";
if (i == "201") Staten = "自动状态";
if (i == "202") Staten = "转入排队";
if (i == "203") Staten = "等待命令";
if (i == "301") Staten = "步骤完成";
if (i == "309") Staten = "输送异常";
return Staten;
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

3
DyeingComputer.csproj

@ -62,6 +62,8 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ConvertMoels\ProductTypeSQLConvert.cs" />
<Compile Include="ConvertMoels\StatenConvert.cs" />
<Compile Include="Properties\Resources.en-US.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@ -91,6 +93,7 @@
<Compile Include="UserClass\SqliteHelper.cs" />
<Compile Include="UserClass\StrToInt.cs" />
<Compile Include="UserClass\TCPServer.cs" />
<Compile Include="ViewModel\MainWindowViewModel.cs" />
<Compile Include="ViewModel\ViewModelLocator.cs" />
<Compile Include="View\CurveDiagramView.xaml.cs">
<DependentUpon>CurveDiagramView.xaml</DependentUpon>

43
MainWindow.xaml

@ -4,10 +4,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lang="clr-namespace:DyeingComputer.Properties"
xmlns:local="clr-namespace:DyeingComputer"
xmlns:local="clr-namespace:DyeingComputer" xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel"
d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}"
mc:Ignorable="d"
Title="SUNLIGHT 838 b0.0.1 (2024/08/10)"
Height="720" Width="1280">
Height="720" Width="1270">
<Window.Resources>
<Style x:Key="RadioButtonStyle" TargetType="{x:Type RadioButton}">
@ -53,8 +54,8 @@
</Setter>
</Style>
</Window.Resources>
<Grid VerticalAlignment="Bottom">
<Grid>
<Rectangle Margin="0,0,0,0" Fill="#FFCCCCCC" VerticalAlignment="Bottom" Height="40"/>
<RadioButton Content="{x:Static lang:Resources.WorkOrder}" x:Name="Work_Order" Tag="&#xF2d2;" Style="{DynamicResource RadioButtonStyle}" HorizontalAlignment="Left" Height="40" Margin="0,0,0,0" VerticalAlignment="Bottom" Width="200" Background="#FFCCCCCC" Checked="RadioButton_Page"/>
<RadioButton Content="{x:Static lang:Resources.TechnologicalProcess}" x:Name="Technological_Process" Tag="&#xF036;" Style="{DynamicResource RadioButtonStyle}" HorizontalAlignment="Left" Height="40" Margin="200,0,0,0" VerticalAlignment="Bottom" Width="200" Background="#FFCCCCCC" Checked="RadioButton_Page"/>
@ -70,8 +71,38 @@
<RadioButton Content="{x:Static lang:Resources.EngineerSet}" x:Name="Engineer_Set" Tag="&#xF0f0;" Style="{DynamicResource RadioButtonStyle}" HorizontalAlignment="Left" Height="40" Margin="800,0,0,0" VerticalAlignment="Bottom" Width="200" Background="#FFCCCCCC" Checked="RadioButton_Page" Visibility="Hidden"/>
<RadioButton Content="{x:Static lang:Resources.Previous}" x:Name="Previous" Tag="&#xF060;" Style="{DynamicResource RadioButtonStyle}" HorizontalAlignment="Right" Height="40" Margin="0,0,0,0" VerticalAlignment="Bottom" Width="200" Background="#FFCCCCCC" Checked="RadioButton_toolbar" GroupName="toolbar" Visibility="Hidden"/>
<Grid Grid.Column="1">
<ContentControl x:Name="container" Margin="0,0,0,40"/>
<Grid Margin="0,50,0,40">
<ContentControl x:Name="container"/>
</Grid>
<Grid Margin="0,0,0,0" VerticalAlignment="Top" Height="50" Background="#FFD2D2D2">
<TextBox Text="{x:Static lang:Resources.Temperature}" HorizontalAlignment="Left" Height="20" Margin="0,0,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="100" FontSize="12"
Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}"
IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/>
<TextBox Text="{x:Static lang:Resources.WorkOrderNumder}" HorizontalAlignment="Left" Height="20" Margin="100,0,5,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="100" FontSize="12"
Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}"
IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/>
<TextBox Text="{Binding Work_Temp}" HorizontalAlignment="Left" Height="30" Margin="0,20,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="100" FontSize="20"
Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}"
IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/>
<TextBox Text="{Binding Work_Numder}" HorizontalAlignment="Left" Height="30" Margin="100,20,5,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="200" FontSize="20"
Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}"
IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/>
<TextBox Text="{Binding Status_Str}" HorizontalAlignment="Center" Height="50" Margin="0,0,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="700" FontSize="35"
Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}"
IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/>
<TextBox Text="{Binding Sys_Time}" HorizontalAlignment="Right" Height="50" Margin="0,0,5,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}"
IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/>
</Grid>
</Grid>
</Window>

2
MainWindow.xaml.cs

@ -26,6 +26,8 @@ namespace DyeingComputer
{
public MainWindow()
{
DataContext = new MainWindowViewModel();
InitializeComponent();
SQLiteStrat();
container.Content = new WorkOrderView();

18
Properties/Resources.Designer.cs

@ -168,6 +168,15 @@ namespace DyeingComputer.Properties {
}
}
/// <summary>
/// 查找类似 Temperature 的本地化字符串。
/// </summary>
public static string Temperature {
get {
return ResourceManager.GetString("Temperature", resourceCulture);
}
}
/// <summary>
/// 查找类似 Worklist 的本地化字符串。
/// </summary>
@ -176,5 +185,14 @@ namespace DyeingComputer.Properties {
return ResourceManager.GetString("WorkOrder", resourceCulture);
}
}
/// <summary>
/// 查找类似 WorkOrderNumder 的本地化字符串。
/// </summary>
public static string WorkOrderNumder {
get {
return ResourceManager.GetString("WorkOrderNumder", resourceCulture);
}
}
}
}

10
Properties/Resources.en-US.resx

@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="WorkOrder" xml:space="preserve">
<value>WorkOrder</value>
<value>Work Order</value>
</data>
<data name="TechnologicalProcess" xml:space="preserve">
<value>Process</value>
@ -151,9 +151,15 @@
<value>Parameter</value>
</data>
<data name="Programgroup" xml:space="preserve">
<value>ProgramGroup</value>
<value>Program Group</value>
</data>
<data name="SysDatLoss" xml:space="preserve">
<value>System Data Lost</value>
</data>
<data name="WorkOrderNumder" xml:space="preserve">
<value>Work Order Numder</value>
</data>
<data name="Temperature" xml:space="preserve">
<value>Temperature</value>
</data>
</root>

6
Properties/Resources.resx

@ -153,7 +153,13 @@
<data name="TechnologicalProcess" xml:space="preserve">
<value>Process</value>
</data>
<data name="Temperature" xml:space="preserve">
<value>Temperature</value>
</data>
<data name="WorkOrder" xml:space="preserve">
<value>Worklist</value>
</data>
<data name="WorkOrderNumder" xml:space="preserve">
<value>WorkOrderNumder</value>
</data>
</root>

6
Properties/Resources.zh-CN.resx

@ -156,4 +156,10 @@
<data name="SysDatLoss" xml:space="preserve">
<value>系统数据丢失</value>
</data>
<data name="WorkOrderNumder" xml:space="preserve">
<value>工单号</value>
</data>
<data name="Temperature" xml:space="preserve">
<value>温度</value>
</data>
</root>

6
Properties/Resources.zh-TW.resx

@ -156,4 +156,10 @@
<data name="SysDatLoss" xml:space="preserve">
<value>系統資料遺失</value>
</data>
<data name="WorkOrderNumder" xml:space="preserve">
<value>工單號碼</value>
</data>
<data name="Temperature" xml:space="preserve">
<value>溫度</value>
</data>
</root>

2
View/WorkOrderView.xaml

@ -9,7 +9,7 @@
<Grid>
<Grid>
<Grid HorizontalAlignment="Left" Height="236" Margin="190,81,0,0" VerticalAlignment="Top" Width="406"/>
<DataGrid HorizontalAlignment="Left" Height="226" Margin="78,91,0,0" VerticalAlignment="Top" Width="437" d:ItemsSource="{d:SampleData ItemCount=5}"/>
<DataGrid HorizontalAlignment="Left" Height="153" Margin="78,91,0,0" VerticalAlignment="Top" Width="418" d:ItemsSource="{d:SampleData ItemCount=5}"/>
</Grid>
</Grid>

84
ViewModel/MainWindowViewModel.cs

@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommonServiceLocator;
using System.Windows.Threading;
namespace DyeingComputer.ViewModel
{
/// <summary>
/// 变量传递至ui
/// </summary>
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public class MainWindowViewModel: ViewModelBase
{
public MainWindowViewModel()
{
CountDown();
}
public string work_Temp; //显示温度
public string Work_Temp //通知UI控件参数改变
{
get { return work_Temp; }
set { work_Temp = value; OnPropertyChanged("Work_Temp"); }
}
public string work_Numder; //显示工单号
public string Work_Numder //通知UI控件参数改变
{
get { return work_Numder; }
set { work_Numder = value; OnPropertyChanged("Work_Numder"); }
}
public string status_Str; //显示状态
public string Status_Str //通知UI控件参数改变
{
get { return status_Str; }
set { status_Str = value; OnPropertyChanged("Status_Str"); }
}
public string sys_Time; //显示系统时间
public string Sys_Time //通知UI控件参数改变
{
get { return sys_Time; }
set { sys_Time = value; OnPropertyChanged("Sys_Time"); }
}
public void CountDown()
{
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick
{
Interval = TimeSpan.FromSeconds(1)
};
timer1s.Tick += Tick_Event_1S;
timer1s.Start();
//设置定时器
// disTimer.Tick += new EventHandler(DisTimer_Tick);//每一秒执行的方法
// disTimer.Interval = new TimeSpan(10000000); //时间间隔为一秒。
// disTimer.Start();//计时开始
}
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件
{
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
Work_Temp = "130"+"℃";
Work_Numder = "r2024011200014";
Status_Str = "qweqeqwqqfwfqef";
}
}
}

28
ViewModel/ViewModelLocator.cs

@ -5,6 +5,8 @@ using System.Text;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommonServiceLocator;
using System.Windows.Navigation;
using CommunityToolkit.Mvvm.DependencyInjection;
namespace DyeingComputer.ViewModel
@ -13,29 +15,17 @@ namespace DyeingComputer.ViewModel
{
public ViewModelLocator()
{
// ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
////if (ViewModelBase.IsInDesignModeStatic)
////{
//// // Create design time view services and models
//// SimpleIoc.Default.Register<IDataService, DesignDataService>();
////}
////else
////{
//// // Create run time view services and models
//// SimpleIoc.Default.Register<IDataService, DataService>();
////}
// SimpleIoc.Default.Register<MainWindowViewModel>();
}
// public MainWindowViewModel Main
// {
// get
// {
// return ServiceLocator.Current.GetInstance<MainWindowViewModel>();
// }
// }
public MainWindowViewModel Main
{
get
{
return ServiceLocator.Current.GetInstance<MainWindowViewModel>();
}
}
}
}

Loading…
Cancel
Save