| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Text.RegularExpressions;
- namespace Core.LZMes.Client.UIM.comm
- {
- public partial class YardControl : UserControl
- {
- private const string _numPattern = @"^\d+$";
- private const string _layerPattern = @"^[ABCabc]?$";
- private const string _yardPattern = @"^[2-7]?$";//= @"^[3-5]?$"
- private bool _enabled = true;
- public new bool Enabled
- {
- get { return _enabled;}
- set
- {
- _enabled = value;
- uteYard.Enabled = _enabled;
- uteRow.Enabled = _enabled;
- uteFl.Enabled = _enabled;
- uteCol.Enabled = _enabled;
- }
- }
- public string Stock
- {
- get { return string.IsNullOrEmpty(uteYard.Text) ? "" : Convert.ToInt32(uteYard.Text,10).ToString(); }
- set
- {
- uteYard.Text = value;
- }
- }
- public string Row
- {
- get { return string.IsNullOrEmpty(uteRow.Text) ? "" : Convert.ToInt32(uteRow.Text, 10).ToString(); }
- set
- {
- uteRow.Text = value;
- }
- }
- public string Column
- {
- get { return string.IsNullOrEmpty(uteCol.Text) ? "" : Convert.ToInt32(uteCol.Text, 10).ToString(); }
- set
- {
- uteCol.Text = value;
- }
- }
- public string Layer
- {
- get { return string.IsNullOrEmpty(uteFl.Text) ? "" : uteFl.Text; }
- set
- {
- uteFl.Text = value;
- }
- }
- public YardControl()
- {
- InitializeComponent();
- }
- public string GetYardFlag()
- {
- string yardFlag = string.Empty;
- if (!string.IsNullOrEmpty(uteYard.Text) && !string.IsNullOrEmpty(uteRow.Text) && !string.IsNullOrEmpty(uteFl.Text) && !string.IsNullOrEmpty(uteCol.Text))
- {
- string rowStr = Convert.ToInt32(uteRow.Text,10).ToString(), colStr = Convert.ToInt32(uteCol.Text,10).ToString();
- if (colStr.Length < 2)
- {
- colStr = "0" + colStr;
- }
- while (rowStr.Length < 3)
- {
- rowStr = "0" + rowStr;
- }
- yardFlag = uteYard.Text + "-" + colStr + uteFl.Text + "-" + rowStr;
- }
- return yardFlag;
- }
- public string GetYardFlagZJ()
- {
- string yardFlag = string.Empty;
- if (!string.IsNullOrEmpty(uteYard.Text) && !string.IsNullOrEmpty(uteRow.Text) && !string.IsNullOrEmpty(uteFl.Text) && !string.IsNullOrEmpty(uteCol.Text))
- {
- string rowStr = Convert.ToInt32(uteRow.Text, 10).ToString(), colStr = Convert.ToInt32(uteCol.Text, 10).ToString();
- if (colStr.Length < 2)
- {
- colStr = "0" + colStr;
- }
- while (rowStr.Length < 2)
- {
- rowStr = "0" + rowStr;
- }
- yardFlag = uteYard.Text + "-" + colStr + uteFl.Text + "-" + rowStr;
- }
- return yardFlag;
- }
- public void SetYardFlag(string yardFlag)
- {
- try
- {
- if (string.IsNullOrEmpty(yardFlag))
- {
- uteYard.Text = string.Empty;
- uteRow.Text = string.Empty;
- uteFl.Text = string.Empty;
- uteCol.Text = string.Empty;
- }
- else
- {
- string[] flags = yardFlag.Split(new char[] { '-' });
- if (flags.Length == 3)
- {
- uteYard.Text = flags[0];
- uteCol.Text = flags[1].Substring(1, flags[1].Length - 2);
- uteFl.Text = flags[1].Substring(flags[1].Length - 1);
- uteRow.Text = flags[2];
- }
- }
- }
- catch (Exception ex)
- {
- }
- }
- public new void Focus()
- {
- uteYard.Focus();
- }
- private void uteYard_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyValue == 39 || e.KeyValue == 40 || e.KeyValue == 13)
- {
- uteCol.Focus();
- }
- }
- private void uteYard_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!"2345".Contains(e.KeyChar) && (int)e.KeyChar != 8)
- {
- e.Handled = true;
- }
- e.KeyChar = char.ToUpper(e.KeyChar);
- }
- private void uteYard_TextChanged(object sender, EventArgs e)
- {
- Infragistics.Win.UltraWinEditors.UltraTextEditor te = (Infragistics.Win.UltraWinEditors.UltraTextEditor)sender;
- if (!Regex.IsMatch(te.Text, _yardPattern))
- {
- te.Text = string.Empty;
- }
- if (te.Text.Length > 0)
- {
- uteCol.Focus();
- uteCol.SelectAll();
- }
- }
- private void uteRow_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyValue == 37 || e.KeyValue == 38)
- {
- uteFl.Focus();
- uteFl.SelectAll();
- }
- }
- private void uteRow_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (((((int)e.KeyChar) < 48 || ((int)e.KeyChar) > 57)) && (int)e.KeyChar != 8)
- {
- e.Handled = true;
- }
- if ((int)e.KeyChar == 8 && string.IsNullOrEmpty(uteRow.Text))
- {
- uteFl.Focus();
- uteFl.SelectAll();
- }
- }
- private void uteRow_TextChanged(object sender, EventArgs e)
- {
- Infragistics.Win.UltraWinEditors.UltraTextEditor te = (Infragistics.Win.UltraWinEditors.UltraTextEditor)sender;
- if (!Regex.IsMatch(te.Text, _numPattern))
- {
- te.Text = string.Empty;
- }
- }
- private void uteFl_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyValue == 39 || e.KeyValue == 40 || e.KeyValue == 13)
- {
- uteRow.Focus();
- uteRow.SelectAll();
- }
- else if (e.KeyValue == 37 || e.KeyValue == 38)
- {
- uteCol.Focus();
- uteCol.SelectAll();
- }
- }
- private void uteFl_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!"AaBbCc".Contains(e.KeyChar) && (int)e.KeyChar != 8)
- {
- e.Handled = true;
- }
- if ((int)e.KeyChar == 8 && string.IsNullOrEmpty(uteFl.Text))
- {
- uteCol.Focus();
- uteCol.SelectAll();
- }
- }
- private void uteFl_TextChanged(object sender, EventArgs e)
- {
- Infragistics.Win.UltraWinEditors.UltraTextEditor te = (Infragistics.Win.UltraWinEditors.UltraTextEditor)sender;
- if (!Regex.IsMatch(te.Text, _layerPattern))
- {
- te.Text = string.Empty;
- }
- else
- {
- te.Text = te.Text.ToUpper();
- }
- if (te.Text.Length > 0)
- {
- uteRow.Focus();
- uteRow.SelectAll();
- }
- }
- private void uteCol_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (((((int)e.KeyChar) < 48 || ((int)e.KeyChar) > 57)) && (int)e.KeyChar != 8)
- {
- e.Handled = true;
- }
- if ((int)e.KeyChar == 8 && string.IsNullOrEmpty(uteCol.Text))
- {
- uteYard.Focus();
- uteYard.SelectAll();
- }
- }
- private void uteCol_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyValue == 39 || e.KeyValue == 40 || e.KeyValue == 13)
- {
- uteFl.Focus();
- uteFl.SelectAll();
- }
- else if (e.KeyValue == 37 || e.KeyValue == 38)
- {
- uteYard.Focus();
- uteYard.SelectAll();
- }
- }
- private void uteCol_TextChanged(object sender, EventArgs e)
- {
- Infragistics.Win.UltraWinEditors.UltraTextEditor te = (Infragistics.Win.UltraWinEditors.UltraTextEditor)sender;
- if (!Regex.IsMatch(te.Text, _numPattern))
- {
- te.Text = string.Empty;
- }
- if (te.Text.Length > 1)
- {
- uteFl.Focus();
- uteFl.SelectAll();
- }
- }
- }
- }
|