// Make this panel the current one. Remove from previous // position in list and re-add in front of current panel public void MakePanelCurrent() { if (SuperPuTTY.MainForm.CurrentPanel == this) return; // Remove ourselves from our position in chain this.PreviousPanel.NextPanel = this.NextPanel; this.NextPanel.PreviousPanel = this.PreviousPanel; this.PreviousPanel = SuperPuTTY.MainForm.CurrentPanel; this.NextPanel = SuperPuTTY.MainForm.CurrentPanel.NextPanel; SuperPuTTY.MainForm.CurrentPanel.NextPanel = this; this.NextPanel.PreviousPanel = this; SuperPuTTY.MainForm.CurrentPanel = this; }
protected override void OnFormClosed(FormClosedEventArgs e) { base.OnFormClosed(e); if (SuperPuTTY.MainForm == null) return; // only 1 panel if (SuperPuTTY.MainForm.CurrentPanel == this && this.NextPanel == this && this.PreviousPanel == this) { SuperPuTTY.MainForm.CurrentPanel = null; return; } // Remove ourselves from our position in chain and set last active tab as current if (this.PreviousPanel != null) { this.PreviousPanel.NextPanel = this.NextPanel; } if (this.NextPanel != null) { this.NextPanel.PreviousPanel = this.PreviousPanel; } SuperPuTTY.MainForm.CurrentPanel = this.PreviousPanel; // manipulate tabs if (this.DockHandler.Pane != null) { int idx = this.DockHandler.Pane.Contents.IndexOf(this); if (idx > 0) { IDockContent contentToActivate = this.DockHandler.Pane.Contents[idx - 1]; contentToActivate.DockHandler.Activate(); } } }