| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- using Core.StlMes.Client.LgClassModel;
- namespace Core.StlMes.Client.LgCommon
- {
- public partial class frmManualOperate : Form
- {
- private string _DEVICE_POSITION = ""; //设备位置:BOF01
- private string _OBJECTPOS = ""; //当前工位:BOF01_DEVICE
- private CommandCollection _CC; //当前岗位手动操作配置集合
- private COM_STL_COMMAND _csc; //返回选中的手动操作
- /// <summary>
- /// COM_STL_COMMAND%ROWTYPE
- /// </summary>
- public COM_STL_COMMAND CSC
- {
- get { return _csc; }
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="DEVICE_POSITION">设备位置:BOF01</param>
- /// <param name="OBJECTPOS">当前工位:BOF01_DEVICE</param>
- /// <param name="MOC">当前岗位手动操作配置集合</param>
- /// <param name="ob"></param>
- public frmManualOperate(string DEVICE_POSITION, string OBJECTPOS, CommandCollection CC)
- {
- InitializeComponent();
- this._DEVICE_POSITION = DEVICE_POSITION.ToUpper();
- this._OBJECTPOS = OBJECTPOS.ToUpper();
- this._CC = CC;
- }
- private void frmManualOperate_Load(object sender, EventArgs e)
- {
- InitUnitItems();
- AdjustForm();
- }
- /// <summary>
- /// 初始化操作配置
- /// </summary>
- private void InitUnitItems()
- {
- try
- {
- if (_CC != null)
- {
- COM_STL_COMMAND csc;
- for (int i = 0; i < _CC.Count; i++)
- {
- csc = _CC[i];
- if (csc == null) continue;
- if (_OBJECTPOS.Equals(csc.OBJECTPOS)) continue; //当前设备位置与目标位置一致
- if (_OBJECTPOS.Equals(csc.OBJECTPOS.Replace("%", _DEVICE_POSITION))) continue; //当前设备位置与目标位置一致
- if (csc.OPTTYPE == "2" && csc.OBJECTPOS.IndexOf(_DEVICE_POSITION) == 0) continue; //所处岗位与目标岗位一致
- if (_OBJECTPOS.Contains("IDLE") && csc.VISIBLE_IDLE != "1") continue;
- if (_OBJECTPOS.Contains("FRONT") && csc.VISIBLE_FRONT != "1") continue;
- if (_OBJECTPOS.Contains("DEVICE") && csc.VISIBLE_DEVICE != "1") continue;
- if (_OBJECTPOS.Contains("BACK") && csc.VISIBLE_BACK != "1") continue;
- if (csc.OPTTYPE == "1") unit_Normal.Add(csc);
- else if (csc.OPTTYPE == "2") unit_Abnormal.Add(csc);
- else if (csc.OPTTYPE == "3") unit_Switch.Add(csc);
- }
- }
- }
- catch { }
- }
- private void AdjustForm()
- {
- try
- {
- unit_Switch.Visible = unit_Switch.Count > 0;
- bool Hidden = (unit_Abnormal.Count == 0 && unit_Switch.Count == 0);
- panel2.Visible = !Hidden;
- if (Hidden)
- {
- Size iSize = panel2.Size;
- Point point = btnOK.Location;
- point.Offset(0, 0 - iSize.Height);
- btnOK.Location = point;
- point = btnCancel.Location;
- point.Offset(0, 0 - iSize.Height);
- btnCancel.Location = point;
- point = new Point(panel1.Size);
- point.Offset(0, 0 - iSize.Height);
- panel1.Size = new Size(point);
- point = new Point(this.Size);
- point.Offset(0, 0 - iSize.Height);
- this.Size = new Size(point);
- }
- }
- catch { }
- finally
- {
- ClsControlPack.GetChildWindowLocation(this.Size);
- }
- }
- private COM_STL_COMMAND GetSelection()
- {
- if (unit_Normal.Value != null) return unit_Normal.Value;
- else if (unit_Abnormal.Value != null) return unit_Abnormal.Value;
- else if (unit_Switch.Value != null) return unit_Switch.Value;
- else return null;
- }
- private void btnOK_Click(object sender, EventArgs e)
- {
- _csc = GetSelection();
- if (_csc == null)
- {
- MessageBox.Show("未选择任何操作!\n如需退出,请点击【退出】按钮。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- }
- }
|