Exemple #1
0
        public void TestTray_Load(object sender, EventArgs e)
        {
            //var i = 1;
            var Keys  = TrayFactory.GetTrayDict.Keys;
            var count = Keys.Count;

            foreach (var key in Keys)
            {
                cmbId.Items.Add(key);
            }
            cmbStart.SelectedIndex      = 0;
            cmbDirect.SelectedIndex     = 0;
            cmbChangeLine.SelectedIndex = 0;
            tp      = new TrayPanel();
            tp.Dock = DockStyle.Fill;
            panel1.Controls.Add(tp);
            if (count > 0)
            {
                cmbId.SelectedIndex = 0;
            }
            else
            {
                return;
            }
            tray = TrayFactory.GetTrayFactory(cmbId.Text);
            tp.SetTrayObj(tray, Color.Gray);
            initControls();
            chShow.Checked = true;
            timer1.Enabled = true;
        }
Exemple #2
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            var cout = cmbId.Items.Count;

            if (cout <= 0)
            {
                return;
            }
            tray = TrayFactory.GetTrayFactory(cmbId.Text);
            tp.SetTrayObj(tray, Color.Gray);
            initControls();
            chShow.Checked = true;
        }
Exemple #3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     SaveParameter();
     TrayFactory.SetTray(cmbId.Text, tray);
     if (TrayFactory.SaveTrayFactory(ConfigTrayName))
     {
         MessageBox.Show("保存托盘参数成功!");
     }
     else
     {
         MessageBox.Show("保存托盘参数失败!");
     }
     tray.IsCalibration = false;
 }
Exemple #4
0
        /// <summary>
        /// 标定计算
        /// </summary>
        /// <param name="key">键</param>
        /// <returns></returns>
        public static bool Calibration(string key)
        {
            Tray tray = TrayFactory.GetTrayFactory(key);

            if (tray == null)
            {
                throw new Exception("托盘不存在!");
            }
            var retR12 = (tray.dic_Index[tray.RowIndex].Row - tray.dic_Index[tray.BaseIndex].Row) != 0;
            var retC12 = (tray.dic_Index[tray.RowIndex].Col - tray.dic_Index[tray.BaseIndex].Col) != 0;
            var retR13 = (tray.dic_Index[tray.ColumnIndex].Row - tray.dic_Index[tray.BaseIndex].Row) != 0;
            var retC13 = (tray.dic_Index[tray.ColumnIndex].Col - tray.dic_Index[tray.BaseIndex].Col) != 0;

            if ((retR12 == retR13) || (retC12 == retC13))
            {
                throw new Exception("三点重合,或者三点再同一直线上!");
            }
            if ((retR12 == retC12) || (retR13 == retC13))
            {
                throw new Exception("三点无法形成直角坐标系,非有效点!");
            }
            var    iRow = 0;
            var    iColumn = 0;
            double detaRowX, detaRowY, detaColX, detaColY;

            if (retR12 && !retR13)
            {
                iRow     = tray.dic_Index[tray.RowIndex].Row - tray.dic_Index[tray.BaseIndex].Row;
                iColumn  = tray.dic_Index[tray.ColumnIndex].Col - tray.dic_Index[tray.BaseIndex].Col;
                detaRowX = tray.RowPosition.X - tray.BasePosition.X;
                detaRowY = tray.RowPosition.Y - tray.BasePosition.Y;
                detaColX = tray.ColumnPosition.X - tray.BasePosition.X;
                detaColY = tray.ColumnPosition.Y - tray.BasePosition.Y;
            }
            else
            {
                iRow     = tray.dic_Index[tray.ColumnIndex].Row - tray.dic_Index[tray.BaseIndex].Row;
                iColumn  = tray.dic_Index[tray.RowIndex].Col - tray.dic_Index[tray.BaseIndex].Col;
                detaColX = tray.RowPosition.X - tray.BasePosition.X;
                detaColY = tray.RowPosition.Y - tray.BasePosition.Y;
                detaRowX = tray.ColumnPosition.X - tray.BasePosition.X;
                detaRowY = tray.ColumnPosition.Y - tray.BasePosition.Y;
            }
            tray.RowXoffset    = detaRowX / iRow;
            tray.RowYoffset    = detaRowY / iRow;
            tray.ColumnXoffset = detaColX / iColumn;
            tray.ColumnYoffset = detaColY / iColumn;
            tray.IsCalibration = true;
            return(true);
        }
Exemple #5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("是否新建托盘型号?", "新建托盘型号", MessageBoxButtons.OKCancel);

            if (result == DialogResult.Cancel)
            {
                return;
            }
            var strType = txtNewPlateType.Text.Trim();

            if (strType == "")
            {
                MessageBox.Show("输入的字符为空!");
                return;
            }
            if (!IsDigitOrNumber(strType))
            {
                MessageBox.Show("输入的字符不是0-9,a-z,A-Z");
                return;
            }
            var Keys  = TrayFactory.GetTrayDict.Keys;
            var count = Keys.Count;

            foreach (var key in Keys)
            {
                if (strType == key)
                {
                    MessageBox.Show("输入的型号已存在!");
                    return;
                }
            }
            var m_tray = new Tray(strType, "", 5, 5);

            TrayFactory.SetTray(strType, m_tray);
            cmbId.Items.Add(strType);
            cmbId.SelectedIndex = cmbId.Items.Count - 1;
            tray = TrayFactory.GetTrayFactory(cmbId.Text);
            tp.SetTrayObj(tray, Color.Gray);
            initControls();
            chShow.Checked = true;
        }
Exemple #6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("是否删除当前托盘型号?", "删除托盘型号", MessageBoxButtons.OKCancel);

            if (result == DialogResult.Cancel)
            {
                return;
            }
            IniHelper.EraseSection(cmbId.Text, ConfigTrayName);
            cmbId.Items.Remove(cmbId.Text);
            TrayFactory.RemoveTray(cmbId.Text);
            if (cmbId.Items.Count <= 0)
            {
                return;
            }
            cmbId.SelectedIndex = 0;
            tray = TrayFactory.GetTrayFactory(cmbId.Text);
            tp.SetTrayObj(tray, Color.Gray);
            initControls();
            chShow.Checked = true;
        }