예제 #1
0
        public void RemoveDisplay(ITelemetryDisplay display)
        {
            var displayToRemove = (Control)Owner.MdiChildren.OfType <ITelemetryDisplay>().FirstOrDefault(d => d.Id == display.Id);

            if (displayToRemove == null)
            {
                throw new ArgumentException($"Could not find display to remove having Id {display.Id}.");
            }

            display.CloseDisplayRequest -= Display_CloseDisplayRequest;

            if (display is ITelemetryFrameDisplay)
            {
                ((ITelemetryFrameDisplay)display).PropertyChanged -= DisplayController_PropertyChanged;
            }
            else if (display is ITelemetryLapDisplay)
            {
                ((ITelemetryLapDisplay)display).PropertyChanged -= DisplayController_PropertyChanged;
            }

            Owner.Controls.Remove(displayToRemove);

            Displays.Remove((ITelemetryDisplay)displayToRemove);

            OnDisplayRemoved((ITelemetryDisplay)displayToRemove);

            display.Dispose();
        }
예제 #2
0
        public void ActivateDisplay(ITelemetryDisplay display)
        {
            display.BringToFront();
            display.Focus();

            OnActiveDisplayChanged(display);
        }
예제 #3
0
        public void AddDisplay(ITelemetryDisplay display)
        {
            display.CloseDisplayRequest += Display_CloseDisplayRequest;
            ((Control)display).GotFocus += DisplayController_GotFocus;

            ((Form)display).MdiParent = Owner;
            ((Form)display).Show();

            if (display is ITelemetryFrameDisplay)
            {
                if (Session != null)
                {
                    ((ITelemetryFrameDisplay)display).Frames = CurrentLap.LapFrames;
                    ((ITelemetryFrameDisplay)display).SetFrameIdx(FrameIdx);
                }
                ((ITelemetryFrameDisplay)display).PropertyChanged += DisplayController_PropertyChanged;
            }
            else if (display is ITelemetryLapDisplay)
            {
                if (Session != null)
                {
                    ((ITelemetryLapDisplay)display).Laps = Session.Laps;
                    ((ITelemetryLapDisplay)display).SetLapNumber(LapNumber);
                }
                ((ITelemetryLapDisplay)display).PropertyChanged += DisplayController_PropertyChanged;
            }

            Displays.Add(display);

            OnDisplayAdded(display);

            ActivateDisplay(display);
        }
예제 #4
0
        protected virtual void OnDisplayRemoved(ITelemetryDisplay displayRemoved)
        {
            var handler = this.DisplayRemoved;

            if (handler != null)
            {
                handler.Invoke(this, new DisplayRemovedEventArgs(displayRemoved));
            }
        }
예제 #5
0
        protected virtual void OnActiveDisplayChanged(ITelemetryDisplay activeDisplay)
        {
            var handler = this.ActiveDisplayChanged;

            if (handler != null)
            {
                handler.Invoke(this, new ActiveDisplayChangedEventArgs(activeDisplay));
            }
        }
예제 #6
0
 public DisplayRemovedEventArgs(ITelemetryDisplay displayRemoved)
 {
     DisplayRemoved = displayRemoved;
 }
예제 #7
0
 public DisplayAddedEventArgs(ITelemetryDisplay displayAdded)
 {
     DisplayAdded = displayAdded;
 }
예제 #8
0
 public ActiveDisplayChangedEventArgs(ITelemetryDisplay activeDisplay)
 {
     ActiveDisplay = activeDisplay;
 }