/// <summary> /// Clears the position of all events /// </summary> public void CleanPositions() { NextY = 0; LastActivationTime = -1.0; AllocatedPositions.Clear(); EventPositions.Clear(); LastStepActivation = null; LastSubStepActivation = null; }
/// <summary> /// Registers an event according to its column /// </summary> /// <param name="evt"></param> public void RegisterEvent(ModelEvent evt) { SubStepActivated currentSubStepActivation = evt as SubStepActivated; if (evt.Time > LastActivationTime || currentSubStepActivation != null) { LastActivationTime = evt.Time; AllocatedPositions.Add(new List <ModelEvent>()); NextY = 0; if (LastSubStepActivation != null) { if (currentSubStepActivation == null) { AllocatedPositions[AllocatedPositions.Count - 1].Add(LastSubStepActivation); } } } List <ModelEvent> events = AllocatedPositions[AllocatedPositions.Count - 1]; if (!events.Contains(evt)) { if (currentSubStepActivation != null) { if (currentSubStepActivation.SubStep.Step != null) { if (LastSubStepActivation != null && LastSubStepActivation.SubStep.Step == currentSubStepActivation.SubStep.Step) { // Extends the step size Rectangle lastRectangle = EventPositions[LastStepActivation]; lastRectangle.Width = lastRectangle.Width + _eventMarging.Width + _stepSize.Width; EventPositions[LastStepActivation] = lastRectangle; } else { // Create a new step activation LastStepActivation = new StepActivation(currentSubStepActivation.SubStep.Step); Point location = new Point((AllocatedPositions.Count - 1) * (_stepSize.Width + _eventMarging.Width), NextY); events.Add(LastStepActivation); EventPositions.Add(LastStepActivation, new Rectangle(location, _stepSize)); } NextY += _stepSize.Height; } // Setup the substep activation size if (LastSubStepActivation != null && LastSubStepActivation.SubStep.Step == currentSubStepActivation.SubStep.Step) { // Increase the previous sub step activation size as it belongs to the same step // This is used to remove gaps between substeps of the same step Rectangle lastRectangle = EventPositions[LastSubStepActivation]; lastRectangle.Width = lastRectangle.Width + (_eventMarging.Width + 1) / 2; EventPositions[LastSubStepActivation] = lastRectangle; events.Add(evt); Point location = new Point( (AllocatedPositions.Count - 1) * (_eventSize.Width + _eventMarging.Width) - (_eventMarging.Width / 2), NextY); EventPositions.Add(evt, new Rectangle(location, new Size(_substepSize.Width + _eventMarging.Width / 2, _substepSize.Height))); } else { events.Add(evt); Point location = new Point((AllocatedPositions.Count - 1) * (_substepSize.Width + _eventMarging.Width), NextY); EventPositions.Add(evt, new Rectangle(location, _substepSize)); } NextY += _substepSize.Height + _eventMarging.Height; } else { // Create the sub step activation { events.Add(evt); Point location = new Point((AllocatedPositions.Count - 1) * (_eventSize.Width + _eventMarging.Width), NextY); EventPositions.Add(evt, new Rectangle(location, _eventSize)); NextY += _eventSize.Height + _eventMarging.Height; } } } else { if (evt == LastSubStepActivation) { // Extent the sub step activation Rectangle lastRectangle = EventPositions[evt]; lastRectangle.Width = lastRectangle.Width + _eventSize.Width + _eventMarging.Width; EventPositions[evt] = lastRectangle; } } if (evt is SubStepActivated) { LastSubStepActivation = evt as SubStepActivated; } }