public void closeCurrentPageAndOpenNewPage(DarkTheme.Page page) { if (this.stackPages.Count > 1) { DarkTheme.Page currentPage = this.stackPages.Peek(); currentPage.Close(); //this.BackClicked -= this.closeCurrentPage; this.SizeChanged -= currentPage.UpdateSize; this.Controls.Remove(currentPage); this.stackPages.Pop(); currentPage.Dispose(); if (this.stackPages.Count == 0) { this.BackClicked -= this.closeCurrentPage; } } page.MouseDown += (s, e) => this.OnMouseDown(e); page.MouseMove += (s, e) => this.OnMouseMove(e); page.MouseDoubleClick += (s, e) => this.ToogleMaximized(); this.SizeChanged += page.UpdateSize; this.Controls.Add(page); this.stackPages.Push(page); page.Show(); if (this.stackPages.Count == 1) { this.BackClicked += this.closeCurrentPage; } }
// Page Control Methods public void openPage(DarkTheme.Page page) { if (this.stackPages.Count > 0) { this.stackPages.Peek().Enabled = false; this.stackPages.Peek().Hide(); } page.MouseDown += (s, e) => this.OnMouseDown(e); page.MouseMove += (s, e) => this.OnMouseMove(e); page.MouseDoubleClick += (s, e) => this.ToogleMaximized(); this.SizeChanged += page.UpdateSize; if (this.stackPages.Count == 1) { this.BackClicked += this.closeCurrentPage; } this.Controls.Add(page); this.stackPages.Push(page); page.Show(); }
public void closeCurrentPage() { // TODO: returning to previous page is buggy (skips previous page and goes to first page sometimes) if (this.stackPages.Count > 1) { DarkTheme.Page currentPage = this.stackPages.Peek(); currentPage.Close(); this.SizeChanged -= currentPage.UpdateSize; this.Controls.Remove(currentPage); this.stackPages.Pop(); currentPage.Dispose(); if (this.stackPages.Count == 1) { this.BackClicked -= this.closeCurrentPage; } this.stackPages.Peek().Enabled = true; this.stackPages.Peek().Show(); } }