public Client(AbstractFactory factory) { water = factory.CreateWater(); bottle = factory.CreateBottle(); cover = factory.CreateCover(); label = factory.CreateLabel(); }
public override void Interact(AbstractLabel label) { System.Console.WriteLine(this + " interact with " + label); }
public override void Interact(AbstractWater water, AbstractCover cover, AbstractLabel label) { Console.WriteLine(this + " interacts with {0}, {1} and {2}", water, cover, label); }
//private void UpdateTreeView2() //{ // for (int i = 0; i < 16; i++) // { // string childNode = "chanel_" + i.ToString(); // TreeNode treeNode = new TreeNode(childNode); // treeNode.Checked = true; // _treeView2.Nodes.Add(treeNode); // } // foreach (var item in _treeView2.Nodes) // { // int geWei = 0; // int shiWei = 0; // TreeNode treeNode = (TreeNode)item; // for (int i = 0; i <= 377; i++) // { // geWei = i % 100 % 10; // shiWei = i % 100 / 10; // if (geWei > 7 || shiWei > 7) // { // continue; // } // string childNode = "label_" + i.ToString(); // TreeNode labelNode = new TreeNode(childNode); // labelNode.Checked = true; // for (int j = 0; j < 4; j++) // { // string SDILabel = string.Empty; // switch (j) // { // case 0: SDILabel = "SDI_00"; break; // case 1: SDILabel = "SDI_01"; break; // case 2: SDILabel = "SDI_10"; break; // case 3: SDILabel = "SDI_11"; break; // } // TreeNode SDINode = new TreeNode(SDILabel); // for (int k = 0; k < 4; k++) // { // string SSMLabel = string.Empty; // switch (k) // { // case 0: SSMLabel = "SSM_00"; break; // case 1: SSMLabel = "SSM_01"; break; // case 2: SSMLabel = "SSM_10"; break; // case 3: SSMLabel = "SSM_11"; break; // } // TreeNode SSMNode = new TreeNode(SSMLabel); // SSMNode.Checked = true; // SDINode.Nodes.Add(SSMNode); // } // SDINode.Checked = true; // labelNode.Nodes.Add(SDINode); // } // treeNode.Nodes.Add(labelNode); // } // } //} public void UpdateTreeView1() { //设备里的信息的新信息添加到_treeView1中 TreeNode node = _treeView1.TopNode; for (int i = 0; i < 16; i++) { Channe429Receive receiveCh = (Channe429Receive)_device429.GetSpecificItem(i); if (!receiveCh.Enabled) { continue; } SimpleTreeNode chNode; if (!node.Nodes.ContainsKey(receiveCh.Name)) { chNode = new SimpleTreeNode() { Text = receiveCh.Name, Name = receiveCh.Name, Path = receiveCh.Path }; node.Nodes.Add(chNode); } else { chNode = (SimpleTreeNode)node.Nodes[receiveCh.Name]; } int count = 0; while (true) { AbstractLabel label429 = null; label429 = receiveCh.GetSpecificItem(count++); if (label429 == null) { break; } if (!chNode.Nodes.ContainsKey(label429.Name)) { SimpleTreeNode labelNode = new SimpleTreeNode() { Text = label429.Name, Name = label429.Name, Path = label429.Path }; chNode.AddChildNode(labelNode); } if (!((Label429)label429).IsSelected) { chNode.Nodes[label429.Name].ForeColor = Color.Gray; } else { chNode.Nodes[label429.Name].ForeColor = Color.Black; } } } //去除Treeview中多余的条目 TreeNode topNode = _treeView1.TopNode; for (int i = 0; i < topNode.Nodes.Count; i++) { SimpleTreeNode channelNode = (SimpleTreeNode)topNode.Nodes[i]; string name = channelNode.Name; Channe429Receive channe429Receive = (Channe429Receive)_device429.GetSpecificItem(name); if (null == channe429Receive) { topNode.Nodes.Remove(channelNode); i--; } else { for (int j = 0; j < channelNode.Nodes.Count; j++) { SimpleTreeNode labelNode = (SimpleTreeNode)channelNode.Nodes[j]; Label429 label = (Label429)channe429Receive.GetSpecificItem(labelNode.Name); if (null == label) { channelNode.Nodes.Remove(labelNode); j--; } } } } node.ExpandAll(); }
public abstract void Interact(AbstractWater water, AbstractCover cover, AbstractLabel label);
public override void Delete(AbstractLabel t) { _componentDic.Delete(t); }
public override void Add(AbstractLabel t) { _componentDic.Add(t); }
public abstract void Interact(AbstractLabel label);