Beispiel #1
0
        // constructor
        public ControlsVisualHandler()
        {
            // 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 wpControlLeftPane = (WrapPanel)MWindow.FindName("wpControlLeftPane");

            // get config wrappanel
            ControlWrapPanel = (WrapPanel)MWindow.FindName("ControlWrapPanel");

            // get all filter buttons from the Configs page
            List <RadioButton> _filterButtons = UIHandler.GetLogicalChildCollection <RadioButton>(wpControlLeftPane);//.Where(r => r.GroupName == "grpSettings").ToList();

            FilterButtons = _filterButtons;

            // setting grid containing right hand content
            Grid controlGrid = (Grid)MWindow.FindName("controlGrid");

            // get all right hand config panels that are dynamic
            var AllControlPanels = UIHandler.GetLogicalChildCollection <Border>(controlGrid).ToList();

            AllDynamicControlPanels = (from a in AllControlPanels
                                       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;
                }
            }
        }