private void refreshStripButton_Click(object sender, EventArgs e) { CurrentSlide = PresentationController.Instance.SelectedSlide; nodesByDevice.Clear(); equipmentList.Nodes.Clear(); FillDeviceTypeNodes(); SelectedNode = nodesByDevice.First().Value; equipmentList.SelectedNode = SelectedNode; }
private void NodeChanging(DeviceNode NewNode) { if (OnDeviceSelected != null) { if (NewNode != null && CurrentSlide != null) OnDeviceSelected(NewNode.Device); else OnDeviceSelected(null); } if (NewNode != null) { LoadDeviceProperties(NewNode.Device); } }
void equipmentList_Selected(object sender, EventArgs e) { if (equipmentList.SelectedNode != null) { DeviceNode newNode = equipmentList.SelectedNode as DeviceNode; NodeChanging(newNode); SelectedNode = newNode; } }
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; }
void Instance_OnSlideSelectionChanged(IEnumerable<Slide> NewSelection) { string currentNodeText = null; if(equipmentList.SelectedNode != null) currentNodeText=equipmentList.SelectedNode.Text; CurrentSlide = NewSelection.FirstOrDefault(); nodesByDevice.Clear(); equipmentList.Nodes.Clear(); if (CurrentSlide != null) { FillDeviceTypeNodes(); //EquipmentController.Instance.DeviceTypes.ForEach(AddNodeVoid); if (equipmentList.Nodes.Count > 0) { SelectedNode = equipmentList.Nodes[0] as DeviceNode; equipmentList.SelectedNode = SelectedNode; } } else { propertyGrid.SelectedObject = null; } for (int i = 0; i < equipmentList.Nodes.Count; i++) // Перейдем к тому же оборудованию, что было выделено ранее { if (equipmentList.Nodes[i].Text == currentNodeText) equipmentList.SelectedNode = equipmentList.Nodes[i]; } return; if (NewSelection != null && NewSelection.Count() > 0) { CurrentSlide = NewSelection.First(); LoadDeviceProperties(this.SelectedDevice); } else { CurrentSlide = null; ClearDeviceProperties(); } }
public void Init() { EquipmentController.CreateEquipmentController(); EquipmentController.Instance.Control = this; nodesByDevice = new SortedDictionary<DeviceType, DeviceNode>(); CurrentSlide = PresentationController.Instance.SelectedSlide; FillDeviceTypeNodes(); //EquipmentController.Instance.DeviceTypes.ForEach(AddNodeVoid); PresentationController.Instance.OnSlideSelectionChanged += new SlideSelectionChanged(Instance_OnSlideSelectionChanged); PresentationController.Instance.OnHardwareStateChanged += new Action<EquipmentType, bool?>(Instance_OnHardwareStateChanged); PresentationController.Instance.OnSlideLockChanged += new SlideLockChanged(Instance_OnSlideLockChanged); if (equipmentList.Nodes.Count > 0) { SelectedNode = equipmentList.Nodes[0] as DeviceNode; equipmentList.SelectedNode = SelectedNode; } }