// Constructor public ConfigsVisualHandler() { // get an instance of the MainWindow MWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); // get 'Base Configuration' button RadioButton btnConfigBase = (RadioButton)MWindow.FindName("btnConfigBase"); // get settings panel WrapPanel wpConfigLeftPane = (WrapPanel)MWindow.FindName("wpConfigLeftPane"); // get config wrappanel ConfigWrapPanel = (WrapPanel)MWindow.FindName("ConfigWrapPanel"); // get all filter buttons from the Configs page List <RadioButton> _filterButtons = UIHandler.GetLogicalChildCollection <RadioButton>(wpConfigLeftPane);//.Where(r => r.GroupName == "grpSettings").ToList(); FilterButtons = _filterButtons; // setting grid containing right hand content Grid configGrid = (Grid)MWindow.FindName("configGrid"); // get all right hand config panels that are dynamic var AllConfigPanels = UIHandler.GetLogicalChildCollection <Border>(configGrid).ToList(); AllDynamicConfigPanels = (from a in AllConfigPanels where (a.Name.Length > 1 && !a.Name.Contains("NONDYNAMIC")) select a).ToList(); GS = GlobalSettings.GetGlobals(); }
// Constructor public SettingsVisualHandler() { // get an instance of the MainWindow MWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); // get 'show all settings' button and click it RadioButton btnAllSettings = (RadioButton)MWindow.FindName("btnAllSettings"); //btnAllSettings.IsChecked = true; // get settings grid WrapPanel wpSettingsLeftPane = (WrapPanel)MWindow.FindName("wpSettingsLeftPane"); // get all filter buttons from the settings page List <RadioButton> _filterButtons = UIHandler.GetLogicalChildCollection <RadioButton>(wpSettingsLeftPane);//.Where(r => r.GroupName == "grpSettings").ToList(); FilterButtons = _filterButtons; // setting grid containing right hand content Grid SettingGrid = (Grid)MWindow.FindName("SettingGrid"); // get all settings panels //AllSettingPanels = UIHandler.GetLogicalChildCollection<Border>("SettingGrid").ToList(); AllSettingPanels = UIHandler.GetLogicalChildCollection <Border>(SettingGrid).ToList(); // iterate through each panel and match the border x:name to the class property name foreach (Border b in AllSettingPanels) { // remove any trailing numerals from the control name string name = StripTrailingNumerals(b.Name); // if the control name matches a property name in this class, add it to that list PropertyInfo property = typeof(SettingsVisualHandler).GetProperty(name); if (property == null) { // no property matched continue; } // add the border control to the correct List switch (property.Name) { case "MednafenPaths": MednafenPaths.Add(b); break; case "GameFolders": GameFolders.Add(b); break; case "SystemBios": SystemBios.Add(b); break; case "Netplay": Netplay.Add(b); break; case "Emulator": Emulator.Add(b); break; case "MedLaunch": MedLaunch.Add(b); break; case "Library": Library.Add(b); break; case "ScrapingSettings": ScrapingSettings.Add(b); break; default: // do nothing break; } } }
// Get the current setup of the games library (selected filters etc), do a refresh then return to previous configuration public static void RefreshGamesLibrary() { // get an instance of the MainWindow MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); App _App = ((App)Application.Current); //var data = _App.GamesList.FilteredSet; //_App.GamesList.FilteredSet = new System.Collections.ObjectModel.ObservableCollection<DataGridGamesView>(data); DataGrid dg = (DataGrid)mw.FindName("dgGameList"); //var items = dg.ItemsSource; // get btnClearFilters button Button btnClearFilters = (Button)mw.FindName("btnClearFilters"); // get the wrappanel that contains all the GameLibrary toggleboxes Grid grdGameLibrary = (Grid)mw.FindName("grdGameLibrary"); // get the dynamic filter textbox tbFilterDatagrid TextBox tbFilterDatagrid = (TextBox)mw.FindName("tbFilterDatagrid"); string tbText = tbFilterDatagrid.Text; // get all grouped radio buttons List <RadioButton> buttons = UIHandler.GetLogicalChildCollection <RadioButton>(grdGameLibrary); foreach (RadioButton but in buttons) { //MessageBox.Show(but.Name); } // get the radio button that is checked RadioButton rtTarget = buttons .Where(r => r.IsChecked == true).Single(); // get the showall button RadioButton btnShowAll = buttons .Where(r => r.Name == "btnShowAll").Single(); // get selected item in datagrid DataGridGamesView row = (DataGridGamesView)dg.SelectedItem; // Clear all settings btnShowAll.IsChecked = true; tbFilterDatagrid.Text = "1337"; // restore settings rtTarget.IsChecked = true; tbFilterDatagrid.Text = tbText; /* * // set column visibuilities * GlobalSettings gs = GlobalSettings.GetGlobals(); * * DataGridTextColumn colYear = (DataGridTextColumn)mw.FindName("colYear"); * DataGridTextColumn colPlayers = (DataGridTextColumn)mw.FindName("colPlayers"); * DataGridTextColumn colCoop = (DataGridTextColumn)mw.FindName("colCoop"); * DataGridTextColumn colPublisher = (DataGridTextColumn)mw.FindName("colPublisher"); * DataGridTextColumn colDeveloper = (DataGridTextColumn)mw.FindName("colDeveloper"); * DataGridTextColumn colRating = (DataGridTextColumn)mw.FindName("colRating"); * * if (gs.showGLCoop == false) * colCoop.Visibility = Visibility.Collapsed; * else * colCoop.Visibility = Visibility.Visible; * * if (gs.showGLPlayers == false) * colPlayers.Visibility = Visibility.Collapsed; * else * colPlayers.Visibility = Visibility.Visible; * * if (gs.showGLYear == false) * colYear.Visibility = Visibility.Collapsed; * else * colYear.Visibility = Visibility.Visible; * * if (gs.showGLPublisher== false) * colPublisher.Visibility = Visibility.Collapsed; * else * colPublisher.Visibility = Visibility.Visible; * * if (gs.showGLDeveloper == false) * colDeveloper.Visibility = Visibility.Collapsed; * else * colDeveloper.Visibility = Visibility.Visible; * * if (gs.showGLESRB == false) * colRating.Visibility = Visibility.Collapsed; * else * colRating.Visibility = Visibility.Visible; */ }