/// <summary> /// Handle the back button click. /// </summary> /// <param name="sender">Event sender</param> /// <param name="e">Event arguments</param> private void GoBack(object sender, RoutedEventArgs e) { //if (navigationRegion.Content != kinectRegionGrid) //{ // navigationRegion.Content = this.kinectRegionGrid; //} //else //{ UIInvoked(); history.RemoveAt(history.Count - 1); DataBase dataBase = DataSource.GetItem(history[history.Count - 1]) as DataBase; if (dataBase == null) { navigationRegion.Content = this.kinectRegionGrid; var type = DataSource.GetGroup(history.Last()).TypeGroup; this.itemsControl.ItemTemplate = (DataTemplate)this.FindResource(type + "Template"); this.itemsControl.ItemsSource = DataSource.GetGroup(history[history.Count - 1]); } else if (dataBase is DataPageBase) { DataPageBase dataPageBase = (DataPageBase)dataBase; if (dataPageBase.NavigationPage != null) { navigationRegion.Content = Activator.CreateInstance(dataPageBase.NavigationPage, dataPageBase.Parametrs); } } else if (dataBase is DataGroupBase) { DataGroupBase dataGroupBase = (DataGroupBase)dataBase; if (dataGroupBase.NewGroup != null) { var type_b = DataSource.GetGroup(history[history.Count - 1]).TypeGroup; this.itemsControl.ItemTemplate = (DataTemplate)this.FindResource(type_b + "Template"); this.itemsControl.ItemsSource = DataSource.GetGroup(dataGroupBase.NewGroup); } } if (history[history.Count - 1] == "Menu") { backButton.Visibility = System.Windows.Visibility.Hidden; } //} }
/// <summary> /// Handle a button click from the wrap panel. /// </summary> /// <param name="sender">Event sender</param> /// <param name="e">Event arguments</param> private void ButtonClick(object sender, RoutedEventArgs e) { UIInvoked(); var button = (Button)e.OriginalSource; DataBase dataBase = button.DataContext as DataBase; if (dataBase != null) { if (dataBase.Title == "Видео") { CreateData.Instance.GetAllVideos(); } else if (dataBase.Title == "Игры") { CreateData.Instance.GetGames(); } else if (dataBase.Title == "Расписание") { CreateData.Instance.GetAllTimetable(); } if (dataBase is DataPageBase) { DataPageBase dataPageBase = (DataPageBase)dataBase; if (dataPageBase.NavigationPage != null) { history.Add(dataPageBase.UniqueId); backButton.Visibility = Visibility.Visible; navigationRegion.Content = Activator.CreateInstance(dataPageBase.NavigationPage, dataPageBase.Parametrs); } } if (dataBase is DataGroupBase) { DataGroupBase dataGroupBase = (DataGroupBase)dataBase; if (dataGroupBase.NewGroup != null) { history.Add(dataGroupBase.NewGroup); backButton.Visibility = Visibility.Visible; scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; var type = DataSource.GetGroup(dataGroupBase.NewGroup).TypeGroup; itemsControl.ItemTemplate = (DataTemplate)FindResource(type + "Template"); itemsControl.ItemsSource = DataSource.GetGroup(dataGroupBase.NewGroup); } } if (dataBase is DataExecuteBase) { DataExecuteBase dataExecuteBase = (DataExecuteBase)dataBase; if (dataExecuteBase.Parametrs != null) { Process.Start(dataExecuteBase.Parametrs[0]); ButtonAutomationPeer peer = new ButtonAutomationPeer(backButton); IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; invokeProv.Invoke(); } } } else { var selectionDisplay = new SelectionDisplay(button.Content as string); this.kinectRegionGrid.Children.Add(selectionDisplay); // Selection dialog covers the entire interact-able area, so the current press interaction // should be completed. Otherwise hover capture will allow the button to be clicked again within // the same interaction (even whilst no longer visible). selectionDisplay.Focus(); // Since the selection dialog covers the entire interact-able area, we should also complete // the current interaction of all other pointers. This prevents other users interacting with elements // that are no longer visible. this.kinectRegion.InputPointerManager.CompleteGestures(); e.Handled = true; } }