예제 #1
0
        public static UIHandler GetChildren(Grid wp)
        {
            // create a new instance of UIHandler class
            UIHandler ui = new UIHandler();

            // get all child buttons
            ui.Buttons        = GetLogicalChildCollection <Button>(wp);
            ui.RadioButtons   = GetLogicalChildCollection <RadioButton>(wp);
            ui.Labels         = GetLogicalChildCollection <Label>(wp);
            ui.CheckBoxes     = GetLogicalChildCollection <CheckBox>(wp);
            ui.TextBoxes      = GetLogicalChildCollection <TextBox>(wp);
            ui.Sliders        = GetLogicalChildCollection <Slider>(wp);
            ui.ComboBoxes     = GetLogicalChildCollection <ComboBox>(wp);
            ui.NumericUpDowns = GetLogicalChildCollection <NumericUpDown>(wp);
            ui.Colorpickers   = GetLogicalChildCollection <ColorPicker>(wp);
            //ui.InputWidgets = GetLogicalChildCollection<InputWidget>(wp);

            return(ui);
        }
예제 #2
0
        // 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;
                }
            }
        }
예제 #3
0
        public static void HideControls(WrapPanel wp, int configId)
        {
            // get a class object with all child controls
            UIHandler ui = UIHandler.GetChildren(wp);

            ConfigsVisualHandler cv = new ConfigsVisualHandler();
            //Border b = (Border)cv.MWindow.FindName("brdNONDYNAMICvfilters");

            // get a list of system codes
            List <string> codes = (from a in GSystem.GetSystems()
                                   select a.systemCode.ToString().ToLower()).ToList();

            // iterate through each ui element and collapse the ones that are not needed for system specific settings
            if (configId != 2000000000)
            {
                //b.Visibility = Visibility.Collapsed;
                foreach (Button x in ui.Buttons)
                {
                    if (x.Name.StartsWith("cfg___"))
                    {
                        x.Visibility = Visibility.Collapsed;
                    }
                }
                foreach (CheckBox x in ui.CheckBoxes)
                {
                    if (x.Name.StartsWith("cfg___"))
                    {
                        x.Visibility = Visibility.Collapsed;
                    }
                }
                foreach (ComboBox x in ui.ComboBoxes)
                {
                    if (x.Name.StartsWith("cfg___"))
                    {
                        x.Visibility = Visibility.Collapsed;
                    }
                }
                foreach (NumericUpDown x in ui.NumericUpDowns)
                {
                    if (x.Name.StartsWith("cfg___"))
                    {
                        x.Visibility = Visibility.Collapsed;
                    }
                }
                foreach (RadioButton x in ui.RadioButtons)
                {
                    if (x.Name.StartsWith("cfg___"))
                    {
                        x.Visibility = Visibility.Collapsed;
                    }
                }
                foreach (Slider x in ui.Sliders)
                {
                    if (x.Name.StartsWith("cfg___"))
                    {
                        x.Visibility = Visibility.Collapsed;
                    }
                }
                foreach (TextBox x in ui.TextBoxes)
                {
                    if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("tb_Generic__"))
                    {
                        x.Visibility = Visibility.Collapsed;
                    }
                }
                foreach (Label x in ui.Labels)
                {
                    if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("lbl_cfg___") || x.Name.StartsWith("lbl_Generic__"))
                    {
                        x.Visibility = Visibility.Collapsed;
                    }
                }
            }
            else
            {
                GlobalSettings gs = GlobalSettings.GetGlobals();
                if (gs.showAllBaseSettings == true)
                {
                    //b.Visibility = Visibility.Collapsed;
                }
                else
                {
                    //b.Visibility = Visibility.Visible;
                    foreach (Button x in ui.Buttons)
                    {
                        if (x.Name.StartsWith("cfg___"))
                        {
                            x.Visibility = Visibility.Visible;
                        }
                    }
                    foreach (CheckBox x in ui.CheckBoxes)
                    {
                        if (x.Name.StartsWith("cfg___"))
                        {
                            x.Visibility = Visibility.Visible;
                        }
                    }
                    foreach (ComboBox x in ui.ComboBoxes)
                    {
                        if (x.Name.StartsWith("cfg___"))
                        {
                            x.Visibility = Visibility.Visible;
                        }
                    }
                    foreach (NumericUpDown x in ui.NumericUpDowns)
                    {
                        if (x.Name.StartsWith("cfg___"))
                        {
                            x.Visibility = Visibility.Visible;
                        }
                    }
                    foreach (RadioButton x in ui.RadioButtons)
                    {
                        if (x.Name.StartsWith("cfg___"))
                        {
                            x.Visibility = Visibility.Visible;
                        }
                    }
                    foreach (Slider x in ui.Sliders)
                    {
                        if (x.Name.StartsWith("cfg___"))
                        {
                            x.Visibility = Visibility.Visible;
                        }
                    }
                    foreach (TextBox x in ui.TextBoxes)
                    {
                        if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("tb_Generic__"))
                        {
                            x.Visibility = Visibility.Visible;
                        }
                    }
                    foreach (Label x in ui.Labels)
                    {
                        if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("lbl_cfg___") || x.Name.StartsWith("lbl_Generic__"))
                        {
                            x.Visibility = Visibility.Visible;
                        }
                    }
                }
            }
        }
        // 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;
             */
        }
예제 #5
0
        /// <summary>
        /// 1 = set tooltips
        /// 2 = unset tooltips
        /// </summary>
        /// <param name="SetOrUnset"></param>
        public static void SetToolTips(int SetOrUnset)
        {
            // get all config controls
            MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();
            // find the root grid
            Grid      RootGrid = (Grid)mw.FindName("RootGrid");
            UIHandler ui       = UIHandler.GetChildren(RootGrid);

            UIHandler u = new UIHandler();

            u.Buttons        = ui.Buttons.Where(a => a.Name.StartsWith("cfg_") || a.Name.StartsWith("cfglbl_")).ToList() ?? new List <Button>();
            u.CheckBoxes     = ui.CheckBoxes.Where(a => a.Name.StartsWith("cfg_") || a.Name.StartsWith("cfglbl_")).ToList() ?? new List <CheckBox>();
            u.Colorpickers   = ui.Colorpickers.Where(a => a.Name.StartsWith("cfg_") || a.Name.StartsWith("cfglbl_")).ToList() ?? new List <ColorPicker>();
            u.ComboBoxes     = ui.ComboBoxes.Where(a => a.Name.StartsWith("cfg_") || a.Name.StartsWith("cfglbl_")).ToList() ?? new List <ComboBox>();
            u.Labels         = ui.Labels.Where(a => a.Name.StartsWith("cfg_") || a.Name.StartsWith("cfglbl_")).ToList() ?? new List <Label>();
            u.NumericUpDowns = ui.NumericUpDowns.Where(a => a.Name.StartsWith("cfg_") || a.Name.StartsWith("cfglbl_")).ToList() ?? new List <NumericUpDown>();
            u.RadioButtons   = ui.RadioButtons.Where(a => a.Name.StartsWith("cfg_") || a.Name.StartsWith("cfglbl_")).ToList() ?? new List <RadioButton>();
            u.Sliders        = ui.Sliders.Where(a => a.Name.StartsWith("cfg_") || a.Name.StartsWith("cfglbl_")).ToList() ?? new List <Slider>();
            u.TextBoxes      = ui.TextBoxes.Where(a => a.Name.StartsWith("cfg_") || a.Name.StartsWith("cfglbl_")).ToList() ?? new List <TextBox>();
            u.ToggleButtons  = new List <System.Windows.Controls.Primitives.ToggleButton>();

            // load json
            List <ToolTips> tips = JsonConvert.DeserializeObject <List <ToolTips> >(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"Data\System\ToolTips.json"));

            // now iterate through each set of controls and assign the tooltips
            foreach (Button c in u.Buttons)
            {
                string Name = c.Name.Replace("cfglbl_", "").Replace("cfg_", "").Replace("__", ".");
                // lookup description
                var bu = tips.Where(a => a.Command.Contains(Name)).ToList();
                if (bu.Count() > 0)
                {
                    ToolTip   tool = new ToolTip();
                    TextBlock tb   = new TextBlock();
                    tb.TextWrapping = TextWrapping.Wrap;
                    tb.MaxWidth     = 800;
                    tb.Text         = bu.First().Description;
                    tool.Content    = tb;
                    if (c.ToolTip == null)
                    {
                        c.ToolTip = tool;
                    }
                }
            }

            foreach (CheckBox c in u.CheckBoxes)
            {
                string Name = c.Name.Replace("cfglbl_", "").Replace("cfg_", "").Replace("__", ".");
                // lookup description
                var bu = tips.Where(a => a.Command.Contains(Name)).ToList();
                if (bu.Count() > 0)
                {
                    ToolTip   tool = new ToolTip();
                    TextBlock tb   = new TextBlock();
                    tb.TextWrapping = TextWrapping.Wrap;
                    tb.MaxWidth     = 800;
                    tb.Text         = bu.First().Description;
                    tool.Content    = tb;
                    if (c.ToolTip == null)
                    {
                        c.ToolTip = tool;
                    }
                }
            }

            foreach (ColorPicker c in u.Colorpickers)
            {
                string Name = c.Name.Replace("cfglbl_", "").Replace("cfg_", "").Replace("__", ".");
                // lookup description
                var bu = tips.Where(a => a.Command.Contains(Name)).ToList();
                if (bu.Count() > 0)
                {
                    ToolTip   tool = new ToolTip();
                    TextBlock tb   = new TextBlock();
                    tb.TextWrapping = TextWrapping.Wrap;
                    tb.MaxWidth     = 800;
                    tb.Text         = bu.First().Description;
                    tool.Content    = tb;
                    if (c.ToolTip == null)
                    {
                        c.ToolTip = tool;
                    }
                }
            }

            foreach (ComboBox c in u.ComboBoxes)
            {
                string Name = c.Name.Replace("cfglbl_", "").Replace("cfg_", "").Replace("__", ".");
                // lookup description
                var bu = tips.Where(a => a.Command.Contains(Name)).ToList();
                if (bu.Count() > 0)
                {
                    ToolTip   tool = new ToolTip();
                    TextBlock tb   = new TextBlock();
                    tb.TextWrapping = TextWrapping.Wrap;
                    tb.MaxWidth     = 800;
                    tb.Text         = bu.First().Description;
                    tool.Content    = tb;
                    if (c.ToolTip == null)
                    {
                        c.ToolTip = tool;
                    }
                }
            }

            foreach (Label c in u.Labels)
            {
                string Name = c.Name.Replace("cfglbl_", "").Replace("cfg_", "").Replace("__", ".");
                // lookup description
                var bu = tips.Where(a => a.Command.Contains(Name)).ToList();
                if (bu.Count() > 0)
                {
                    ToolTip   tool = new ToolTip();
                    TextBlock tb   = new TextBlock();
                    tb.TextWrapping = TextWrapping.Wrap;
                    tb.MaxWidth     = 800;
                    tb.Text         = bu.First().Description;
                    tool.Content    = tb;
                    if (c.ToolTip == null)
                    {
                        c.ToolTip = tool;
                    }
                }
            }

            foreach (NumericUpDown c in u.NumericUpDowns)
            {
                string Name = c.Name.Replace("cfglbl_", "").Replace("cfg_", "").Replace("__", ".");
                // lookup description
                var bu = tips.Where(a => a.Command.Contains(Name)).ToList();
                if (bu.Count() > 0)
                {
                    ToolTip   tool = new ToolTip();
                    TextBlock tb   = new TextBlock();
                    tb.TextWrapping = TextWrapping.Wrap;
                    tb.MaxWidth     = 800;
                    tb.Text         = bu.First().Description;
                    tool.Content    = tb;
                    if (c.ToolTip == null)
                    {
                        c.ToolTip = tool;
                    }
                }
            }


            foreach (RadioButton c in u.RadioButtons)
            {
                string Name = c.Name.Replace("cfglbl_", "").Replace("cfg_", "").Replace("__", ".");
                // lookup description
                var bu = tips.Where(a => a.Command.Contains(Name)).ToList();
                if (bu.Count() > 0)
                {
                    ToolTip   tool = new ToolTip();
                    TextBlock tb   = new TextBlock();
                    tb.TextWrapping = TextWrapping.Wrap;
                    tb.MaxWidth     = 800;
                    tb.Text         = bu.First().Description;
                    tool.Content    = tb;
                    if (c.ToolTip == null)
                    {
                        c.ToolTip = tool;
                    }
                }
            }

            foreach (Slider c in u.Sliders)
            {
                string Name = c.Name.Replace("cfglbl_", "").Replace("cfg_", "").Replace("__", ".");
                // lookup description
                var bu = tips.Where(a => a.Command.Contains(Name)).ToList();
                if (bu.Count() > 0)
                {
                    ToolTip   tool = new ToolTip();
                    TextBlock tb   = new TextBlock();
                    tb.TextWrapping = TextWrapping.Wrap;
                    tb.MaxWidth     = 800;
                    tb.Text         = bu.First().Description;
                    tool.Content    = tb;
                    if (c.ToolTip == null)
                    {
                        c.ToolTip = tool;
                    }
                }
            }

            // skip textboxes
        }