private void AddTags2Group(Form home, KVGroup homeGroup, KeyencePlcDrive kVDrive) { Control.ControlCollection controlCollection = home.Controls; foreach (Control control in controlCollection) { //if (control.Controls != null) //{ // AddGroup(home, homeGroup); //} if (control.GetType().GetInterface("KVBox") != null) { foreach (ITag tag in ((KVBox)control).KVTags) { homeGroup.AddTag(tag); tag.ValueChangeEvent += ((KVBox)control).ValueChange; tag.Parent = kVDrive; } } //KVBox box = control as KVBox; //if (box!=null) //{ // foreach(ITag tag in box.KVTags) // { // homeGroup.AddTag(tag); // } //} } }
private void Home_Load(object sender, EventArgs e) { ParaSettingForm = new ParaSetting() { FromWindow = this }; KeyencePlcDrive kvPLCDrive = new KeyencePlcDrive(1, "KeyencePLCDrive", "192.168.50.211", 5000); //将窗口内的 TAG 加到相应的 Group 里面 AddTags2Group(this, Groups[0] = new KVGroup(true, 1, "homeGroup", 50, new List <ITag>()), kvPLCDrive); AddTags2Group(ParaSettingForm, Groups[1] = new KVGroup(false, 2, "paraSettingGroup", 50, new List <ITag>()), kvPLCDrive); kvPLCDrive.Groups = Groups; kvPLCDrive.init(); }