public void SetSnapshot(EntireSnapshot snapshot) { // Remember the focused control Control focusedControl = Utils.Utils.FindFocusedControl(TopLevelControl); // Clear the tab panel. Clear(); foreach (string filePath in snapshot.FilePaths) { TabPage newPage = new TabPage(Path.GetFileName(filePath)); RichTextBox richText = new RichTextBox(); richText.Dock = DockStyle.Fill; richText.Font = CodeFont; richText.ReadOnly = true; richText.BackColor = Color.White; snapshot.FileSnapshots[filePath].DisplayInRichTextBox(richText, StrikeoutFont); newPage.Controls.Add(richText); this.tabControl.TabPages.Add(newPage); } // Select the first tab. if (this.tabControl.TabPages.Count > 0) { this.tabControl.SelectedTab = this.tabControl.TabPages[0]; } // Restore back the focus if (focusedControl != null) { focusedControl.Focus(); } }
/// <summary> /// Reproduces the snapshot. /// </summary> private void ReproduceSnapshot() { this.snapshotPreview.Clear(); if (this.listViewEvents.SelectedIndices.Count == 0) { return; } int selectedIndex = this.listViewEvents.SelectedIndices[0]; ListViewItem item = this.listViewEvents.Items[selectedIndex]; var selectedEvent = item.Tag as Event; if (selectedEvent == null) { return; } // Do the calculation. EntireSnapshot entireSnapshot = this.SnapshotCalculator.CalculateSnapshotAtEvent(selectedEvent); this.snapshotPreview.SetSnapshot(entireSnapshot); }