示例#1
0
 void frmProtocolTest_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (this.serverSocket != null)
     {
         this.serverSocket.Close();
     }
     if (changed)
     {
         DialogResult dr = MessageBox.Show("协议内容已经改变,需要保存吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         if (dr == DialogResult.Yes)
         {
             CommandMatchHelper.exportCommand(pList);
         }
     }
 }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string name = (string)this.cbCmd.SelectedItem;

            if (name != null)
            {
                if (CommandMatchHelper.updateCommand(pList, new CommandMatch(name, this.txtCmd.Text)))
                {
                    this.changed = true;
                }
                else
                {
                    MessageBox.Show("保存失败,可能已经存在该命令!");
                }
            }
        }
示例#3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            DeviceCommandManager.initialCommandList();
            List <CommandMatch> cmdList = CommandMatchHelper.importCommand();

            DeviceCommandManager.matchCommand(cmdList);

            serverForm form = new serverForm();

            services.showStateForm = form;
            //frmProtocolTest form = new frmProtocolTest();
            Application.Run(form);
        }
示例#4
0
        public frmProtocolTest()
        {
            InitializeComponent();


            pList = CommandMatchHelper.importCommand();
            if (pList == null)
            {
                pList = new List <CommandMatch>();
            }

            Array array = Enum.GetValues(typeof(enumDeviceCommand));

            for (int i = 0; i < array.Length; i++)
            {
                CommandMatchHelper.addCommand(pList, new CommandMatch(array.GetValue(i).ToString(), ""));
            }
            //CommandMatchHelper.addCommand(pList, new CommandMatch(enumDeviceCommand.检查红灯状态.ToString(), ""));
            //CommandMatchHelper.addCommand(pList, new CommandMatch(enumDeviceCommand.检查绿灯状态.ToString(), ""));
            //CommandMatchHelper.addCommand(pList, new CommandMatch(enumDeviceCommand.检查黄灯状态.ToString(), ""));
            // 。。。

            foreach (CommandMatch c in pList)
            {
                this.cbCmd.Items.Add(c.name);
            }

            initial_udp_server(Program.inputPort);

            this.FormClosing += frmProtocolTest_FormClosing;

            this.cbCmd.SelectedIndexChanged += cbCmd_SelectedIndexChanged;
            if (this.cbCmd.Items.Count > 0)
            {
                this.cbCmd.SelectedIndex = 0;
            }
        }