private void instancePriorityDown_Click(object sender, EventArgs e) { IPriorityContainer currentInstance = (IPriorityContainer)instancePriorityListBox.SelectedItem; if (currentInstance != null && currentInstance.Priority < _currentDisp.Instances.Max((inst) => inst.Priority)) { IPriorityContainer lowerPriorityInstance = _currentDisp.Instances.FirstOrDefault((inst) => inst.Priority == currentInstance.Priority + 1); currentInstance.Priority++; lowerPriorityInstance.Priority--; _currentDisp.SortInstances(); _fillInstanceList(); instancePriorityListBox.SetSelected(currentInstance.Priority, true); } }
private void eventPriorityDown_Click(object sender, EventArgs e) { ExecutionModel em = _executionModels.FirstOrDefault(model => model.FBTypeName == _selectedFbType); IPriorityContainer selectedEvent = (IPriorityContainer)eventsPriorityListBox.SelectedItem; if (selectedEvent != null && selectedEvent.Priority < em.InputEventsPriorities.Max(ev => ev.Priority)) { IPriorityContainer lowerPriorityEvent = em.InputEventsPriorities.FirstOrDefault(ep => ep.Priority == selectedEvent.Priority + 1); selectedEvent.Priority++; lowerPriorityEvent.Priority--; em.SortInputEvents(); fillEventsPriorityList(); eventsPriorityListBox.SetSelected(selectedEvent.Priority, true); } }