private void LoadConfig(TabPage page, CfgBase config) { ConfigurationObjectControlPanel panel = new ConfigurationObjectControlPanel(config); panel.Dock = DockStyle.Fill; page.Controls.Add(panel); }
private void LoadFrameConfig(Type clazz, TabPage page, CfgBase config) { CoreConfig core = new CoreConfig(); TabControl sectionsTab = new TabControl(); TabPage sectionPage = new TabPage("Shared"); ConfigurationObjectControlPanel panel = new ConfigurationObjectControlPanel(config, core.Frames); panel.Dock = DockStyle.Fill; sectionPage.Controls.Add(panel); sectionsTab.Controls.Add(sectionPage); foreach (var frame in core.Frames) { config = InstantiateConfig(clazz, clazz.Assembly, frame); sectionPage = new TabPage(frame); panel = new ConfigurationObjectControlPanel(config, frame); panel.Dock = DockStyle.Fill; sectionPage.Controls.Add(panel); sectionsTab.Controls.Add(sectionPage); } sectionsTab.Dock = DockStyle.Fill; page.Controls.Add(sectionsTab); }
/* * ======= * Random shit from merge - I think this is before config tool handled load errors correctly * private void LoadConfigurationObjects() { * string folder = Path.GetDirectoryName(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); * folder = Path.GetFullPath(Path.Combine(folder, "../")); * * //Iterate through every assembly in the folder where the tool is running * foreach (var assembly in * Directory.GetFiles(folder). * !f.Contains("SlimDX") && * !f.Contains("openjpeg")). * * }). * Where(a => a != null). * Concat(new Assembly[] { typeof(CfgBase).Assembly })) { * ListViewGroup g = null; * //Iterate through every class which implements one of the interfaces on the interfaces list * foreach (var clazz in * assembly.GetTypes(). * Where(t => * !t.IsAbstract && * !t.IsInterface && * IsConfig(t))) { * * * * >>>>>>> No idea what is going on. */ private void LoadConfigurationObjects() { string folder = Path.GetDirectoryName(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); folder = Path.GetFullPath(Path.Combine(folder, "../")); var assemblies = ConfigurationFolderPanel.LoadAssemblies(folder); //Iterate through every assembly in the folder where the tool is running foreach (var assembly in assemblies.Concat(new Assembly[] { typeof(CfgBase).Assembly })) { ListViewGroup g = null; IEnumerable <Type> classes = null; try { classes = assembly.GetTypes(). Where(t => !t.IsAbstract && !t.IsInterface && IsConfig(t)); } catch (ReflectionTypeLoadException e) { Console.WriteLine("Problem loading types for " + assembly.FullName.Split(',')[0] + ". " + e.Message); foreach (var ex in e.LoaderExceptions) { Console.WriteLine(ex.Message); } continue; } Console.WriteLine("Loading {1,3} configuration objects from {0}.", assembly.FullName.Split(',')[0], classes.Count()); //Iterate through every class which implements one of the interfaces on the interfaces list foreach (var clazz in classes) { CfgBase config = InstantiateConfig(clazz, assembly, CfgBase.IGNORE_FRAME); if (config == null) { continue; } Invoke(new Action(() => { TabPage page = new TabPage(clazz.Name.Replace("Config", "")); if (InheritsFrom(clazz, typeof(AxisConfig))) { LoadAxisConfig(page, config as AxisConfig); } if (config.Frame == null) { LoadConfig(page, config); } else { LoadFrameConfig(clazz, page, config); } MainTab.Controls.Add(page); })); } } }