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.
183 lines
6.3 KiB
C#
183 lines
6.3 KiB
C#
using Rs.Controls;
|
|
using Rs.DataAccess;
|
|
using Rs.Motion;
|
|
using Rs.Motion.Base;
|
|
using Rs.MotionPlat.Commom;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Rs.MotionPlat
|
|
{
|
|
|
|
public partial class FormIO2 : BaseForm
|
|
{
|
|
List<ButtonEx> btnList = new List<ButtonEx>();
|
|
|
|
private PanelEx menuPanel;
|
|
private PanelEx ioPanel;
|
|
private TableLayoutPanel menuTable;
|
|
private bool V = true;
|
|
private InAndOut inout = new InAndOut();
|
|
private string m_query = "";
|
|
public FormIO2()
|
|
{
|
|
InitializeComponent();
|
|
menuPanel = new PanelEx();
|
|
ioPanel = new PanelEx();
|
|
menuPanel.BackColor = Color.FromArgb(11, 16, 36);
|
|
menuTable = new TableLayoutPanel();
|
|
|
|
}
|
|
|
|
public FormIO2(string query)
|
|
{
|
|
InitializeComponent();
|
|
menuPanel = new PanelEx();
|
|
ioPanel = new PanelEx();
|
|
menuPanel.BackColor = Color.FromArgb(11, 16, 36);
|
|
menuTable = new TableLayoutPanel();
|
|
m_query = query;
|
|
if(m_query!="")
|
|
{
|
|
V = false;
|
|
}
|
|
else
|
|
{
|
|
V = true;
|
|
}
|
|
}
|
|
|
|
private void FormIO2_Load(object sender, EventArgs e)
|
|
{
|
|
if (!V)
|
|
{
|
|
ioPanel.Dock = DockStyle.Fill;
|
|
inout.Dock = DockStyle.Fill;
|
|
ioPanel.Controls.Add(inout);
|
|
menuPanel.Height = 50;
|
|
menuPanel.Dock = DockStyle.Top;
|
|
AddMneu();
|
|
menuPanel.Width = 170;
|
|
menuTable.Dock = DockStyle.Fill;
|
|
menuPanel.Controls.Add(menuTable);
|
|
|
|
this.Controls.Add(ioPanel);
|
|
this.Controls.Add(menuPanel);
|
|
}
|
|
else
|
|
{
|
|
|
|
ioPanel.Dock = DockStyle.Fill;
|
|
inout.Dock = DockStyle.Fill;
|
|
ioPanel.Controls.Add(inout);
|
|
menuPanel.Dock = DockStyle.Left;
|
|
AddMneu();
|
|
menuTable.Dock = DockStyle.Fill;
|
|
menuPanel.Controls.Add(menuTable);
|
|
this.Controls.Add(ioPanel);
|
|
this.Controls.Add(menuPanel);
|
|
}
|
|
}
|
|
|
|
private void AddMneu()
|
|
{
|
|
SqliteHelper db = new SqliteHelper();
|
|
DataTable dt = new DataTable();
|
|
if(string.IsNullOrEmpty(m_query))
|
|
{
|
|
V = true;
|
|
dt = db.GetDataTable("select * from io where enable=1 order by sortindex asc");
|
|
}
|
|
else
|
|
{
|
|
V = false;
|
|
dt = db.GetDataTable($"select * from io where enable=1 and cardname like '%{m_query}%' order by sortindex asc");
|
|
}
|
|
if (!V)
|
|
{
|
|
menuTable.ColumnCount = dt.Rows.Count + 1;
|
|
menuTable.RowCount = 1;
|
|
menuTable.ColumnStyles.Clear();
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
menuTable.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 120));
|
|
ButtonEx button = new ButtonEx();
|
|
button.SelectedColor = Color.Red;
|
|
button.Cursor = Cursors.Hand;
|
|
btnList.Add(button);
|
|
button.Tag = IoManager.Instance.GetCard(ushort.Parse(dt.Rows[i]["cardid"].ToString()), dt.Rows[i]["vender"].ToString().ToLower());
|
|
button.Click += Button_Click;
|
|
button.ForeColor = Color.White;
|
|
button.BackColor = Color.FromArgb(19, 52, 104);
|
|
button.Margin = new Padding(0, 3, 0, 0);
|
|
button.ShowText = dt.Rows[i]["cardname"].ToString();
|
|
button.Dock = DockStyle.Fill;
|
|
button.FlatStyle = FlatStyle.Flat;
|
|
button.FlatAppearance.BorderColor = System.Drawing.Color.White;
|
|
menuTable.Controls.Add(button, i, 0);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
menuTable.RowCount = dt.Rows.Count + 1;
|
|
menuTable.ColumnCount = 1;
|
|
menuTable.RowStyles.Clear();
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
menuTable.RowStyles.Add(new RowStyle(SizeType.Absolute, 53));
|
|
ButtonEx button = new ButtonEx();
|
|
button.SelectedColor = Color.Red;
|
|
button.Cursor = Cursors.Hand;
|
|
btnList.Add(button);
|
|
button.Tag = IoManager.Instance.GetCard(ushort.Parse(dt.Rows[i]["cardid"].ToString()), dt.Rows[i]["vender"].ToString().ToLower());
|
|
button.Click += Button_Click;
|
|
button.ForeColor = Color.White;
|
|
button.BackColor = Color.FromArgb(19, 52, 104);
|
|
button.Margin = new Padding(0, 3, 0, 0);
|
|
button.ShowText = dt.Rows[i]["cardname"].ToString();
|
|
button.Dock = DockStyle.Fill;
|
|
button.FlatStyle = FlatStyle.Flat;
|
|
button.FlatAppearance.BorderColor = System.Drawing.Color.White;
|
|
menuTable.Controls.Add(button, 0, i);
|
|
}
|
|
}
|
|
if (btnList != null && btnList.Count > 0)
|
|
{
|
|
btnList[0].PerformClick();
|
|
}
|
|
}
|
|
private void ClearSelect()
|
|
{
|
|
foreach (ButtonEx btn in btnList)
|
|
{
|
|
btn.Selected = false;
|
|
}
|
|
}
|
|
private void Button_Click(object sender, EventArgs e)
|
|
{
|
|
int subWdith = 0;
|
|
if(V)
|
|
{
|
|
subWdith = 170;
|
|
}
|
|
else
|
|
{
|
|
subWdith = 400;
|
|
}
|
|
int btnWidth = (((Screen.PrimaryScreen.WorkingArea.Width - subWdith) / 2) - 130) / 4;
|
|
ClearSelect();
|
|
((ButtonEx)sender).Selected = true;
|
|
IIOCard card = (IIOCard)(((ButtonEx)sender).Tag);
|
|
if (card == null) return;
|
|
inout.LoadIO(card, btnWidth - 10, GlobalUser.UserName);
|
|
}
|
|
}
|
|
}
|