public Device GetDeviceByName(DeviceType deviceType)
        {
            Device device = PresentationController.Instance.SelectedSlide.DeviceList.Where(s => s.Name == deviceType.Name).FirstOrDefault();
            if (device != null) return device;

            device = deviceType.CreateNewDevice();
            PresentationController.Instance.SelectedSlide.DeviceList.Add(device);
            return device;
        }
Exemple #2
0
 public DeviceNode(DeviceType ADeviceType)
     : base(ADeviceType.Name)
 {
     this.DeviceType = ADeviceType;
     this.Device = ADeviceType.CreateNewDevice();
 }
 Device AddNewNode(DeviceType d)
 {
     if (!d.Visible)
         return null;
     DeviceNode node = new DeviceNode(d);
     Device dev;
     if (CurrentSlide.DeviceList.Any(x => x.Type.Equals(d)))
     {
         node.Checked = true;
         dev = CurrentSlide.DeviceList.Find(x => x.Type.Equals(d));
     }
     else
         dev = d.CreateNewDevice(DesignerClient.Instance.PresentationWorker.GetGlobalDeviceSources());
     if (nodesByDevice.ContainsKey(d))
     {
         equipmentList.Nodes.Remove(nodesByDevice[d]);
         nodesByDevice[d] = node;
     }
     else
         nodesByDevice.Add(d, node);
     bool? isOnline = EquipmentController.Instance.IsOnline(dev);
     node.TextColor = isOnline.HasValue ? (isOnline.Value ? Color.Green : Color.Red) : Color.Black;
     node.Device = dev;
     equipmentList.Nodes.Add(node);
     return dev;
 }