Exemple #1
0
        void _udpPortScan_RobotResponseEvent(object sender, RobotFinderLibrary.ProgressEventArgs args)
        {
            #region 记录这个IP
            if (string.IsNullOrEmpty(args.ResponseText))
            {
                return;
            }

            string[] tt = args.ResponseText.Replace("Robot_", string.Empty).Split(':');
            if (tt != null && tt.Length >= 2)
            {
                try
                {
                    RobotConfigItem rci = new RobotConfigItem();
                    rci.NickName = args.ResponseText;
                    rci.IP       = tt[0];
                    rci.Port     = int.Parse(tt[1]);
                    totalRobotList.Add(rci);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.ToString());
                }
            }
            #endregion

            //刷新列表
            UpdateConnectionList();
        }
 private void lvConnectionList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lvConnectionList.SelectedItems.Count > 0)
     {
         SelectedRobot = (RobotConfigItem)lvConnectionList.SelectedItems[0].Tag;
     }
 }
        private void btnModify_Click(object sender, EventArgs e)
        {
            if (lvConnectionList.SelectedItems.Count > 0)
            {
                RobotConfigItem rci = (RobotConfigItem)lvConnectionList.SelectedItems[0].Tag;

                DeviceEditorForm def = new DeviceEditorForm();
                def.Text     = "修改";
                def.NickName = rci.NickName;
                def.IP       = rci.IP;
                def.Port     = rci.Port;
                if (def.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    rci.NickName = def.NickName;
                    rci.IP       = def.IP;
                    rci.Port     = def.Port;

                    SaveConfig();
                    LoadConfig();
                }
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DeviceEditorForm def = new DeviceEditorForm();

            def.Text = "新增";
            if (def.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (string.IsNullOrEmpty(def.NickName) || string.IsNullOrEmpty(def.IP) || def.Port <= 100)
                {
                    return;
                }
                else
                {
                    RobotConfigItem rci = new RobotConfigItem();
                    rci.NickName = def.NickName;
                    rci.IP       = def.IP;
                    rci.Port     = def.Port;
                    RobotConfigList.Add(rci);

                    SaveConfig();
                    LoadConfig();
                }
            }
        }