private ConfigurationFolderPanel AddFolder(string folder) { TabPage page = new TabPage(folder); ConfigurationFolderPanel panel = new ConfigurationFolderPanel(folder, mSetter); mPanels.Add(panel); panel.Dock = DockStyle.Fill; page.Controls.Add(panel); FoldersTab.TabPages.Add(page); return panel; }
} private void createButton_Click(object sender, EventArgs e) { if (nameBox.Text == "" || nameBox.Text == NAME_DEFAULT) { MessageBox.Show("You must enter a folder name for the new configuration.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string dir = Path.Combine(Environment.CurrentDirectory, nameBox.Text); try { Directory.CreateDirectory(dir); if (copyList.SelectedItem.ToString() != NONE) { foreach (var file in Directory.GetFiles(copyList.SelectedItem.ToString()).Where(f => !f.EndsWith("~"))) File.Copy(file, Path.Combine(nameBox.Text, Path.GetFileName(file))); } mNewPanel = AddFolder(nameBox.Text); loader.DoWork -= Init; loader.DoWork += InitNewPanel; loader.RunWorkerAsync(); folderList.Items.Add(nameBox.Text); copyList.Items.Add(nameBox.Text); } catch (Exception ex) { MessageBox.Show("Unable to create configuration.\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
/* * ======= * 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); })); } } }