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(); }
public void ActivateDisplay(ITelemetryDisplay display) { display.BringToFront(); display.Focus(); OnActiveDisplayChanged(display); }
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); }
protected virtual void OnDisplayRemoved(ITelemetryDisplay displayRemoved) { var handler = this.DisplayRemoved; if (handler != null) { handler.Invoke(this, new DisplayRemovedEventArgs(displayRemoved)); } }
protected virtual void OnActiveDisplayChanged(ITelemetryDisplay activeDisplay) { var handler = this.ActiveDisplayChanged; if (handler != null) { handler.Invoke(this, new ActiveDisplayChangedEventArgs(activeDisplay)); } }
public DisplayRemovedEventArgs(ITelemetryDisplay displayRemoved) { DisplayRemoved = displayRemoved; }
public DisplayAddedEventArgs(ITelemetryDisplay displayAdded) { DisplayAdded = displayAdded; }
public ActiveDisplayChangedEventArgs(ITelemetryDisplay activeDisplay) { ActiveDisplay = activeDisplay; }