/// <summary> /// Initializes a new instance of the <see cref="MainWindow"/> class. /// </summary> public MainWindow() { this.InitializeComponent(); this.Loaded += (s, e) => { var menuDockPanel = (DockPanel)this.menuStrip.Template.FindName("MenuStrip", this.menuStrip); this.menuStripItems = menuDockPanel.Children.OfType <TextBlock>().ToList(); foreach (var menuStripItem in this.menuStripItems) { menuStripItem.PreviewMouseDown += this.HandleMenuStripPreviewMouseDown; } this.pages = new Control[] { new ConnectPage(), new ExplorePage(), new AboutPage() }; this.SelectMenuStripItem(this.menuStripItems[0]); }; this.Closed += (s, e) => { try { Settings.Default.Save(); DatabaseSession.Disconnect(); } catch { } }; DatabaseSession.ConnectionStateChanged += (s, e) => { if (e.ConnectionState == ConnectionState.Connected) { this.SelectMenuStripItem(this.menuStripItems[1]); } }; }
/// <summary> /// The dispose. /// </summary> public void Dispose() { DatabaseSession.Disconnect(); }