예제 #1
0
 private void textBox2_GotFocus(object sender, EventArgs e)
 {
     button1.Focus();
     FormInput input = new FormInput(formFrame);
     ParamItem item = new ParamItem();
     item.param_value = byte.Parse(textBox2.Text);
     item.unit = "";
     item.param_type = TypeCode.Byte;
     item.name = "线振机时间";
     input.SetValue(item, true);
     input.ShowDialog();
     textBox2.Text = input.GetValue().param_value.ToString();
 }
예제 #2
0
        private void tb_number_GotFocus(object sender, EventArgs e)
        {
            banOcxCtl1.Focus();
            ParamItem item = new ParamItem();
            item.name = "设备地址";
            item.unit = "";
            item.param_type = TypeCode.Int32;
            item.param_value = Convert.ToInt32(tb_number.Text);

            FormInput dlg = new FormInput(formFrame);
            dlg.SetValue(item, true);
            dlg.ShowDialog();
            if (dlg.GetAck())
            {
                item = dlg.GetValue();
                tb_number.Text = item.param_value.ToString();
                //ChangeCalibWeight(((CalibInfo)alSource[r]).Addr, Convert.ToInt32(item.param_value));

            }
            dlg.Dispose();
        }
예제 #3
0
        private void pnLeft_Click(object sender, EventArgs e)
        {
            int title_height = 100;
            if (Control.MousePosition.Y < (pnLeft.Top + title_height + 48)) return;     //״̬���߶�Ϊ48pix
            int height = (pnLeft.Height - title_height) / PageSize;
            int tempIndex = (Control.MousePosition.Y - pnLeft.Top - title_height - 48) / height;
            if (tempIndex != SelectIndex)
            {
                SelectIndex = -1;
                pnLeft.Invalidate();
                return;     //�û���ѡ���ƶ���������¼
            }
            int index = SelectIndex + PageIndex * PageSize;

            if (CategoryIndex < 0) return;
            Category cate = formFrame.visCateList[CategoryIndex];
            if (index >= cate.list.Count) return;

            if ((SelectIndex < 0) || (SelectIndex >= CurPageList.Count))
            {
                return;
            }

            if (CategoryIndex == formFrame.configManage.cfg.paramFormWeight.EverySensorCateIndex)    //��������������IJ���
            {
                FormMsgBox.Show("index:" + index.ToString() + ",SelectIndex:" + SelectIndex.ToString(), "tip");
                return;
            }

            bool bOverLen = (CurPageList[SelectIndex].Length > MaxItemStringlen);
            if ((cate.list[index].write != 0) || bOverLen)
            {
                if (timer.Enabled)
                {
                    timer.Enabled = false;
                }
                ParamItem item;
                if ((SelectIndex >= 0) && (SelectIndex < itemListRecv.Count))
                {
                    item = itemListRecv[SelectIndex];
                }
                else
                {
                    item = itemListSend[SelectIndex];
                }
                item.param_type = cate.list[index].param_type;
                item.param_len = cate.list[index].param_len;
                item.unit = cate.list[index].unit;
                item.op_write = cate.list[index].write;

                if ((cate.list[index].listOption != null) && (cate.list[index].listOption.Count > 0))
                {
                    //ѡ��������û�ѡ������
                    FormRadio dlg = new FormRadio(this.formFrame);
                    dlg.SetValue(item, cate.list[index].listOption);
                    dlg.ShowDialog();
                    if (dlg.bAck)
                    {
                        if (JudgePurview())
                        {
                            item = dlg.GetValue();
                            item.op_write = 1;
                            Protocol protocol = formFrame.protocol;
                            SerialOperate Serial = SerialOperate.instance;
                            byte[] buf;
                            itemListModify.Clear();
                            itemListModify.Add(item);
                            int len = protocol.Produce(formFrame.configManage.cfg.paramDeviceId.Ctrl, out buf, itemListModify);
                            if (len > 0) Serial.Send(buf, len);

                            System.Threading.Thread.Sleep(100);
                            ShowPage(PageIndex);
                            pnLeft.Invalidate();
                        }
                    }
                    dlg.Dispose();
                }
                else
                {
                    //����������û���������
                    InputInterface dlg;
                    dlg = new FormInput(this.formFrame);

                    dlg.SetValue(item, !bOverLen);
                    dlg.ShowDialog();
                    if (dlg.GetAck())
                    {
                        if (JudgePurview())
                        {
                            item = dlg.GetValue();
                            item.op_write = 1;
                            Protocol protocol = formFrame.protocol;
                            SerialOperate Serial = SerialOperate.instance;
                            byte[] buf;
                            itemListModify.Clear();
                            itemListModify.Add(item);
                            int len = protocol.Produce(formFrame.configManage.cfg.paramDeviceId.Ctrl, out buf, itemListModify);
                            if (len > 0) Serial.Send(buf, len);

                            System.Threading.Thread.Sleep(100);
                            ShowPage(PageIndex);
                            pnLeft.Invalidate();
                        }
                    }
                    dlg.Dispose();
                }

                if (formFrame.visCateList[CategoryIndex].refresh == 2)
                {
                    timer.Enabled = true;
                }
            }
            SelectIndex = -1;
        }
예제 #4
0
        private void dgCalib_CurrentCellChanged(object sender, EventArgs e)
        {
            int r = dgCalib.CurrentCell.RowNumber;
            int c = dgCalib.CurrentCell.ColumnNumber;
            //FormMsgBox.Show(r.ToString() + "|" + c.ToString(), "");
            if (c == 1)
            {
                ParamItem item = new ParamItem();
                item.name = "�궨����";
                item.unit = "kg";
                item.param_type = TypeCode.Int32;
                item.param_value = ((CalibInfo)alSource[r]).Weight;
                FormInput dlg = new FormInput(formFrame);
                dlg.SetValue(item, true);
                dlg.ShowDialog();
                if (dlg.GetAck())
                {
                    item = dlg.GetValue();
                    ChangeCalibWeight(((CalibInfo)alSource[r]).Addr, Convert.ToInt32(item.param_value));
                    DataBind();
                }
                dlg.Dispose();
             }
            else if (c == 2)
            {

            }
        }
예제 #5
0
        private void pnLeft_Click(object sender, EventArgs e)
        {
            byte slaveAddr = formFrame.configManage.cfg.paramDeviceId.Ctrl;
            //int title_height = 90;
            if (Control.MousePosition.Y < (pnLeft.Top + title_height)) return;     //״̬���߶�Ϊ48pix
            int height = (pnLeft.Height - title_height) / PageSize;
            int tempIndex = (Control.MousePosition.Y - pnLeft.Top - title_height) / height;
            if (tempIndex != SelectIndex)
            {
                SelectIndex = -1;
                pnLeft.Invalidate();
                return;     //�û���ѡ���ƶ���������¼
            }
            int index = SelectIndex + PageIndex * PageSize;

            ParamItem item;

            item = TotalPageList[index];
            if (item.param_id == 34)
            {
                FormPicture dlg = new FormPicture(formFrame);
                dlg.ShowDialog();
                dlg.Dispose();
                int id = dlg.GetSelectPicID();
                if (id != -1)
                {
                    //MessageBox.Show(id.ToString());
                    TotalPageList[index].param_value = id;
                    ShowPage(PageIndex); //ˢ�µ�ǰҳ������.
                    pnLeft.Invalidate();
                }
            }
            else if (item.param_id == 48)
            {
                int id = ParseID(TotalPageList[0].param_value);
                formFrame.ucXzj.XZJ_Load(id);
                formFrame.ShowUC(formFrame.ucXzj);

                //TotalPageList[index].param_value = "�������...";
                //ShowPage(PageIndex); //ˢ�µ�ǰҳ������.
               // pnLeft.Invalidate();

            }
            else
            {
                //����������û���������
                InputInterface dlg;
                if (item.permit_write == 0)
                {
                    return;
                }

                dlg = new FormInput(this.formFrame);

                dlg.SetValue(item, true);

                dlg.ShowDialog();
                pnLeft.Invalidate();                                  //�������FormMsgBox�Ի�����ʧ����Ļûˢ�µ����
                if (dlg.GetAck())
                {
                    //������޸����߲���������Ҫ�������������
                    UpdateTotalList(index, dlg.GetValue());

                    ShowPage(PageIndex); //ˢ�µ�ǰҳ������.
                    pnLeft.Invalidate();

                }
                dlg.Dispose();
            }

            SelectIndex = -1;
        }