添加语言设置
This commit is contained in:
commit
a15058af34
11 files changed
+275
-70
No files matched your search
+3
-1
@@ -18,14 +18,16 @@ namespace DyeingComputer
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
private UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "DyeingComputer.ini");
|
||||
|
||||
public App()
|
||||
{
|
||||
this.Startup += new StartupEventHandler(App_Startup);
|
||||
this.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
|
||||
|
||||
//DyeingComputer.Properties.Resources.Culture = new System.Globalization.CultureInfo("en-US");//设定语言
|
||||
DyeingComputer.Properties.Resources.Culture = new System.Globalization.CultureInfo(Configini.IniReadvalue("SYS", "Language"));//设定语言
|
||||
}
|
||||
|
||||
System.Threading.Mutex mutex;
|
||||
void App_Startup(object sender, StartupEventArgs e)
|
||||
{
|
||||
|
||||
Generated
+18
@@ -258,6 +258,15 @@ namespace DyeingComputer.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Dide 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Dide {
|
||||
get {
|
||||
return ResourceManager.GetString("Dide", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Directives 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -411,6 +420,15 @@ namespace DyeingComputer.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Language 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Language {
|
||||
get {
|
||||
return ResourceManager.GetString("Language", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 LineUp 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -408,4 +408,10 @@
|
||||
<data name="Port" xml:space="preserve">
|
||||
<value>Port</value>
|
||||
</data>
|
||||
<data name="Dide" xml:space="preserve">
|
||||
<value>Dide</value>
|
||||
</data>
|
||||
<data name="Language" xml:space="preserve">
|
||||
<value>Language</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -408,4 +408,10 @@
|
||||
<data name="Port" xml:space="preserve">
|
||||
<value>Port</value>
|
||||
</data>
|
||||
<data name="Dide" xml:space="preserve">
|
||||
<value>Dide</value>
|
||||
</data>
|
||||
<data name="Language" xml:space="preserve">
|
||||
<value>Language</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -408,4 +408,10 @@
|
||||
<data name="Port" xml:space="preserve">
|
||||
<value>端口号</value>
|
||||
</data>
|
||||
<data name="Dide" xml:space="preserve">
|
||||
<value>待机</value>
|
||||
</data>
|
||||
<data name="Language" xml:space="preserve">
|
||||
<value>语言</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -408,4 +408,10 @@
|
||||
<data name="Port" xml:space="preserve">
|
||||
<value>連接埠</value>
|
||||
</data>
|
||||
<data name="Dide" xml:space="preserve">
|
||||
<value>待機</value>
|
||||
</data>
|
||||
<data name="Language" xml:space="preserve">
|
||||
<value>語言</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -8,7 +8,10 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="630" d:DesignWidth="1280" VerticalAlignment="Top">
|
||||
<Grid>
|
||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="190,10,0,0" x:Name="comboBoxCOM" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="20" IsEditable="True" IsReadOnly="True"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="90,10,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Port}" VerticalAlignment="Top" Width="80" FontSize="25"/>
|
||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,10,0,0" x:Name="comboBoxCOM" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="20" IsEditable="True" IsReadOnly="True"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,10,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Port}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,50,0,0" x:Name="comboBoxLanguage" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxLanguage_SelectionChanged" FontSize="20" IsEditable="True" IsReadOnly="True"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,50,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Language}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -27,6 +27,10 @@ namespace DyeingComputer.View
|
||||
string[] ports = System.IO.Ports.SerialPort.GetPortNames();
|
||||
comboBoxCOM.ItemsSource = ports;
|
||||
comboBoxCOM.Text = Configini.IniReadvalue("SYS", "COM");
|
||||
|
||||
string[] Language = {"en-US","zh-CN","zh -TW" };
|
||||
comboBoxLanguage.ItemsSource = Language;
|
||||
comboBoxLanguage.Text = Configini.IniReadvalue("SYS", "Language");
|
||||
}
|
||||
//调用配置文件
|
||||
private UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "DyeingComputer.ini");
|
||||
@@ -35,5 +39,10 @@ namespace DyeingComputer.View
|
||||
{
|
||||
Configini.IniWritevalue("SYS","COM",comboBoxCOM.SelectedValue.ToString());
|
||||
}
|
||||
|
||||
private void comboBoxLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Configini.IniWritevalue("SYS", "Language", comboBoxLanguage.SelectedValue.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,28 +51,16 @@ namespace DyeingComputer.ViewModel
|
||||
{
|
||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
||||
private PID PID = null;
|
||||
private IniFile.IniFiles Configini = new IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "DyeingComputer.ini");
|
||||
PID pid = new PID();
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
pid.Kp = Convert.ToDouble( SQLiteHelpers.ExecuteScalar("select value from system where ParameterID = 'ST01'", null)); //读取
|
||||
pid.Ki = Convert.ToDouble( SQLiteHelpers.ExecuteScalar("select value from system where ParameterID = 'ST02'", null));
|
||||
pid.Kd = Convert.ToDouble( SQLiteHelpers.ExecuteScalar("select value from system where ParameterID = 'ST03'", null));
|
||||
pid.N = Convert.ToDouble(SQLiteHelpers.ExecuteScalar("select value from system where ParameterID = 'ST04'", null));
|
||||
pid.OutputUpperLimit = Convert.ToDouble(SQLiteHelpers.ExecuteScalar("select value from system where ParameterID = 'ST05'", null));
|
||||
pid.OutputLowerLimit = Convert.ToDouble(SQLiteHelpers.ExecuteScalar("select value from system where ParameterID = 'ST06'", null));
|
||||
SQLiteHelpers.Close();
|
||||
|
||||
WorkNumder = "----------";
|
||||
SYS_SET(); //crbl
|
||||
CountDown(); //启动循环任务
|
||||
SQL_data(); //读数据库
|
||||
UPort(); //启动串口
|
||||
|
||||
}
|
||||
|
||||
double ST11;
|
||||
@@ -80,8 +68,32 @@ namespace DyeingComputer.ViewModel
|
||||
{
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
ST11 = Convert.ToDouble(SQLiteHelpers.ExecuteScalar("select value from system where ParameterID = 'ST11'", null));
|
||||
dt_sys = SQLiteHelpers.ExecuteDataSet("select * from System", null).Tables[0]; //读取表写入缓存
|
||||
SQLiteHelpers.Close();
|
||||
|
||||
ST11 = Convert.ToDouble(Selet_sys("ST11"));//温度偏差参数
|
||||
|
||||
pid.Kp = Convert.ToDouble(Selet_sys("ST01")); //读取pid
|
||||
pid.Ki = Convert.ToDouble(Selet_sys("ST02"));
|
||||
pid.Kd = Convert.ToDouble(Selet_sys("ST03"));
|
||||
pid.N = Convert.ToDouble(Selet_sys("ST04"));
|
||||
pid.OutputUpperLimit = Convert.ToDouble(Selet_sys("ST05"));
|
||||
pid.OutputLowerLimit = Convert.ToDouble(Selet_sys("ST06"));
|
||||
}
|
||||
DataTable dt_sys = new DataTable();
|
||||
public string Selet_sys(string key)//配置缓存
|
||||
{
|
||||
try
|
||||
{
|
||||
DataRow[] arrRows = dt_sys.Select("ParameterID ='" + key+"'");
|
||||
string index = arrRows[0]["Value"].ToString();
|
||||
return index;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.LogGingDATA(ex.ToString());
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
|
||||
public string work_Temp; //显示温度
|
||||
@@ -113,7 +125,7 @@ namespace DyeingComputer.ViewModel
|
||||
{
|
||||
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
||||
{
|
||||
Interval = TimeSpan.FromSeconds(0.5)//秒
|
||||
Interval = TimeSpan.FromSeconds(1)//秒
|
||||
};
|
||||
timer1s.Tick += Tick_Event_1S;
|
||||
timer1s.Start();
|
||||
@@ -136,6 +148,7 @@ namespace DyeingComputer.ViewModel
|
||||
|
||||
public static object Name_err;
|
||||
public static object WorkNumder;
|
||||
public Int32 DIDETime;
|
||||
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
||||
{
|
||||
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
@@ -144,13 +157,16 @@ namespace DyeingComputer.ViewModel
|
||||
// Status_Str = "qweqeqwqqfwfqef";
|
||||
|
||||
if (LINK_OK) Modbus_link();
|
||||
if (!SETP_runtime) STEP_RUN();
|
||||
|
||||
DIDETime++;
|
||||
IO_data();
|
||||
}
|
||||
void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S
|
||||
{
|
||||
if (!LINK_OK) Modbus_link();
|
||||
if (Name_err != null) Status_Str = Name_err.ToString();
|
||||
STEP_RUN();
|
||||
if(SETP_runtime) STEP_RUN();
|
||||
}
|
||||
void DisTimer_100MS(object sender, EventArgs e)//Tick_Event周期执行事件100MS
|
||||
{
|
||||
@@ -165,19 +181,61 @@ namespace DyeingComputer.ViewModel
|
||||
double STEP_P3 = 0;
|
||||
double STEP_P4 = 0;
|
||||
double STEP_P5 = 0;
|
||||
bool SETP_runtime = false;
|
||||
|
||||
void STEP_START(object sender, AddressUpdateEventArgs e)
|
||||
{
|
||||
|
||||
public void STEP_START(object sender, AddressUpdateEventArgs e)
|
||||
{
|
||||
if (e.StepID == "001")
|
||||
{
|
||||
updata_dtm("1003",Convert.ToDouble( e.P2));
|
||||
STEP_ID = "001";
|
||||
STEP_P1 = Convert.ToDouble(e.P1);
|
||||
STEP_P2 = Convert.ToDouble(e.P2);
|
||||
STEP_P3 = Convert.ToDouble(e.P3);
|
||||
|
||||
updata_dtm("1003",Convert.ToDouble( e.P2)/12);
|
||||
|
||||
SETP_runtime=true;
|
||||
//STEP_RUN();
|
||||
}
|
||||
}
|
||||
|
||||
void STEP_RUN()
|
||||
{
|
||||
if (SETP_runtime)
|
||||
{
|
||||
switch (STEP_ID)
|
||||
{
|
||||
case "001":
|
||||
|
||||
break;
|
||||
case "007":
|
||||
|
||||
break;
|
||||
case "008":
|
||||
|
||||
break;
|
||||
case "013":
|
||||
|
||||
break;
|
||||
case "015":
|
||||
|
||||
break;
|
||||
case "017":
|
||||
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Name_err == null)
|
||||
{
|
||||
int TIMEH = DIDETime / 3600;
|
||||
int TIMEM = (DIDETime - TIMEH * 3600) / 60;
|
||||
int TIMES = DIDETime - TIMEH*3600 - TIMEM*60;
|
||||
Status_Str = Properties.Resources.Dide + string.Format(" {0:D4}", TIMEH) +":"+ string.Format(" {0:D2}", TIMEM) + ":" + string.Format(" {0:D2}", TIMES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -270,17 +328,11 @@ namespace DyeingComputer.ViewModel
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
lock (dt_d)
|
||||
{
|
||||
for (ushort i = 0; i < DO_L; i++) { updata_dtd((i + 2001).ToString(), DO[i]); }
|
||||
//for (ushort i = 0; i < DQ_L; i++) { updata_dtd((i + 3001).ToString(), DQ[i]); }
|
||||
for (ushort i = 0; i < DQ_L; i++) { DQ[i] = Selet_dtd((i + 3001).ToString()); }
|
||||
}
|
||||
lock (dt_a)
|
||||
{
|
||||
for (ushort i = 0; i < RW_L; i++) { updata_dta((i + 4001).ToString(), RW[i]); }
|
||||
for (ushort i = 0; i < DW_L; i++) { DW[i] = Convert.ToUInt16(Selet_dta((i + 5001).ToString())); }
|
||||
}
|
||||
for (ushort i = 0; i < DO_L; i++) { updata_dtd((i + 2001).ToString(), DO[i]); }
|
||||
//for (ushort i = 0; i < DQ_L; i++) { updata_dtd((i + 3001).ToString(), DQ[i]); }
|
||||
for (ushort i = 0; i < DQ_L; i++) { DQ[i] = Selet_dtd((i + 3001).ToString()); }
|
||||
for (ushort i = 0; i < RW_L; i++) { updata_dta((i + 4001).ToString(), RW[i]); }
|
||||
for (ushort i = 0; i < DW_L; i++) { DW[i] = Convert.ToUInt16(Selet_dta((i + 5001).ToString())); }
|
||||
});
|
||||
|
||||
await Task.Run(() =>
|
||||
@@ -293,58 +345,111 @@ namespace DyeingComputer.ViewModel
|
||||
|
||||
public int Selet_dtm(string key)//M寄存器
|
||||
{
|
||||
DataRow[] arrRows = dt_m.Select("ID=" + key);
|
||||
int index = Convert.ToInt16(arrRows[0]["Value"].ToString());
|
||||
return index;
|
||||
}
|
||||
try
|
||||
{
|
||||
DataRow[] arrRows = dt_m.Select("ID='" + key+"'");
|
||||
int index = Convert.ToInt16(arrRows[0]["Value"].ToString());
|
||||
return index;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.LogGingDATA(ex.ToString());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
public bool Selet_dtd(string key)//D寄存器
|
||||
{
|
||||
DataRow[] arrRows = dt_d.Select("ID=" + key);
|
||||
try {
|
||||
DataRow[] arrRows = dt_d.Select("ID='" + key + "'");
|
||||
bool index = Convert.ToBoolean(arrRows[0]["DIO"].ToString());
|
||||
return index;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.LogGingDATA(ex.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public int Selet_dta(string key)//A寄存器
|
||||
{
|
||||
DataRow[] arrRows = dt_a.Select("ID=" + key);
|
||||
try {
|
||||
DataRow[] arrRows = dt_a.Select("ID='" + key + "'");
|
||||
int index = Convert.ToInt16(arrRows[0]["AIO"].ToString());
|
||||
return index;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.LogGingDATA(ex.ToString());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
public void updata_dtm(string key,double Value)//更新M寄存器
|
||||
{
|
||||
DataRow[] arrRows = dt_m.Select("ID="+key);
|
||||
int index = dt_m.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
try
|
||||
{
|
||||
DataRow drEmployee = dt_m.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["Value"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
lock (dt_m)
|
||||
{
|
||||
DataRow[] arrRows = dt_m.Select("ID='" + key + "'");
|
||||
int index = dt_m.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
{
|
||||
DataRow drEmployee = dt_m.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["Value"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.LogGingDATA(ex.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
public void updata_dtd(string key, bool Value)//更新D寄存器
|
||||
{
|
||||
DataRow[] arrRows = dt_d.Select("ID='" + key+"'");
|
||||
int index = dt_d.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
try
|
||||
{
|
||||
DataRow drEmployee = dt_d.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["DIO"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
lock (dt_d)//锁
|
||||
{
|
||||
DataRow[] arrRows = dt_d.Select("ID='" + key + "'");
|
||||
int index = dt_d.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
{
|
||||
DataRow drEmployee = dt_d.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["DIO"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.LogGingDATA(ex.ToString());
|
||||
}
|
||||
}
|
||||
public void updata_dta(string key, int Value)//更新A寄存器
|
||||
{
|
||||
DataRow[] arrRows = dt_a.Select("ID=" + key);
|
||||
int index = dt_a.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
try
|
||||
{
|
||||
DataRow drEmployee = dt_a.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["AIO"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
lock (dt_a)
|
||||
{
|
||||
DataRow[] arrRows = dt_a.Select("ID='" + key + "'");
|
||||
int index = dt_a.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
{
|
||||
DataRow drEmployee = dt_a.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["AIO"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.LogGingDATA(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,19 +18,19 @@
|
||||
|
||||
<TextBlock x:Name="P1N" HorizontalAlignment="Left" Height="30" Margin="10,120,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" Background="#FFEFEEEE"/>
|
||||
<TextBox x:Name="P1" HorizontalAlignment="Right" Height="30" Margin="0,120,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
|
||||
Text="0" PreviewTextInput="Tb_KeyPress" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" />
|
||||
Text="0" PreviewTextInput="Tb_KeyP1" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" />
|
||||
<TextBlock x:Name="P2N" HorizontalAlignment="Left" Height="30" Margin="10,155,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" Background="#FFEFEEEE"/>
|
||||
<TextBox x:Name="P2" HorizontalAlignment="Right" Height="30" Margin="0,155,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
|
||||
Text="0" PreviewTextInput="Tb_KeyPress" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" />
|
||||
Text="0" PreviewTextInput="Tb_KeyP2" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" />
|
||||
<TextBlock x:Name="P3N" HorizontalAlignment="Left" Height="30" Margin="10,190,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" Background="#FFEFEEEE"/>
|
||||
<TextBox x:Name="P3" HorizontalAlignment="Right" Height="30" Margin="0,190,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
|
||||
Text="0" PreviewTextInput="Tb_KeyPress" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" />
|
||||
Text="0" PreviewTextInput="Tb_KeyP3" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" />
|
||||
<TextBlock x:Name="P4N" HorizontalAlignment="Left" Height="30" Margin="10,225,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" Background="#FFEFEEEE"/>
|
||||
<TextBox x:Name="P4" HorizontalAlignment="Right" Height="30" Margin="0,225,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
|
||||
Text="0" PreviewTextInput="Tb_KeyPress" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" />
|
||||
Text="0" PreviewTextInput="Tb_KeyP4" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" />
|
||||
<TextBlock x:Name="P5N" HorizontalAlignment="Left" Height="30" Margin="10,260,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" Background="#FFEFEEEE"/>
|
||||
<TextBox x:Name="P5" HorizontalAlignment="Right" Height="30" Margin="0,260,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
|
||||
Text="0" PreviewTextInput="Tb_KeyPress" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" />
|
||||
Text="0" PreviewTextInput="Tb_KeyP5" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" />
|
||||
|
||||
<Button Content="{x:Static lang:Resources.YES}" HorizontalAlignment="Left" Height="35" Margin="50,70,0,5" VerticalAlignment="Bottom" Width="80" Click="YES_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.NO}" HorizontalAlignment="Right" Height="35" Margin="0,70,50,5" VerticalAlignment="Bottom" Width="80" Click="NO_Click"/>
|
||||
|
||||
@@ -53,11 +53,55 @@ namespace DyeingComputer.Windows
|
||||
|
||||
private void Tb_KeyPress(object sender, TextCompositionEventArgs e)//输入事件
|
||||
{
|
||||
|
||||
//Regex re = new Regex("[^0-9.-]+");
|
||||
Regex re = new Regex(@"^[0-9]+(.[0-9]{1,3})?$");// 非零的正整数
|
||||
Regex re = new Regex(@"^[0-9.]+(.[0-9]{1,3})?$");// 非零的正整数
|
||||
e.Handled = !re.IsMatch(e.Text);
|
||||
}
|
||||
private void Tb_KeyP1(object sender, TextCompositionEventArgs e)//输入事件P1
|
||||
{
|
||||
Regex numbeRegex = new Regex("^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");
|
||||
e.Handled =
|
||||
!numbeRegex.IsMatch(
|
||||
P1.Text.Insert(
|
||||
P1.SelectionStart, e.Text));
|
||||
P1.Text = P1.Text.Trim();
|
||||
}
|
||||
private void Tb_KeyP2(object sender, TextCompositionEventArgs e)//输入事件P2
|
||||
{
|
||||
Regex numbeRegex = new Regex("^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");
|
||||
e.Handled =
|
||||
!numbeRegex.IsMatch(
|
||||
P2.Text.Insert(
|
||||
P2.SelectionStart, e.Text));
|
||||
P2.Text = P2.Text.Trim();
|
||||
}
|
||||
private void Tb_KeyP3(object sender, TextCompositionEventArgs e)//输入事件P3
|
||||
{
|
||||
Regex numbeRegex = new Regex("^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");
|
||||
e.Handled =
|
||||
!numbeRegex.IsMatch(
|
||||
P3.Text.Insert(
|
||||
P3.SelectionStart, e.Text));
|
||||
P3.Text = P3.Text.Trim();
|
||||
}
|
||||
private void Tb_KeyP4(object sender, TextCompositionEventArgs e)//输入事件P4
|
||||
{
|
||||
Regex numbeRegex = new Regex("^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");
|
||||
e.Handled =
|
||||
!numbeRegex.IsMatch(
|
||||
P4.Text.Insert(
|
||||
P4.SelectionStart, e.Text));
|
||||
P4.Text = P4.Text.Trim();
|
||||
}
|
||||
private void Tb_KeyP5(object sender, TextCompositionEventArgs e)//输入事件P5
|
||||
{
|
||||
Regex numbeRegex = new Regex("^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");
|
||||
e.Handled =
|
||||
!numbeRegex.IsMatch(
|
||||
P5.Text.Insert(
|
||||
P5.SelectionStart, e.Text));
|
||||
P5.Text = P5.Text.Trim();
|
||||
}
|
||||
|
||||
|
||||
private readonly string[] a = {"001","007","008","013","015" ,"017", "020", "022", "031", "035", "036", "039", "040", "041", "049", "050",
|
||||
"051", "054", "055", "056","064","065","066","067","090","091","093","094" };
|
||||
|
||||
Reference in new issue
Block a user