private void PushEvent(Operation operation) { if (ContainsEvent(operation.Id)) { return; } bool isOperationNew = !operation.IsAcknowledged; bool isNewToList = AddOperation(operation); // If no event is selected yet, select the newest one (also do this if the selected operation is older. Newer operations have priority!). if (SelectedEvent == null || (SelectedEvent != null && SelectedEvent.Operation.TimestampIncome < AvailableEvents[0].Operation.TimestampIncome)) { SelectedEvent = AvailableEvents[0]; } if (isNewToList) { if (App.GetApp().Configuration.FullscreenOnAlarm) { _mainWindow.SetFullscreen(true); } UpdateEventsProperties(); if (isOperationNew) { _operationViewer.OnNewOperation(operation); App.GetApp().ExtensionManager.RunUIJobs(_operationViewer, operation); } } _operationViewer.OnOperationChanged(SelectedEvent.Operation); }
/// <summary> /// Pushes a new event to the window, either causing it to spawn, or to extend its list box by this event if already shown. /// </summary> /// <param name="operation">The event to push.</param> /// <returns>Whether or not the event was pushed. This is true if the event was a new one, and false if the event did already exist.</returns> public bool PushEvent(Operation operation) { // Sanity-check if (AvailableEvents.Any(o => o.Operation.Id == operation.Id)) { return(false); } bool isOperationNew = !operation.IsAcknowledged; if (!isOperationNew && App.GetApp().Configuration.TreatOldOperationsAsNew) { Logger.Instance.LogFormat(LogType.Warning, this, "Debug option activated - treating operation '{0}' as a new operation!", operation.OperationNumber); isOperationNew = true; } // Notify operation viewer of this new operation (only if the operation is not acknowledged and thus new) if (isOperationNew) { _operationViewer.OnNewOperation(operation); } // Add the operation and perform a "sanity-sort" (don't trust the web service or whoever...) OperationViewModel ovm = new OperationViewModel(operation); AvailableEvents.Add(ovm); AvailableEvents = new List <OperationViewModel>(AvailableEvents.OrderByDescending(o => o.Operation.Timestamp)); OnPropertyChanged("AvailableEvents"); OnPropertyChanged("AreMultipleEventsPresent"); // If no event is selected yet, select the newest one (also do this if the selected operation is older. Newer operations have priority!). if (SelectedEvent == null || (SelectedEvent != null && SelectedEvent.Operation.Timestamp < AvailableEvents[0].Operation.Timestamp)) { SelectedEvent = AvailableEvents[0]; } // Call the UI-jobs now on this specific job (only if the operation is not acknowledged and thus new) if (isOperationNew) { App.GetApp().ExtensionManager.RunUIJobs(_operationViewer, operation); } // When the jobs are done, change over to the job (necessary in most cases albeit not perfect solution :-/ ) _operationViewer.OnOperationChanged(SelectedEvent.Operation); return(true); }