private TabItem GetItem(BaseScreen baseScreen) { foreach (TabItem tabItem in this.tabControl.Items) { if (tabItem.Content == null) { continue; } BaseScreen screen = tabItem.Content as BaseScreen; if (screen != null && screen.BaseScreenId.Equals(baseScreen.BaseScreenId)) { return tabItem; } } return null; }
private TabItem CreateTabItem(BaseScreen baseScreen, bool closeable) { TabItem tabItem = closeable ? new CloseableTabItem() : new TabItem(); tabItem.Header = baseScreen.BaseScreenTitle; tabItem.Content = baseScreen; baseScreen.Width = Double.NaN; baseScreen.Height = Double.NaN; return tabItem; }
public void Show(ScreenType type, int insertIndex) { TabItem tabItem = null; if ((this.loadedScreens & type) == type) { int index = this.GetScreenIndex(type); if (index != -1) { this.tabControl.SelectedIndex = index; } return; } switch (type) { case ScreenType.About: tabItem = this.CreateTabItem(this.ScreenAbout, true); break; case ScreenType.Authentication: tabItem = this.CreateTabItem(this.ScreenAuthentication, false); break; case ScreenType.Options: tabItem = this.CreateTabItem(this.ScreenOptions, true); break; case ScreenType.History: tabItem = this.CreateTabItem(this.ScreenHistory, false); break; case ScreenType.Contacts: tabItem = this.CreateTabItem(this.ScreenContacts, false); break; case ScreenType.Registrations: tabItem = this.CreateTabItem(this.ScreenRegistrations, true); break; case ScreenType.Authorizations: tabItem = this.CreateTabItem(this.ScreenWatchers, true); break; } if (tabItem != null) { // Events (tabItem.Content as BaseScreen).BeforeLoading(); if (lastScreen != null) lastScreen.BeforeUnLoading(); if (insertIndex >= 0 && insertIndex < this.tabControl.Items.Count) { this.tabControl.Items.Insert(insertIndex, tabItem); } else { this.tabControl.Items.Add(tabItem); } this.tabControl.SelectedItem = tabItem; this.loadedScreens |= type; // Events if (lastScreen != null) lastScreen.AfterUnLoading(); (tabItem.Content as BaseScreen).AfterLoading(); lastScreen = (tabItem.Content as BaseScreen); } }
public void Show(BaseScreen baseScreen) { this.Show(baseScreen, -1); }
public void Show(BaseScreen baseScreen, int insertIndex) { int index = -1; foreach (TabItem item in this.tabControl.Items) { index ++; if (item.Content == null) { continue; } BaseScreen _baseScreen = item.Content as BaseScreen; if (_baseScreen == baseScreen) { this.tabControl.SelectedIndex = index; return; } } TabItem tabItem = this.CreateTabItem(baseScreen, true); // Events baseScreen.BeforeLoading(); if (lastScreen != null) lastScreen.BeforeUnLoading(); if (insertIndex >= 0 && insertIndex < this.tabControl.Items.Count) { this.tabControl.Items.Insert(insertIndex, tabItem); } else { this.tabControl.Items.Add(tabItem); } this.tabControl.SelectedItem = tabItem; // Events if (lastScreen != null) lastScreen.AfterUnLoading(); baseScreen.AfterLoading(); lastScreen = baseScreen; }
public void Hide(BaseScreen baseScreen) { TabItem tabItem = this.GetItem(baseScreen); if (tabItem != null) { // Events baseScreen.BeforeUnLoading(); this.tabControl.Items.Remove(tabItem); tabItem.Content = null; this.loadedScreens &= ~((ScreenType)baseScreen.BaseScreenType); // Events baseScreen.AfterUnLoading(); } }