private void MasterFrame_Navigating(object sender, NavigatingCancelEventArgs e) { ResetUI(); masterPanel.lastSelected = lastSelected; if (e.NavigationMode == NavigationMode.Forward) { if (forwardStack.Count == 0) { e.Cancel = true; return; } backStack.Push(masterPanel); masterPanel = forwardStack.Pop(); } else if (e.NavigationMode == NavigationMode.Back) { forwardStack.Push(masterPanel); masterPanel = backStack.Pop(); } else if (e.NavigationMode == NavigationMode.New) { lastSelected = masterPanel.resources[0]; masterPanel.lastSelected = lastSelected; Select(masterPanel.resources[0]); } UpdateNavButs(); RefreshParent(masterPanel); }
void RefreshParent(MasterPanel mp) { parent = mp.parent; resources = mp.resources; lastSelected = mp.lastSelected; lastSelected.IsSelected = false; Select(lastSelected); CurrentGroupTitle = parent == null ? "All resources" : parent.Title; CurrentGroupStock = parent == null ? "" : "(" + parent.Size + "/" + parent.InitialSize + ")"; }
public MainWindow() { InitializeComponent(); Loaded += MainWindow_Loaded; if (!File.Exists(DatabaseHandler.databaseFile)) { DatabaseHandler.CreateNewDatabase(); } masterPanel = new MasterPanel(this, GetResources()); masterFrame.Content = masterPanel; masterFrame.Navigating += MasterFrame_Navigating; masterGrid.DataContext = this; backStack = new Stack <MasterPanel>(); forwardStack = new Stack <MasterPanel>(); UpdateNavButs(); selected = new ObservableCollection <Resource>(); toMove = new ObservableCollection <Resource>(); }
public void GoToGroup(Resource selected) { if (InMoveMode && (toMove.Contains(selected))) { return; } lastSelected.IsSelected = false; selected.IsSelected = true; lastSelected = selected; masterPanel.lastSelected = lastSelected; backStack.Push(masterPanel); MasterPanel mp; while (forwardStack.Count > 0 && (mp = forwardStack.Pop()) != null) { mp.lastSelected.IsSelected = false; } masterPanel = new MasterPanel(this, selected); masterFrame.NavigationService.Navigate(masterPanel); }