You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
327 lines
11 KiB
C#
327 lines
11 KiB
C#
using Rs.Camera;
|
|
using Rs.Controls;
|
|
using Rs.DataAccess;
|
|
using Rs.Framework;
|
|
using Rs.Motion;
|
|
using Rs.MotionPlat.Commom;
|
|
using Rs.MotionPlat.Entitys;
|
|
using Rs.MotionPlat.Flow;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Rs.MotionPlat.SysConfig
|
|
{
|
|
public partial class CommonConfig : BaseForm
|
|
{
|
|
SqliteHelper db = new SqliteHelper();
|
|
IniHelper ini = new IniHelper(Path.Combine(GlobalVar.CurRecipe, "default.ini"));
|
|
public CommonConfig()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
private void CommonConfig_Load(object sender, EventArgs e)
|
|
{
|
|
string lang = Properties.Settings.Default.DefaultLanguage;
|
|
if(lang=="zh-CN")
|
|
{
|
|
cboxLanguage.SelectedIndex= 0;
|
|
}
|
|
else
|
|
{
|
|
cboxLanguage.SelectedIndex = 1;
|
|
}
|
|
|
|
|
|
List<string> cameras = HikCamera.Instance.GetCameras();
|
|
|
|
foreach (var con in groupBox1.Controls)
|
|
{
|
|
if (con is TextBox)
|
|
{
|
|
TextBox txt = (TextBox)con;
|
|
txt.Text = SysConfigParam.GetValue<string>(txt.Name.Replace("txt", ""));
|
|
}
|
|
else if (con is TrackBar)
|
|
{
|
|
TrackBar tb = (TrackBar)con;
|
|
tb.Value = SysConfigParam.GetValue<int>(tb.Name.Replace("tbar", ""));
|
|
}
|
|
else if (con is CheckBox)
|
|
{
|
|
CheckBox cbox = (CheckBox)con;
|
|
|
|
cbox.Checked = SysConfigParam.GetValue<bool>(cbox.Name.Replace("cbox", ""));
|
|
}
|
|
else if (con is ComboBox)
|
|
{
|
|
ComboBox cbox = (ComboBox)con;
|
|
cbox.SelectedItem = SysConfigParam.GetValue<string>(cbox.Name.Replace("cbox", ""));
|
|
}
|
|
}
|
|
|
|
foreach (var con in groupBox3.Controls)
|
|
{
|
|
if (con is ComboBox)
|
|
{
|
|
ComboBox cbox = (ComboBox)con;
|
|
cbox.SelectedItem = SysConfigParam.GetValue<string>(cbox.Name.Replace("cbox", ""));
|
|
}
|
|
if (con is TextBox)
|
|
{
|
|
TextBox txt = (TextBox)con;
|
|
txt.Text = SysConfigParam.GetValue<string>(txt.Name.Replace("txt", ""));
|
|
}
|
|
}
|
|
|
|
//foreach (var con in groupBox3.Controls)
|
|
//{
|
|
// if (con is ComboBox)
|
|
// {
|
|
// ComboBox cbox = (ComboBox)con;
|
|
// cbox.SelectedItem = SysConfigParam.GetValue<string>(cbox.Name.Replace("cbox", ""));
|
|
// }
|
|
//}
|
|
PositionHelper.BindPosition(groupBox8);
|
|
if(GlobalUser.IsVender() || GlobalUser.IsSuper())
|
|
{
|
|
cboxRunSpace.Visible = cboxVirtualAxis.Visible = cboxEnableVirtuleBarCode.Visible = cboxInputTrayLoop.Visible = cboxCheckSafeEnable.Visible = cboxEnableIndexTimeStatistics.Visible = true;
|
|
}
|
|
dataGridView1.AutoGenerateColumns = false;
|
|
BindMenu();
|
|
}
|
|
|
|
private void BindMenu()
|
|
{
|
|
string querySql = "select * from submenus";
|
|
DataTable dt = db.GetDataTable(querySql);
|
|
if(dt!=null&& dt.Rows.Count>0)
|
|
{
|
|
dataGridView1.DataSource = dt;
|
|
}
|
|
if (GlobalUser.IsSuper())
|
|
{
|
|
groupBox4.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
groupBox4.Visible = false;
|
|
}
|
|
}
|
|
private void btnSaveSpeedParam_Click(object sender, EventArgs e)
|
|
{
|
|
foreach (var con in groupBox1.Controls)
|
|
{
|
|
if(con is TextBox)
|
|
{
|
|
TextBox txt=(TextBox)con;
|
|
SysConfigParam.Update(txt.Name.Replace("txt",""), txt.Text);
|
|
}
|
|
else if(con is TrackBar)
|
|
{
|
|
TrackBar tb= (TrackBar)con;
|
|
SysConfigParam.Update(tb.Name.Replace("tbar",""), tb.Value.ToString());
|
|
}
|
|
else if(con is CheckBox)
|
|
{
|
|
CheckBox cbox= (CheckBox)con;
|
|
|
|
SysConfigParam.Update(cbox.Name.Replace("cbox",""), cbox.Checked.ToString());
|
|
}
|
|
else if(con is ComboBox)
|
|
{
|
|
ComboBox cbox= (ComboBox)con;
|
|
if(cbox.SelectedItem!=null)
|
|
{
|
|
SysConfigParam.Update(cbox.Name.Replace("cbox", ""), cbox.SelectedItem.ToString());
|
|
}
|
|
|
|
}
|
|
}
|
|
Msg.ShowInfo("Save success!");
|
|
|
|
}
|
|
|
|
private void tbarWholeSpeed_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
lblWholeSpeed.Text = $"{tbarWholeSpeed.Value}%";
|
|
}
|
|
|
|
|
|
|
|
public void txtSysParam_KeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
if(e.KeyCode== Keys.Enter)
|
|
{
|
|
TextBox txt= (TextBox)sender;
|
|
|
|
UpdateSysParam((TextBox)sender);
|
|
|
|
//if (txt.Name == "txtGrrProductNum" && cboxGRR.Checked)
|
|
{
|
|
//GlobalTray.GrrTray.ChangeStatus(ESlotStatus.NotHave);
|
|
//for (int i = 1; i <= GlobalVar.GrrProductNum; i++)
|
|
//{
|
|
// GlobalTray.GrrTray.ChangeStatus(i, ESlotStatus.Have);
|
|
//}
|
|
}
|
|
}
|
|
}
|
|
private void txtQifuValue_KeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
TextBox txt = (TextBox)sender;
|
|
string value = txt.Text;
|
|
//QifuManager.Instance.Write(float.Parse(value));
|
|
SysConfigParam.Update(txt.Name.Replace("txt", ""), value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void tbarTakeTrayFromNg2InputSpeed_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
lblTakeTrayFromNg2InputSpeed.Text = $"{tbarTakeTrayFromNg2InputSpeed.Value}%";
|
|
}
|
|
|
|
|
|
|
|
private void cbox_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
CheckBox cbox = (CheckBox)sender;
|
|
if(cbox.Text=="GRR" && cbox.Checked)
|
|
{
|
|
GlobalTray.GrrTray.ChangeStatus(ESlotStatus.NotHave);
|
|
for (int i=1;i<= GlobalVar.GrrProductNum; i++)
|
|
{
|
|
GlobalTray.GrrTray.ChangeStatus(i, ESlotStatus.Have);
|
|
}
|
|
}
|
|
SysConfigParam.Update(cbox.Name.Replace("cbox", ""), cbox.Checked.ToString());
|
|
}
|
|
|
|
|
|
private void cboxFixture_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
int num = 0;
|
|
CheckBox cbox = (CheckBox)sender;
|
|
SysConfigParam.Update(cbox.Name.Replace("cbox", ""), cbox.Checked.ToString());
|
|
TestFixtureManager.Instance.GetTestFixture(int.Parse(cbox.Text.Replace("TC", "").ToString())).Enable = cbox.Checked;
|
|
if(cboxEnableTC1.Checked)
|
|
{
|
|
num++;
|
|
}
|
|
if (cboxEnableTC2.Checked)
|
|
{
|
|
num++;
|
|
}
|
|
if (cboxEnableTC3.Checked)
|
|
{
|
|
num++;
|
|
}
|
|
if (cboxEnableTC4.Checked)
|
|
{
|
|
num++;
|
|
}
|
|
if (cboxEnableTC5.Checked)
|
|
{
|
|
num++;
|
|
}
|
|
if (cboxEnableTC6.Checked)
|
|
{
|
|
num++;
|
|
}
|
|
if(num==1)
|
|
{
|
|
SysConfigParam.Update("TestMethod", "A");
|
|
SysConfigParam.Init();
|
|
}
|
|
}
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
if (cboxLanguage.SelectedIndex == 0)
|
|
{
|
|
LanguageHelper.SetDefaultLanguage("zh-CN");
|
|
}
|
|
else
|
|
{
|
|
LanguageHelper.SetDefaultLanguage("en-US");
|
|
}
|
|
LanguageHelper.LoadLanguage(this, typeof(CommonConfig));
|
|
|
|
FormCollection forms = Application.OpenForms;
|
|
foreach (Form fm in forms)
|
|
{
|
|
if (fm is SubMenuForm)
|
|
{
|
|
((SubMenuForm)fm).ReloadMenu();
|
|
}
|
|
else
|
|
{
|
|
LanguageHelper.LoadLanguage(fm, fm.GetType());
|
|
if(fm is Home)
|
|
{
|
|
fm.FormBorderStyle = FormBorderStyle.None;
|
|
//fm.MaximizedBounds = Screen.PrimaryScreen.WorkingArea;
|
|
fm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
int rowIndex = e.RowIndex;
|
|
int id = int.Parse(dataGridView1.Rows[rowIndex].Cells[0].Value.ToString());
|
|
string cnName = dataGridView1.Rows[rowIndex].Cells[1].Value.ToString();
|
|
string enName = dataGridView1.Rows[rowIndex].Cells[2].Value.ToString();
|
|
int enable = 0;
|
|
if(dataGridView1.Rows[rowIndex].Cells[3].Value!=null && dataGridView1.Rows[rowIndex].Cells[3].Value.ToString()=="1")
|
|
{
|
|
enable = 1;
|
|
}
|
|
int needlogin = 0;
|
|
if (dataGridView1.Rows[rowIndex].Cells[4].Value != null && dataGridView1.Rows[rowIndex].Cells[4].Value.ToString() == "1")
|
|
{
|
|
needlogin = 1;
|
|
}
|
|
string updateSql = $"update submenus set showtext='{cnName}',showentext='{enName}',enable={enable},needlogin={needlogin} where id={id}";
|
|
db.ExecuteNonQuery(updateSql);
|
|
}
|
|
|
|
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
|
{
|
|
if(e.RowIndex>=0 && e.ColumnIndex==3)
|
|
{
|
|
if(e.Value!=null && e.Value.ToString()=="1")
|
|
{
|
|
|
|
}
|
|
//((DataGridViewCheckBoxCell)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex]).Value = true;
|
|
}
|
|
}
|
|
|
|
private void tbarFlyCameraSpeed_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
lblFlyCameraSpeed.Text = $"{tbarFlyCameraSpeed.Value}%";
|
|
}
|
|
|
|
private void cboxConfigName_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
SysConfigParam.Update("ConfigName", cboxConfigName.SelectedItem.ToString());
|
|
}
|
|
}
|
|
}
|