Example #1
0
        /// <summary>
        /// Registers the fact that a new event is present at current time
        /// </summary>
        /// <param name="eventControl"></param>
        private void RegisterEventAtTime(EventControl eventControl)
        {
            if (!EventsAtTime.ContainsKey(eventControl.ModelEvent.Time))
            {
                EventsAtTime[eventControl.ModelEvent.Time] = 0;
            }

            EventsAtTime[eventControl.ModelEvent.Time] += 1;
        }
Example #2
0
        /// <summary>
        /// Removes one event control from the displayed event controls
        /// </summary>
        /// <param name="control"></param>
        private void RemoveEventControl(EventControl control)
        {
            HandledEvents.Remove(control.ModelEvent);
            control.ModelEvent = null;
            control.Parent     = null;

            Controls.Remove(control);
            control.Dispose();
        }
Example #3
0
        /// <summary>
        /// Sets the size of the time line to ensure that the new Event is displayed
        /// </summary>
        /// <param name="newEvent"></param>
        private void SetPanelSize(EventControl newEvent)
        {
            int width  = newEvent.Location.X + newEvent.Width + MARGIN_OFFSET;
            int height = newEvent.Location.Y + newEvent.Height + MARGIN_OFFSET;

            if (RequiredSize.Width < width || RequiredSize.Height < height)
            {
                RequiredSize = new Size(width, height);
            }
        }
Example #4
0
        /// <summary>
        /// Synchronizes the EventControls with the Events located in the time line
        /// Hyp : When removing an event at some time, all the events for the corresponding time are also removed
        /// </summary>
        private void SynchronizeWithTimeLine()
        {
            // Handles the existing EventControls : counts the ones that already exist
            // and remove the ones that should be removed
            EventsAtTime.Clear();
            List <EventControl> toBeRemoved = new List <EventControl>();

            foreach (EventControl eventControl in HandledEvents.Values)
            {
                if (TimeLine.Contains(eventControl.ModelEvent))
                {
                    // Counts the number of events at all given times
                    RegisterEventAtTime(eventControl);
                }
                else
                {
                    // Remove the events that no more exist in the time line
                    toBeRemoved.Add(eventControl);
                }
            }

            // Actually performs the removal
            foreach (EventControl eventControl in toBeRemoved)
            {
                RemoveEventControl(eventControl);
            }


            // Create new EventControl for each new Event in the time line
            if (TimeLine != null)
            {
                foreach (ModelEvent modelEvent in TimeLine.Events)
                {
                    // add a EventControl for this event
                    if (FilterConfiguration.VisibleEvent(modelEvent))
                    {
                        if (!HandledEvents.ContainsKey(modelEvent))
                        {
                            if (HandledEvents.Count <= MAX_NUMBER_OF_EVENTS)
                            {
                                EventControl eventControl = new EventControl(this, modelEvent);
                                eventControl.Top  = EventTop(modelEvent);
                                eventControl.Left = EventLeft(modelEvent);
                                SetPanelSize(eventControl);
                                Controls.Add(eventControl);

                                string msg = modelEvent.Message;
                                if (msg.Length > 1000)
                                {
                                    // Message is too big for tool tips, reduce it.
                                    msg = msg.Substring(0, 1000) + "...";
                                }
                                ToolTip.SetToolTip(eventControl, msg);

                                // TODO : I do not understand this one...
                                if (!HandledEvents.ContainsKey(modelEvent))
                                {
                                    HandledEvents[modelEvent] = eventControl;
                                }
                                RegisterEventAtTime(eventControl);

                                if (HandledEvents.Count == MAX_NUMBER_OF_EVENTS)
                                {
                                    MessageBox.Show("Too many events displayed.\nDisplaying only the " + MAX_NUMBER_OF_EVENTS + " first events.\nPlease consider filtering out events.", "Too many events", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Synchronizes the EventControls with the Events located in the time line
        /// Hyp : When removing an event at some time, all the events for the corresponding time are also removed
        /// </summary>
        private void SynchronizeWithTimeLine()
        {
            // Handles the existing EventControls : counts the ones that already exist
            // and remove the ones that should be removed
            EventsAtTime.Clear();
            List<EventControl> toBeRemoved = new List<EventControl>();
            foreach (EventControl eventControl in HandledEvents.Values)
            {
                if (TimeLine.Contains(eventControl.ModelEvent))
                {
                    // Counts the number of events at all given times
                    RegisterEventAtTime(eventControl);
                }
                else
                {
                    // Remove the events that no more exist in the time line
                    toBeRemoved.Add(eventControl);
                }
            }

            // Actually performs the removal
            foreach (EventControl eventControl in toBeRemoved)
            {
                RemoveEventControl(eventControl);
            }

            // Create new EventControl for each new Event in the time line
            if (TimeLine != null)
            {
                foreach (ModelEvent modelEvent in TimeLine.Events)
                {
                    // add a EventControl for this event
                    if (FilterConfiguration.VisibleEvent(modelEvent))
                    {
                        if (!HandledEvents.ContainsKey(modelEvent))
                        {
                            if (HandledEvents.Count <= MAX_NUMBER_OF_EVENTS)
                            {
                                EventControl eventControl = new EventControl(this, modelEvent);
                                eventControl.Top = EventTop(modelEvent);
                                eventControl.Left = EventLeft(modelEvent);
                                SetPanelSize(eventControl);
                                Controls.Add(eventControl);

                                string msg = modelEvent.Message;
                                if (msg.Length > 1000)
                                {
                                    // Message is too big for tool tips, reduce it.
                                    msg = msg.Substring(0, 1000) + "...";
                                }
                                ToolTip.SetToolTip(eventControl, msg);

                                // TODO : I do not understand this one...
                                if (!HandledEvents.ContainsKey(modelEvent))
                                {
                                    HandledEvents[modelEvent] = eventControl;
                                }
                                RegisterEventAtTime(eventControl);

                                if (HandledEvents.Count == MAX_NUMBER_OF_EVENTS)
                                {
                                    MessageBox.Show("Too many events displayed.\nDisplaying only the " + MAX_NUMBER_OF_EVENTS + " first events.\nPlease consider filtering out events.", "Too many events", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Sets the size of the time line to ensure that the new Event is displayed
        /// </summary>
        /// <param name="newEvent"></param>
        private void SetPanelSize(EventControl newEvent)
        {
            int width = newEvent.Location.X + newEvent.Width + MARGIN_OFFSET;
            int height = newEvent.Location.Y + newEvent.Height + MARGIN_OFFSET;

            if (RequiredSize.Width < width || RequiredSize.Height < height)
            {
                RequiredSize = new Size(width, height);
            }
        }
        /// <summary>
        /// Removes one event control from the displayed event controls
        /// </summary>
        /// <param name="control"></param>
        private void RemoveEventControl(EventControl control)
        {
            HandledEvents.Remove(control.ModelEvent);
            control.ModelEvent = null;
            control.Parent = null;

            Controls.Remove(control);
            control.Dispose();
        }
        /// <summary>
        /// Registers the fact that a new event is present at current time
        /// </summary>
        /// <param name="eventControl"></param>
        private void RegisterEventAtTime(EventControl eventControl)
        {
            if (!EventsAtTime.ContainsKey(eventControl.ModelEvent.Time))
            {
                EventsAtTime[eventControl.ModelEvent.Time] = 0;
            }

            EventsAtTime[eventControl.ModelEvent.Time] += 1;
        }