Index: core/details/0_2_6_x_profileloader/Loader.cs =================================================================== --- core/details/0_2_6_x_profileloader/Loader.cs (revision 0) +++ core/details/0_2_6_x_profileloader/Loader.cs (revision 0) @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using MeGUI.core.util; +using System.Xml.Serialization; +using MeGUI.core.plugins.interfaces; + +namespace MeGUI.core.details._0_2_6_x_profileloader +{ + class Loader + { + private static Profile loadProfile(string name) + where T : GenericSettings + { + GenericProfile prof = Util.XmlDeserialize>(name); + if (prof == null) + return null; + + Type t = typeof(GenericProfile<>).MakeGenericType(prof.Settings.GetType()); + return (Profile)Activator.CreateInstance(t, prof.Name, prof.Settings); + } + + private static List getProfiles(string folder) + where T : GenericSettings + { + List ps = new List(); + if (!Directory.Exists(folder)) + return ps; + + DirectoryInfo di = new DirectoryInfo(folder); + foreach (FileInfo fi in di.GetFiles("*.xml")) + { + Profile p = loadProfile(fi.FullName); + if (p != null) + ps.Add(p); + } + return ps; + } + + public static List TryLoadProfiles(string path) + { + List ps = new List(); + ps.AddRange(getProfiles(path + @"\profiles\video")); + ps.AddRange(getProfiles(path + @"\profiles\audio")); + ps.AddRange(getProfiles(path + @"\profiles\avisynth")); + ps.AddRange(getProfiles(path + @"\profiles\oneclick")); + + return ps; + } + } +} Index: core/details/0_2_6_x_profileloader/Loader.cs =================================================================== --- core/details/0_2_6_x_profileloader/Loader.cs (revision 0) +++ core/details/0_2_6_x_profileloader/Loader.cs (revision 0) @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using MeGUI.core.util; +using System.Xml.Serialization; +using MeGUI.core.plugins.interfaces; + +namespace MeGUI.core.details._0_2_6_x_profileloader +{ + class Loader + { + private static Profile loadProfile(string name) + where T : GenericSettings + { + GenericProfile prof = Util.XmlDeserialize>(name); + if (prof == null) + return null; + + Type t = typeof(GenericProfile<>).MakeGenericType(prof.Settings.GetType()); + return (Profile)Activator.CreateInstance(t, prof.Name, prof.Settings); + } + + private static List getProfiles(string folder) + where T : GenericSettings + { + List ps = new List(); + if (!Directory.Exists(folder)) + return ps; + + DirectoryInfo di = new DirectoryInfo(folder); + foreach (FileInfo fi in di.GetFiles("*.xml")) + { + Profile p = loadProfile(fi.FullName); + if (p != null) + ps.Add(p); + } + return ps; + } + + public static List TryLoadProfiles(string path) + { + List ps = new List(); + ps.AddRange(getProfiles(path + @"\profiles\video")); + ps.AddRange(getProfiles(path + @"\profiles\audio")); + ps.AddRange(getProfiles(path + @"\profiles\avisynth")); + ps.AddRange(getProfiles(path + @"\profiles\oneclick")); + + return ps; + } + } +} Index: core/details/audio/AudioCodecSettings.cs =================================================================== --- core/details/audio/AudioCodecSettings.cs (revision 426) +++ core/details/audio/AudioCodecSettings.cs (working copy) @@ -60,13 +60,12 @@ XmlInclude(typeof(OggVorbisSettings)), XmlInclude(typeof(AftenSettings)) ] - public class AudioCodecSettings : MeGUI.core.plugins.interfaces.GenericSettings + public abstract class AudioCodecSettings : MeGUI.core.plugins.interfaces.GenericSettings { + private readonly string id; + public string SettingsID { get { return id; } } + public virtual void FixFileNames(Dictionary _) {} - public string getSettingsType() - { - return "Audio"; - } private ChannelMode downmixMode; private BitrateManagementMode bitrateMode; private int bitrate; @@ -92,8 +91,9 @@ set { audioEncoderType = value; } } - public AudioCodecSettings() + public AudioCodecSettings(string id) { + this.id = id; downmixMode = ChannelMode.KeepOriginal; bitrateMode = BitrateManagementMode.CBR; bitrate = 128; @@ -177,4 +177,4 @@ #endregion } -} \ No newline at end of file +} Index: core/details/audio/AudioConfigurationPanel.cs =================================================================== --- core/details/audio/AudioConfigurationPanel.cs (revision 426) +++ core/details/audio/AudioConfigurationPanel.cs (working copy) @@ -8,18 +8,10 @@ namespace MeGUI.core.details.audio { - public partial class AudioConfigurationPanel : UserControl, MeGUI.core.plugins.interfaces.Gettable + public partial class AudioConfigurationPanel : UserControl { - #region variables - private string input, output; - private MainForm mainForm; - - private EnumProxy[] _avisynthChannelSet; - #endregion - #region polyphormism - #endregion #region start / stop public AudioConfigurationPanel() @@ -63,18 +55,6 @@ this.besweetDownmixMode.BindingContext = new BindingContext(); } - public AudioConfigurationPanel(MainForm mainForm, string[] audioInfo):this() - { - InitDialog(mainForm, audioInfo); - } - - public void InitDialog(MainForm mainForm, string[] audioInfo) - { - this.mainForm = mainForm; - this.input = audioInfo[0]; - this.output = audioInfo[1]; - } - #endregion #region dropdowns @@ -114,11 +94,11 @@ { get { - return new AudioCodecSettings(); + throw new NotImplementedException("Must be overridden"); } set { - // Do nothing + throw new NotImplementedException("Must be overridden"); } } Index: core/details/audio/AudioJob.cs =================================================================== --- core/details/audio/AudioJob.cs (revision 426) +++ core/details/audio/AudioJob.cs (working copy) @@ -65,7 +65,7 @@ { get { - return Settings.getSettingsType(); + return Settings.SettingsID; } } Index: core/details/CodecManager.cs =================================================================== --- core/details/CodecManager.cs (revision 426) +++ core/details/CodecManager.cs (working copy) @@ -96,6 +96,11 @@ this.id = id; this.codec = codec; } + + public override string ToString() + { + return ID; + } public static readonly VideoEncoderType XVID = new VideoEncoderType("XVID", VideoCodec.ASP); public static readonly VideoEncoderType LMP4 = new VideoEncoderType("LMP4", VideoCodec.ASP); public static readonly VideoEncoderType X264 = new VideoEncoderType("X264", VideoCodec.AVC); @@ -142,21 +147,6 @@ public static GenericRegisterer VideoEncoderTypes = new GenericRegisterer(); public static GenericRegisterer AudioEncoderTypes = new GenericRegisterer(); - // Audio Codecs - public static readonly ISettingsProvider NAAC = new NeroAACSettingsProvider(); - // Video Codecs - public static readonly ISettingsProvider X264 = new X264SettingsProvider(); - public static readonly ISettingsProvider Snow = new SnowSettingsProvider(); - public static readonly ISettingsProvider Lavc = new LavcSettingsProvider(); - public static readonly ISettingsProvider XviD = new XviDSettingsProvider(); - - // All Audio Codecs -#warning this must be renamed - public static readonly ISettingsProvider[] ListOfAudioCodecs = new ISettingsProvider[] { NAAC/*, WAAC, Lame, AudX, Vorbis, AC3, MP2, FAAC*/}; - // All Audio Codecs -#warning this must be renamed - public static readonly ISettingsProvider[] ListOfVideoCodecs = new ISettingsProvider[] { Lavc, X264, Snow, XviD }; - static CodecManager() { if (!( Index: core/details/JobControl.cs =================================================================== --- core/details/JobControl.cs (revision 426) +++ core/details/JobControl.cs (working copy) @@ -347,9 +347,7 @@ public void loadJobs() { string jobsPath = mainForm.MeGUIPath + "\\jobs\\"; - if (!Directory.Exists(jobsPath)) - Directory.CreateDirectory(jobsPath); - DirectoryInfo di = new DirectoryInfo(mainForm.MeGUIPath + "\\jobs\\"); + DirectoryInfo di = FileUtil.ensureDirectoryExists(jobsPath); FileInfo[] files = di.GetFiles("*.xml"); foreach (FileInfo fi in files) { Index: core/details/PackageSystem.cs =================================================================== --- core/details/PackageSystem.cs (revision 426) +++ core/details/PackageSystem.cs (working copy) @@ -23,8 +23,6 @@ GenericRegisterer tools = new GenericRegisterer(); GenericRegisterer options = new GenericRegisterer(); GenericRegisterer mediaFileTypes = new GenericRegisterer(); - GenericRegisterer> videoSettingsProviders = new GenericRegisterer>(); - GenericRegisterer> audioSettingsProviders = new GenericRegisterer>(); GenericRegisterer muxers = new GenericRegisterer(); GenericRegisterer jobPreProcessors = new GenericRegisterer(); GenericRegisterer jobPostProcessors = new GenericRegisterer(); @@ -47,14 +45,6 @@ { get { return mediaFileTypes; } } - public GenericRegisterer> VideoSettingsProviders - { - get { return videoSettingsProviders; } - } - public GenericRegisterer> AudioSettingsProviders - { - get { return audioSettingsProviders; } - } public GenericRegisterer MuxerProviders { get { return muxers; } Index: core/details/ProfileManager.cs =================================================================== --- core/details/ProfileManager.cs (revision 426) +++ core/details/ProfileManager.cs (working copy) @@ -8,75 +8,179 @@ using System.Text.RegularExpressions; using MeGUI.core.plugins.interfaces; using MeGUI.core.util; +using System.Diagnostics; +using MeGUI.core.gui; +using MeGUI.packages.video.x264; +using MeGUI.packages.tools.oneclick; +using MeGUI.packages.audio.faac; +using MeGUI.core.details._0_2_6_x_profileloader; namespace MeGUI { + public interface Editable + { + TSettings Settings + { + get; + set; + } + } + public class ProfileManager { + #region init + public ProfileManager(string path) + { + this.path = path; + profileGroups.Add(new ProfileGroup(typeof(VideoCodecSettings), "Video")); + SafeRegister("Video"); + SafeRegister("Video"); + SafeRegister("Video"); + SafeRegister("Video"); + profileGroups.Add(new ProfileGroup(typeof(AudioCodecSettings), "Audio")); + SafeRegister("Audio"); + SafeRegister("Audio"); + SafeRegister("Audio"); + SafeRegister("Audio"); + SafeRegister("Audio"); + SafeRegister("Audio"); + SafeRegister("Audio"); + SafeRegister("Audio"); + SafeRegister("Audio"); + + SafeRegister(); + SafeRegister(); + } + #endregion + + public static readonly string ScratchPadName = "*scratchpad*"; + string path; - Dictionary selectedProfiles = new Dictionary(); - List settingsTypes = new List(); - Dictionary profileTypes = new Dictionary(); - Dictionary> profiles = new Dictionary>(); + private List profileTypes = new List(); + private List profileGroups = new List(); - public bool Register(string name, Type type) + + + #region registration + public bool SafeRegister(params string[] groups) + where TSettings : GenericSettings, new() + where TPanel : Control, Editable, new() { - if (settingsTypes.Contains(name)) return false; - System.Diagnostics.Debug.Assert((!profileTypes.ContainsKey(name)) && (!profiles.ContainsKey(name))); - settingsTypes.Add(name); - profileTypes[name] = type; - profiles[name] = new Dictionary(); - selectedProfiles[name] = ""; + string name = new TSettings().SettingsID; + if (byName(name) != null) return false; + if (bySettingsType(typeof(TSettings)) != null) return false; + + ProfileType p = new SpecificProfileType(name); + profileTypes.Add(p); + + foreach (string g in groups) + groupByName(g).Register(p, name, typeof(TSettings)); return true; } - public ProfileManager(string path) + public bool Register(Type TSettings, Type TPanel, string name) { - this.path = path; - Register(new x264Settings().getSettingsType(), typeof(GenericProfile)); - Register(new AudioCodecSettings().getSettingsType(), typeof(GenericProfile)); - Register(new OneClickSettings().getSettingsType(), typeof(GenericProfile)); - Register(new AviSynthSettings().getSettingsType(), typeof(GenericProfile)); + MethodInfo m = typeof(ProfileManager).GetMethod("SafeRegister"); + MethodInfo m2 = m.MakeGenericMethod(TSettings, TPanel); + return (bool)m2.Invoke(this, new object[] { name }); } + #endregion + + #region private util + /// + /// eliminates non allowed characters and replaced them with an underscore + /// + /// + /// + private static string fixName(string name) + { + name = name.Replace("\"", "_hc_"); + name = name.Replace("*", "_st_"); + name = name.Replace("/", "_sl_"); + name = name.Replace(":", "_dp_"); + name = name.Replace("<", "_lt_"); + name = name.Replace(">", "_rt_"); + name = name.Replace("?", "_qm_"); + name = name.Replace("\\", "_bs_"); + name = name.Replace("|", "_vl_"); + return name; + } + + private ProfileGroup groupByName(string name) + { + return Util.ByID(profileGroups, name); + } + + private ProfileType byName(string name) + { + return Util.ByID(profileTypes, name); + } + + private ProfileType bySettingsType(Type t) + { + return profileTypes.Find(delegate(ProfileType p) { return p.SettingsType == t; }); + } + + private Type profileType(string id) + { + return typeof(GenericProfile<>).MakeGenericType(byName(id).SettingsType); + } + #endregion + #region loading and saving - public void LoadProfiles() + private static string profilePath(string path, Profile prof) { - loadProfiles(); + return Path.Combine(Path.Combine(GetSaveFolder(path), prof.BaseSettings.SettingsID), fixName(prof.FQName) + ".xml"); } + + const string SaveFolderName = "allprofiles"; + + public static string GetSaveFolder(string path) + { + return Path.Combine(path, SaveFolderName); + } + /// /// saves all the profiles /// this is called when the program exists and ensures that all /// currently defined profiles are saved, overwriting currently existing ones /// - public void SaveProfiles() + public static void WriteProfiles(string path, IEnumerable profiles) { - foreach (Dictionary profileSet in profiles.Values) + try { - foreach (Profile prof in profileSet.Values) - { - saveProfile(prof); - } + FileUtil.DeleteDirectoryIfExists(GetSaveFolder(path), true); } + catch (IOException e) + { + MessageBox.Show("There was an error clearing the profiles folder before deletion: " + e.Message, "Error saving profiles", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + foreach (Profile p in profiles) + Util.XmlSerialize(p, profilePath(path, p)); + } + + public void SaveProfiles() + { + WriteProfiles(path, AllProfiles); saveSelectedProfiles(); } private void saveSelectedProfiles() { - string filename = path + @"\profiles\SelectedProfiles.xml"; + string filename = Path.Combine(GetSaveFolder(path), "SelectedProfiles.xml"); XmlSerializer ser = null; using (Stream s = File.Open(filename, System.IO.FileMode.Create, System.IO.FileAccess.Write)) { try { // Hacky workaround because serialization of dictionaries isn't possible - string[] keys = new string[selectedProfiles.Count]; - string[] values = new string[selectedProfiles.Count]; - selectedProfiles.Keys.CopyTo(keys, 0); - for (int i = 0; i < keys.Length; i++) - { - values[i] = selectedProfiles[keys[i]]; - } - string[][] data = new string[][] { keys, values }; + string[] groupKeys = profileGroups.ConvertAll(delegate(ProfileGroup g) { return g.ID; }).ToArray(); + string[] groupValues = profileGroups.ConvertAll(delegate(ProfileGroup g) { return g.SelectedChild; }).ToArray(); + string[] keys = profileTypes.ConvertAll(delegate(ProfileType p) { return p.ID; }).ToArray(); + string[] values = profileTypes.ConvertAll(delegate(ProfileType p) { return p.SelectedProfile.Name; }).ToArray(); + string[][] data = new string[][] { keys, values, groupKeys, groupValues }; ser = new XmlSerializer(data.GetType()); ser.Serialize(s, data); } @@ -89,9 +193,9 @@ private void loadSelectedProfiles() { - string file = path + @"\profiles\SelectedProfiles.xml"; + string file = Path.Combine(GetSaveFolder(path), "SelectedProfiles.xml"); if (!File.Exists(file)) return; - using (Stream s = File.OpenRead(path + @"\profiles\SelectedProfiles.xml")) + using (Stream s = File.OpenRead(file)) { try { @@ -100,11 +204,19 @@ string[][] data = (string[][])ser.Deserialize(s); string[] keys = data[0]; string[] values = data[1]; + string[] groupKeys = data[2]; + string[] groupValues = data[3]; System.Diagnostics.Debug.Assert(keys.Length == values.Length); + Debug.Assert(groupKeys.Length == groupValues.Length); for (int i = 0; i < keys.Length; i++) { - selectedProfiles[keys[i]] = values[i]; + byName(keys[i]).SelectedProfile = byName(keys[i]).ByName(values[i]); } + + for (int i = 0; i < groupKeys.Length; ++i) + { + groupByName(groupKeys[i]).SelectedChild = groupValues[i]; + } } catch (Exception) { @@ -113,369 +225,394 @@ } } - private void loadProfiles() + public void LoadProfiles() { - foreach (string type in settingsTypes) + if (Directory.Exists(Path.Combine(path, "profiles"))) { - string profilePath = path + @"\profiles\" + type; - if (!Directory.Exists(profilePath)) - Directory.CreateDirectory(profilePath); - DirectoryInfo di = new DirectoryInfo(profilePath); - FileInfo[] files = di.GetFiles("*.xml"); - foreach (FileInfo fi in files) - { - string fileName = fi.FullName; - if (Path.GetFileNameWithoutExtension(fileName) != "") // additional check to ensure that rogue profiles are not loaded - { - Profile prof = loadProfile(fileName, type); - if (prof != null) - { - if (profiles[type].ContainsKey(prof.Name)) - MessageBox.Show(type + " profile " + prof.Name + " is has already been loaded\nDiscarding duplicate profile " + fi.FullName, "Duplicate profile name", - MessageBoxButtons.OK, MessageBoxIcon.Warning); - else - { - profiles[type].Add(prof.Name, prof); - } - } - } - } + setAllProfiles(Loader.TryLoadProfiles(path)); + FileUtil.DeleteDirectoryIfExists(Path.Combine(path, "profiles"), true); + return; } + + foreach (ProfileType t in profileTypes) + t.Profiles = readAllProfiles(t); + loadSelectedProfiles(); - } - /// - /// saves a profile to program directory\profiles\profilename.xml - /// the serializer mechanism used is xml which yields a humanly readable profile - /// - /// the Profile to be saved - private void saveProfile(Profile prof) - { - if (prof.Name == "") - return; // redundant check to eliminate rogue profiles - XmlSerializer ser = null; - string fileName = ProfilePath(prof); - FileUtil.ensureDirectoryExists(Path.GetDirectoryName(fileName)); - using (Stream s = File.Open(fileName, System.IO.FileMode.Create, System.IO.FileAccess.Write)) - { - try - { - ser = new XmlSerializer(prof.GetType()); - ser.Serialize(s, prof); - } - catch (Exception e) - { - MessageBox.Show("Profile " + prof.Name + " could not be saved. Error message: " + e.Message, "Error saving profile", MessageBoxButtons.OK); - s.Close(); - try { File.Delete(fileName); } - catch (IOException) { } - } - } - } + } - /// - /// loads a profile with a given name from program-directory\profiles\profilename.xml - /// - /// name of the profile - /// the loaded Profile or null if the profile could not be loaded - private Profile loadProfile(string name, string type) + public static List ReadAllProfiles(string path) { - XmlSerializer ser = null; - using (Stream s = File.OpenRead(name)) - { - try - { - try - { - ser = new XmlSerializer(profileTypes[type]); - return (Profile)ser.Deserialize(s); - } - catch (InvalidOperationException) - { - s.Close(); - return updateProfile(name, type); // If this fails, it will throw to the catch below - } - } - catch (Exception) - { - DialogResult r = MessageBox.Show("Profile " + name + " could not be loaded. Delete?", "Error loading profile", MessageBoxButtons.YesNo, MessageBoxIcon.Error); - return null; - } - } + ProfileManager p = new ProfileManager(path); + if (Directory.Exists(Path.Combine(path, "profiles"))) + return Loader.TryLoadProfiles(path); + + List ps = new List(); + + foreach (ProfileType t in p.profileTypes) + ps.AddRange(p.readAllProfiles(t)); + + return ps; } - private Profile updateProfile(string name, string type) + private List readAllProfiles(ProfileType type) { - string[] data = File.ReadAllLines(name); - if (new Regex("GenericProfileOf[a-zA-Z]+").IsMatch(data[1])) // It's already a new profile - return null; - Regex matchLine2 = new Regex(@"(?<=\<)[a-zA-Z]+"); - string replaceName = "GenericProfileOf" + profileTypes[type].GetGenericArguments()[0].Name; - data[1] = matchLine2.Replace(data[1], replaceName); - Regex matchLastLine = new Regex(@"(?<=\(files).ConvertAll( + delegate(FileInfo fi) + { + return (Profile)Util.XmlDeserialize(fi.FullName, type.GenericProfileType); + })); } - #endregion - #region individual setting and getting - /// - /// delets the audio profile with the given name - /// - /// the name of the profile to be deleted - public bool DeleteProfile(string name, string type) + + private void setAllProfiles(List ps) { - if (profiles[type].Remove(name)) + ps = Util.RemoveDuds(ps); + foreach (ProfileType type in profileTypes) { - if (selectedProfiles[type] == name) selectedProfiles[type] = ""; - string fileName = path + @"\profiles\" + type + "\\" + name + ".xml"; - if (File.Exists(fileName)) - File.Delete(fileName); - return true; + type.Profiles = ps.FindAll( + delegate(Profile p) { return p.GetType().Equals(type.GenericProfileType); }); } - else - { - MessageBox.Show("Profile " + name + " could not be found and can thus not be deleted.", "Error loading profile", MessageBoxButtons.OK); - return false; - } } - /// - /// adds a new audio profile - /// - /// the new profile to be added - /// true if the insertion succeeded, false if not - public bool AddProfile(Profile prof, string type) + #endregion + + #region selected profiles + public Profile GetSelectedProfile(string profileType) { - if (profiles[type].ContainsKey(prof.Name)) - return false; - else - { - profiles[type].Add(prof.Name, prof); - saveProfile(prof); - return true; - } + ProfileType t = byName(profileType); + if (t != null) + return t.SelectedProfile; + + ProfileGroup g = groupByName(profileType); + Debug.Assert(g != null); + + return GetSelectedProfile(g.SelectedChild); } - public string GetSelectedProfileName(string profileType) + public void SetSelectedProfile(Profile prof) { - return selectedProfiles[profileType]; + bySettingsType(GetSettingsType(prof)).SelectedProfile = prof; } + #endregion - public Profile GetSelectedProfile(string profileType) + public Profile GetProfile(string type, string name) { - string name = GetSelectedProfileName(profileType); - if (string.IsNullOrEmpty(name)) return null; - try { return profiles[profileType][name]; } - catch { } - return null; + return byName(type).ByName(name); } - public void SetSelectedProfile(Profile prof) + #region profileset operations + private List byProfileSet(string profileSet) { - SetSelectedProfile(prof.BaseSettings.getSettingsType(), prof.Name); + List res = new List(); + ProfileType p = byName(profileSet); + if (p != null) + { + res.Add(p); + return res; + } + + ProfileGroup g = groupByName(profileSet); + if (g == null) + throw new Exception(); + + foreach (string s in g.ChildIDs) + res.AddRange(byProfileSet(s)); + + return res; } - public void SetSelectedProfile(string profileType, string name) + public IEnumerable> Profiles(string type) { - selectedProfiles[profileType] = name; + List ps = byProfileSet(type); + + if (ps.Count == 1) + return Util.ConvertAll>(ps[0].Profiles, delegate (Profile pr) { return new Named(pr.Name, pr); }); + + List> profiles = new List>(); + foreach (ProfileType p in ps) + profiles.AddRange(Util.ConvertAll>(p.Profiles, delegate (Profile prof) { return new Named(prof.FQName, prof); })); + + return profiles; } - #endregion - #region helper methods - /// - /// eliminates non allowed characters and replaced them with an underscore - /// - /// - /// - private static string fixName(string name) + + public void AddProfilesChangedListener(string profileSet, EventHandler listener) { - name = name.Replace("\"", "_hc_"); - name = name.Replace("*", "_st_"); - name = name.Replace("/", "_sl_"); - name = name.Replace(":", "_dp_"); - name = name.Replace("<", "_lt_"); - name = name.Replace(">", "_rt_"); - name = name.Replace("?", "_qm_"); - name = name.Replace("\\", "_bs_"); - name = name.Replace("|", "_vl_"); - return name; + foreach (ProfileType p in byProfileSet(profileSet)) + p.ProfilesChanged += listener; } - public string ProfilePath(Profile prof) + public void RemoveProfilesChangedListener(string profileSet, EventHandler listener) { - return ProfilePath(prof, this.path); + foreach (ProfileType p in byProfileSet(profileSet)) + p.ProfilesChanged -= listener; } + #endregion - public static string ProfilePath(Profile prof, string path) + #region Profile Listing + private Profile byFormattedName(string formattedName) { - return Path.Combine(path, @"profiles\" + prof.BaseSettings.getSettingsType() + "\\" + fixName(prof.Name) + ".xml"); + string type = formattedName.Substring(0, formattedName.IndexOf(':')); + System.Diagnostics.Debug.Assert(formattedName.StartsWith(type + ": ")); + string profileName = formattedName.Substring(type.Length + 2); + return GetProfile(type, profileName); } - #endregion - #region my hasher - class MyHashTable - where TSettings : GenericSettings + public Profile[] AllProfiles { - private Dictionary impl; - public GenericProfile this[string key] + get { - get - { - return (GenericProfile)impl[key]; - } - set - { - impl[key] = value; - } + List profileList = new List(); + + foreach (ProfileType ty in profileTypes) + profileList.AddRange(ty.Profiles); + + return profileList.ToArray(); } - MyHashTable(Dictionary impl) + } + + public void AddAll(Profile[] profiles, DialogManager asker) + { + foreach (Profile prof in profiles) { - this.impl = impl; + bySettingsType(GetSettingsType(prof)).Add(prof, asker); } } #endregion - #region properties -#warning look at properties here. Work out how to do the types - public Dictionary AudioProfiles + + + #region misc operations + private static Type GetSettingsType(Profile p) { - get { return profiles[new AudioCodecSettings().getSettingsType()]; } - set { profiles[new AudioCodecSettings().getSettingsType()] = value; } + return p.GetType().GetGenericArguments()[0]; } - public Dictionary AvsProfiles + + public void Configure(Profile SelectedProfile) { - get { return profiles[new AviSynthSettings().getSettingsType()]; } - set { profiles[new AviSynthSettings().getSettingsType()] = value; } + bySettingsType(GetSettingsType(SelectedProfile)).ConfigureProfiles(); } - public Dictionary OneClickProfiles + + public void SetSettings(GenericSettings s) { - get { return profiles[new OneClickSettings().getSettingsType()]; } - set { profiles[new OneClickSettings().getSettingsType()] = value; } + bySettingsType(s.GetType()).SetSettings(s); } - public Dictionary VideoProfiles + + public GenericSettings GetCurrentSettings(string p) { - get { return profiles[new x264Settings().getSettingsType()]; } - set { profiles[new x264Settings().getSettingsType()] = value; } + return GetSelectedProfile(p).BaseSettings; } - public Dictionary Profiles(string type) { return profiles[type]; } #endregion - #region Profile Listing - public Profile ByFormattedName(string formattedName) - { - string type = formattedName.Substring(0, formattedName.IndexOf(':')); - System.Diagnostics.Debug.Assert(formattedName.StartsWith(type + ": ")); - string profileName = formattedName.Substring(type.Length + 2); - return Profiles(type)[profileName]; - } + } - public string[] AllProfileNames + abstract class ProfileType : IIDable + { + public event EventHandler SelectedProfileSet; + public event EventHandler ProfilesChanged; + + private readonly string profileTypeID; + + public string ID { get { return profileTypeID; } } + + public Tuple, Profile> ProfilesAndSelected { - get + get { return new Tuple, Profile>(profiles, selectedProfile); } + set { - List profileList = new List(); - foreach (string key in profiles.Keys) - { - Dictionary profileSet = profiles[key]; - foreach (string name in profileSet.Keys) - { - profileList.Add(key + ": " + name); - } - } - return profileList.ToArray(); + profiles = new List(value.a); + if (profiles.Count == 0) + profiles.Add(genScratchpad()); + + selectedProfile = value.b ?? profiles[0]; + + raiseChangedEvent(); } } - public void AddDependantProfiles(string formattedName, Dictionary includedProfiles) + public IEnumerable Profiles { - if (includedProfiles.ContainsKey(formattedName)) return; // This profile has already been added - - Profile prof = ByFormattedName(formattedName); - includedProfiles[formattedName] = prof; - - string[] formattedNames = prof.BaseSettings.RequiredProfiles; - foreach (string profileName in formattedNames) - { - AddDependantProfiles(profileName, includedProfiles); - } + get { return ProfilesAndSelected.a; } + set { ProfilesAndSelected = new Tuple,Profile>(value, null); } } - public Profile[] AllProfiles(string[] formattedProfileNames) + + private void raiseChangedEvent() { - Dictionary profileList = new Dictionary(); - foreach (string formattedProfileName in formattedProfileNames) + if (ProfilesChanged != null) + ProfilesChanged(this, EventArgs.Empty); + } + + protected List profiles = new List(); + + protected abstract Profile genScratchpad(); + + private Profile selectedProfile; + public Profile SelectedProfile + { + get { return selectedProfile; } + set { - AddDependantProfiles(formattedProfileName, profileList); + selectedProfile = value ?? selectedProfile; + if (SelectedProfileSet != null) + SelectedProfileSet(this, EventArgs.Empty); } - Profile[] array = new Profile[profileList.Count]; - profileList.Values.CopyTo(array, 0); - return array; } - public List AllRequiredFiles(Profile[] profiles) + public void SetSettings(GenericSettings s) { - List files = new List(); - - // Generate the list of files - foreach (Profile prof in profiles) - files.AddRange(prof.BaseSettings.RequiredFiles); + if (s.GetType() != SettingsType) + throw new Exception("Wrong type of settings used"); - // Make it unique - for (int i = 0; i < files.Count; i++) + Profile p = ByName(ProfileManager.ScratchPadName); + if (p == null) { - string file = files[i]; - int index; - while ((index = files.LastIndexOf(file)) > i) - { - files.RemoveAt(index); - } + p = genScratchpad(); + profiles.Add(p); } + p.BaseSettings = s; + SelectedProfile = p; + } - return files; + public abstract void ConfigureProfiles(); + + public abstract Type SettingsType { get; } + + public Type GenericProfileType + { + get { return typeof(GenericProfile<>).MakeGenericType(SettingsType); } } - public static void FixFileNames(Profile[] profileList, Dictionary substitutionTable) + + public ProfileType(string name) { - foreach (Profile prof in profileList) - { - prof.BaseSettings.FixFileNames(substitutionTable); - } + profileTypeID = name; } - public void AddAll(Profile[] profiles, DialogManager asker) + public Profile ByName(string name) { - foreach (Profile prof in profiles) + int i = indexOf(name); + if (i >= 0) + return profiles[i]; + else + return null; + } + + private int indexOf(string name) + { + return profiles.FindIndex(delegate(Profile p) { return p.Name == name; }); + } + + public void Add(Profile prof, DialogManager asker) + { + int i = indexOf(prof.Name); + if (i < 0) { - Add(prof, asker); + profiles.Add(prof); + raiseChangedEvent(); } + else if (asker.overwriteProfile(prof.FQName)) + profiles[i] = prof; + else { /* skip this profile */ } } - public void Add(Profile prof, DialogManager asker) + } + + abstract class SpecificProfileType : ProfileType + where TSettings : GenericSettings, new() + { + public SpecificProfileType(string name) : base(name) { } + + public override Type SettingsType { - if (!AddProfile(prof, prof.BaseSettings.getSettingsType())) + get { return typeof(TSettings); } + } + + public GenericProfile SByName(string name) + { + return (GenericProfile)ByName(name); + } + + public Tuple>, GenericProfile> SProfiles + { + get { - if (!asker.overwriteProfile(prof.Name)) - return; - else - { - DeleteProfile(prof); - Add(prof, asker); - } + Tuple, Profile> p = ProfilesAndSelected; + + return new Tuple>, GenericProfile>( + Util.CastAll>(p.a), + (GenericProfile)p.b); } + set + { + ProfilesAndSelected = new Tuple, Profile>( + Util.CastAll, Profile>(value.a), + value.b); + } } - public bool DeleteProfile(Profile prof) + + public GenericProfile SSelectedProfile { - return DeleteProfile(prof.Name, prof.BaseSettings.getSettingsType()); + get { return (GenericProfile)SelectedProfile; } + set { SelectedProfile = value; } } - #endregion - public bool AddProfile(Profile prof) + protected override Profile genScratchpad() { - return AddProfile(prof, prof.BaseSettings.getSettingsType()); + return new GenericProfile(ProfileManager.ScratchPadName, new TSettings()); } + } - public bool AddVideoProfile(GenericProfile prof) + class SpecificProfileType : SpecificProfileType + where TSettings : GenericSettings, new() + where TPanel : Control, Editable, new() + { + public override void ConfigureProfiles() { - return AddProfile(prof, prof.BaseSettings.getSettingsType()); + // used to init with mainForm, but that is not required any more. OTOH, a ProfileManager instance might be required + TPanel t = new TPanel(); + ProfileConfigurationWindow w = new ProfileConfigurationWindow(t, ID); + w.Profiles = SProfiles; + if (w.ShowDialog() == DialogResult.Cancel) + return; + + SProfiles = w.Profiles; } + public SpecificProfileType(string name) + : base(name) + { } } + + class ProfileGroup : IIDable + { + private readonly string profileGroupID; + + public string ID { get { return profileGroupID; } } + + public List ChildIDs = new List(); + public readonly Type CommonType; + public string SelectedChild = null; + + public ProfileGroup(Type t, string name) + { + Debug.Assert(Array.IndexOf(t.GetInterfaces(), typeof(GenericSettings)) >= 0); + //Debug.Assert(t.IsSubclassOf(typeof(GenericSettings))); + CommonType = t; + profileGroupID = name; + } + + public void Register(ProfileType t, string childID, Type childType) + { + Debug.Assert(childType.IsSubclassOf(CommonType)); + + if (!ChildIDs.Contains(childID)) + ChildIDs.Add(childID); + + if (SelectedChild == null) + SelectedChild = childID; + + t.SelectedProfileSet += delegate(object _, EventArgs __) + { + SelectedChild = childID; + }; + } + } + } Index: core/details/video/VideoCodecSettings.cs =================================================================== --- core/details/video/VideoCodecSettings.cs (revision 426) +++ core/details/video/VideoCodecSettings.cs (working copy) @@ -29,6 +29,9 @@ [XmlInclude(typeof(lavcSettings)), XmlInclude(typeof(x264Settings)), XmlInclude(typeof(snowSettings)), XmlInclude(typeof(xvidSettings)), XmlInclude(typeof(hfyuSettings))] public abstract class VideoCodecSettings : MeGUI.core.plugins.interfaces.GenericSettings { + private string id; + public string SettingsID { get { return id; } } + public virtual void setAdjustedNbThreads(int nbThreads) { NbThreads = nbThreads; @@ -44,10 +47,6 @@ return base.GetHashCode(); } - public string getSettingsType() - { - return "Video"; - } public enum Mode : int { CBR = 0, CQ, twopass1, twopass2, twopassAutomated, threepass1, threepass2, threepass3, threepassAutomated, quality }; int encodingMode, bitrateQuantizer, keyframeInterval, nbBframes, minQuantizer, maxQuantizer, fourCC, maxNumberOfPasses, nbThreads; @@ -56,27 +55,30 @@ private string logfile, customEncoderOptions; private Zone[] zones; private string[] fourCCs; + private VideoEncoderType vet; public abstract bool UsesSAR { get; } - public VideoCodecSettings() + public VideoCodecSettings(string id, VideoEncoderType vet) { + this.id = id; + this.vet = vet; logfile = ".stats"; customEncoderOptions = ""; fourCC = 0; nbThreads = 1; zones = new Zone[0]; } - public abstract VideoCodec Codec + public VideoCodec Codec { - get; + get { return EncoderType.VCodec; } } - public abstract VideoEncoderType EncoderType + public VideoEncoderType EncoderType { - get; + get { return vet; } } public int EncodingMode { Index: core/details/video/VideoConfigurationPanel.cs =================================================================== --- core/details/video/VideoConfigurationPanel.cs (revision 426) +++ core/details/video/VideoConfigurationPanel.cs (working copy) @@ -20,7 +20,7 @@ private bool loaded; private int introEndFrame = 0, creditsStartFrame = 0; - protected string input = "", output = "", encoderPath = ""; + protected string input = "input", output = "output", encoderPath = "program"; #endregion protected ToolTip tooltipHelp; private IContainer components; @@ -34,14 +34,9 @@ { loaded = false; InitializeComponent(); - zonesControl.UpdateGUIEvent += new ZonesControl.UpdateConfigGUI(genericUpdate); - zonesControl.MainForm = mainForm; input = info.VideoInput; - zonesControl.Input = input; output = info.VideoOutput; - zonesControl.IntroEndFrame = info.IntroEndFrame; - zonesControl.CreditsStartFrame = info.CreditsStartFrame; } private void VideoConfigurationPanel_Load(object sender, EventArgs e) @@ -51,11 +46,6 @@ genericUpdate(); } - private void VideoConfigurationPanel_VisibleChanged(object sender, EventArgs e) - { - if (!Visible) zonesControl.closePlayer(); - } - #endregion #region codec specific adjustments @@ -133,65 +123,14 @@ set { bytesPerFrame = value; } } - /// - /// sets the video input (for commandline generation and zone previews) - /// - public string Input - { - set - { - this.input = value; - zonesControl.Input = value; - } - } - /// - /// sets the video output (for commandline generation) - /// - public string Output - { - set { this.output = value; } - } - /// - /// sets the path of besweet - /// - public string EncoderPath - { - set { this.encoderPath = value; } - } - /// - /// gets / sets the start frame of the credits - /// - public int CreditsStartFrame - { - get { return this.creditsStartFrame; } - set { creditsStartFrame = value; } - } - /// - /// gets / sets the end frame of the intro - /// - public int IntroEndFrame - { - get { return this.introEndFrame; } - set { introEndFrame = value; } - } - /// - /// gets / sets the zones of the video - /// - public Zone[] Zones - { - get { return zonesControl.Zones; } - set { zonesControl.Zones = value; } - } #endregion - - - - + + + + protected TabControl tabControl1; - protected TabPage zoneTabPage; protected TextBox commandline; protected TabPage mainTabPage; - protected ZonesControl zonesControl; private void InitializeComponent() @@ -199,12 +138,9 @@ this.components = new System.ComponentModel.Container(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.mainTabPage = new System.Windows.Forms.TabPage(); - this.zoneTabPage = new System.Windows.Forms.TabPage(); - this.zonesControl = new MeGUI.ZonesControl(); this.commandline = new System.Windows.Forms.TextBox(); this.tooltipHelp = new System.Windows.Forms.ToolTip(this.components); this.tabControl1.SuspendLayout(); - this.zoneTabPage.SuspendLayout(); this.SuspendLayout(); // // tabControl1 @@ -213,7 +149,6 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.tabControl1.Controls.Add(this.mainTabPage); - this.tabControl1.Controls.Add(this.zoneTabPage); this.tabControl1.Location = new System.Drawing.Point(0, 0); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; @@ -225,34 +160,11 @@ this.mainTabPage.Location = new System.Drawing.Point(4, 22); this.mainTabPage.Name = "mainTabPage"; this.mainTabPage.Padding = new System.Windows.Forms.Padding(3); - this.mainTabPage.Size = new System.Drawing.Size(319, 318); + this.mainTabPage.Size = new System.Drawing.Size(360, 318); this.mainTabPage.TabIndex = 0; this.mainTabPage.Text = "Main"; this.mainTabPage.UseVisualStyleBackColor = true; // - // zoneTabPage - // - this.zoneTabPage.Controls.Add(this.zonesControl); - this.zoneTabPage.Location = new System.Drawing.Point(4, 22); - this.zoneTabPage.Name = "zoneTabPage"; - this.zoneTabPage.Size = new System.Drawing.Size(360, 318); - this.zoneTabPage.TabIndex = 2; - this.zoneTabPage.Text = "Zones"; - this.zoneTabPage.UseVisualStyleBackColor = true; - // - // zonesControl - // - this.zonesControl.AutoSize = true; - this.zonesControl.CreditsStartFrame = 0; - this.zonesControl.Input = ""; - this.zonesControl.IntroEndFrame = 0; - this.zonesControl.Location = new System.Drawing.Point(0, 3); - this.zonesControl.MainForm = null; - this.zonesControl.Name = "zonesControl"; - this.zonesControl.Size = new System.Drawing.Size(319, 286); - this.zonesControl.TabIndex = 0; - this.zonesControl.Zones = new MeGUI.Zone[0]; - // // commandline // this.commandline.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) @@ -278,11 +190,8 @@ this.Controls.Add(this.tabControl1); this.Name = "VideoConfigurationPanel"; this.Size = new System.Drawing.Size(372, 409); - this.VisibleChanged += new System.EventHandler(this.VideoConfigurationPanel_VisibleChanged); this.Load += new System.EventHandler(this.VideoConfigurationPanel_Load); this.tabControl1.ResumeLayout(false); - this.zoneTabPage.ResumeLayout(false); - this.zoneTabPage.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); Index: core/details/video/VideoEncodingComponent.cs =================================================================== --- core/details/video/VideoEncodingComponent.cs (revision 426) +++ core/details/video/VideoEncodingComponent.cs (working copy) @@ -10,13 +10,14 @@ using MeGUI.core.plugins.interfaces; using MeGUI.core.details.video; using MeGUI.packages.video; +using MeGUI.core.util; namespace MeGUI { public partial class VideoEncodingComponent : UserControl { private VideoPlayer player; // window that shows a preview of the video - private MainForm mainForm; + private MainForm mainForm = MainForm.Instance; #region video info private VideoInfo info; @@ -41,22 +42,14 @@ } #endregion #region generic handlers: filetype, profiles and codec. Also, encoder provider - private FileTypeHandler fileTypeHandler; - public FileTypeHandler FileTypeHandler - { - get { return fileTypeHandler; } - } - private ProfilesControlHandler profileHandler; - public ProfilesControlHandler ProfileHandler - { - get { return profileHandler; } - } - public VideoCodecSettings CurrentSettings { - get { return codecHandler.Getter(); } + get + { + return (VideoCodecSettings)videoProfile.SelectedProfile.BaseSettings; + } } private VideoEncoderProvider videoEncoderProvider = new VideoEncoderProvider(); @@ -64,71 +57,11 @@ { initVideoInfo(); InitializeComponent(); + videoProfile.Manager = MainForm.Instance.Profiles; } #endregion - #region wrappers for the above handlers - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ISettingsProvider CurrentSettingsProvider - { - get { return codecHandler.CurrentSettingsProvider; } - set { codecHandler.CurrentSettingsProvider = value; } - } - - private MultipleConfigurersHandler codecHandler; - public MultipleConfigurersHandler CodecHandler - { - get { return codecHandler; } - } - #endregion - #region initialization of those handlers - public VideoInfo getInfo() - { - return Info; - } - - public void InitializeDropdowns() - { - videoCodec.Items.Clear(); - videoCodec.Items.AddRange(mainForm.PackageSystem.VideoSettingsProviders.ValuesArray); - try { videoCodec.SelectedItem = mainForm.PackageSystem.VideoSettingsProviders["x264"]; } - catch (Exception) - { - try { videoCodec.SelectedIndex = 0; } - catch (Exception) { MessageBox.Show("No valid video codecs are set up", "No valid video codecs", MessageBoxButtons.OK, MessageBoxIcon.Error); } - } - - - fileTypeHandler = new FileTypeHandler(fileType, videoCodec, - new FileTypeHandler.SupportedOutputGetter(delegate - { - return videoEncoderProvider.GetSupportedOutput(codecHandler.CurrentSettingsProvider.EncoderType); - })); - - fileTypeHandler.FileTypeChanged += new FileTypeHandler.FileTypeEvent(delegate - (object sender, VideoType currentType) { - VideoCodecSettings settings = CurrentSettings; - this.updateIOConfig(); - if (MainForm.verifyOutputFile(this.VideoOutput) == null) - this.VideoOutput = Path.ChangeExtension(this.VideoOutput, currentType.Extension); - }); - - codecHandler = - new MultipleConfigurersHandler(videoCodec); - - profileHandler = new ProfilesControlHandler("Video", mainForm, profileControl1, - codecHandler.EditSettings, new InfoGetter(getInfo), - codecHandler.Getter, codecHandler.Setter); - codecHandler.Register(profileHandler); - fileTypeHandler.RefreshFiletypes(); - } - #endregion #region extra properties - public MainForm MainForm - { - set { mainForm = value; } - } public string VideoInput { get { return info.VideoInput; } @@ -203,27 +136,15 @@ MessageBox.Show(settingsError, "Unsupported configuration", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } - VideoCodecSettings vSettings = this.CurrentVideoCodecSettings.clone(); - mainForm.JobUtil.AddVideoJobs(info.VideoInput, info.VideoOutput, this.CurrentVideoCodecSettings.clone(), - info.IntroEndFrame, info.CreditsStartFrame, info.DAR, addPrerenderJob.Checked, true); + VideoCodecSettings vSettings = this.CurrentSettings.clone(); + mainForm.JobUtil.AddVideoJobs(info.VideoInput, info.VideoOutput, this.CurrentSettings.clone(), + info.IntroEndFrame, info.CreditsStartFrame, info.DAR, PrerenderJob, true); } private void fileType_SelectedIndexChanged(object sender, EventArgs e) { - VideoType currentType = CurrentVideoOutputType; - videoOutput.Filter = currentType.OutputFilterString; - this.VideoOutput = Path.ChangeExtension(this.VideoOutput, currentType.Extension); + videoOutput.Filter = CurrentVideoOutputType.OutputFilterString; + this.VideoOutput = Path.ChangeExtension(this.VideoOutput, CurrentVideoOutputType.Extension); } - /// - /// handles changes in the codec selection - /// enables / disabled the proper GUI fields - /// and changes the available fourCCs - /// at the end, the proper encodingmode_changed method is triggered to ensure a proper GUI update - /// - /// - /// - private void codec_SelectedIndexChanged(object sender, System.EventArgs e) - { - } /// /// enables / disables output fields depending on the codec configuration /// @@ -276,20 +197,9 @@ } #endregion #region helpers - /// - /// returns the video codec settings for the currently active video codec - /// - public VideoCodecSettings CurrentVideoCodecSettings - { -#warning remove - get - { - return CurrentSettings; - } - } public MuxableType CurrentMuxableVideoType { - get { return new MuxableType(CurrentVideoOutputType, CurrentVideoCodecSettings.Codec); } + get { return new MuxableType(CurrentVideoOutputType, CurrentSettings.Codec); } } public void openVideoFile(string fileName) { @@ -297,13 +207,7 @@ info.IntroEndFrame = -1; info.VideoInput = fileName; info.DAR = null; - //reset the zones for all codecs, zones are supposed to be source bound - foreach (ISettingsProvider p in (videoCodec.Items)) - { - VideoCodecSettings s = p.GetCurrentSettings(); - s.Zones = new Zone[0]; - p.LoadSettings(s); - } + if (mainForm.Settings.AutoOpenScript) openAvisynthScript(fileName); string filePath = Path.GetDirectoryName(fileName); @@ -314,7 +218,7 @@ } private bool isFirstPass() { - VideoCodecSettings settings = CurrentVideoCodecSettings; + VideoCodecSettings settings = CurrentSettings; if (settings.EncodingMode == 2 || settings.EncodingMode == 5) return true; else @@ -388,7 +292,7 @@ /// returns true if there is no intersetion between zones and credits and false if there is an intersection private bool validateCredits(int creditsStartFrame) { - VideoCodecSettings settings = this.CurrentVideoCodecSettings; + VideoCodecSettings settings = this.CurrentSettings; foreach (Zone z in settings.Zones) { if (creditsStartFrame <= z.endFrame) // credits start before end of this zone -> intersection @@ -408,7 +312,7 @@ /// true if the intro zone does not interesect with a zone, false otherwise private bool validateIntro(int introEndFrame) { - VideoCodecSettings settings = this.CurrentVideoCodecSettings; + VideoCodecSettings settings = this.CurrentSettings; foreach (Zone z in settings.Zones) { if (introEndFrame >= z.startFrame) @@ -434,11 +338,6 @@ this.VideoOutput = ""; info.CreditsStartFrame = 0; } - - public void RefreshProfiles() - { - ProfileHandler.RefreshProfiles(); - } #endregion private void addAnalysisPass_Click(object sender, EventArgs e) @@ -452,5 +351,16 @@ AviSynthJob job = new AviSynthJob(VideoInput); mainForm.Jobs.addJobsToQueue(new AviSynthJob(VideoInput)); } + + VideoEncoderType lastCodec = null; + private void videoProfile_SelectedProfileChanged(object sender, EventArgs e) + { + if (CurrentSettings.EncoderType == lastCodec) + return; + + lastCodec = CurrentSettings.EncoderType; + Util.ChangeItemsKeepingSelectedSame(fileType, videoEncoderProvider.GetSupportedOutput(lastCodec)); + + } } } Index: core/details/video/VideoEncodingComponent.Designer.cs =================================================================== --- core/details/video/VideoEncodingComponent.Designer.cs (revision 426) +++ core/details/video/VideoEncodingComponent.Designer.cs (working copy) @@ -29,18 +29,17 @@ private void InitializeComponent() { this.videoOutputLabel = new System.Windows.Forms.Label(); - this.videoCodec = new System.Windows.Forms.ComboBox(); this.fileType = new System.Windows.Forms.ComboBox(); - this.videoCodecLabel = new System.Windows.Forms.Label(); this.videoInputLabel = new System.Windows.Forms.Label(); this.queueVideoButton = new System.Windows.Forms.Button(); this.addPrerenderJob = new System.Windows.Forms.CheckBox(); this.addAnalysisPass = new System.Windows.Forms.Button(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.videoProfile = new MeGUI.core.gui.ConfigableProfilesControl(); this.label1 = new System.Windows.Forms.Label(); - this.profileControl1 = new MeGUI.core.details.video.ProfileControl(); this.videoOutput = new MeGUI.FileBar(); this.videoInput = new MeGUI.FileBar(); + this.label2 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // @@ -53,37 +52,15 @@ this.videoOutputLabel.TabIndex = 2; this.videoOutputLabel.Text = "Video Output"; // - // videoCodec - // - this.videoCodec.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.videoCodec.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.videoCodec.Location = new System.Drawing.Point(113, 79); - this.videoCodec.Name = "videoCodec"; - this.videoCodec.Size = new System.Drawing.Size(156, 21); - this.videoCodec.TabIndex = 5; - this.videoCodec.SelectedIndexChanged += new System.EventHandler(this.codec_SelectedIndexChanged); - // // fileType // - this.fileType.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.fileType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.fileType.Location = new System.Drawing.Point(341, 79); + this.fileType.Location = new System.Drawing.Point(113, 110); this.fileType.Name = "fileType"; this.fileType.Size = new System.Drawing.Size(143, 21); this.fileType.TabIndex = 7; this.fileType.SelectedIndexChanged += new System.EventHandler(this.fileType_SelectedIndexChanged); // - // videoCodecLabel - // - this.videoCodecLabel.AutoSize = true; - this.videoCodecLabel.Location = new System.Drawing.Point(6, 82); - this.videoCodecLabel.Name = "videoCodecLabel"; - this.videoCodecLabel.Size = new System.Drawing.Size(38, 13); - this.videoCodecLabel.TabIndex = 4; - this.videoCodecLabel.Text = "Codec"; - this.videoCodecLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // // videoInputLabel // this.videoInputLabel.AutoSize = true; @@ -126,18 +103,17 @@ // // groupBox1 // + this.groupBox1.Controls.Add(this.videoProfile); this.groupBox1.Controls.Add(this.label1); - this.groupBox1.Controls.Add(this.profileControl1); this.groupBox1.Controls.Add(this.videoInputLabel); this.groupBox1.Controls.Add(this.videoOutput); this.groupBox1.Controls.Add(this.videoInput); + this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.videoOutputLabel); this.groupBox1.Controls.Add(this.addAnalysisPass); this.groupBox1.Controls.Add(this.addPrerenderJob); this.groupBox1.Controls.Add(this.queueVideoButton); - this.groupBox1.Controls.Add(this.videoCodec); this.groupBox1.Controls.Add(this.fileType); - this.groupBox1.Controls.Add(this.videoCodecLabel); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox1.Location = new System.Drawing.Point(0, 0); this.groupBox1.Name = "groupBox1"; @@ -146,26 +122,26 @@ this.groupBox1.TabStop = false; this.groupBox1.Text = "Video encoding"; // + // videoProfile + // + this.videoProfile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.videoProfile.Location = new System.Drawing.Point(113, 79); + this.videoProfile.Name = "videoProfile"; + this.videoProfile.ProfileSet = "Video"; + this.videoProfile.Size = new System.Drawing.Size(371, 22); + this.videoProfile.TabIndex = 12; + this.videoProfile.SelectedProfileChanged += new System.EventHandler(this.videoProfile_SelectedProfileChanged); + // // label1 // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(275, 82); + this.label1.Location = new System.Drawing.Point(6, 110); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(55, 13); this.label1.TabIndex = 6; this.label1.Text = "File format"; // - // profileControl1 - // - this.profileControl1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.profileControl1.LabelText = "Video profile"; - this.profileControl1.Location = new System.Drawing.Point(9, 104); - this.profileControl1.Name = "profileControl1"; - this.profileControl1.Size = new System.Drawing.Size(475, 29); - this.profileControl1.TabIndex = 8; - // // videoOutput // this.videoOutput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -199,6 +175,15 @@ this.videoInput.Title = "Open AviSynth script"; this.videoInput.FileSelected += new MeGUI.FileBarEventHandler(this.videoInput_FileSelected); // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 84); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(86, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Encoder settings"; + // // VideoEncodingComponent // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -215,9 +200,7 @@ #endregion private System.Windows.Forms.Label videoOutputLabel; - private System.Windows.Forms.ComboBox videoCodec; private System.Windows.Forms.ComboBox fileType; - private System.Windows.Forms.Label videoCodecLabel; private System.Windows.Forms.Label videoInputLabel; private System.Windows.Forms.Button queueVideoButton; private System.Windows.Forms.CheckBox addPrerenderJob; @@ -225,8 +208,9 @@ private FileBar videoInput; private FileBar videoOutput; private System.Windows.Forms.GroupBox groupBox1; - private MeGUI.core.details.video.ProfileControl profileControl1; private System.Windows.Forms.Label label1; + private MeGUI.core.gui.ConfigableProfilesControl videoProfile; + private System.Windows.Forms.Label label2; } } Index: core/gui/AudioEncodingComponent.cs =================================================================== --- core/gui/AudioEncodingComponent.cs (revision 426) +++ core/gui/AudioEncodingComponent.cs (working copy) @@ -36,7 +36,6 @@ AudioEncodingTab a = new AudioEncodingTab(); tabs.Add(a); a.Dock = System.Windows.Forms.DockStyle.Fill; - a.InitializeDropdowns(); a.QueueJob = tabs[0].QueueJob; TabPage p = new TabPage("Track " + tabs.Count); @@ -105,18 +104,6 @@ tabControl1.SelectedIndex = files.Length - 1; } - internal void RefreshProfiles() - { - foreach (AudioEncodingTab t in tabs) - t.RefreshProfiles(); - } - - internal void InitializeDropdowns() - { - foreach (AudioEncodingTab t in tabs) - t.InitializeDropdowns(); - } - private void newTrackToolStripMenuItem_Click(object sender, EventArgs e) { AddTab(); @@ -144,4 +131,4 @@ removeTrackToolStripMenuItem.Enabled = true; } } -} \ No newline at end of file +} Index: core/gui/AudioEncodingTab.cs =================================================================== --- core/gui/AudioEncodingTab.cs (revision 426) +++ core/gui/AudioEncodingTab.cs (working copy) @@ -21,53 +21,6 @@ /// public Setter QueueJob; - #region handlers - private FileTypeHandler fileTypeHandler; - public FileTypeHandler FileTypeHandler - { - get { return fileTypeHandler; } - } - - private ProfilesControlHandler profileHandler; - public ProfilesControlHandler ProfileHandler - { - get { return profileHandler; } - } - - private MultipleConfigurersHandler codecHandler; - public MultipleConfigurersHandler CodecHandler - { - get { return codecHandler; } - } - #endregion - - #region init - public void InitializeDropdowns() - { - audioCodec.Items.Clear(); - audioCodec.Items.AddRange(MainForm.Instance.PackageSystem.AudioSettingsProviders.ValuesArray); - try { audioCodec.SelectedItem = MainForm.Instance.PackageSystem.AudioSettingsProviders["NAAC"]; } - catch (Exception) - { - try { audioCodec.SelectedIndex = 0; } - catch (Exception) { MessageBox.Show("No valid audio codecs are set up", "No valid audio codecs", MessageBoxButtons.OK, MessageBoxIcon.Error); } - } - - fileTypeHandler = new FileTypeHandler(audioContainer, audioCodec, new FileTypeHandler.SupportedOutputGetter(delegate - { - return audioEncoderProvider.GetSupportedOutput(codecHandler.CurrentSettingsProvider.EncoderType); - })); - - codecHandler = new MultipleConfigurersHandler(audioCodec); - - profileHandler = new ProfilesControlHandler("Audio", MainForm.Instance, profileControl1, codecHandler.EditSettings, - new InfoGetter(delegate { return new string[] { AudioInput, AudioOutput }; }), codecHandler.Getter, codecHandler.Setter); - - codecHandler.Register(profileHandler); - fileTypeHandler.RefreshFiletypes(); - } - #endregion - public string QueueButtonText { get { return queueAudioButton.Text; } @@ -96,14 +49,11 @@ { get { - if (string.IsNullOrEmpty(profileHandler.SelectedProfile)) - return codecHandler.CurrentSettingsProvider.GetCurrentSettings(); - else - return (AudioCodecSettings)profileHandler.CurrentProfile.BaseSettings; + return (AudioCodecSettings)audioProfile.SelectedProfile.BaseSettings; } private set { - codecHandler.Setter(value); + audioProfile.SetSettings(value); } } @@ -162,6 +112,7 @@ public AudioEncodingTab() { InitializeComponent(); + audioProfile.Manager = MainForm.Instance.Profiles; } @@ -243,12 +194,18 @@ this.AudioOutput = ""; this.delay.Value = 0; } + #endregion - internal void RefreshProfiles() + + private AudioEncoderType lastCodec = null; + private void audioProfile_SelectedProfileChanged(object sender, EventArgs e) { - profileHandler.RefreshProfiles(); + if (lastCodec == AudCodecSettings.EncoderType) + return; + + lastCodec = AudCodecSettings.EncoderType; + Util.ChangeItemsKeepingSelectedSame(audioContainer, AudioEncoderProvider.GetSupportedOutput(lastCodec)); } - #endregion } } Index: core/gui/AudioEncodingTab.Designer.cs =================================================================== --- core/gui/AudioEncodingTab.Designer.cs (revision 426) +++ core/gui/AudioEncodingTab.Designer.cs (working copy) @@ -31,19 +31,18 @@ this.label1 = new System.Windows.Forms.Label(); this.audioContainer = new System.Windows.Forms.ComboBox(); this.audioContainerLabel = new System.Windows.Forms.Label(); - this.audioCodecLabel = new System.Windows.Forms.Label(); this.queueAudioButton = new System.Windows.Forms.Button(); this.audioInputLabel = new System.Windows.Forms.Label(); this.audioOutputLabel = new System.Windows.Forms.Label(); this.deleteAudioButton = new System.Windows.Forms.Button(); - this.audioCodec = new System.Windows.Forms.ComboBox(); this.label2 = new System.Windows.Forms.Label(); this.delay = new System.Windows.Forms.NumericUpDown(); this.label3 = new System.Windows.Forms.Label(); + this.audioProfile = new MeGUI.core.gui.ConfigableProfilesControl(); this.cuts = new MeGUI.FileBar(); - this.profileControl1 = new MeGUI.core.details.video.ProfileControl(); this.audioOutput = new MeGUI.FileBar(); this.audioInput = new MeGUI.FileBar(); + this.label4 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.delay)).BeginInit(); this.SuspendLayout(); // @@ -58,11 +57,9 @@ // // audioContainer // - this.audioContainer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.audioContainer.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.audioContainer.FormattingEnabled = true; - this.audioContainer.Location = new System.Drawing.Point(314, 119); + this.audioContainer.Location = new System.Drawing.Point(110, 119); this.audioContainer.Name = "audioContainer"; this.audioContainer.Size = new System.Drawing.Size(85, 21); this.audioContainer.TabIndex = 25; @@ -71,22 +68,12 @@ // audioContainerLabel // this.audioContainerLabel.AutoSize = true; - this.audioContainerLabel.Location = new System.Drawing.Point(252, 122); + this.audioContainerLabel.Location = new System.Drawing.Point(3, 122); this.audioContainerLabel.Name = "audioContainerLabel"; this.audioContainerLabel.Size = new System.Drawing.Size(56, 13); this.audioContainerLabel.TabIndex = 24; this.audioContainerLabel.Text = "Extension "; // - // audioCodecLabel - // - this.audioCodecLabel.AutoSize = true; - this.audioCodecLabel.Location = new System.Drawing.Point(3, 122); - this.audioCodecLabel.Name = "audioCodecLabel"; - this.audioCodecLabel.Size = new System.Drawing.Size(38, 13); - this.audioCodecLabel.TabIndex = 22; - this.audioCodecLabel.Text = "Codec"; - this.audioCodecLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // // queueAudioButton // this.queueAudioButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -119,26 +106,18 @@ // deleteAudioButton // this.deleteAudioButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.deleteAudioButton.Location = new System.Drawing.Point(405, 117); + this.deleteAudioButton.Location = new System.Drawing.Point(339, 146); this.deleteAudioButton.Name = "deleteAudioButton"; this.deleteAudioButton.Size = new System.Drawing.Size(48, 23); this.deleteAudioButton.TabIndex = 26; this.deleteAudioButton.Text = "X"; this.deleteAudioButton.Click += new System.EventHandler(this.deleteAudioButton_Click); // - // audioCodec - // - this.audioCodec.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.audioCodec.Location = new System.Drawing.Point(110, 119); - this.audioCodec.Name = "audioCodec"; - this.audioCodec.Size = new System.Drawing.Size(136, 21); - this.audioCodec.Sorted = true; - this.audioCodec.TabIndex = 23; - // // label2 // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(3, 151); + this.label2.Location = new System.Drawing.Point(228, 122); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(34, 13); this.label2.TabIndex = 28; @@ -146,7 +125,8 @@ // // delay // - this.delay.Location = new System.Drawing.Point(110, 147); + this.delay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.delay.Location = new System.Drawing.Point(268, 120); this.delay.Maximum = new decimal(new int[] { 10000, 0, @@ -163,13 +143,25 @@ // // label3 // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(252, 151); + this.label3.Location = new System.Drawing.Point(410, 122); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(20, 13); this.label3.TabIndex = 30; this.label3.Text = "ms"; // + // audioProfile + // + this.audioProfile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.audioProfile.Location = new System.Drawing.Point(110, 89); + this.audioProfile.Name = "audioProfile"; + this.audioProfile.ProfileSet = "Audio"; + this.audioProfile.Size = new System.Drawing.Size(343, 22); + this.audioProfile.TabIndex = 31; + this.audioProfile.SelectedProfileChanged += new System.EventHandler(this.audioProfile_SelectedProfileChanged); + // // cuts // this.cuts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -185,16 +177,6 @@ this.cuts.TabIndex = 18; this.cuts.Title = "Select a file with cuts"; // - // profileControl1 - // - this.profileControl1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.profileControl1.LabelText = "Audio Profile"; - this.profileControl1.Location = new System.Drawing.Point(6, 86); - this.profileControl1.Name = "profileControl1"; - this.profileControl1.Size = new System.Drawing.Size(447, 29); - this.profileControl1.TabIndex = 21; - // // audioOutput // this.audioOutput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -227,26 +209,34 @@ this.audioInput.Title = "Select your audio input"; this.audioInput.FileSelected += new MeGUI.FileBarEventHandler(this.audioInput_FileSelected); // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(3, 94); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(86, 13); + this.label4.TabIndex = 19; + this.label4.Text = "Encoder settings"; + // // AudioEncodingTab // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.audioProfile); this.Controls.Add(this.label3); this.Controls.Add(this.delay); this.Controls.Add(this.label2); this.Controls.Add(this.cuts); this.Controls.Add(this.label1); - this.Controls.Add(this.profileControl1); this.Controls.Add(this.audioOutput); this.Controls.Add(this.audioInput); this.Controls.Add(this.audioContainer); this.Controls.Add(this.audioContainerLabel); - this.Controls.Add(this.audioCodecLabel); this.Controls.Add(this.queueAudioButton); this.Controls.Add(this.audioInputLabel); + this.Controls.Add(this.label4); this.Controls.Add(this.audioOutputLabel); this.Controls.Add(this.deleteAudioButton); - this.Controls.Add(this.audioCodec); this.Name = "AudioEncodingTab"; this.Size = new System.Drawing.Size(456, 173); ((System.ComponentModel.ISupportInitialize)(this.delay)).EndInit(); @@ -259,19 +249,18 @@ private FileBar cuts; private System.Windows.Forms.Label label1; - private MeGUI.core.details.video.ProfileControl profileControl1; private FileBar audioOutput; private FileBar audioInput; private System.Windows.Forms.ComboBox audioContainer; private System.Windows.Forms.Label audioContainerLabel; - private System.Windows.Forms.Label audioCodecLabel; private System.Windows.Forms.Button queueAudioButton; private System.Windows.Forms.Label audioInputLabel; private System.Windows.Forms.Label audioOutputLabel; private System.Windows.Forms.Button deleteAudioButton; - private System.Windows.Forms.ComboBox audioCodec; private System.Windows.Forms.Label label2; private System.Windows.Forms.NumericUpDown delay; private System.Windows.Forms.Label label3; + private ConfigableProfilesControl audioProfile; + private System.Windows.Forms.Label label4; } } Index: core/gui/AudioEncodingWindow.cs =================================================================== --- core/gui/AudioEncodingWindow.cs (revision 426) +++ core/gui/AudioEncodingWindow.cs (working copy) @@ -22,19 +22,16 @@ if (w.ShowDialog() == DialogResult.OK) j = w.audioEncodingTab1.AudioJob; - MainForm.Instance.Audio.RefreshProfiles(); - return j; }); public AudioEncodingWindow() { InitializeComponent(); - audioEncodingTab1.InitializeDropdowns(); audioEncodingTab1.QueueJob = delegate(AudioJob j) { this.DialogResult = DialogResult.OK; }; } } -} \ No newline at end of file +} Index: core/gui/AviSynthProfileConfigPanel.cs =================================================================== --- core/gui/AviSynthProfileConfigPanel.cs (revision 426) +++ core/gui/AviSynthProfileConfigPanel.cs (working copy) @@ -8,9 +8,9 @@ namespace MeGUI.core.gui { - public partial class AviSynthProfileConfigPanel : UserControl, MeGUI.core.plugins.interfaces.Gettable + public partial class AviSynthProfileConfigPanel : UserControl, Editable { - public AviSynthProfileConfigPanel(MainForm mainForm, MeGUI.core.details.video.Empty dummy) + public AviSynthProfileConfigPanel() { InitializeComponent(); this.resizeFilterType.DataSource = ScriptServer.ListOfResizeFilterType; Index: core/gui/ConfigableProfilesControl.cs =================================================================== --- core/gui/ConfigableProfilesControl.cs (revision 0) +++ core/gui/ConfigableProfilesControl.cs (revision 0) @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace MeGUI.core.gui +{ + public partial class ConfigableProfilesControl : MeGUI.core.gui.SimpleProfilesControl + { + public ConfigableProfilesControl() + { + InitializeComponent(); + } + + private void config_Click(object sender, EventArgs e) + { + Manager.Configure(SelectedProfile); + //RefreshProfiles(); + } + } +} + Index: core/gui/ConfigableProfilesControl.Designer.cs =================================================================== --- core/gui/ConfigableProfilesControl.Designer.cs (revision 0) +++ core/gui/ConfigableProfilesControl.Designer.cs (revision 0) @@ -0,0 +1,68 @@ +namespace MeGUI.core.gui +{ + partial class ConfigableProfilesControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.config = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // comboBox1 + // + this.comboBox1.Size = new System.Drawing.Size(194, 21); + // + // config + // + this.config.AutoSize = true; + this.config.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.config.Dock = System.Windows.Forms.DockStyle.Right; + this.config.Location = new System.Drawing.Point(194, 0); + this.config.Name = "config"; + this.config.Size = new System.Drawing.Size(47, 22); + this.config.TabIndex = 1; + this.config.Text = "Config"; + this.config.UseVisualStyleBackColor = true; + this.config.Click += new System.EventHandler(this.config_Click); + // + // ConfigableProfilesControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.Controls.Add(this.config); + this.Name = "ConfigableProfilesControl"; + this.Size = new System.Drawing.Size(241, 22); + this.Controls.SetChildIndex(this.config, 0); + this.Controls.SetChildIndex(this.comboBox1, 0); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button config; + } +} Index: core/gui/ConfigableProfilesControl.resx =================================================================== --- core/gui/ConfigableProfilesControl.resx (revision 0) +++ core/gui/ConfigableProfilesControl.resx (revision 0) @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Index: core/gui/Form1.cs =================================================================== --- core/gui/Form1.cs (revision 426) +++ core/gui/Form1.cs (working copy) @@ -693,6 +693,7 @@ public MainForm() { Instance = this; + constructMeGUIInfo(); InitializeComponent(); Util.SetSize(this, MeGUI.Properties.Settings.Default.MainFormSize, MeGUI.Properties.Settings.Default.MainFormWindowState); System.Reflection.Assembly myAssembly = this.GetType().Assembly; @@ -703,9 +704,8 @@ string[] resources = myAssembly.GetManifestResourceNames(); this.trayIcon.Icon = new Icon(myAssembly.GetManifestResourceStream(name + "App.ico")); this.Icon = trayIcon.Icon; - constructMeGUIInfo(); this.TitleText = Application.ProductName + " " + Application.ProductVersion; - + setGUIInfo(); Jobs.showAfterEncodingStatus(Settings); } @@ -985,8 +985,7 @@ try { string logDirectory = path + @"\logs"; - if (!Directory.Exists(logDirectory)) - Directory.CreateDirectory(logDirectory); + FileUtil.ensureDirectoryExists(logDirectory); string fileName = logDirectory + @"\logfile-" + DateTime.Now.ToString("yy'-'MM'-'dd'_'HH'-'mm'-'ss") + ".log"; File.WriteAllText(fileName, text); } @@ -1235,10 +1234,7 @@ private void importProfiles(string file) { - ProfilePorter importer = new ProfilePorter(profileManager, file, this); - importer.ShowDialog(); - Video.RefreshProfiles(); - Audio.RefreshProfiles(); + new ProfileImporter(this, file).ShowDialog(); } #endregion #region Drag 'n' Drop @@ -1266,29 +1262,25 @@ #region importing public void importProfiles(Stream data) { - if (this.InvokeRequired) + Util.ThreadSafeRun(this, delegate { - Invoke(new MethodInvoker(delegate { importProfiles(data); })); - return; - } - ProfilePorter importer = new ProfilePorter(profileManager, this, data); - importer.ShowDialog(); - Video.RefreshProfiles(); - Audio.RefreshProfiles(); + ProfileImporter importer = new ProfileImporter(this, data); + importer.ShowDialog(); + }); } private void mnuFileImport_Click(object sender, EventArgs e) { - ProfilePorter importer = new ProfilePorter(profileManager, true, this); - importer.ShowDialog(); - Video.RefreshProfiles(); - Audio.RefreshProfiles(); + try + { + new ProfileImporter(this).ShowDialog(); + } + catch (CancelledException) { } } private void mnuFileExport_Click(object sender, EventArgs e) { - ProfilePorter exporter = new ProfilePorter(profileManager, false, this); - exporter.ShowDialog(); + new ProfileExporter(this).ShowDialog(); } #endregion @@ -1373,7 +1365,7 @@ { try { - if (Directory.Exists(file)) Directory.Delete(file, true); + FileUtil.DeleteDirectoryIfExists(file, true); if (File.Exists(file)) File.Delete(file); } catch { } @@ -1427,6 +1419,14 @@ } } + public void setGUIInfo() + { + fillMenus(); + jobControl1.MainForm = this; + jobControl1.loadJobs(); + + } + /// /// default constructor /// initializes all the GUI components, initializes the internal objects and makes a default selection for all the GUI dropdowns @@ -1440,16 +1440,10 @@ this.jobUtil = new JobUtil(this); this.settings = new MeGUISettings(); addPackages(); - fillMenus(); - videoEncodingComponent1.MainForm = this; this.profileManager = new ProfileManager(this.path); this.profileManager.LoadProfiles(); this.mediaFileFactory = new MediaFileFactory(this); - videoEncodingComponent1.InitializeDropdowns(); - audioEncodingComponent1.InitializeDropdowns(); this.loadSettings(); - jobControl1.MainForm = this; - jobControl1.loadJobs(); this.dialogManager = new DialogManager(this); } @@ -1583,19 +1577,6 @@ PackageSystem.Tools.Register(new D2VCreatorTool()); PackageSystem.Tools.Register(new AVCLevelTool()); PackageSystem.Tools.Register(new VobSubTool()); - PackageSystem.VideoSettingsProviders.Register(new X264SettingsProvider()); - PackageSystem.VideoSettingsProviders.Register(new XviDSettingsProvider()); - PackageSystem.VideoSettingsProviders.Register(new SnowSettingsProvider()); - PackageSystem.VideoSettingsProviders.Register(new LavcSettingsProvider()); - PackageSystem.AudioSettingsProviders.Register(new NeroAACSettingsProvider()); - PackageSystem.AudioSettingsProviders.Register(new AudXSettingsProvider()); - PackageSystem.AudioSettingsProviders.Register(new faacSettingsProvider()); - PackageSystem.AudioSettingsProviders.Register(new ffac3SettingsProvider()); - PackageSystem.AudioSettingsProviders.Register(new ffmp2SettingsProvider()); - PackageSystem.AudioSettingsProviders.Register(new lameSettingsProvider()); - PackageSystem.AudioSettingsProviders.Register(new vorbisSettingsProvider()); - PackageSystem.AudioSettingsProviders.Register(new waacSettingsProvider()); - PackageSystem.AudioSettingsProviders.Register(new aftenSettingsProvider()); PackageSystem.MediaFileTypes.Register(new AvsFileFactory()); PackageSystem.MediaFileTypes.Register(new d2vFileFactory()); PackageSystem.MediaFileTypes.Register(new MediaInfoFileFactory()); Index: core/gui/ProfileConfigurationWindow.cs =================================================================== --- core/gui/ProfileConfigurationWindow.cs (revision 0) +++ core/gui/ProfileConfigurationWindow.cs (revision 0) @@ -0,0 +1,198 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using MeGUI.core.plugins.interfaces; +using System.Diagnostics; +using MeGUI.core.util; + +namespace MeGUI.core.gui +{ + public partial class ProfileConfigurationWindow : Form + where TSettings : GenericSettings, new() + where TPanel : Control, Editable + { + private GenericProfile scratchPadProfile + { + get + { + return byName(ProfileManager.ScratchPadName); + } + } + + private TPanel s; + + private TSettings Settings + { + get { return s.Settings; } + set { s.Settings = value; } + } + + /// + /// gets the name of the currently selected profile + /// + public string CurrentProfileName + { + get + { + return SelectedProfile.Name; + } + } + + + +/* public ProfileConfigurationWindow(ProfileManager p, Control sPanel, Gettable s, string initialProfile) + : this(p, sPanel, s, initialProfile, new TSettings().getSettingsType()) { }*/ + + public ProfileConfigurationWindow(TPanel t, string title) + { + InitializeComponent(); + this.Text = title + " configuration dialog"; + this.s = t; + System.Drawing.Size size = Size; + size.Height += t.Height - panel1.Height; + size.Width += Math.Max(t.Width - panel1.Width, 0); + Size = size; + t.Dock = DockStyle.Fill; + panel1.Controls.Add(t); + } + + private void loadDefaultsButton_Click(object sender, EventArgs e) + { + s.Settings = new TSettings(); + putSettingsInScratchpad(); + } + + private void updateButton_Click(object sender, EventArgs e) + { + GenericProfile prof = SelectedProfile; + prof.Settings = s.Settings; + } + + private void newVideoProfileButton_Click(object sender, EventArgs e) + { + string profileName = Microsoft.VisualBasic.Interaction.InputBox("Please give the profile a name", "Please give the profile a name", "", -1, -1); + if (profileName == null) + return; + profileName = profileName.Trim(); + if (profileName.Length == 0) + return; + GenericProfile prof = new GenericProfile(profileName, s.Settings); + if (byName(profileName) != null) + MessageBox.Show("Sorry, profiles must have unique names", "Duplicate profile name", MessageBoxButtons.OK); + else + { + videoProfile.Items.Add(prof); + videoProfile.SelectedItem = prof; + } + } + + public GenericProfile SelectedProfile + { + get { return (GenericProfile)videoProfile.SelectedItem; } + set + { + // We can't just set videoProfile.SelectedItem = value, because the profiles in videoProfile are cloned + foreach (GenericProfile p in videoProfile.Items) + if (p.Name == value.Name) + { + videoProfile.SelectedItem = p; + return; + } + } + } + + public Tuple>, GenericProfile> Profiles + { + get + { + return new Tuple>, GenericProfile>( + Util.CastAll>(videoProfile.Items), + SelectedProfile); + } + + set + { + videoProfile.Items.Clear(); + foreach (GenericProfile p in value.a) + videoProfile.Items.Add(p.clone()); + + SelectedProfile = value.b; + } + } + + private GenericProfile byName(string profileName) + { + foreach (GenericProfile p in Profiles.a) + if (p.Name == profileName) + return p; + + return null; + } + + private void videoProfile_SelectedIndexChanged(object sender, EventArgs e) + { + this.Settings = SelectedProfile.Settings; + } + + private void deleteVideoProfileButton_Click(object sender, EventArgs e) + { + GenericProfile prof = (GenericProfile)this.videoProfile.SelectedItem; + Debug.Assert(prof != null); + + videoProfile.Items.Remove(prof); + + if (prof.Name == ProfileManager.ScratchPadName && videoProfile.Items.Count > 0) + videoProfile.SelectedIndex = 0; + else + loadDefaultsButton_Click(null, null); + } + + private void okButton_Click(object sender, EventArgs e) + { + Profile prof = SelectedProfile; + if (prof.Name == ProfileManager.ScratchPadName) + prof.BaseSettings = Settings; + else if (!Settings.Equals(prof.BaseSettings)) + { + switch (MessageBox.Show("Profile has been changed. Update the selected profile? (Pressing No will save your changes to the scratchpad)", + "Profile update", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) + { + case DialogResult.Yes: + prof.BaseSettings = Settings; + break; + + case DialogResult.No: + putSettingsInScratchpad(); + break; + + case DialogResult.Cancel: + return; + } + } + this.DialogResult = DialogResult.OK; + } + + private void putSettingsInScratchpad() + { + TSettings s = Settings; + GenericProfile p = scratchPadProfile; + + if (p == null) + { + p = new GenericProfile(ProfileManager.ScratchPadName, s); + videoProfile.Items.Add(p); + } + + p.Settings = s; + videoProfile.SelectedItem = p; + } + } + + + + +} Index: core/gui/ProfileConfigurationWindow.Designer.cs =================================================================== --- core/gui/ProfileConfigurationWindow.Designer.cs (revision 0) +++ core/gui/ProfileConfigurationWindow.Designer.cs (revision 0) @@ -0,0 +1,172 @@ +using System.Windows.Forms; + +namespace MeGUI.core.gui +{ + partial class ProfileConfigurationWindow + { + protected GroupBox profilesGroupbox; + private Panel panel1; + protected Button cancelButton; + protected Button okButton; + private Button updateButton; + private Button loadDefaultsButton; + private ComboBox videoProfile; + private Button newVideoProfileButton; + private Button deleteVideoProfileButton; + + + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.profilesGroupbox = new System.Windows.Forms.GroupBox(); + this.updateButton = new System.Windows.Forms.Button(); + this.loadDefaultsButton = new System.Windows.Forms.Button(); + this.videoProfile = new System.Windows.Forms.ComboBox(); + this.newVideoProfileButton = new System.Windows.Forms.Button(); + this.deleteVideoProfileButton = new System.Windows.Forms.Button(); + this.panel1 = new System.Windows.Forms.Panel(); + this.cancelButton = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.profilesGroupbox.SuspendLayout(); + this.SuspendLayout(); + // + // profilesGroupbox + // + this.profilesGroupbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.profilesGroupbox.Controls.Add(this.updateButton); + this.profilesGroupbox.Controls.Add(this.loadDefaultsButton); + this.profilesGroupbox.Controls.Add(this.videoProfile); + this.profilesGroupbox.Controls.Add(this.newVideoProfileButton); + this.profilesGroupbox.Controls.Add(this.deleteVideoProfileButton); + this.profilesGroupbox.Location = new System.Drawing.Point(6, 405); + this.profilesGroupbox.Name = "profilesGroupbox"; + this.profilesGroupbox.Size = new System.Drawing.Size(400, 48); + this.profilesGroupbox.TabIndex = 44; + this.profilesGroupbox.TabStop = false; + this.profilesGroupbox.Text = "Profiles"; + // + // updateButton + // + this.updateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.updateButton.Location = new System.Drawing.Point(235, 18); + this.updateButton.Name = "updateButton"; + this.updateButton.Size = new System.Drawing.Size(50, 23); + this.updateButton.TabIndex = 15; + this.updateButton.Text = "Update"; + this.updateButton.UseVisualStyleBackColor = true; + this.updateButton.Click += new System.EventHandler(this.updateButton_Click); + // + // loadDefaultsButton + // + this.loadDefaultsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.loadDefaultsButton.Location = new System.Drawing.Point(291, 18); + this.loadDefaultsButton.Name = "loadDefaultsButton"; + this.loadDefaultsButton.Size = new System.Drawing.Size(103, 23); + this.loadDefaultsButton.TabIndex = 14; + this.loadDefaultsButton.Text = "Load Defaults"; + this.loadDefaultsButton.UseVisualStyleBackColor = true; + this.loadDefaultsButton.Click += new System.EventHandler(this.loadDefaultsButton_Click); + // + // videoProfile + // + this.videoProfile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.videoProfile.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.videoProfile.Location = new System.Drawing.Point(8, 18); + this.videoProfile.Name = "videoProfile"; + this.videoProfile.Size = new System.Drawing.Size(121, 21); + this.videoProfile.Sorted = true; + this.videoProfile.TabIndex = 11; + this.videoProfile.SelectedIndexChanged += new System.EventHandler(this.videoProfile_SelectedIndexChanged); + // + // newVideoProfileButton + // + this.newVideoProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.newVideoProfileButton.Location = new System.Drawing.Point(189, 18); + this.newVideoProfileButton.Name = "newVideoProfileButton"; + this.newVideoProfileButton.Size = new System.Drawing.Size(40, 23); + this.newVideoProfileButton.TabIndex = 12; + this.newVideoProfileButton.Text = "New"; + this.newVideoProfileButton.Click += new System.EventHandler(this.newVideoProfileButton_Click); + // + // deleteVideoProfileButton + // + this.deleteVideoProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.deleteVideoProfileButton.Location = new System.Drawing.Point(135, 18); + this.deleteVideoProfileButton.Name = "deleteVideoProfileButton"; + this.deleteVideoProfileButton.Size = new System.Drawing.Size(48, 23); + this.deleteVideoProfileButton.TabIndex = 13; + this.deleteVideoProfileButton.Text = "Delete"; + this.deleteVideoProfileButton.Click += new System.EventHandler(this.deleteVideoProfileButton_Click); + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Location = new System.Drawing.Point(2, 2); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(411, 399); + this.panel1.TabIndex = 45; + // + // cancelButton + // + this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(358, 459); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(48, 23); + this.cancelButton.TabIndex = 47; + this.cancelButton.Text = "Cancel"; + // + // okButton + // + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(312, 459); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(40, 23); + this.okButton.TabIndex = 46; + this.okButton.Text = "OK"; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // ProfileConfigurationWindow + // + this.ClientSize = new System.Drawing.Size(414, 490); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.panel1); + this.Controls.Add(this.profilesGroupbox); + this.Name = "ProfileConfigurationWindow"; + this.profilesGroupbox.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + } +} Index: core/gui/ProfileExporter.cs =================================================================== --- core/gui/ProfileExporter.cs (revision 0) +++ core/gui/ProfileExporter.cs (revision 0) @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.IO; +using MeGUI.core.util; + +namespace MeGUI.core.gui +{ + public partial class ProfileExporter : MeGUI.core.gui.ProfilePorter + { + private MainForm mainForm; + private DirectoryInfo tempFolder; + + public ProfileExporter(MainForm mainForm) + { + InitializeComponent(); + this.mainForm = mainForm; + + Profiles = mainForm.Profiles.AllProfiles; + } + + private List getRequiredFiles(List ps) + { + List files = new List(); + + foreach (Profile p in ps) + files.AddRange(p.BaseSettings.RequiredFiles); + + return Util.Unique(files); + } + + + + private void export_Click(object sender, EventArgs e) + { + Util.CatchExceptionsAndTellUser("An error occurred when saving the file", delegate + { + try + { + string filename = askForFilename(); + + tempFolder = FileUtil.CreateTempDirectory(); + + List profs = SelectedAndRequiredProfiles; + Dictionary subTable = + copyExtraFilesToFolder(getRequiredFiles(profs), + Path.Combine(tempFolder.FullName, "extra")); + + turnValuesToZippedStyleName(subTable); + + fixFileNames(profs, subTable); + + ProfileManager.WriteProfiles(tempFolder.FullName, profs); + + FileUtil.CreateZipFile(tempFolder.FullName, filename); + + DialogResult = DialogResult.OK; + MessageBox.Show("Completed successfully", "Export completed successfully", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (CancelledException) + { + DialogResult = DialogResult.Cancel; + } + }); + } + + private void turnValuesToZippedStyleName(Dictionary subTable) + { + foreach (string key in subTable.Keys) + subTable[key] = getZippedExtraFileName(subTable[key]); + } + + private static string askForFilename() + { + SaveFileDialog outputFilesChooser = new SaveFileDialog(); + outputFilesChooser.Title = "Choose your output file"; + outputFilesChooser.Filter = "Zip archives|*.zip"; + if (outputFilesChooser.ShowDialog() != DialogResult.OK) + throw new CancelledException(); + + return outputFilesChooser.FileName; + } + } +} + Index: core/gui/ProfileExporter.Designer.cs =================================================================== --- core/gui/ProfileExporter.Designer.cs (revision 0) +++ core/gui/ProfileExporter.Designer.cs (revision 0) @@ -0,0 +1,59 @@ +namespace MeGUI.core.gui +{ + partial class ProfileExporter + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // label1 + // + this.label1.Size = new System.Drawing.Size(135, 13); + this.label1.Text = "Select the profiles to export"; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(259, 323); + this.button2.Size = new System.Drawing.Size(56, 23); + this.button2.Text = "Export..."; + this.button2.Click += new System.EventHandler(this.export_Click); + // + // ProfileExporter + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.ClientSize = new System.Drawing.Size(383, 358); + this.Name = "ProfileExporter"; + this.Controls.SetChildIndex(this.label1, 0); + this.Controls.SetChildIndex(this.button2, 0); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + } +} Index: core/gui/ProfileExporter.resx =================================================================== --- core/gui/ProfileExporter.resx (revision 0) +++ core/gui/ProfileExporter.resx (revision 0) @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Index: core/gui/ProfileImporter.cs =================================================================== --- core/gui/ProfileImporter.cs (revision 0) +++ core/gui/ProfileImporter.cs (revision 0) @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using ICSharpCode.SharpZipLib.Zip; +using MeGUI.core.util; +using System.IO; + +namespace MeGUI.core.gui +{ + public partial class ProfileImporter : MeGUI.core.gui.ProfilePorter + { + private static string askForZipFile() + { + OpenFileDialog inputChooser = new OpenFileDialog(); + inputChooser.Filter = "Zip archives|*.zip"; + inputChooser.Title = "Select your input file"; + + if (inputChooser.ShowDialog() != DialogResult.OK) + throw new CancelledException(); + + return inputChooser.FileName; + } + + private DirectoryInfo tempFolder; + private DirectoryInfo extraFiles; + private MainForm mainForm; + + public ProfileImporter(MainForm mf) + :this(mf, askForZipFile()) + {} + + public ProfileImporter(MainForm mf, string filename) + : this(mf, File.OpenRead(filename)) + {} + + public ProfileImporter(MainForm mf, Stream s) + { + InitializeComponent(); + + mainForm = mf; + + tempFolder = FileUtil.CreateTempDirectory(); + FileUtil.ExtractZipFile(s, tempFolder.FullName); + + extraFiles = FileUtil.ensureDirectoryExists(Path.Combine(tempFolder.FullName, "extra")); + List ps = ProfileManager.ReadAllProfiles(tempFolder.FullName); + fixFileNames(ps, createInitSubTable()); + + Profiles = ps.ToArray(); + } + + private Dictionary createInitSubTable() + { + Dictionary d = new Dictionary(); + + foreach (FileInfo f in extraFiles.GetFiles()) + d[getZippedExtraFileName(f.Name)] = f.FullName; + + return d; + } + + private List extraFilesList + { + get { return new List(extraFiles.GetFiles()).ConvertAll(delegate(FileInfo f) { return f.FullName; }); } + } + + private void import_Click(object sender, EventArgs e) + { + Util.CatchExceptionsAndTellUser("Error importing file", delegate + { + List ps = SelectedAndRequiredProfiles; + fixFileNames(ps, + copyExtraFilesToFolder(extraFilesList, Path.Combine(mainForm.MeGUIPath, "extra"))); + + mainForm.Profiles.AddAll(ps.ToArray(), mainForm.DialogManager); + + DialogResult = DialogResult.OK; + }); + } + } + + public class CancelledException : MeGUIException + { + public CancelledException() : base("User cancelled") { } + } +} + Index: core/gui/ProfileImporter.Designer.cs =================================================================== --- core/gui/ProfileImporter.Designer.cs (revision 0) +++ core/gui/ProfileImporter.Designer.cs (revision 0) @@ -0,0 +1,60 @@ +namespace MeGUI.core.gui +{ + partial class ProfileImporter + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // label1 + // + this.label1.Size = new System.Drawing.Size(134, 13); + this.label1.Text = "Select the profiles to import"; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(269, 323); + this.button2.Size = new System.Drawing.Size(46, 23); + this.button2.Text = "Import"; + this.button2.Click += new System.EventHandler(this.import_Click); + // + // ProfileImporter + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.ClientSize = new System.Drawing.Size(383, 358); + this.Name = "ProfileImporter"; + this.Text = "Profile Importer"; + this.Controls.SetChildIndex(this.label1, 0); + this.Controls.SetChildIndex(this.button2, 0); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + } +} Index: core/gui/ProfileImporter.resx =================================================================== --- core/gui/ProfileImporter.resx (revision 0) +++ core/gui/ProfileImporter.resx (revision 0) @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Index: core/gui/ProfilePorter.cs =================================================================== --- core/gui/ProfilePorter.cs (revision 426) +++ core/gui/ProfilePorter.cs (working copy) @@ -1,362 +1,107 @@ using System; -using System.Xml.Serialization; -using System.IO; -using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; -using ICSharpCode.SharpZipLib.Zip; -using ICSharpCode.SharpZipLib.Zip.Compression; -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; using System.Windows.Forms; using MeGUI.core.util; +using System.Collections; +using System.IO; -namespace MeGUI +namespace MeGUI.core.gui { public partial class ProfilePorter : Form { - private ProfileManager profiles; - private MainForm mainForm; - private bool importMode; - private string path; - - private ProfileManager importedProfiles; - private string inputFileName = null; - private ZipFile inputFile; - private ZipOutputStream outputFile; - - public ProfilePorter(ProfileManager profiles, MainForm mainForm, Stream data) - : this (profiles, true, mainForm) + public ProfilePorter() { - inputFile = new ZipFile(data); - } - - public ProfilePorter(ProfileManager profiles, bool importMode, MainForm mainForm) - { InitializeComponent(); - this.importMode = importMode; - if (importMode) - { - okButton.Text = "Import"; - this.Text = "Profile Importer"; - helpButton1.ArticleName = "Profile importer"; - label1.Text = "Select the profiles you want to import (Ctrl or Shift might help):"; - } - this.profiles = profiles; - this.mainForm = mainForm; - this.path = Path.Combine(mainForm.MeGUIPath, "ProfilePorter.temp"); - try - { - // This will fail unless the folder is inexistant or empty - if (Directory.Exists(path)) Directory.Delete(path); - Directory.CreateDirectory(path); - mainForm.DeleteOnClosing(path); - } - catch (IOException ioe) { - throw new Exception("Could not start porter because of inability to access " + path, ioe); - } } - public ProfilePorter(ProfileManager profiles, string file, MainForm mainForm) - : this(profiles, true, mainForm) + private static object[] profilesToObjects(Profile[] ps) { - this.inputFileName = file; + return Array.ConvertAll(ps, + delegate(Profile p) { return new Named(p.FQName, p); }); } - private void moveProfiles(ProfileManager from, ProfileManager to) + private static Profile[] objectsToProfiles(IEnumerable objects) { - // Gather the list of selected profiles and convert them to strings - IList list_selectedProfiles = profileListBox.SelectedItems; - int i = 0; - string[] selectedProfiles = new string[list_selectedProfiles.Count]; - foreach (object o in list_selectedProfiles) - { - selectedProfiles[i] = (string)o; - i++; - } - - // List the profiles to be imported - Profile[] profileList = from.AllProfiles(selectedProfiles); - // List the extra files to be copied - List fileList = from.AllRequiredFiles(profileList); - // Copy the extra files, generating a list of the new files - Dictionary subTable = copyExtraFiles(fileList); - // Update the profiles to show the new files - ProfileManager.FixFileNames(profileList, subTable); - //Add the profiles to 'to' - to.AddAll(profileList, mainForm.DialogManager); - - this.Close(); + return Array.ConvertAll( + Util.ToArray(objects), delegate (object o) { return ((Named)o).Data; }); } - /// - /// Copies the extra files needed by the profiles to the relevant place. Returns a substitution table - /// for the new locations of the extra files - /// - /// - private Dictionary copyExtraFiles(List fileList) + protected Profile[] Profiles { - Dictionary substitutionTable = new Dictionary(); - if (importMode) + get { return objectsToProfiles(profileList.Items); } + set { - // These files come from a *.zip file and move to MeGUIPath/extra - /* If there's already a file there with the same name, overwrite it -- - * it's probably an older version of the same file. It is the user's responsibility - * to make sure that different 'extra' files have different names. (The other alternative - * is that we generate a new name if it already exists. The problem is that we do mostly - * actually want to overwrite it, and if we don't, we end up with multiple copies of the - * same file, under names like file.cfg, 0_file.cfg, 1_file.cfg */ - - if (!Directory.Exists(mainForm.MeGUIPath + "\\extra")) - Directory.CreateDirectory(mainForm.MeGUIPath + "\\extra"); - - foreach (string file in fileList) - { - string filename = Path.GetFileName(file); - string pathname = mainForm.MeGUIPath + "\\extra\\" + filename; - substitutionTable[file] = pathname; - - // Copy the file - if (File.Exists(pathname)) - File.Delete(pathname); - - File.Move(Path.Combine(path, file), pathname); - } + profileList.Items.Clear(); + profileList.Items.AddRange(profilesToObjects(value)); } - else // Export mode - { - List addedFilenames = new List(); - foreach (string file in fileList) - { - string zipFileName = FileUtil.getUniqueFilename("extra\\" + Path.GetFileName(file), addedFilenames); - addedFilenames.Add(zipFileName); - ZipEntry newEntry = new ZipEntry(zipFileName); - outputFile.PutNextEntry(newEntry); - FileStream input = File.OpenRead(file); - FileUtil.copyData(input, outputFile); - input.Close(); - substitutionTable[file] = zipFileName; - } - } - return substitutionTable; } - - private void okButton_Click(object sender, EventArgs e) + protected List SelectedAndRequiredProfiles { - if (importMode) - moveProfiles(importedProfiles, profiles); - else + get { - // Choose output filename - SaveFileDialog outputFilesChooser = new SaveFileDialog(); - outputFilesChooser.Title = "Choose your output file"; - outputFilesChooser.Filter = "Zip archives|*.zip"; - if (outputFilesChooser.ShowDialog() != DialogResult.OK) - return; - string filename = outputFilesChooser.FileName; - - // This outputfile is accessed by moveProfiles, so must be initialised beforehand - outputFile = new ZipOutputStream(File.OpenWrite(filename)); + Profile[] allProfs = Profiles; + List profs = new List(objectsToProfiles(profileList.CheckedItems)); - ProfileManager to = new ProfileManager(path); - moveProfiles(profiles, to); - to.SaveProfiles(); - - foreach (string file in FileUtil.AllFiles(path)) + while (true) { - ZipEntry newEntry = new ZipEntry(file.Substring(path.Length).TrimStart('\\', '/')); - outputFile.PutNextEntry(newEntry); - FileStream input = File.OpenRead(file); - FileUtil.copyData(input, outputFile); - input.Close(); - } - outputFile.Close(); - MessageBox.Show("Completed successfully", "Export completed successfully", MessageBoxButtons.OK, MessageBoxIcon.Information); - } -#if UNUSED - if (importMode) - { - // Gather the list of selected profiles and convert them to strings - IList list_selectedProfiles = profileListBox.SelectedItems; - int i = 0; - string[] selectedProfiles = new string[list_selectedProfiles.Count]; - foreach (object o in list_selectedProfiles) - { - selectedProfiles[i] = (string)o; - i++; - } + int oldCount = profs.Count; - // List the profiles to be imported - Profile[] profileList = importedProfiles.AllProfiles(selectedProfiles); - // List the extra files to be copied - List fileList = importedProfiles.AllRequiredFiles(profileList); + List newProfs = new List(); - // Copy the files and store where they have been moved to (in the substitution table) - #region copying - Dictionary substitutionTable = new Dictionary(); - foreach (string file in fileList) - { - string filename = Path.GetFileName(file); - string pathname = mainForm.MeGUIPath + "\\extra\\" + filename; - int count = 0; - while (File.Exists(pathname)) + foreach (Profile p in profs) { - pathname = mainForm.MeGUIPath + "\\extra\\" + count + "_" + filename; - count++; + // add the profiles we don't already have + newProfs.AddRange(Array.ConvertAll(p.BaseSettings.RequiredProfiles, + delegate(string s) { return Util.ByID(allProfs, s); })); } - substitutionTable[file] = pathname; - /* if (substitutionTable.ContainsKey(file)) - substitutionTable.Remove(file); - substitutionTable.Add(file, pathname);*/ - try - { - if (!Directory.Exists(mainForm.MeGUIPath + "\\extra")) - Directory.CreateDirectory(mainForm.MeGUIPath + "\\extra"); - Stream outputStream = File.OpenWrite(pathname); - copyData(inputFile.GetInputStream(extraFiles[file]), outputStream); - outputStream.Close(); - } - catch (IOException ioe) - { - MessageBox.Show( - string.Format("Error opening selected file: {0}{1}{0}Import cancelled", Environment.NewLine, ioe.Message), - "Error opening file", - MessageBoxButtons.OK, MessageBoxIcon.Error); - this.Close(); - return; - } - } - #endregion - // Fix up the filenames with the substitution table - ProfileManager.FixFileNames(profileList, substitutionTable); - // Add the profiles to the main manager - profiles.AddAll(profileList, mainForm.DialogManager); - this.Close(); - } - else // export mode - { - // Choose output filename - SaveFileDialog outputFilesChooser = new SaveFileDialog(); - outputFilesChooser.Title = "Choose your output file"; - outputFilesChooser.Filter = "Zip archives|*.zip"; - if (outputFilesChooser.ShowDialog() != DialogResult.OK) - return; - string filename = outputFilesChooser.FileName; + profs.AddRange(newProfs); + profs = Util.RemoveDuds(profs); - // List profile names - IList list_selectedProfiles = profileListBox.SelectedItems; - int i = 0; - string[] selectedProfiles = new string[list_selectedProfiles.Count]; - foreach (object o in list_selectedProfiles) - { - selectedProfiles[i] = (string)o; - i++; + if (oldCount == profs.Count) + break; } - // List profiles - Profile[] profileList = profiles.AllProfiles(selectedProfiles); - Dictionary substitutionTable = new Dictionary(); - Dictionary fileList = profiles.AllRequiredFiles(profileList, out substitutionTable); - ProfileManager.FixFileNames(profileList, substitutionTable); - - ZipOutputStream outputFile = new ZipOutputStream(File.OpenWrite(filename)); - - foreach (string zipFilename in fileList.Keys) - { - ZipEntry newEntry = new ZipEntry(zipFilename); - outputFile.PutNextEntry(newEntry); - FileStream input = File.OpenRead(fileList[zipFilename]); - copyData(input, outputFile); - input.Close(); - } - - foreach (Profile prof in profileList) - { - ZipEntry newEntry = new ZipEntry(ProfileManager.ProfilePath(prof, "").TrimStart(new char[] { '\\' })); - outputFile.PutNextEntry(newEntry); - XmlSerializer outputter = new XmlSerializer(prof.GetType()); - outputter.Serialize(outputFile, prof); - } - outputFile.Close(); - MessageBox.Show("Completed successfully", "Export completed successfully", MessageBoxButtons.OK, MessageBoxIcon.Information); - this.Close(); + return profs; } -#endif } - protected override void OnClosed(EventArgs e) + protected Dictionary copyExtraFilesToFolder(List extraFiles, string folder) { - try { Directory.Delete(path, true); } - catch { } - base.OnClosed(e); - } + Dictionary subTable = new Dictionary(); + FileUtil.ensureDirectoryExists(folder); - - - private void ProfileExporter_Load(object sender, EventArgs e) - { - if (!importMode) + foreach (string file in extraFiles) { - profileListBox.DataSource = profiles.AllProfileNames; - return; - } + string filename = Path.GetFileName(file); + string pathname = Path.Combine(folder, filename); + subTable[file] = pathname; - if (inputFile == null) - { - if (string.IsNullOrEmpty(inputFileName)) - { - OpenFileDialog inputChooser = new OpenFileDialog(); - inputChooser.Filter = "Zip archives|*.zip"; - inputChooser.Title = "Select your input file"; + // Copy the file + if (File.Exists(pathname)) + File.Delete(pathname); - if (inputChooser.ShowDialog() != DialogResult.OK) - { - Close(); - return; - } - inputFileName = inputChooser.FileName; - } - try - { - inputFile = new ZipFile(File.OpenRead(inputFileName)); - } - catch (IOException ioe) - { - MessageBox.Show( - string.Format("Error opening selected file: {0}{1}{0}Import cancelled", Environment.NewLine, ioe.Message), - "Error opening file", - MessageBoxButtons.OK, MessageBoxIcon.Error); - this.Close(); - return; - } + File.Copy(file, pathname); } - foreach (ZipEntry entry in inputFile) - { - string pathname = Path.Combine(path, entry.Name); - if (entry.IsDirectory) - { - Directory.CreateDirectory(pathname); - } - else // entry.isFile - { - System.Diagnostics.Debug.Assert(entry.IsFile); - FileUtil.ensureDirectoryExists(Path.GetDirectoryName(pathname)); - Stream outputStream = File.OpenWrite(pathname); - FileUtil.copyData(inputFile.GetInputStream(entry), outputStream); - outputStream.Close(); - } - } - inputFile.Close(); - inputFile = null; + return subTable; + } - importedProfiles = new ProfileManager(path); - importedProfiles.LoadProfiles(); - profileListBox.DataSource = importedProfiles.AllProfileNames; + protected static void fixFileNames(List ps, Dictionary subTable) + { + foreach (Profile p in ps) + p.BaseSettings.FixFileNames(subTable); } + + protected static string getZippedExtraFileName(string p) + { + return "extra\\" + p; + } + } -} \ No newline at end of file +} Index: core/gui/ProfilePorter.Designer.cs =================================================================== --- core/gui/ProfilePorter.Designer.cs (revision 426) +++ core/gui/ProfilePorter.Designer.cs (working copy) @@ -1,4 +1,4 @@ -namespace MeGUI +namespace MeGUI.core.gui { partial class ProfilePorter { @@ -28,87 +28,70 @@ /// private void InitializeComponent() { - this.profileListBox = new System.Windows.Forms.ListBox(); - this.okButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); + System.Windows.Forms.Button cancelButton; + this.profileList = new System.Windows.Forms.CheckedListBox(); this.label1 = new System.Windows.Forms.Label(); - this.helpButton1 = new MeGUI.core.gui.HelpButton(); - this.helpProvider1 = new System.Windows.Forms.HelpProvider(); + this.button2 = new System.Windows.Forms.Button(); + cancelButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // profileListBox + // profileList // - this.profileListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.profileList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.profileListBox.FormattingEnabled = true; - this.profileListBox.Location = new System.Drawing.Point(12, 25); - this.profileListBox.Name = "profileListBox"; - this.profileListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this.profileListBox.Size = new System.Drawing.Size(358, 251); - this.profileListBox.TabIndex = 0; + this.profileList.FormattingEnabled = true; + this.profileList.IntegralHeight = false; + this.profileList.Location = new System.Drawing.Point(12, 25); + this.profileList.Name = "profileList"; + this.profileList.Size = new System.Drawing.Size(359, 288); + this.profileList.TabIndex = 0; // - // okButton - // - this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.Location = new System.Drawing.Point(214, 282); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 1; - this.okButton.Text = "Export..."; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.okButton_Click); - // - // cancelButton - // - this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(295, 282); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(75, 23); - this.cancelButton.TabIndex = 2; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 9); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(295, 13); - this.label1.TabIndex = 3; - this.label1.Text = "Select the profiles you want to export (Ctrl or Shift might help):"; + this.label1.Size = new System.Drawing.Size(168, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Select the profiles to import/export"; // - // helpButton1 + // cancelButton // - this.helpButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.helpButton1.ArticleName = "Profile exporter"; - this.helpButton1.AutoSize = true; - this.helpButton1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.helpButton1.Location = new System.Drawing.Point(12, 282); - this.helpButton1.Name = "helpButton1"; - this.helpButton1.Size = new System.Drawing.Size(39, 23); - this.helpButton1.TabIndex = 4; + cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + cancelButton.AutoSize = true; + cancelButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + cancelButton.Location = new System.Drawing.Point(321, 323); + cancelButton.Name = "cancelButton"; + cancelButton.Size = new System.Drawing.Size(50, 23); + cancelButton.TabIndex = 2; + cancelButton.Text = "Cancel"; + cancelButton.UseVisualStyleBackColor = true; // - // ProfilePorter + // button2 // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.AutoSize = true; + this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.button2.Location = new System.Drawing.Point(216, 323); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(99, 23); + this.button2.TabIndex = 2; + this.button2.Text = "Import.../Export..."; + this.button2.UseVisualStyleBackColor = true; + // + // ProfilePorter2 + // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(382, 313); - this.Controls.Add(this.helpButton1); + this.ClientSize = new System.Drawing.Size(383, 358); + this.Controls.Add(this.button2); + this.Controls.Add(cancelButton); this.Controls.Add(this.label1); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.profileListBox); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ProfilePorter"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.Text = "Profile Exporter"; - this.TopMost = true; - this.Load += new System.EventHandler(this.ProfileExporter_Load); + this.Controls.Add(this.profileList); + this.Name = "ProfilePorter2"; + this.Text = "ProfilePorter2"; this.ResumeLayout(false); this.PerformLayout(); @@ -116,11 +99,8 @@ #endregion - private System.Windows.Forms.ListBox profileListBox; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.Label label1; - private MeGUI.core.gui.HelpButton helpButton1; - private System.Windows.Forms.HelpProvider helpProvider1; + private System.Windows.Forms.CheckedListBox profileList; + protected System.Windows.Forms.Label label1; + protected System.Windows.Forms.Button button2; } } Index: core/gui/ProfilePorter.resx =================================================================== --- core/gui/ProfilePorter.resx (revision 426) +++ core/gui/ProfilePorter.resx (working copy) @@ -117,7 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 + + False - \ No newline at end of file + Index: core/gui/Profiles.cs =================================================================== --- core/gui/Profiles.cs (revision 426) +++ core/gui/Profiles.cs (working copy) @@ -3,289 +3,10 @@ using System.Text; using System.Windows.Forms; using System.Reflection; +using MeGUI.core.gui; namespace MeGUI.core.plugins.interfaces { - public class ConfigurationWindow : Form - where TProfileSettings : GenericSettings - where TSettings : TProfileSettings, new() - { - ProfileManager profileManager; - private Gettable s; - protected GroupBox profilesGroupbox; - private Panel panel1; - protected Button cancelButton; - protected Button okButton; - private Button updateButton; - private Button loadDefaultsButton; - private ComboBox videoProfile; - private Button newVideoProfileButton; - private Button deleteVideoProfileButton; - private string initialProfile; - - public TProfileSettings Settings - { - get { return s.Settings; } - set { s.Settings = value; } - } - - /// - /// gets the name of the currently selected profile - /// - public string CurrentProfileName - { - get - { - return videoProfile.Text; - } - } - - private bool createTempSettings = false; - /// - /// Returns true if the selected settings should be copied into a temporary location and no profile selected when returned. - /// Returns false if the selected profile here should be selected when this returns. - /// - public bool CreateTempSettings - { - get - { - return createTempSettings; - } - } - - public GenericProfile CurrentProfile - { - get - { - return (GenericProfile)videoProfile.SelectedItem; - } - } - - private void InitializeComponent() - { - this.profilesGroupbox = new System.Windows.Forms.GroupBox(); - this.updateButton = new System.Windows.Forms.Button(); - this.loadDefaultsButton = new System.Windows.Forms.Button(); - this.videoProfile = new System.Windows.Forms.ComboBox(); - this.newVideoProfileButton = new System.Windows.Forms.Button(); - this.deleteVideoProfileButton = new System.Windows.Forms.Button(); - this.panel1 = new System.Windows.Forms.Panel(); - this.cancelButton = new System.Windows.Forms.Button(); - this.okButton = new System.Windows.Forms.Button(); - this.profilesGroupbox.SuspendLayout(); - this.SuspendLayout(); - // - // profilesGroupbox - // - this.profilesGroupbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.profilesGroupbox.Controls.Add(this.updateButton); - this.profilesGroupbox.Controls.Add(this.loadDefaultsButton); - this.profilesGroupbox.Controls.Add(this.videoProfile); - this.profilesGroupbox.Controls.Add(this.newVideoProfileButton); - this.profilesGroupbox.Controls.Add(this.deleteVideoProfileButton); - this.profilesGroupbox.Location = new System.Drawing.Point(6, 405); - this.profilesGroupbox.Name = "profilesGroupbox"; - this.profilesGroupbox.Size = new System.Drawing.Size(400, 48); - this.profilesGroupbox.TabIndex = 44; - this.profilesGroupbox.TabStop = false; - this.profilesGroupbox.Text = "Profiles"; - // - // updateButton - // - this.updateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.updateButton.Location = new System.Drawing.Point(235, 18); - this.updateButton.Name = "updateButton"; - this.updateButton.Size = new System.Drawing.Size(50, 23); - this.updateButton.TabIndex = 15; - this.updateButton.Text = "Update"; - this.updateButton.UseVisualStyleBackColor = true; - this.updateButton.Click += new System.EventHandler(this.updateButton_Click); - // - // loadDefaultsButton - // - this.loadDefaultsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.loadDefaultsButton.Location = new System.Drawing.Point(291, 18); - this.loadDefaultsButton.Name = "loadDefaultsButton"; - this.loadDefaultsButton.Size = new System.Drawing.Size(103, 23); - this.loadDefaultsButton.TabIndex = 14; - this.loadDefaultsButton.Text = "Load Defaults"; - this.loadDefaultsButton.UseVisualStyleBackColor = true; - this.loadDefaultsButton.Click += new System.EventHandler(this.loadDefaultsButton_Click); - // - // videoProfile - // - this.videoProfile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.videoProfile.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.videoProfile.Location = new System.Drawing.Point(8, 18); - this.videoProfile.Name = "videoProfile"; - this.videoProfile.Size = new System.Drawing.Size(121, 21); - this.videoProfile.Sorted = true; - this.videoProfile.TabIndex = 11; - this.videoProfile.SelectedIndexChanged += new System.EventHandler(this.videoProfile_SelectedIndexChanged); - // - // newVideoProfileButton - // - this.newVideoProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.newVideoProfileButton.Location = new System.Drawing.Point(189, 18); - this.newVideoProfileButton.Name = "newVideoProfileButton"; - this.newVideoProfileButton.Size = new System.Drawing.Size(40, 23); - this.newVideoProfileButton.TabIndex = 12; - this.newVideoProfileButton.Text = "New"; - this.newVideoProfileButton.Click += new System.EventHandler(this.newVideoProfileButton_Click); - // - // deleteVideoProfileButton - // - this.deleteVideoProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.deleteVideoProfileButton.Location = new System.Drawing.Point(135, 18); - this.deleteVideoProfileButton.Name = "deleteVideoProfileButton"; - this.deleteVideoProfileButton.Size = new System.Drawing.Size(48, 23); - this.deleteVideoProfileButton.TabIndex = 13; - this.deleteVideoProfileButton.Text = "Delete"; - this.deleteVideoProfileButton.Click += new System.EventHandler(this.deleteVideoProfileButton_Click); - // - // panel1 - // - this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.panel1.Location = new System.Drawing.Point(2, 2); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(411, 399); - this.panel1.TabIndex = 45; - // - // cancelButton - // - this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(358, 459); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(48, 23); - this.cancelButton.TabIndex = 47; - this.cancelButton.Text = "Cancel"; - // - // okButton - // - this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(312, 459); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(40, 23); - this.okButton.TabIndex = 46; - this.okButton.Text = "OK"; - this.okButton.Click += new System.EventHandler(this.okButton_Click); - // - // ConfigurationWindow - // - this.ClientSize = new System.Drawing.Size(414, 490); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.panel1); - this.Controls.Add(this.profilesGroupbox); - this.Name = "ConfigurationWindow"; - this.Load += new System.EventHandler(this.ConfigurationWindow_Load); - this.profilesGroupbox.ResumeLayout(false); - this.ResumeLayout(false); - - } - - public ConfigurationWindow(ProfileManager p, Control sPanel, Gettable s, string initialProfile) - : this(p, sPanel, s, initialProfile, new TSettings().getSettingsType()) { } - - public ConfigurationWindow(ProfileManager p, Control sPanel, Gettable s, string initialProfile, string title) - { - this.initialProfile = initialProfile; - InitializeComponent(); - this.Text = title + " configuration dialog"; - this.profileManager = p; - this.s = s; - System.Drawing.Size size = Size; - size.Height += sPanel.Height - panel1.Height; - size.Width += Math.Max(sPanel.Width - panel1.Width, 0); - Size = size; - sPanel.Dock = DockStyle.Fill; - panel1.Controls.Add(sPanel); - } - - private void ConfigurationWindow_Load(object sender, EventArgs e) - { - Profile selected = null; - foreach (Profile prof in this.profileManager.Profiles(new TSettings().getSettingsType()).Values) - { - if (prof.BaseSettings is TSettings) // those are the profiles we're interested in - { - this.videoProfile.Items.Add(prof); - if (prof.Name == initialProfile) - selected = prof; - } - } - this.videoProfile.SelectedItem = selected; - } - private void loadDefaultsButton_Click(object sender, EventArgs e) - { - s.Settings = new TSettings(); - videoProfile.SelectedIndex = -1; - } - - private void updateButton_Click(object sender, EventArgs e) - { - GenericProfile prof = (GenericProfile)this.videoProfile.SelectedItem; - if (prof == null) - { - MessageBox.Show("You must select a profile to update!", "No profile selected", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - prof.Settings = s.Settings; - } - - private void newVideoProfileButton_Click(object sender, EventArgs e) - { - string profileName = Microsoft.VisualBasic.Interaction.InputBox("Please give the profile a name", "Please give the profile a name", "", -1, -1); - if (profileName == null) - return; - profileName = profileName.Trim(); - if (profileName.Length == 0) - return; - GenericProfile prof = new GenericProfile(profileName, s.Settings); - if (this.profileManager.AddProfile(prof)) - { - this.videoProfile.Items.Add(prof); - this.videoProfile.SelectedItem = prof; - } - else - MessageBox.Show("Sorry, profiles must have unique names", "Duplicate name detected", MessageBoxButtons.OK); - } - - private void videoProfile_SelectedIndexChanged(object sender, EventArgs e) - { - GenericProfile prof = this.videoProfile.SelectedItem as GenericProfile; - if (prof == null) - return; - this.Settings = prof.Settings; - } - - private void deleteVideoProfileButton_Click(object sender, EventArgs e) - { - GenericProfile prof = (GenericProfile)this.videoProfile.SelectedItem; - if (prof == null) - { - MessageBox.Show("You must select a profile to delete!", "No profile selected", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - profileManager.DeleteProfile(prof); - videoProfile.Items.Remove(prof); - loadDefaultsButton_Click(null, null); - } - - private void okButton_Click(object sender, EventArgs e) - { - } - } - - - - /** This is the base type for any kind of settings which can be stored in a profile.*/ public interface GenericSettings { /************************************************************************************ @@ -306,7 +27,8 @@ /// to group like profile types. There should be one meta-type per settings type. /// /// - string getSettingsType(); + string SettingsID { get; } + /// /// Substitutes any filenames stored in this profile (eg quantizer matrices) according to @@ -327,14 +49,6 @@ } - public interface Gettable - { - TSettings Settings - { - get; - set; - } - } [AttributeUsage(AttributeTargets.Property)] public class PropertyEqualityIgnoreAttribute : Attribute Index: core/gui/SimpleProfilesControl.cs =================================================================== --- core/gui/SimpleProfilesControl.cs (revision 0) +++ core/gui/SimpleProfilesControl.cs (revision 0) @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using System.Diagnostics; +using MeGUI.core.details.video; +using MeGUI.core.util; + +namespace MeGUI.core.gui +{ + public partial class SimpleProfilesControl : UserControl + { + public SimpleProfilesControl() + { + InitializeComponent(); + } + + public void SetSettings(AudioCodecSettings value) + { + manager.SetSettings(value); + } + + + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public Profile SelectedProfile + { + get { return ((Named)comboBox1.SelectedItem).Data; } + } + + public void SelectProfile(string fqname) + { + foreach (Named n in comboBox1.Items) + if (n.Data.FQName == fqname) + { + comboBox1.SelectedItem = n; + return; + } + + throw new ProfileCouldntBeSelectedException(fqname); + } + + public void SelectProfile(Profile prof) + { + SelectProfile(prof.FQName); + } + + public void SetProfileNameOrWarn(string fqname) + { + if (string.IsNullOrEmpty(fqname)) + return; + try + { + SelectProfile(fqname); + } + catch (ProfileCouldntBeSelectedException) + { + MessageBox.Show("The profile, " + fqname + ", could not be selected.", "Profile couldn't be selected", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + + private ProfileManager manager = new ProfileManager(""); + + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ProfileManager Manager + { + get { return manager; } + set { + if (!string.IsNullOrEmpty(ProfileSet)) + { + manager.RemoveProfilesChangedListener(ProfileSet, ProfilesChanged); + value.AddProfilesChangedListener(ProfileSet, ProfilesChanged); + } + manager = value; + RefreshProfiles(); + } + } + + private void ProfilesChanged(object _, EventArgs __) + { + RefreshProfiles(); + } + + private string profileSet; + /// + /// The string describing the profile set to request from the profile manager + /// + public string ProfileSet + { + get { return profileSet; } + set { + if (!string.IsNullOrEmpty(profileSet)) + Manager.RemoveProfilesChangedListener(profileSet, ProfilesChanged); + if (!string.IsNullOrEmpty(value)) + Manager.AddProfilesChangedListener(value, ProfilesChanged); + + profileSet = value; + } + } + + protected void RefreshProfiles() + { + comboBox1.Items.Clear(); + comboBox1.Items.AddRange(Util.ToArray(Manager.Profiles(ProfileSet))); + SelectProfile(Manager.GetSelectedProfile(ProfileSet)); + } + + protected void raiseProfileChangedEvent() + { + if (SelectedProfileChanged != null) + SelectedProfileChanged(this, EventArgs.Empty); + } + + public event EventHandler SelectedProfileChanged; + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + Manager.SetSelectedProfile(SelectedProfile); + raiseProfileChangedEvent(); + } + } + + public class ProfileCouldntBeSelectedException : MeGUIException + { + private string name; + public string ProfileName + { + get { return name; } + } + + public ProfileCouldntBeSelectedException(string name) + : base("The profile '" + name + "' couldn't be selected.") + { + this.name = name; + } + } + +} Index: core/gui/SimpleProfilesControl.Designer.cs =================================================================== --- core/gui/SimpleProfilesControl.Designer.cs (revision 0) +++ core/gui/SimpleProfilesControl.Designer.cs (revision 0) @@ -0,0 +1,62 @@ +namespace MeGUI.core.gui +{ + partial class SimpleProfilesControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // comboBox1 + // + this.comboBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(0, 0); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(200, 21); + this.comboBox1.Sorted = true; + this.comboBox1.TabIndex = 0; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // SimpleProfilesControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.comboBox1); + this.Name = "SimpleProfilesControl"; + this.Size = new System.Drawing.Size(200, 22); + this.ResumeLayout(false); + + } + + #endregion + + protected System.Windows.Forms.ComboBox comboBox1; + + } +} Index: core/gui/SimpleProfilesControl.resx =================================================================== --- core/gui/SimpleProfilesControl.resx (revision 0) +++ core/gui/SimpleProfilesControl.resx (revision 0) @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Index: core/gui/ZonesControl.cs =================================================================== --- core/gui/ZonesControl.cs (revision 426) +++ core/gui/ZonesControl.cs (working copy) @@ -29,7 +29,12 @@ } #region variables - private event UpdateConfigGUI updateGUI; + private void updateGUI() + { + if (UpdateGUIEvent != null) + UpdateGUIEvent(); + } + public event UpdateConfigGUI UpdateGUIEvent; private Zone[] zones; private string input; private VideoPlayer player; @@ -304,21 +309,6 @@ set { input = value; showVideoButton.Enabled = !string.IsNullOrEmpty(value); } get { return input; } } - /// - /// Configures the event handling for GUI updates when the zones have been modified. - /// - public event UpdateConfigGUI UpdateGUIEvent - { - add - { - updateGUI += value; - } - remove - { - updateGUI -= value; - } - } - #endregion public void closePlayer() Index: core/gui/ZonesControl.Designer.cs =================================================================== --- core/gui/ZonesControl.Designer.cs (revision 426) +++ core/gui/ZonesControl.Designer.cs (working copy) @@ -29,111 +29,45 @@ private void InitializeComponent() { this.zonesGroupbox = new System.Windows.Forms.GroupBox(); - this.zoneModifier = new System.Windows.Forms.NumericUpDown(); - this.modifierLabel = new System.Windows.Forms.Label(); - this.zoneLabel = new System.Windows.Forms.Label(); - this.zoneMode = new System.Windows.Forms.ComboBox(); - this.endFrame = new System.Windows.Forms.TextBox(); - this.startFrame = new System.Windows.Forms.TextBox(); this.zoneListView = new System.Windows.Forms.ListView(); this.startFrameColumn = new System.Windows.Forms.ColumnHeader(); this.endFrameColumn = new System.Windows.Forms.ColumnHeader(); this.modeColumn = new System.Windows.Forms.ColumnHeader(); this.modifierColumn = new System.Windows.Forms.ColumnHeader(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.startFrame = new System.Windows.Forms.TextBox(); + this.endFrame = new System.Windows.Forms.TextBox(); + this.endFrameLabel = new System.Windows.Forms.Label(); + this.zoneLabel = new System.Windows.Forms.Label(); + this.zoneModifier = new System.Windows.Forms.NumericUpDown(); + this.zoneMode = new System.Windows.Forms.ComboBox(); this.startFrameLabel = new System.Windows.Forms.Label(); - this.endFrameLabel = new System.Windows.Forms.Label(); - this.addZoneButton = new System.Windows.Forms.Button(); - this.clearZonesButton = new System.Windows.Forms.Button(); - this.updateZoneButton = new System.Windows.Forms.Button(); + this.modifierLabel = new System.Windows.Forms.Label(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.showVideoButton = new System.Windows.Forms.Button(); this.removeZoneButton = new System.Windows.Forms.Button(); + this.updateZoneButton = new System.Windows.Forms.Button(); + this.clearZonesButton = new System.Windows.Forms.Button(); + this.addZoneButton = new System.Windows.Forms.Button(); this.zonesGroupbox.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.zoneModifier)).BeginInit(); + this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // zonesGroupbox // - this.zonesGroupbox.Controls.Add(this.zoneModifier); - this.zonesGroupbox.Controls.Add(this.modifierLabel); - this.zonesGroupbox.Controls.Add(this.zoneLabel); - this.zonesGroupbox.Controls.Add(this.zoneMode); - this.zonesGroupbox.Controls.Add(this.endFrame); - this.zonesGroupbox.Controls.Add(this.startFrame); this.zonesGroupbox.Controls.Add(this.zoneListView); - this.zonesGroupbox.Controls.Add(this.startFrameLabel); - this.zonesGroupbox.Controls.Add(this.endFrameLabel); - this.zonesGroupbox.Controls.Add(this.addZoneButton); - this.zonesGroupbox.Controls.Add(this.clearZonesButton); - this.zonesGroupbox.Controls.Add(this.updateZoneButton); - this.zonesGroupbox.Controls.Add(this.showVideoButton); - this.zonesGroupbox.Controls.Add(this.removeZoneButton); + this.zonesGroupbox.Controls.Add(this.tableLayoutPanel1); + this.zonesGroupbox.Controls.Add(this.flowLayoutPanel1); this.zonesGroupbox.Dock = System.Windows.Forms.DockStyle.Fill; this.zonesGroupbox.Location = new System.Drawing.Point(0, 0); this.zonesGroupbox.Name = "zonesGroupbox"; - this.zonesGroupbox.Size = new System.Drawing.Size(317, 288); + this.zonesGroupbox.Size = new System.Drawing.Size(295, 412); this.zonesGroupbox.TabIndex = 2; this.zonesGroupbox.TabStop = false; this.zonesGroupbox.Text = "Zones"; // - // zoneModifier - // - this.zoneModifier.Location = new System.Drawing.Point(263, 200); - this.zoneModifier.Maximum = new decimal(new int[] { - 51, - 0, - 0, - 0}); - this.zoneModifier.Name = "zoneModifier"; - this.zoneModifier.Size = new System.Drawing.Size(48, 20); - this.zoneModifier.TabIndex = 3; - this.zoneModifier.Value = new decimal(new int[] { - 26, - 0, - 0, - 0}); - // - // modifierLabel - // - this.modifierLabel.Location = new System.Drawing.Point(160, 202); - this.modifierLabel.Name = "modifierLabel"; - this.modifierLabel.Size = new System.Drawing.Size(56, 16); - this.modifierLabel.TabIndex = 6; - this.modifierLabel.Text = "Quantizer"; - // - // zoneLabel - // - this.zoneLabel.Location = new System.Drawing.Point(160, 230); - this.zoneLabel.Name = "zoneLabel"; - this.zoneLabel.Size = new System.Drawing.Size(32, 13); - this.zoneLabel.TabIndex = 5; - this.zoneLabel.Text = "Mode"; - // - // zoneMode - // - this.zoneMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.zoneMode.Items.AddRange(new object[] { - "Quantizer", - "Weight"}); - this.zoneMode.Location = new System.Drawing.Point(231, 226); - this.zoneMode.Name = "zoneMode"; - this.zoneMode.Size = new System.Drawing.Size(80, 21); - this.zoneMode.TabIndex = 4; - this.zoneMode.SelectedIndexChanged += new System.EventHandler(this.zoneMode_SelectedIndexChanged); - // - // endFrame - // - this.endFrame.Location = new System.Drawing.Point(88, 226); - this.endFrame.Name = "endFrame"; - this.endFrame.Size = new System.Drawing.Size(48, 20); - this.endFrame.TabIndex = 2; - // - // startFrame - // - this.startFrame.Location = new System.Drawing.Point(88, 200); - this.startFrame.Name = "startFrame"; - this.startFrame.Size = new System.Drawing.Size(48, 20); - this.startFrame.TabIndex = 1; - // // zoneListView // this.zoneListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { @@ -141,11 +75,12 @@ this.endFrameColumn, this.modeColumn, this.modifierColumn}); + this.zoneListView.Dock = System.Windows.Forms.DockStyle.Fill; this.zoneListView.FullRowSelect = true; this.zoneListView.HideSelection = false; - this.zoneListView.Location = new System.Drawing.Point(8, 24); + this.zoneListView.Location = new System.Drawing.Point(3, 16); this.zoneListView.Name = "zoneListView"; - this.zoneListView.Size = new System.Drawing.Size(303, 168); + this.zoneListView.Size = new System.Drawing.Size(289, 311); this.zoneListView.TabIndex = 0; this.zoneListView.UseCompatibleStateImageBehavior = false; this.zoneListView.View = System.Windows.Forms.View.Details; @@ -167,79 +102,203 @@ // this.modifierColumn.Text = "Modifier"; // - // startFrameLabel + // tableLayoutPanel1 // - this.startFrameLabel.Location = new System.Drawing.Point(8, 202); - this.startFrameLabel.Name = "startFrameLabel"; - this.startFrameLabel.Size = new System.Drawing.Size(64, 16); - this.startFrameLabel.TabIndex = 1; - this.startFrameLabel.Text = "Start Frame"; + this.tableLayoutPanel1.AutoSize = true; + this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanel1.ColumnCount = 4; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.Controls.Add(this.startFrame, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.endFrame, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.endFrameLabel, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.zoneLabel, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.zoneModifier, 3, 0); + this.tableLayoutPanel1.Controls.Add(this.zoneMode, 3, 1); + this.tableLayoutPanel1.Controls.Add(this.startFrameLabel, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.modifierLabel, 2, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 327); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 2; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.Size = new System.Drawing.Size(289, 53); + this.tableLayoutPanel1.TabIndex = 10; // + // startFrame + // + this.startFrame.Location = new System.Drawing.Point(73, 3); + this.startFrame.Name = "startFrame"; + this.startFrame.Size = new System.Drawing.Size(48, 20); + this.startFrame.TabIndex = 1; + // + // endFrame + // + this.endFrame.Location = new System.Drawing.Point(73, 29); + this.endFrame.Name = "endFrame"; + this.endFrame.Size = new System.Drawing.Size(48, 20); + this.endFrame.TabIndex = 2; + // // endFrameLabel // - this.endFrameLabel.Location = new System.Drawing.Point(8, 228); + this.endFrameLabel.Dock = System.Windows.Forms.DockStyle.Fill; + this.endFrameLabel.Location = new System.Drawing.Point(3, 26); this.endFrameLabel.Name = "endFrameLabel"; - this.endFrameLabel.Size = new System.Drawing.Size(64, 16); + this.endFrameLabel.Size = new System.Drawing.Size(64, 27); this.endFrameLabel.TabIndex = 2; this.endFrameLabel.Text = "End Frame"; + this.endFrameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // addZoneButton + // zoneLabel // - this.addZoneButton.Location = new System.Drawing.Point(260, 256); - this.addZoneButton.Name = "addZoneButton"; - this.addZoneButton.Size = new System.Drawing.Size(52, 23); - this.addZoneButton.TabIndex = 7; - this.addZoneButton.Text = "Add"; - this.addZoneButton.Click += new System.EventHandler(this.addZoneButton_Click); + this.zoneLabel.Dock = System.Windows.Forms.DockStyle.Fill; + this.zoneLabel.Location = new System.Drawing.Point(127, 26); + this.zoneLabel.Name = "zoneLabel"; + this.zoneLabel.Size = new System.Drawing.Size(56, 27); + this.zoneLabel.TabIndex = 5; + this.zoneLabel.Text = "Mode"; + this.zoneLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // clearZonesButton + // zoneModifier // - this.clearZonesButton.Location = new System.Drawing.Point(76, 256); - this.clearZonesButton.Name = "clearZonesButton"; - this.clearZonesButton.Size = new System.Drawing.Size(52, 23); - this.clearZonesButton.TabIndex = 5; - this.clearZonesButton.Text = "Clear"; - this.clearZonesButton.Click += new System.EventHandler(this.clearZonesButton_Click); + this.zoneModifier.Dock = System.Windows.Forms.DockStyle.Fill; + this.zoneModifier.Location = new System.Drawing.Point(189, 3); + this.zoneModifier.Maximum = new decimal(new int[] { + 51, + 0, + 0, + 0}); + this.zoneModifier.Name = "zoneModifier"; + this.zoneModifier.Size = new System.Drawing.Size(97, 20); + this.zoneModifier.TabIndex = 3; + this.zoneModifier.Value = new decimal(new int[] { + 26, + 0, + 0, + 0}); // - // updateZoneButton + // zoneMode // - this.updateZoneButton.Location = new System.Drawing.Point(134, 256); - this.updateZoneButton.Name = "updateZoneButton"; - this.updateZoneButton.Size = new System.Drawing.Size(52, 23); - this.updateZoneButton.TabIndex = 9; - this.updateZoneButton.Text = "Update"; - this.updateZoneButton.Click += new System.EventHandler(this.updateZoneButton_Click); + this.zoneMode.Dock = System.Windows.Forms.DockStyle.Fill; + this.zoneMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.zoneMode.Items.AddRange(new object[] { + "Quantizer", + "Weight"}); + this.zoneMode.Location = new System.Drawing.Point(189, 29); + this.zoneMode.Name = "zoneMode"; + this.zoneMode.Size = new System.Drawing.Size(97, 21); + this.zoneMode.TabIndex = 4; + this.zoneMode.SelectedIndexChanged += new System.EventHandler(this.zoneMode_SelectedIndexChanged); // + // startFrameLabel + // + this.startFrameLabel.Dock = System.Windows.Forms.DockStyle.Fill; + this.startFrameLabel.Location = new System.Drawing.Point(3, 0); + this.startFrameLabel.Name = "startFrameLabel"; + this.startFrameLabel.Size = new System.Drawing.Size(64, 26); + this.startFrameLabel.TabIndex = 1; + this.startFrameLabel.Text = "Start Frame"; + this.startFrameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // modifierLabel + // + this.modifierLabel.Dock = System.Windows.Forms.DockStyle.Fill; + this.modifierLabel.Location = new System.Drawing.Point(127, 0); + this.modifierLabel.Name = "modifierLabel"; + this.modifierLabel.Size = new System.Drawing.Size(56, 26); + this.modifierLabel.TabIndex = 6; + this.modifierLabel.Text = "Quantizer"; + this.modifierLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoSize = true; + this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flowLayoutPanel1.Controls.Add(this.showVideoButton); + this.flowLayoutPanel1.Controls.Add(this.removeZoneButton); + this.flowLayoutPanel1.Controls.Add(this.updateZoneButton); + this.flowLayoutPanel1.Controls.Add(this.clearZonesButton); + this.flowLayoutPanel1.Controls.Add(this.addZoneButton); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 380); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(289, 29); + this.flowLayoutPanel1.TabIndex = 11; + // // showVideoButton // + this.showVideoButton.AutoSize = true; + this.showVideoButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.showVideoButton.Enabled = false; - this.showVideoButton.Location = new System.Drawing.Point(9, 256); + this.showVideoButton.Location = new System.Drawing.Point(3, 3); this.showVideoButton.Name = "showVideoButton"; - this.showVideoButton.Size = new System.Drawing.Size(61, 23); + this.showVideoButton.Size = new System.Drawing.Size(55, 23); this.showVideoButton.TabIndex = 9; this.showVideoButton.Text = "Preview"; this.showVideoButton.Click += new System.EventHandler(this.showVideoButton_Click); // // removeZoneButton // - this.removeZoneButton.Location = new System.Drawing.Point(192, 256); + this.removeZoneButton.AutoSize = true; + this.removeZoneButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.removeZoneButton.Location = new System.Drawing.Point(64, 3); this.removeZoneButton.Name = "removeZoneButton"; - this.removeZoneButton.Size = new System.Drawing.Size(62, 23); + this.removeZoneButton.Size = new System.Drawing.Size(57, 23); this.removeZoneButton.TabIndex = 6; this.removeZoneButton.Text = "Remove"; this.removeZoneButton.Click += new System.EventHandler(this.removeZoneButton_Click); // + // updateZoneButton + // + this.updateZoneButton.AutoSize = true; + this.updateZoneButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.updateZoneButton.Location = new System.Drawing.Point(127, 3); + this.updateZoneButton.Name = "updateZoneButton"; + this.updateZoneButton.Size = new System.Drawing.Size(52, 23); + this.updateZoneButton.TabIndex = 9; + this.updateZoneButton.Text = "Update"; + this.updateZoneButton.Click += new System.EventHandler(this.updateZoneButton_Click); + // + // clearZonesButton + // + this.clearZonesButton.AutoSize = true; + this.clearZonesButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.clearZonesButton.Location = new System.Drawing.Point(185, 3); + this.clearZonesButton.Name = "clearZonesButton"; + this.clearZonesButton.Size = new System.Drawing.Size(41, 23); + this.clearZonesButton.TabIndex = 5; + this.clearZonesButton.Text = "Clear"; + this.clearZonesButton.Click += new System.EventHandler(this.clearZonesButton_Click); + // + // addZoneButton + // + this.addZoneButton.AutoSize = true; + this.addZoneButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.addZoneButton.Location = new System.Drawing.Point(232, 3); + this.addZoneButton.Name = "addZoneButton"; + this.addZoneButton.Size = new System.Drawing.Size(36, 23); + this.addZoneButton.TabIndex = 7; + this.addZoneButton.Text = "Add"; + this.addZoneButton.Click += new System.EventHandler(this.addZoneButton_Click); + // // ZonesControl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.zonesGroupbox); this.Name = "ZonesControl"; - this.Size = new System.Drawing.Size(317, 288); + this.Size = new System.Drawing.Size(295, 412); this.Load += new System.EventHandler(this.ZonesControl_Load); this.zonesGroupbox.ResumeLayout(false); this.zonesGroupbox.PerformLayout(); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.zoneModifier)).EndInit(); + this.flowLayoutPanel1.ResumeLayout(false); + this.flowLayoutPanel1.PerformLayout(); this.ResumeLayout(false); } @@ -265,5 +324,7 @@ private System.Windows.Forms.Button updateZoneButton; private System.Windows.Forms.Button showVideoButton; private System.Windows.Forms.Button removeZoneButton; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; } } Index: core/plugins/interfaces/ISettingsProvider.cs =================================================================== --- core/plugins/interfaces/ISettingsProvider.cs (revision 426) +++ core/plugins/interfaces/ISettingsProvider.cs (working copy) @@ -22,48 +22,7 @@ namespace MeGUI { - public interface ISettingsProvider : IIDable - where TSettings : GenericSettings - { - /// - /// Returns the codec (format, eg AVC, MP3, etc) type - /// - TCodec CodecType { get; } - /// - /// Returns the encoder (eg x264, LAME, etc) type - /// - TEncoder EncoderType { get; } - - /// - /// Sets the settings back to default - /// - void LoadDefaults(); - - /// - /// Returns true if settings is the type that this settings provider supports - /// - /// - /// - bool IsSameType(TSettings settings); - - /// - /// Returns the current settings - /// - /// - TSettings GetCurrentSettings(); - - /// - /// Sets the Current Settings - /// - /// - void LoadSettings(TSettings settings); - - /// - /// Opens the configuration dialog for the current settings/profiles - /// - SettingsEditor EditSettings { get; } - } public delegate void StringChanged(object sender, string val); public delegate void IntChanged(object sender, int val); public class VideoInfo @@ -118,236 +77,4 @@ public VideoInfo() : this("", "", -1, -1, -1, -1) { } } - - - public class SettingsProviderImpl2 - : ISettingsProvider - where TProfileSettings : GenericSettings - where TSettings : TProfileSettings, new() - where TPanel : System.Windows.Forms.Control, Gettable - { - private string title; - private TSettings settings; - private TCodec codec; - private TEncoder encoderType; - - public SettingsProviderImpl2(string title, TEncoder encoderType, TCodec codec) - { - this.title = title; - this.encoderType = encoderType; - this.codec = codec; - LoadDefaults(); - } - - public string ID - { - get - { - return title; - } - } - public override string ToString() - { - return this.title; - } - - public TEncoder EncoderType - { - get { return encoderType; } - } - - #region IVideoSettingsProvider Members - - public TCodec CodecType - { - get { return this.codec; } - } - - public void LoadDefaults() - { - this.settings = new TSettings(); - } - - public bool IsSameType(TProfileSettings settings) - { - return settings is TSettings; - } - - public TProfileSettings GetCurrentSettings() - { - return this.settings; - } - - public void LoadSettings(TProfileSettings settings) - { - this.settings = (TSettings)settings; - } - - public virtual string EncoderPath(MeGUISettings settings) - { - return settings.MencoderPath; - } - - public SettingsEditor EditSettings - { - get { return EditorProvider.Create(); } - } - #endregion - } - - public class EditorProvider - where TProfileSettings : GenericSettings - where TSettings : TProfileSettings, new() - where TPanel : System.Windows.Forms.Control, Gettable - { - public static SettingsEditor Create() - { - return new SettingsEditor( - delegate(MainForm mainForm, ref TProfileSettings settings, - ref string profileName, TInfo info) - { - TPanel t = (TPanel)System.Activator.CreateInstance(typeof(TPanel), mainForm, info); - using (ConfigurationWindow scd = - new ConfigurationWindow(mainForm.Profiles, t, t, profileName)) - { - scd.Settings = (TSettings)settings; // Set the settings in case there is no profile configured - if (scd.ShowDialog() == System.Windows.Forms.DialogResult.OK) - { - /* Get the selected profile and see if its settings match the current - * configuration of the window. If they do, continue as normal. If not, - * ask the user whether he/she wants to overwrite the profile's settings - * with the currently configured ones. If the user answers no, then the - * settings are returned as an unnamed profile; this is a special case, - * and generates a temporary group of settings. */ - Profile prof = scd.CurrentProfile; - if (prof != null && !scd.Settings.Equals(prof.BaseSettings)) - { - if (MessageBox.Show("Profile has been changed. Update the selected profile?", - "Profile update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) - == DialogResult.Yes) - prof.BaseSettings = scd.Settings; - else - prof = null; - } - if (prof == null) - profileName = ""; - else - profileName = prof.Name; - - settings = scd.Settings; - return true; - } - else - return false; - } - }); - } - } - - #region providers - public class X264SettingsProvider : SettingsProviderImpl2 - { - public X264SettingsProvider() - : base("x264", VideoEncoderType.X264, VideoCodec.AVC) - { - } - public override string EncoderPath(MeGUISettings settings) - { - return settings.X264Path; - } - } - public class XviDSettingsProvider : SettingsProviderImpl2 - { - public XviDSettingsProvider() - : base("Xvid", VideoEncoderType.XVID, VideoCodec.ASP) - { - } - public override string EncoderPath(MeGUISettings settings) - { - return settings.XviDEncrawPath; - } - } - public class LavcSettingsProvider : SettingsProviderImpl2 - { - public LavcSettingsProvider() - : base("LMP4", VideoEncoderType.LMP4, VideoCodec.ASP) - { - } - } - public class SnowSettingsProvider : SettingsProviderImpl2 - { - public SnowSettingsProvider() - : base("Snow", VideoEncoderType.SNOW, VideoCodec.SNOW) - { - } - } - public class NeroAACSettingsProvider : SettingsProviderImpl2 - { - public NeroAACSettingsProvider() - : base("AAC - Nero Digital", AudioEncoderType.NAAC, AudioCodec.AAC) - { - } - } - public class AudXSettingsProvider : SettingsProviderImpl2 - { - public AudXSettingsProvider() - : base("MP3 - Aud-X", AudioEncoderType.AUDX, AudioCodec.MP3) - { } - } - public class faacSettingsProvider : SettingsProviderImpl2 - { - public faacSettingsProvider() - : base("AAC - FAAC", AudioEncoderType.FAAC, AudioCodec.AAC) - { } - } - public class ffac3SettingsProvider : SettingsProviderImpl2 - { - public ffac3SettingsProvider() - : base("AC3 - FFmpeg", AudioEncoderType.FFAC3, AudioCodec.AC3) - { } - } - public class ffmp2SettingsProvider : SettingsProviderImpl2 - { - public ffmp2SettingsProvider() - : base("MP2 - FFmpeg", AudioEncoderType.FFMP2, AudioCodec.MP2) - { } - } - public class lameSettingsProvider : SettingsProviderImpl2 - { - public lameSettingsProvider() - : base("MP3 - Lame", AudioEncoderType.LAME, AudioCodec.MP3) - { } - } - public class vorbisSettingsProvider : SettingsProviderImpl2 - { - public vorbisSettingsProvider() - : base("OGG - Xiph", AudioEncoderType.VORBIS, AudioCodec.VORBIS) - { } - } - public class waacSettingsProvider : SettingsProviderImpl2 - { - public waacSettingsProvider() - : base("AAC - Winamp", AudioEncoderType.WAAC, AudioCodec.AAC) - { } - } - public class aftenSettingsProvider : SettingsProviderImpl2 - { - public aftenSettingsProvider() - : base("AC3 - Aften", AudioEncoderType.AFTEN, AudioCodec.AC3) - { } - } - #endregion } Index: core/plugins/interfaces/Profile.cs =================================================================== --- core/plugins/interfaces/Profile.cs (revision 426) +++ core/plugins/interfaces/Profile.cs (working copy) @@ -21,6 +21,7 @@ using System; using System.Xml.Serialization; using MeGUI.core.plugins.interfaces; +using System.Diagnostics; namespace MeGUI { @@ -28,7 +29,7 @@ /// Superclass of an actual video or audio profile /// defines some basic properties /// - public abstract class Profile + public abstract class Profile : IIDable { private string name; // name of the profile /// @@ -42,15 +43,35 @@ { this.name = name; } + /// - /// name of the profile as shown in the profile dropdown in the GUI + /// Local name of the profile. Within a given settings type, this + /// is guaranteed to be unique, but not within the entire profile + /// collection /// - public string Name - { - get {return name;} - set {name = value;} - } + public string Name + { + get + { + Debug.Assert(!string.IsNullOrEmpty(name)); + return name; + } + set + { + name = value; + Debug.Assert(!string.IsNullOrEmpty(name)); + } + } + /// + /// Fully qualified name in format 'type: name'. For a given profile + /// collection, this is guaranteed to be unique. + /// + public string FQName + { + get { return BaseSettings.SettingsID + ": " + Name; } + } + public override string ToString() { return Name; @@ -64,6 +85,8 @@ } public abstract Profile baseClone(); + + public string ID { get { return FQName; } } } public class GenericProfile : Profile @@ -100,4 +123,4 @@ return clone(); } } -} \ No newline at end of file +} Index: core/util/FileUtil.cs =================================================================== --- core/util/FileUtil.cs (revision 426) +++ core/util/FileUtil.cs (working copy) @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using System.IO; +using ICSharpCode.SharpZipLib.Zip; namespace MeGUI.core.util { @@ -9,12 +10,76 @@ class FileUtil { - public static void ensureDirectoryExists(string p) + public static DirectoryInfo CreateTempDirectory() { - if (Directory.Exists(p)) return; + while (true) + { + string file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + + if (!File.Exists(file) && !Directory.Exists(file)) + { + MainForm.Instance.DeleteOnClosing(file); + return Directory.CreateDirectory(file); + } + } + } + + public static void CreateZipFile(string path, string filename) + { + using (ZipOutputStream outputFile = new ZipOutputStream(File.OpenWrite(filename))) + { + foreach (string file in FileUtil.AllFiles(path)) + { + ZipEntry newEntry = new ZipEntry(file.Substring(path.Length).TrimStart('\\', '/')); + outputFile.PutNextEntry(newEntry); + FileStream input = File.OpenRead(file); + FileUtil.copyData(input, outputFile); + input.Close(); + } + } + } + + public static void ExtractZipFile(string file, string extractFolder) + { + ExtractZipFile(File.OpenRead(file), extractFolder); + } + + public static void ExtractZipFile(Stream s, string extractFolder) + { + using (ZipFile inputFile = new ZipFile(s)) + { + foreach (ZipEntry entry in inputFile) + { + string pathname = Path.Combine(extractFolder, entry.Name); + if (entry.IsDirectory) + { + Directory.CreateDirectory(pathname); + } + else // entry.isFile + { + System.Diagnostics.Debug.Assert(entry.IsFile); + FileUtil.ensureDirectoryExists(Path.GetDirectoryName(pathname)); + Stream outputStream = File.OpenWrite(pathname); + FileUtil.copyData(inputFile.GetInputStream(entry), outputStream); + outputStream.Close(); + } + } + } + } + + public static void DeleteDirectoryIfExists(string p, bool recursive) + { + if (Directory.Exists(p)) + Directory.Delete(p, recursive); + } + + + public static DirectoryInfo ensureDirectoryExists(string p) + { + if (Directory.Exists(p)) return new DirectoryInfo(p); if (string.IsNullOrEmpty(p)) throw new IOException("Can't create directory"); ensureDirectoryExists(Path.GetDirectoryName(p)); - Directory.CreateDirectory(p); + return Directory.CreateDirectory(p); } /// /// Generates a filename not in the list Index: core/util/JobUtil.cs =================================================================== --- core/util/JobUtil.cs (revision 426) +++ core/util/JobUtil.cs (working copy) @@ -633,7 +633,7 @@ { Zone introZone = new Zone(); Zone creditsZone = new Zone(); - ulong nbOfFrames = getNumberOfFrames(mainForm.Video.Info.VideoInput); + ulong nbOfFrames = getNumberOfFrames(mainForm.Video.VideoInput); bool doIntroZone = false, doCreditsZone = false; int flushZonesStart = 0, flushZonesEnd = 0; if (introEndFrame > 0) // add the intro zone Index: core/util/Util.cs =================================================================== --- core/util/Util.cs (revision 426) +++ core/util/Util.cs (working copy) @@ -8,9 +8,16 @@ using System.Drawing; using System.ComponentModel; using System.Globalization; +using System.Collections; +using System.Reflection; namespace MeGUI.core.util { + public delegate R Delegate(); + public delegate R Delegate(P1 p1); + public delegate R Delegate(P1 p1, P2 p2); + public delegate R Delegate(P1 p1, P2 p2, P3 p3); + public delegate R Delegate(P1 p1, P2 P2, P3 p3); public class Pair { @@ -28,8 +35,36 @@ public delegate T Getter(); public delegate void Setter(T thing); + public delegate void Action(); + public class Util { + public static void CatchAndTellUser(string processDescription, Action action) + where TException : Exception + { + try { action(); } + catch (TException e) + { + MessageBox.Show(processDescription + ". Error message: " + e.Message, "Error occurred", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + public static void CatchAndTellUser(Action action) + where TException : Exception + { + CatchAndTellUser("An error occurred", action); + } + + public static void CatchExceptionsAndTellUser(string processDescription, Action action) + { + CatchAndTellUser(processDescription, action); + } + + public static void CatchExceptionsAndTellUser(Action action) + { + CatchAndTellUser(action); + } + public static void SetSize(Form f, Size s, FormWindowState state) { f.WindowState = state; @@ -52,17 +87,24 @@ m(); } - public static void XmlSerialize(T t, string path) + public static void XmlSerialize(object o, string path) { - XmlSerializer ser = new XmlSerializer(typeof(T)); + FileUtil.ensureDirectoryExists(Path.GetDirectoryName(path)); + XmlSerializer ser = new XmlSerializer(o.GetType()); using (Stream s = File.Open(path, System.IO.FileMode.Create, System.IO.FileAccess.Write)) { try { - ser.Serialize(s, t); + ser.Serialize(s, o); } catch (Exception e) { + s.Close(); + try + { + File.Delete(path); + } + catch (IOException) { } Console.Write(e.Message); } } @@ -95,7 +137,15 @@ } else return new T(); } - + + public static object XmlDeserialize(string path, Type t) + { + MethodInfo ms = (MethodInfo)Array.Find(typeof(Util).GetMember("XmlDeserialize"), + delegate(MemberInfo m) { return (m is MethodInfo) && (m as MethodInfo).IsGenericMethod; }); + ms = ms.MakeGenericMethod(t); + return ms.Invoke(null, new object[] { path }); + } + public static T XmlDeserialize(string path) where T : class { @@ -185,8 +235,122 @@ } } return ret; - } - + } + + public static T ByID(IEnumerable i, string id) + where T : IIDable + { + foreach (T t in i) + if (t.ID == id) + return t; + + return default(T); + } + + public static List Unique(List l, Delegate cmp) + where T : class + { + for (int i = 0; i < l.Count; ++i) + { + if (l.FindIndex(0, i, delegate(T t) { return cmp(t, l[i]); }) >= 0) + { + l.RemoveAt(i); + --i; + } + } + return l.FindAll(delegate(T t) { + return l.FindIndex(delegate(T t2) { return cmp(t, t2); }) == l.IndexOf(t); }); + } + + public static List Unique(List l) + where T : class + { + return Unique(l, delegate(T t1, T t2) { return t1.Equals(t2); }); + } + + public static List UniqueByIDs(List l) + where T : class, IIDable + { + return Unique(l, delegate(T t1, T t2) { return t1.ID == t2.ID; }); + } + + public static List RemoveDuds(List ps) + where T : class, IIDable + { + ps = ps.FindAll(delegate(T p) { return p != null; }); + + // eliminate duplicate names + return Util.UniqueByIDs(ps); + } + + + public static IEnumerable CastAll(IEnumerable i) + { + foreach (To t in i) + yield return t; + } + + + public static IEnumerable CastAll(IEnumerable i) + where To : class + { + foreach (From f in i) + yield return f as To; + } + + public static List CastAll(List i) + where To : class + { + return i.ConvertAll(delegate(From f) { return f as To; }); + } + + public static To[] CastAll(From[] fr) + where To : class + { + if (fr == null) + return null; + return Array.ConvertAll(fr, delegate(From f) { return f as To; }); + } + + public static To[] CastAll(object[] os) + { + return Array.ConvertAll(os, delegate(object o) { return (To)o; }); + } + + public static void RegisterTypeConverter() where TC : TypeConverter + { + Attribute[] attr = new Attribute[1]; + TypeConverterAttribute vConv = new TypeConverterAttribute(typeof(TC)); + attr[0] = vConv; + TypeDescriptor.AddAttributes(typeof(T), attr); + } + + public static T[] ToArray(IEnumerable i) + { + return new List(i).ToArray(); + } + + public static object[] ToArray(IEnumerable i) + { + List l = new List(); + foreach (object o in i) + l.Add(o); + return l.ToArray(); + } + + public static IEnumerable Append(params IEnumerable[] lists) + { + foreach (IEnumerable list in lists) + foreach (T t in list) + yield return t; + } + + public static IEnumerable ConvertAll(IEnumerable input, Converter c) + { + foreach (TIn t in input) + yield return c(t); + } + #region range clamping public static void clampedSet(NumericUpDown box, decimal value) { @@ -237,25 +401,21 @@ } #endregion - public static To[] CastAll(From[] fr) - where To : class + + public static void ChangeItemsKeepingSelectedSame(ComboBox box, T[] newItems) { - if (fr == null) - return null; - return Array.ConvertAll(fr, delegate(From f) { return f as To; }); - } + T sel = (T)box.SelectedItem; + if (Array.IndexOf(newItems, sel) < 0 || sel == null) + sel = newItems[0]; - public static To[] CastAll(object[] os) - { - return Array.ConvertAll(os, delegate(object o) { return (To)o; }); + box.Items.Clear(); + box.Items.AddRange(Util.CastAll(newItems)); + box.SelectedItem = sel; } - public static void RegisterTypeConverter() where TC : TypeConverter - { - Attribute[] attr = new Attribute[1]; - TypeConverterAttribute vConv = new TypeConverterAttribute(typeof(TC)); - attr[0] = vConv; - TypeDescriptor.AddAttributes(typeof(T), attr); - } + + } + + public delegate TOut Converter(TIn iinput); } Index: hfyuSettings.cs =================================================================== --- hfyuSettings.cs (revision 426) +++ hfyuSettings.cs (working copy) @@ -6,18 +6,12 @@ { public class hfyuSettings : VideoCodecSettings { + public static string ID = "huffyuv"; + private static readonly string[] m_fourCCs = { "FFVH" }; - public override VideoCodec Codec - { - get { return VideoCodec.HFYU; } - } - public override VideoEncoderType EncoderType - { - get { return VideoEncoderType.HFYU; } - } public hfyuSettings() - : base() + : base(ID, VideoEncoderType.HFYU) { base.BitrateQuantizer = 0; base.EncodingMode = (int)Mode.CQ; Index: MeGUI.csproj =================================================================== --- MeGUI.csproj (revision 426) +++ MeGUI.csproj (working copy) @@ -173,6 +173,7 @@ + UserControl @@ -278,6 +279,12 @@ AviSynthProfileConfigPanel.cs + + UserControl + + + ConfigableProfilesControl.cs + Form @@ -353,12 +360,24 @@ NumberChooser.cs - - UserControl + + Form - - ProfileControl.cs + + ProfileConfigurationWindow.cs + + Form + + + ProfileExporter.cs + + + Form + + + ProfileImporter.cs + Form @@ -366,7 +385,6 @@ ProfilePorter.cs - Form Form @@ -375,6 +393,12 @@ Form + + UserControl + + + SimpleProfilesControl.cs + UserControl @@ -688,6 +712,10 @@ Designer AviSynthProfileConfigPanel.cs + + Designer + ConfigableProfilesControl.cs + Designer CountdownWindow.cs @@ -736,10 +764,14 @@ Designer NumberChooser.cs - - ProfileControl.cs + Designer + ProfileExporter.cs + + Designer + ProfileImporter.cs + Designer ProfilePorter.cs @@ -756,6 +788,10 @@ SettingsForm.cs Designer + + Designer + SimpleProfilesControl.cs + Designer TextViewer.cs @@ -913,4 +949,4 @@ - \ No newline at end of file + Index: packages/audio/aften/AftenConfigurationPanel.cs =================================================================== --- packages/audio/aften/AftenConfigurationPanel.cs (revision 426) +++ packages/audio/aften/AftenConfigurationPanel.cs (working copy) @@ -8,10 +8,9 @@ namespace MeGUI.packages.audio.aften { - public partial class AftenConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel + public partial class AftenConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel, Editable { - public AftenConfigurationPanel(MainForm mainForm, string[] info) - : base(mainForm, info) + public AftenConfigurationPanel():base() { InitializeComponent(); comboBox1.Items.AddRange(AftenSettings.SupportedBitrates); @@ -36,6 +35,24 @@ } } #endregion + + #region Editable Members + + AftenSettings Editable.Settings + { + get + { + return (AftenSettings)Settings; + } + set + { + Settings = value; + } + } + + #endregion } } + + Index: packages/audio/aften/AftenSettings.cs =================================================================== --- packages/audio/aften/AftenSettings.cs (revision 426) +++ packages/audio/aften/AftenSettings.cs (working copy) @@ -6,10 +6,11 @@ { public class AftenSettings : AudioCodecSettings { + public static readonly string ID = "Aften AC-3"; public static readonly object[] SupportedBitrates = new object[] {64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 448, 512, 576, 640}; public AftenSettings() - : base() + : base(ID) { this.Bitrate = 384; this.Codec = AudioCodec.AC3; Index: packages/audio/audx/AudXConfigurationPanel.cs =================================================================== --- packages/audio/audx/AudXConfigurationPanel.cs (revision 426) +++ packages/audio/audx/AudXConfigurationPanel.cs (working copy) @@ -8,10 +8,9 @@ namespace MeGUI.packages.audio.audx { - public partial class AudXConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel + public partial class AudXConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel, Editable { - public AudXConfigurationPanel(MainForm mainForm, string[] info) - : base(mainForm, info) + public AudXConfigurationPanel():base() { InitializeComponent(); comboBox1.Items.AddRange(EnumProxy.CreateArray(typeof(AudXSettings.QualityMode))); @@ -43,6 +42,24 @@ } } #endregion + + #region Editable Members + + AudXSettings Editable.Settings + { + get + { + return (AudXSettings)Settings; + } + set + { + Settings = value; + } + } + + #endregion } } + + Index: packages/audio/audx/AudXSettings.cs =================================================================== --- packages/audio/audx/AudXSettings.cs (revision 426) +++ packages/audio/audx/AudXSettings.cs (working copy) @@ -6,7 +6,7 @@ { public class AudXSettings: AudioCodecSettings { - + public static readonly string ID = "Aud-X MP3"; public enum QualityMode { //0 (STRQ 80 kbps), 1 (STDQ 128 kbps), 2 (HGHQ 192 kbps) or 3 (SPBQ 192 kbps), default is 1 @@ -23,7 +23,7 @@ public QualityMode Quality; public AudXSettings() - : base() + : base(ID) { this.Quality = QualityMode.STDQ; this.Codec = AudioCodec.MP3; Index: packages/audio/faac/faacConfigurationPanel.cs =================================================================== --- packages/audio/faac/faacConfigurationPanel.cs (revision 426) +++ packages/audio/faac/faacConfigurationPanel.cs (working copy) @@ -8,10 +8,9 @@ namespace MeGUI.packages.audio.faac { - public partial class faacConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel + public partial class faacConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel, Editable { - public faacConfigurationPanel(MainForm mainForm, string[] info) - : base(mainForm, info) + public faacConfigurationPanel():base() { InitializeComponent(); cbrBitrate.DataSource = FaacSettings.SupportedBitrates; @@ -47,6 +46,24 @@ cbrBitrate.Enabled = !(vbrQuality.Enabled = qualityModeRadioButton.Checked); } #endregion + + #region Editable Members + + FaacSettings Editable.Settings + { + get + { + return (FaacSettings)Settings; + } + set + { + Settings = value; + } + } + + #endregion } } + + Index: packages/audio/faac/FaacSettings.cs =================================================================== --- packages/audio/faac/FaacSettings.cs (revision 426) +++ packages/audio/faac/FaacSettings.cs (working copy) @@ -27,6 +27,8 @@ /// public class FaacSettings : AudioCodecSettings { + public static string ID = "FAAC"; + public static readonly int[] SupportedBitrates = new int[] { 64, 80, @@ -42,7 +44,7 @@ 448}; private decimal quality; - public FaacSettings() : base() + public FaacSettings() : base(ID) { Quality = 100; Bitrate = 128; @@ -59,4 +61,4 @@ set {quality = value;} } } -} \ No newline at end of file +} Index: packages/audio/ffac3/AC3ConfigurationPanel.cs =================================================================== --- packages/audio/ffac3/AC3ConfigurationPanel.cs (revision 426) +++ packages/audio/ffac3/AC3ConfigurationPanel.cs (working copy) @@ -8,10 +8,9 @@ namespace MeGUI.packages.audio.ffac3 { - public partial class AC3ConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel + public partial class AC3ConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel, Editable { - public AC3ConfigurationPanel(MainForm mainForm, string[] info) - : base(mainForm, info) + public AC3ConfigurationPanel():base() { InitializeComponent(); comboBox1.Items.AddRange(AC3Settings.SupportedBitrates); @@ -36,6 +35,24 @@ } } #endregion + + #region Editable Members + + AC3Settings Editable.Settings + { + get + { + return (AC3Settings)Settings; + } + set + { + Settings = value; + } + } + + #endregion } } + + Index: packages/audio/ffac3/AC3Settings.cs =================================================================== --- packages/audio/ffac3/AC3Settings.cs (revision 426) +++ packages/audio/ffac3/AC3Settings.cs (working copy) @@ -6,10 +6,12 @@ { public class AC3Settings : AudioCodecSettings { + public static string ID = "FFmpeg AC-3"; + public static readonly object[] SupportedBitrates = new object[] { 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 448, 512, 576, 640}; public AC3Settings() - : base() + : base(ID) { this.Bitrate = 384; this.Codec = AudioCodec.AC3; Index: packages/audio/ffmp2/MP2ConfigurationPanel.cs =================================================================== --- packages/audio/ffmp2/MP2ConfigurationPanel.cs (revision 426) +++ packages/audio/ffmp2/MP2ConfigurationPanel.cs (working copy) @@ -8,10 +8,9 @@ namespace MeGUI.packages.audio.ffmp2 { - public partial class MP2ConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel + public partial class MP2ConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel, Editable { - public MP2ConfigurationPanel(MainForm mainForm, string[] info) - : base(mainForm, info) + public MP2ConfigurationPanel():base() { InitializeComponent(); comboBox1.Items.AddRange(MP2Settings.SupportedBitrates); @@ -44,6 +43,24 @@ } } #endregion + + #region Editable Members + + MP2Settings Editable.Settings + { + get + { + return (MP2Settings)Settings; + } + set + { + Settings = value; + } + } + + #endregion } } + + Index: packages/audio/ffmp2/MP2Settings.cs =================================================================== --- packages/audio/ffmp2/MP2Settings.cs (revision 426) +++ packages/audio/ffmp2/MP2Settings.cs (working copy) @@ -6,12 +6,13 @@ { public class MP2Settings : AudioCodecSettings { + public static readonly string ID = "FFmpeg MP2"; public static readonly object[] SupportedBitrates = new object[] { 64, 128, 160, 192, 224, 256, 288, 320 }; public MP2Settings() - : base() + : base(ID) { this.Codec = AudioCodec.MP2; this.EncoderType = AudioEncoderType.FFMP2; Index: packages/audio/lame/lameConfigurationPanel.cs =================================================================== --- packages/audio/lame/lameConfigurationPanel.cs (revision 426) +++ packages/audio/lame/lameConfigurationPanel.cs (working copy) @@ -8,10 +8,9 @@ namespace MeGUI.packages.audio.lame { - public partial class lameConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel + public partial class lameConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel, Editable { - public lameConfigurationPanel(MainForm mainForm, string[] info) - : base(mainForm, info) + public lameConfigurationPanel():base() { InitializeComponent(); this.encodingMode.Items.Add(BitrateManagementMode.CBR); @@ -88,6 +87,24 @@ } #endregion + + #region Editable Members + + MP3Settings Editable.Settings + { + get + { + return (MP3Settings)Settings; + } + set + { + Settings = value; + } + } + + #endregion } } + + Index: packages/audio/lame/MP3Settings.cs =================================================================== --- packages/audio/lame/MP3Settings.cs (revision 426) +++ packages/audio/lame/MP3Settings.cs (working copy) @@ -7,8 +7,9 @@ /// public class MP3Settings : AudioCodecSettings { + public static readonly string ID = "LAME MP3"; int quality; - public MP3Settings():base() + public MP3Settings():base(ID) { quality = 50; Codec = AudioCodec.MP3; @@ -23,4 +24,4 @@ set {quality = value;} } } -} \ No newline at end of file +} Index: packages/audio/naac/NeroAACSettings.cs =================================================================== --- packages/audio/naac/NeroAACSettings.cs (revision 426) +++ packages/audio/naac/NeroAACSettings.cs (working copy) @@ -38,7 +38,8 @@ public class NeroAACSettings : AudioCodecSettings { - public NeroAACSettings() : base() + public static readonly string ID = "Nero AAC"; + public NeroAACSettings() : base(ID) { Quality = 0.5M; Profile = AacProfile.Auto; @@ -72,4 +73,4 @@ } -} \ No newline at end of file +} Index: packages/audio/naac/neroConfigurationPanel.cs =================================================================== --- packages/audio/naac/neroConfigurationPanel.cs (revision 426) +++ packages/audio/naac/neroConfigurationPanel.cs (working copy) @@ -10,7 +10,7 @@ namespace MeGUI.packages.audio.naac { - public partial class neroConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel, Gettable + public partial class neroConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel, Editable { public TrackBar vQuality; public RadioButton rbtnVBR; @@ -23,9 +23,7 @@ #endregion #region start / stop - public neroConfigurationPanel(MainForm mainForm, string[] audioInfo) - : base(mainForm, audioInfo) - + public neroConfigurationPanel():base() { // // Required for Windows Form Designer support @@ -184,7 +182,7 @@ } set { - NeroAACSettings nas = value as NeroAACSettings; + NeroAACSettings nas = (NeroAACSettings)value; rbtnABR.Checked = nas.BitrateMode == BitrateManagementMode.ABR; rbtnCBR.Checked = nas.BitrateMode == BitrateManagementMode.CBR; rbtnVBR.Checked = nas.BitrateMode == BitrateManagementMode.VBR; @@ -213,7 +211,25 @@ Decimal q = ((Decimal)vQuality.Value) / vQuality.Maximum; rbtnVBR.Text = String.Format("Variable Bitrate (Q={0}) ", q); } + + #region Editable Members + + NeroAACSettings Editable.Settings + { + get + { + return (NeroAACSettings)Settings; + } + set + { + Settings = value; + } + } + + #endregion } } + + Index: packages/audio/vorbis/OggVorbisConfigurationPanel.cs =================================================================== --- packages/audio/vorbis/OggVorbisConfigurationPanel.cs (revision 426) +++ packages/audio/vorbis/OggVorbisConfigurationPanel.cs (working copy) @@ -8,10 +8,9 @@ namespace MeGUI.packages.audio.vorbis { - public partial class OggVorbisConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel + public partial class OggVorbisConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel, Editable { - public OggVorbisConfigurationPanel(MainForm mainForm, string[] info) - : base(mainForm, info) + public OggVorbisConfigurationPanel():base() { InitializeComponent(); vQuality_ValueChanged(null, null); @@ -40,6 +39,24 @@ Decimal q = ((Decimal)vQuality.Value) * 10.0M / vQuality.Maximum; label1.Text = String.Format("Variable Bitrate (Q={0}) ", q); } + + #region Editable Members + + OggVorbisSettings Editable.Settings + { + get + { + return (OggVorbisSettings)Settings; + } + set + { + Settings = value; + } + } + + #endregion } } + + Index: packages/audio/vorbis/OggVorbisSettings.cs =================================================================== --- packages/audio/vorbis/OggVorbisSettings.cs (revision 426) +++ packages/audio/vorbis/OggVorbisSettings.cs (working copy) @@ -6,8 +6,10 @@ { public class OggVorbisSettings: AudioCodecSettings { + public static readonly string ID = "Vorbis"; + public OggVorbisSettings() - : base() + : base(ID) { this.Quality = 1.0M; this.Codec = AudioCodec.VORBIS; Index: packages/audio/waac/WinAmpAACConfigurationPanel.cs =================================================================== --- packages/audio/waac/WinAmpAACConfigurationPanel.cs (revision 426) +++ packages/audio/waac/WinAmpAACConfigurationPanel.cs (working copy) @@ -8,10 +8,9 @@ namespace MeGUI.packages.audio.waac { - public partial class WinAmpAACConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel + public partial class WinAmpAACConfigurationPanel : MeGUI.core.details.audio.AudioConfigurationPanel, Editable { - public WinAmpAACConfigurationPanel(MainForm mainForm, string[] info) - : base(mainForm, info) + public WinAmpAACConfigurationPanel():base() { InitializeComponent(); comboBox1.Items.AddRange(EnumProxy.CreateArray(WinAmpAACSettings.SupportedProfiles)); @@ -50,6 +49,24 @@ } + + #region Editable Members + + WinAmpAACSettings Editable.Settings + { + get + { + return (WinAmpAACSettings)Settings; + } + set + { + Settings = value; + } + } + + #endregion } } + + Index: packages/audio/waac/WinAmpAACSettings.cs =================================================================== --- packages/audio/waac/WinAmpAACSettings.cs (revision 426) +++ packages/audio/waac/WinAmpAACSettings.cs (working copy) @@ -6,7 +6,7 @@ { public class WinAmpAACSettings: AudioCodecSettings { - + public static readonly string ID = "Winamp AAC"; public enum AacStereoMode { Joint, @@ -17,7 +17,7 @@ public static readonly AacProfile[] SupportedProfiles = new AacProfile[] { AacProfile.PS, AacProfile.HE, AacProfile.LC }; public WinAmpAACSettings() - : base() + : base(ID) { this.Bitrate = 48; this.Profile = AacProfile.PS; Index: packages/AVCLevels.cs =================================================================== --- packages/AVCLevels.cs (revision 426) +++ packages/AVCLevels.cs (working copy) @@ -21,7 +21,7 @@ else { int compliantLevel = 15; - x264Settings currentX264Settings = (x264Settings)CodecManager.X264.GetCurrentSettings(); + x264Settings currentX264Settings = (x264Settings)MainForm.Instance.Profiles.GetCurrentSettings("x264"); bool succ = info.JobUtil.validateAVCLevel(info.Video.VideoInput, currentX264Settings, out compliantLevel); if (succ) MessageBox.Show("This file matches the criteria for the level chosen", "Video validated", @@ -631,4 +631,4 @@ } } #endregion -} \ No newline at end of file +} Index: packages/AviSynthSettings.cs =================================================================== --- packages/AviSynthSettings.cs (revision 426) +++ packages/AviSynthSettings.cs (working copy) @@ -8,6 +8,9 @@ /// public sealed class AviSynthSettings : GenericSettings { + public static string ID = "AviSynth"; + public string SettingsID { get { return ID; } } + public void FixFileNames(System.Collections.Generic.Dictionary _) { } public override bool Equals(object obj) @@ -20,10 +23,6 @@ return base.GetHashCode(); } - public string getSettingsType() - { - return "AviSynth"; - } private string template; private ResizeFilterType resizeMethod; private DenoiseFilterType denoiseMethod; Index: packages/AviSynthWindow.cs =================================================================== --- packages/AviSynthWindow.cs (revision 426) +++ packages/AviSynthWindow.cs (working copy) @@ -26,11 +26,10 @@ #region variable declaration string originalScript; bool originalInlineAvs; + bool loaded; bool isPreviewMode = false; - ISettingsProvider settingsProvider = new SettingsProviderImpl2< - MeGUI.core.gui.AviSynthProfileConfigPanel, Empty, AviSynthSettings, AviSynthSettings, int, int>("AviSynth", 0, 0); private CultureInfo ci = new CultureInfo("en-us"); private bool eventsOn = true; private string path; @@ -94,7 +93,6 @@ private Label resizeFilterLabel; private CheckBox resize; private ComboBox mod16Box; - private ProfileControl profileControl1; private Label label1; private Button openDLLButton; private TextBox dllPath; @@ -108,6 +106,8 @@ private NumericUpDown fpsBox; private MeGUI.core.gui.HelpButton helpButton1; private MeGUI.core.gui.ARChooser arChooser; + private MeGUI.core.gui.ConfigableProfilesControl avsProfile; + private Label label6; /// /// Required designer variable. @@ -117,8 +117,11 @@ #region construction/deconstruction public AviSynthWindow(MainForm mainForm) { + this.loaded = false; this.mainForm = mainForm; InitializeComponent(); + avsProfile.Manager = MainForm.Instance.Profiles; + this.controlsToDisable = new List(); this.controlsToDisable.Add(filtersGroupbox); @@ -182,23 +185,14 @@ this.jobUtil = new JobUtil(mainForm); this.showScript(); + this.loaded = true; + ProfileChanged(null, null); - - - - ProfilesControlHandler profileHandler = new ProfilesControlHandler( - "AviSynth", mainForm, profileControl1, settingsProvider.EditSettings, Empty.Getter, - new SettingsGetter(settingsProvider.GetCurrentSettings), new SettingsSetter(settingsProvider.LoadSettings)); - - SingleConfigurerHandler configurerHandler = new SingleConfigurerHandler(profileHandler, settingsProvider); - configurerHandler.ProfileChanged += new SelectedProfileChangedEvent(ProfileChanged); - - ProfileChanged(null, null); } - void ProfileChanged(object sender, Profile prof) + void ProfileChanged(object sender, EventArgs e) { - this.Settings = settingsProvider.GetCurrentSettings(); + this.Settings = GetProfileSettings(); } /// /// constructor that first initializes everything using the default constructor @@ -262,12 +256,13 @@ this.tabControl1 = new System.Windows.Forms.TabControl(); this.optionsTab = new System.Windows.Forms.TabPage(); this.videoGroupBox = new System.Windows.Forms.GroupBox(); + this.avsProfile = new MeGUI.core.gui.ConfigableProfilesControl(); this.arChooser = new MeGUI.core.gui.ARChooser(); this.reopenOriginal = new System.Windows.Forms.Button(); - this.profileControl1 = new MeGUI.core.details.video.ProfileControl(); this.mod16Box = new System.Windows.Forms.ComboBox(); this.signalAR = new System.Windows.Forms.CheckBox(); this.tvTypeLabel = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); this.inputDARLabel = new System.Windows.Forms.Label(); this.videoInput = new System.Windows.Forms.TextBox(); this.videoInputLabel = new System.Windows.Forms.Label(); @@ -379,7 +374,7 @@ this.resNCropGroupbox.Controls.Add(this.verticalResolution); this.resNCropGroupbox.Controls.Add(this.horizontalResolution); this.resNCropGroupbox.Enabled = false; - this.resNCropGroupbox.Location = new System.Drawing.Point(3, 227); + this.resNCropGroupbox.Location = new System.Drawing.Point(3, 211); this.resNCropGroupbox.Name = "resNCropGroupbox"; this.resNCropGroupbox.Size = new System.Drawing.Size(412, 112); this.resNCropGroupbox.TabIndex = 0; @@ -608,23 +603,35 @@ // // videoGroupBox // + this.videoGroupBox.Controls.Add(this.avsProfile); this.videoGroupBox.Controls.Add(this.arChooser); this.videoGroupBox.Controls.Add(this.reopenOriginal); - this.videoGroupBox.Controls.Add(this.profileControl1); this.videoGroupBox.Controls.Add(this.mod16Box); this.videoGroupBox.Controls.Add(this.signalAR); this.videoGroupBox.Controls.Add(this.tvTypeLabel); + this.videoGroupBox.Controls.Add(this.label6); this.videoGroupBox.Controls.Add(this.inputDARLabel); this.videoGroupBox.Controls.Add(this.videoInput); this.videoGroupBox.Controls.Add(this.videoInputLabel); this.videoGroupBox.Controls.Add(this.openVideoButton); this.videoGroupBox.Location = new System.Drawing.Point(3, 8); this.videoGroupBox.Name = "videoGroupBox"; - this.videoGroupBox.Size = new System.Drawing.Size(412, 213); + this.videoGroupBox.Size = new System.Drawing.Size(412, 197); this.videoGroupBox.TabIndex = 5; this.videoGroupBox.TabStop = false; this.videoGroupBox.Text = "Video"; // + // avsProfile + // + this.avsProfile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.avsProfile.Location = new System.Drawing.Point(96, 163); + this.avsProfile.Name = "avsProfile"; + this.avsProfile.ProfileSet = "AviSynth"; + this.avsProfile.Size = new System.Drawing.Size(310, 22); + this.avsProfile.TabIndex = 22; + this.avsProfile.SelectedProfileChanged += new System.EventHandler(this.ProfileChanged); + // // arChooser // this.arChooser.HasLater = false; @@ -649,14 +656,6 @@ this.reopenOriginal.UseVisualStyleBackColor = true; this.reopenOriginal.Click += new System.EventHandler(this.reopenOriginal_Click); // - // profileControl1 - // - this.profileControl1.LabelText = "AVS profile"; - this.profileControl1.Location = new System.Drawing.Point(11, 178); - this.profileControl1.Name = "profileControl1"; - this.profileControl1.Size = new System.Drawing.Size(395, 29); - this.profileControl1.TabIndex = 6; - // // mod16Box // this.mod16Box.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -690,6 +689,15 @@ this.tvTypeLabel.Size = new System.Drawing.Size(48, 23); this.tvTypeLabel.TabIndex = 10; // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(8, 168); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(82, 13); + this.label6.TabIndex = 7; + this.label6.Text = "Avisynth profile"; + // // inputDARLabel // this.inputDARLabel.Location = new System.Drawing.Point(8, 95); @@ -731,7 +739,7 @@ this.filterTab.Controls.Add(this.filtersGroupbox); this.filterTab.Location = new System.Drawing.Point(4, 22); this.filterTab.Name = "filterTab"; - this.filterTab.Size = new System.Drawing.Size(418, 388); + this.filterTab.Size = new System.Drawing.Size(192, 74); this.filterTab.TabIndex = 2; this.filterTab.Text = "Filters"; this.filterTab.UseVisualStyleBackColor = true; @@ -973,7 +981,7 @@ this.editTab.Controls.Add(this.avisynthScript); this.editTab.Location = new System.Drawing.Point(4, 22); this.editTab.Name = "editTab"; - this.editTab.Size = new System.Drawing.Size(418, 388); + this.editTab.Size = new System.Drawing.Size(192, 74); this.editTab.TabIndex = 1; this.editTab.Text = "Edit"; this.editTab.UseVisualStyleBackColor = true; @@ -981,7 +989,7 @@ // openDLLButton // this.openDLLButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.openDLLButton.Location = new System.Drawing.Point(387, 353); + this.openDLLButton.Location = new System.Drawing.Point(161, 39); this.openDLLButton.Name = "openDLLButton"; this.openDLLButton.Size = new System.Drawing.Size(24, 23); this.openDLLButton.TabIndex = 3; @@ -992,16 +1000,16 @@ // this.dllPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.dllPath.Location = new System.Drawing.Point(80, 354); + this.dllPath.Location = new System.Drawing.Point(80, 40); this.dllPath.Name = "dllPath"; this.dllPath.ReadOnly = true; - this.dllPath.Size = new System.Drawing.Size(301, 21); + this.dllPath.Size = new System.Drawing.Size(75, 21); this.dllPath.TabIndex = 2; // // label1 // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label1.Location = new System.Drawing.Point(8, 358); + this.label1.Location = new System.Drawing.Point(8, 44); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(66, 13); this.label1.TabIndex = 1; @@ -1016,7 +1024,7 @@ this.avisynthScript.Multiline = true; this.avisynthScript.Name = "avisynthScript"; this.avisynthScript.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.avisynthScript.Size = new System.Drawing.Size(400, 340); + this.avisynthScript.Size = new System.Drawing.Size(174, 26); this.avisynthScript.TabIndex = 0; // // openVideoDialog @@ -1167,6 +1175,8 @@ #region script generation private string generateScript() { + if (!this.loaded) + return ""; script = new StringBuilder(); //scriptLoad = new StringBuilder(); Better to use AviSynth plugin dir and it is easier for avs templates/profiles @@ -1185,7 +1195,7 @@ resizeLine = ScriptServer.GetResizeLine(resize.Checked, (int)horizontalResolution.Value, (int)verticalResolution.Value, (ResizeFilterType)(resizeFilterType.SelectedItem as EnumProxy).RealValue); denoiseLines = ScriptServer.GetDenoiseLines(noiseFilter.Checked, (DenoiseFilterType)(noiseFilterType.SelectedItem as EnumProxy).RealValue); - string newScript = ScriptServer.CreateScriptFromTemplate(settingsProvider.GetCurrentSettings().Template, inputLine, cropLine, resizeLine, denoiseLines, deinterlaceLines); + string newScript = ScriptServer.CreateScriptFromTemplate(GetProfileSettings().Template, inputLine, cropLine, resizeLine, denoiseLines, deinterlaceLines); if (this.signalAR.Checked && suggestedDar.HasValue) newScript = string.Format("# Set DAR in encoder to {0} : {1}. The following line is for automatic signalling\r\nglobal MeGUI_darx = {0}\r\nglobal MeGUI_dary = {1}\r\n", @@ -1193,6 +1203,12 @@ return newScript; } + + private AviSynthSettings GetProfileSettings() + { + return (AviSynthSettings)avsProfile.SelectedProfile.BaseSettings; + } + private void showScript() { string text = this.generateScript(); Index: packages/tools/autoencode/AutoEncodeWindow.cs =================================================================== --- packages/tools/autoencode/AutoEncodeWindow.cs (revision 426) +++ packages/tools/autoencode/AutoEncodeWindow.cs (working copy) @@ -788,14 +788,14 @@ return; } #warning must be fixed up to be more generic - if (info.Video.CurrentVideoCodecSettings.EncodingMode == 2 || info.Video.CurrentVideoCodecSettings.EncodingMode == 5) + if (info.Video.CurrentSettings.EncodingMode == 2 || info.Video.CurrentSettings.EncodingMode == 5) { MessageBox.Show("First pass encoding is not supported for automated encoding as no output is generated.\nPlease choose another encoding mode", "Improper configuration", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } - VideoCodecSettings vSettings = info.Video.CurrentVideoCodecSettings.clone(); + VideoCodecSettings vSettings = info.Video.CurrentSettings.clone(); bool cont = info.JobUtil.getFinalZoneConfiguration(vSettings, info.Video.Info.IntroEndFrame, info.Video.Info.CreditsStartFrame); if (cont) { Index: packages/tools/calculator/Calculator.cs =================================================================== --- packages/tools/calculator/Calculator.cs (revision 426) +++ packages/tools/calculator/Calculator.cs (working copy) @@ -89,8 +89,8 @@ InitializeComponent(); this.mainForm = mainForm; this.muxProvider = mainForm.MuxProvider; - this.videoCodec.Items.AddRange(CodecManager.ListOfVideoCodecs); - videoCodec.SelectedItem = CodecManager.X264; + this.videoCodec.Items.AddRange(CodecManager.VideoEncoderTypes.ValuesArray); + videoCodec.SelectedItem = CodecManager.VideoEncoderTypes["X264"]; this.containerFormat.Items.AddRange(muxProvider.GetSupportedContainers().ToArray()); containerFormat.SelectedItem = ContainerType.MKV; audioTabs.Add(audioTrackSizeTab1); @@ -602,20 +602,20 @@ /// container /// bitrate of the first audio track /// bitrate of the second audio track - public void setDefaults(ulong nbFrames, double framerate, ISettingsProvider codec, List audioStreams) + public void setDefaults(ulong nbFrames, double framerate, VideoCodecSettings vSettings, List audioStreams) { setFPSToBest(framerate); try { - bframes.Checked = codec.GetCurrentSettings().NbBframes > 0; + bframes.Checked = vSettings.NbBframes > 0; } catch (Exception) { } if (nbFrames > 0) this.nbFrames.Value = nbFrames; - if (videoCodec.Items.Contains(codec)) - videoCodec.SelectedItem = codec; + if (videoCodec.Items.Contains(vSettings.EncoderType)) + videoCodec.SelectedItem = vSettings.EncoderType; int i = 0; foreach (AudioJob s in audioStreams) @@ -654,10 +654,15 @@ /// gets the selected codec /// /// - public ISettingsProvider getSelectedCodec() +/* public ISettingsProvider getSelectedCodec() { return (ISettingsProvider)videoCodec.SelectedItem; - } + }*/ + + public VideoEncoderType SelectedVCodec + { + get { return (VideoEncoderType)videoCodec.SelectedItem; } + } /// /// gets the calculated bitrate /// @@ -871,7 +876,7 @@ if (updatingContainers) return; updatingContainers = true; - VideoEncoderType vCodec = (videoCodec.SelectedItem as ISettingsProvider).EncoderType; + VideoEncoderType vCodec = SelectedVCodec; List muxableTypes = new List(); muxableTypes.AddRange(getAudioTypes()); ContainerType previousContainer = null; @@ -917,7 +922,7 @@ audioStreamsArray = getAudioStreams().ToArray(); try { - codec = (videoCodec.SelectedItem as ISettingsProvider).CodecType; + codec = SelectedVCodec.VCodec; containerType = (containerFormat.SelectedItem as ContainerType); } catch (Exception) @@ -1094,19 +1099,25 @@ if (!string.IsNullOrEmpty(info.Video.VideoInput)) JobUtil.getInputProperties(out nbFrames, out framerate, info.Video.VideoInput); - calc.setDefaults(nbFrames, framerate, info.Video.CurrentSettingsProvider, info.Audio.AudioStreams); - + calc.setDefaults(nbFrames, framerate, info.Video.CurrentSettings, info.Audio.AudioStreams); + DialogResult dr = calc.ShowDialog(); - if (dr == DialogResult.OK) + if (dr != DialogResult.OK) + return; + + if (info.Video.CurrentSettings.EncoderType != calc.SelectedVCodec) + return; + + dr = MessageBox.Show("Copy calculated bitrate into video settings?", "Save calculated bitrate?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dr != DialogResult.Yes) + return; + + VideoCodecSettings settings = info.Video.CurrentSettings; + if (settings.EncodingMode == 1 || settings.EncodingMode == 9) { - info.Video.CurrentSettingsProvider = calc.getSelectedCodec(); - VideoCodecSettings settings = info.Video.CodecHandler.Getter(); - if (settings.EncodingMode == 1 || settings.EncodingMode == 9) - { - settings.EncodingMode = 0; - } - settings.BitrateQuantizer = calc.getBitrate(); + settings.EncodingMode = 0; } + settings.BitrateQuantizer = calc.getBitrate(); } } Index: packages/tools/oneclick/AudioConfigControl.cs =================================================================== --- packages/tools/oneclick/AudioConfigControl.cs (revision 426) +++ packages/tools/oneclick/AudioConfigControl.cs (working copy) @@ -15,24 +15,9 @@ MainForm mainForm = MainForm.Instance; #region Audio profiles - MultipleConfigurersHandler audioCodecHandler; - ProfilesControlHandler audioProfileHandler; private void initAudioHandler() { - this.audioCodec.Items.AddRange(mainForm.PackageSystem.AudioSettingsProviders.ValuesArray); - try - { - this.audioCodec.SelectedItem = mainForm.PackageSystem.AudioSettingsProviders["ND AAC"]; - } - catch (Exception) { } - - // Init audio handlers - audioCodecHandler = new MultipleConfigurersHandler(audioCodec); - audioProfileHandler = new ProfilesControlHandler("Audio", mainForm, audioProfileControl, audioCodecHandler.EditSettings, - new InfoGetter(delegate { return new string[] { "input", "output" }; }), audioCodecHandler.Getter, audioCodecHandler.Setter); - audioCodecHandler.Register(audioProfileHandler); - audioProfileHandler.ProfileChanged += new SelectedProfileChangedEvent(ProfileChanged); ; - audioCodec.SelectedIndexChanged += new EventHandler(audioCodec_SelectedIndexChanged); + audioProfile.Manager = mainForm.Profiles; } void audioCodec_SelectedIndexChanged(object sender, EventArgs e) @@ -41,7 +26,7 @@ } #endregion - private void ProfileChanged(object o, Profile p) + private void ProfileChanged(object o, EventArgs e) { raiseEvent(); } @@ -51,8 +36,7 @@ private void dontEncodeAudio_CheckedChanged(object sender, EventArgs e) { bool aChecked = dontEncodeAudio.Checked; - audioCodec.Enabled = !aChecked; - audioProfileControl.Enabled = !aChecked; + audioProfile.Enabled = !aChecked; raiseEvent(); } @@ -61,16 +45,11 @@ if (SomethingChanged != null) SomethingChanged(this, null); } - private ISettingsProvider AudioSettingsProvider - { - get { return audioCodecHandler.CurrentSettingsProvider; } - } - [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public AudioCodecSettings Settings { - get { return AudioSettingsProvider.GetCurrentSettings(); } + get { return (AudioCodecSettings)audioProfile.SelectedProfile.BaseSettings; } } [Browsable(false)] @@ -96,11 +75,6 @@ initAudioHandler(); } - internal void RefreshProfiles() - { - audioProfileHandler.RefreshProfiles(); - } - [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool DontEncode @@ -115,18 +89,9 @@ } } - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string SelectedProfile + public void SelectProfileNameOrWarn(string fqname) { - get - { - return audioProfileHandler.SelectedProfile; - } - set - { - audioProfileHandler.SelectedProfile = value; - } + audioProfile.SetProfileNameOrWarn(fqname); } [Browsable(false)] Index: packages/tools/oneclick/AudioConfigControl.Designer.cs =================================================================== --- packages/tools/oneclick/AudioConfigControl.Designer.cs (revision 426) +++ packages/tools/oneclick/AudioConfigControl.Designer.cs (working copy) @@ -28,58 +28,26 @@ /// private void InitializeComponent() { - this.audioCodecLabel = new System.Windows.Forms.Label(); this.dontEncodeAudio = new System.Windows.Forms.CheckBox(); - this.audioCodec = new System.Windows.Forms.ComboBox(); - this.audioProfileControl = new MeGUI.core.details.video.ProfileControl(); this.label3 = new System.Windows.Forms.Label(); this.delay = new System.Windows.Forms.NumericUpDown(); this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.audioProfile = new MeGUI.core.gui.ConfigableProfilesControl(); ((System.ComponentModel.ISupportInitialize)(this.delay)).BeginInit(); this.SuspendLayout(); // - // audioCodecLabel - // - this.audioCodecLabel.AutoSize = true; - this.audioCodecLabel.Location = new System.Drawing.Point(3, 8); - this.audioCodecLabel.Name = "audioCodecLabel"; - this.audioCodecLabel.Size = new System.Drawing.Size(38, 13); - this.audioCodecLabel.TabIndex = 39; - this.audioCodecLabel.Text = "Codec"; - this.audioCodecLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // // dontEncodeAudio // this.dontEncodeAudio.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.dontEncodeAudio.AutoSize = true; - this.dontEncodeAudio.Location = new System.Drawing.Point(288, 6); + this.dontEncodeAudio.Location = new System.Drawing.Point(107, 35); this.dontEncodeAudio.Name = "dontEncodeAudio"; this.dontEncodeAudio.Size = new System.Drawing.Size(114, 17); this.dontEncodeAudio.TabIndex = 38; this.dontEncodeAudio.Text = "Keep original track"; this.dontEncodeAudio.CheckedChanged += new System.EventHandler(this.dontEncodeAudio_CheckedChanged); // - // audioCodec - // - this.audioCodec.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.audioCodec.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.audioCodec.Location = new System.Drawing.Point(107, 4); - this.audioCodec.Name = "audioCodec"; - this.audioCodec.Size = new System.Drawing.Size(173, 21); - this.audioCodec.Sorted = true; - this.audioCodec.TabIndex = 36; - // - // audioProfileControl - // - this.audioProfileControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.audioProfileControl.LabelText = "Audio Profile"; - this.audioProfileControl.Location = new System.Drawing.Point(3, 29); - this.audioProfileControl.Name = "audioProfileControl"; - this.audioProfileControl.Size = new System.Drawing.Size(407, 29); - this.audioProfileControl.TabIndex = 41; - // // label3 // this.label3.AutoSize = true; @@ -115,17 +83,37 @@ this.label2.TabIndex = 42; this.label2.Text = "Delay"; // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 8); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 13); + this.label1.TabIndex = 39; + this.label1.Text = "Codec"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // audioProfile + // + this.audioProfile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.audioProfile.Location = new System.Drawing.Point(107, 3); + this.audioProfile.Name = "audioProfile"; + this.audioProfile.ProfileSet = "Audio"; + this.audioProfile.Size = new System.Drawing.Size(295, 22); + this.audioProfile.TabIndex = 45; + this.audioProfile.SelectedProfileChanged += new System.EventHandler(this.ProfileChanged); + // // AudioConfigControl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.audioProfile); this.Controls.Add(this.label3); this.Controls.Add(this.delay); this.Controls.Add(this.label2); - this.Controls.Add(this.audioProfileControl); - this.Controls.Add(this.audioCodecLabel); + this.Controls.Add(this.label1); this.Controls.Add(this.dontEncodeAudio); - this.Controls.Add(this.audioCodec); this.Name = "AudioConfigControl"; this.Size = new System.Drawing.Size(416, 90); ((System.ComponentModel.ISupportInitialize)(this.delay)).EndInit(); @@ -136,12 +124,11 @@ #endregion - private MeGUI.core.details.video.ProfileControl audioProfileControl; - private System.Windows.Forms.Label audioCodecLabel; private System.Windows.Forms.CheckBox dontEncodeAudio; - private System.Windows.Forms.ComboBox audioCodec; private System.Windows.Forms.Label label3; private System.Windows.Forms.NumericUpDown delay; private System.Windows.Forms.Label label2; + private MeGUI.core.gui.ConfigableProfilesControl audioProfile; + private System.Windows.Forms.Label label1; } } Index: packages/tools/oneclick/OneClickConfigPanel.cs =================================================================== --- packages/tools/oneclick/OneClickConfigPanel.cs (revision 426) +++ packages/tools/oneclick/OneClickConfigPanel.cs (working copy) @@ -14,29 +14,23 @@ namespace MeGUI.packages.tools.oneclick { - public partial class OneClickConfigPanel : UserControl, MeGUI.core.plugins.interfaces.Gettable + public partial class OneClickConfigPanel : UserControl, Editable { private MainForm mainForm; #region profiles #region AVS profiles - ISettingsProvider avsSettingsProvider = new SettingsProviderImpl2< - MeGUI.core.gui.AviSynthProfileConfigPanel, MeGUI.core.details.video.Empty, AviSynthSettings, AviSynthSettings, int, int>("AviSynth", 0, 0); - ProfilesControlHandler avsProfileHandler; private void initAvsHandler() { // Init AVS handlers - avsProfileHandler = new ProfilesControlHandler( - "AviSynth", mainForm, avsProfileControl, avsSettingsProvider.EditSettings, Empty.Getter, - new SettingsGetter(avsSettingsProvider.GetCurrentSettings), new SettingsSetter(avsSettingsProvider.LoadSettings)); - SingleConfigurerHandler configurerHandler = new SingleConfigurerHandler(avsProfileHandler, avsSettingsProvider); + avsProfile.Manager = mainForm.Profiles; } #endregion #region Video profiles - MultipleConfigurersHandler videoCodecHandler; - ProfilesControlHandler videoProfileHandler; + /*MultipleConfigurersHandler videoCodecHandler; + ProfilesControlHandler videoProfileHandler;*/ private void initVideoHandler() { - this.videoCodec.Items.AddRange(mainForm.PackageSystem.VideoSettingsProviders.ValuesArray); + /*this.videoCodec.Items.AddRange(mainForm.PackageSystem.VideoSettingsProviders.ValuesArray); try { this.videoCodec.SelectedItem = mainForm.PackageSystem.VideoSettingsProviders["x264"]; @@ -49,15 +43,16 @@ new ProfilesControlHandler("Video", mainForm, videoProfileControl, videoCodecHandler.EditSettings, new InfoGetter(delegate() { return new VideoInfo(); }), videoCodecHandler.Getter, videoCodecHandler.Setter); - videoCodecHandler.Register(videoProfileHandler); + videoCodecHandler.Register(videoProfileHandler);*/ + videoProfile.Manager = mainForm.Profiles; } #endregion #region Audio profiles - MultipleConfigurersHandler audioCodecHandler; - ProfilesControlHandler audioProfileHandler; + /*MultipleConfigurersHandler audioCodecHandler; + ProfilesControlHandler audioProfileHandler;*/ private void initAudioHandler() { - this.audioCodec.Items.AddRange(mainForm.PackageSystem.AudioSettingsProviders.ValuesArray); + /*this.audioCodec.Items.AddRange(mainForm.PackageSystem.AudioSettingsProviders.ValuesArray); try { this.audioCodec.SelectedItem = mainForm.PackageSystem.AudioSettingsProviders["ND AAC"]; @@ -68,16 +63,16 @@ audioCodecHandler = new MultipleConfigurersHandler(audioCodec); audioProfileHandler = new ProfilesControlHandler("Audio", mainForm, audioProfileControl, audioCodecHandler.EditSettings, new InfoGetter(delegate { return new string[] { "input", "output" }; }), audioCodecHandler.Getter, audioCodecHandler.Setter); - audioCodecHandler.Register(audioProfileHandler); + audioCodecHandler.Register(audioProfileHandler);*/ + audioProfile.Manager = mainForm.Profiles; } #endregion #endregion - public OneClickConfigPanel(MainForm mainForm, MeGUI.core.details.video.Empty dummy) + public OneClickConfigPanel() { - this.mainForm = mainForm; InitializeComponent(); - + mainForm = MainForm.Instance; // We do this because the designer will attempt to put such a long string in the resources otherwise containerFormatLabel.Text = "Since the possible output filetypes are not known until the input is configured, the output type cannot be configured in a profile. Instead, here is a list of known file-types. You choose which you are happy with, and MeGUI will attempt to encode to one of those on the list."; @@ -95,9 +90,9 @@ get { OneClickSettings val = new OneClickSettings(); - val.AudioProfileName = audioProfileHandler.SelectedProfile; + val.AudioProfileName = audioProfile.SelectedProfile.FQName; val.AutomaticDeinterlacing = autoDeint.Checked; - val.AvsProfileName = avsProfileHandler.SelectedProfile; + val.AvsProfileName = avsProfile.SelectedProfile.FQName; val.ContainerCandidates = ContainerCandidates; val.DontEncodeAudio = dontEncodeAudio.Checked; val.Filesize = fileSize.Value; @@ -105,22 +100,22 @@ val.PrerenderVideo = preprocessVideo.Checked; val.SignalAR = signalAR.Checked; val.SplitSize = splitSize.Value; - val.VideoProfileName = videoProfileHandler.SelectedProfile; + val.VideoProfileName = videoProfile.SelectedProfile.FQName; return val; } set { - try { audioProfileHandler.SelectedProfile = value.AudioProfileName; } catch (ProfileCouldntBeSelectedException) { } + audioProfile.SetProfileNameOrWarn(value.AudioProfileName); autoDeint.Checked = value.AutomaticDeinterlacing; - try { avsProfileHandler.SelectedProfile = value.AvsProfileName; } catch (ProfileCouldntBeSelectedException) { } - ContainerCandidates = value.ContainerCandidates; + avsProfile.SetProfileNameOrWarn(value.AvsProfileName); + ContainerCandidates = value.ContainerCandidates; dontEncodeAudio.Checked = value.DontEncodeAudio; fileSize.Value = value.Filesize; horizontalResolution.Value = value.OutputResolution; preprocessVideo.Checked = value.PrerenderVideo; signalAR.Checked = value.SignalAR; splitSize.Value = value.SplitSize; - try { videoProfileHandler.SelectedProfile = value.VideoProfileName; } catch (ProfileCouldntBeSelectedException) { } + videoProfile.SetProfileNameOrWarn(value.VideoProfileName); } } @@ -128,8 +123,7 @@ private void dontEncodeAudio_CheckedChanged(object sender, EventArgs e) { - audioProfileControl.Enabled = !dontEncodeAudio.Checked; - audioCodec.Enabled = !dontEncodeAudio.Checked; + audioProfile.Enabled = !dontEncodeAudio.Checked; } private string[] ContainerCandidates Index: packages/tools/oneclick/OneClickConfigPanel.Designer.cs =================================================================== --- packages/tools/oneclick/OneClickConfigPanel.Designer.cs (revision 426) +++ packages/tools/oneclick/OneClickConfigPanel.Designer.cs (working copy) @@ -28,9 +28,13 @@ /// private void InitializeComponent() { + System.Windows.Forms.Label label3; this.otherGroupBox = new System.Windows.Forms.GroupBox(); + this.avsProfile = new MeGUI.core.gui.ConfigableProfilesControl(); + this.splitSize = new MeGUI.core.gui.TargetSizeSCBox(); + this.fileSize = new MeGUI.core.gui.TargetSizeSCBox(); this.preprocessVideo = new System.Windows.Forms.CheckBox(); - this.avsProfileControl = new MeGUI.core.details.video.ProfileControl(); + this.label2 = new System.Windows.Forms.Label(); this.filesizeLabel = new System.Windows.Forms.Label(); this.autoDeint = new System.Windows.Forms.CheckBox(); this.signalAR = new System.Windows.Forms.CheckBox(); @@ -38,21 +42,17 @@ this.outputResolutionLabel = new System.Windows.Forms.Label(); this.extraGroupbox = new System.Windows.Forms.GroupBox(); this.label1 = new System.Windows.Forms.Label(); - this.audioProfileControl = new MeGUI.core.details.video.ProfileControl(); - this.videoProfileControl = new MeGUI.core.details.video.ProfileControl(); + this.audioProfile = new MeGUI.core.gui.ConfigableProfilesControl(); + this.videoProfile = new MeGUI.core.gui.ConfigableProfilesControl(); this.audioProfileLabel = new System.Windows.Forms.Label(); this.dontEncodeAudio = new System.Windows.Forms.CheckBox(); this.videoCodecLabel = new System.Windows.Forms.Label(); - this.audioCodec = new System.Windows.Forms.ComboBox(); - this.videoCodec = new System.Windows.Forms.ComboBox(); this.containerFormatLabel = new System.Windows.Forms.Label(); this.containerTypeList = new System.Windows.Forms.CheckedListBox(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage(); - this.fileSize = new MeGUI.core.gui.TargetSizeSCBox(); - this.label2 = new System.Windows.Forms.Label(); - this.splitSize = new MeGUI.core.gui.TargetSizeSCBox(); + label3 = new System.Windows.Forms.Label(); this.otherGroupBox.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.horizontalResolution)).BeginInit(); this.extraGroupbox.SuspendLayout(); @@ -61,13 +61,23 @@ this.tabPage2.SuspendLayout(); this.SuspendLayout(); // + // label3 + // + label3.AutoSize = true; + label3.Location = new System.Drawing.Point(6, 111); + label3.Name = "label3"; + label3.Size = new System.Drawing.Size(78, 13); + label3.TabIndex = 40; + label3.Text = "Avisynth profile"; + // // otherGroupBox // + this.otherGroupBox.Controls.Add(label3); + this.otherGroupBox.Controls.Add(this.avsProfile); this.otherGroupBox.Controls.Add(this.splitSize); this.otherGroupBox.Controls.Add(this.fileSize); this.otherGroupBox.Controls.Add(this.preprocessVideo); this.otherGroupBox.Controls.Add(this.label2); - this.otherGroupBox.Controls.Add(this.avsProfileControl); this.otherGroupBox.Controls.Add(this.filesizeLabel); this.otherGroupBox.Controls.Add(this.autoDeint); this.otherGroupBox.Controls.Add(this.signalAR); @@ -81,6 +91,36 @@ this.otherGroupBox.TabStop = false; this.otherGroupBox.Text = "Filesize and Avisynth setup"; // + // avsProfile + // + this.avsProfile.Location = new System.Drawing.Point(110, 106); + this.avsProfile.Name = "avsProfile"; + this.avsProfile.ProfileSet = "AviSynth"; + this.avsProfile.Size = new System.Drawing.Size(298, 22); + this.avsProfile.TabIndex = 39; + // + // splitSize + // + this.splitSize.Location = new System.Drawing.Point(110, 45); + this.splitSize.MaximumSize = new System.Drawing.Size(1000, 29); + this.splitSize.MinimumSize = new System.Drawing.Size(64, 29); + this.splitSize.Name = "splitSize"; + this.splitSize.NullString = "Dont split"; + this.splitSize.SelectedIndex = 0; + this.splitSize.Size = new System.Drawing.Size(208, 29); + this.splitSize.TabIndex = 38; + // + // fileSize + // + this.fileSize.Location = new System.Drawing.Point(110, 19); + this.fileSize.MaximumSize = new System.Drawing.Size(1000, 29); + this.fileSize.MinimumSize = new System.Drawing.Size(64, 29); + this.fileSize.Name = "fileSize"; + this.fileSize.NullString = "Don\'t care"; + this.fileSize.SelectedIndex = 0; + this.fileSize.Size = new System.Drawing.Size(208, 29); + this.fileSize.TabIndex = 38; + // // preprocessVideo // this.preprocessVideo.AutoSize = true; @@ -91,15 +131,13 @@ this.preprocessVideo.Text = "Prerender video (for slow scripts)"; this.preprocessVideo.UseVisualStyleBackColor = true; // - // avsProfileControl + // label2 // - this.avsProfileControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.avsProfileControl.LabelText = "AVS profile"; - this.avsProfileControl.Location = new System.Drawing.Point(6, 100); - this.avsProfileControl.Name = "avsProfileControl"; - this.avsProfileControl.Size = new System.Drawing.Size(406, 29); - this.avsProfileControl.TabIndex = 36; + this.label2.Location = new System.Drawing.Point(6, 53); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(90, 13); + this.label2.TabIndex = 25; + this.label2.Text = "Splitting:"; // // filesizeLabel // @@ -166,17 +204,15 @@ // extraGroupbox // this.extraGroupbox.Controls.Add(this.label1); - this.extraGroupbox.Controls.Add(this.audioProfileControl); - this.extraGroupbox.Controls.Add(this.videoProfileControl); + this.extraGroupbox.Controls.Add(this.audioProfile); + this.extraGroupbox.Controls.Add(this.videoProfile); this.extraGroupbox.Controls.Add(this.audioProfileLabel); this.extraGroupbox.Controls.Add(this.dontEncodeAudio); this.extraGroupbox.Controls.Add(this.videoCodecLabel); - this.extraGroupbox.Controls.Add(this.audioCodec); - this.extraGroupbox.Controls.Add(this.videoCodec); this.extraGroupbox.Dock = System.Windows.Forms.DockStyle.Bottom; - this.extraGroupbox.Location = new System.Drawing.Point(3, 175); + this.extraGroupbox.Location = new System.Drawing.Point(3, 172); this.extraGroupbox.Name = "extraGroupbox"; - this.extraGroupbox.Size = new System.Drawing.Size(419, 176); + this.extraGroupbox.Size = new System.Drawing.Size(419, 155); this.extraGroupbox.TabIndex = 39; this.extraGroupbox.TabStop = false; this.extraGroupbox.Text = "Encoding Setup"; @@ -185,36 +221,32 @@ // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.label1.Location = new System.Drawing.Point(16, 135); + this.label1.Location = new System.Drawing.Point(16, 110); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(396, 31); this.label1.TabIndex = 29; this.label1.Text = "Note: unless changed in the One Click Window, these audio settings will be used f" + "or all selected tracks."; // - // audioProfileControl + // audioProfile // - this.audioProfileControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.audioProfileControl.LabelText = "Audio Profile"; - this.audioProfileControl.Location = new System.Drawing.Point(19, 103); - this.audioProfileControl.Name = "audioProfileControl"; - this.audioProfileControl.Size = new System.Drawing.Size(393, 29); - this.audioProfileControl.TabIndex = 28; + this.audioProfile.Location = new System.Drawing.Point(123, 47); + this.audioProfile.Name = "audioProfile"; + this.audioProfile.ProfileSet = "Audio"; + this.audioProfile.Size = new System.Drawing.Size(285, 22); + this.audioProfile.TabIndex = 39; // - // videoProfileControl + // videoProfile // - this.videoProfileControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.videoProfileControl.LabelText = "Video Profile"; - this.videoProfileControl.Location = new System.Drawing.Point(19, 41); - this.videoProfileControl.Name = "videoProfileControl"; - this.videoProfileControl.Size = new System.Drawing.Size(393, 29); - this.videoProfileControl.TabIndex = 28; + this.videoProfile.Location = new System.Drawing.Point(123, 19); + this.videoProfile.Name = "videoProfile"; + this.videoProfile.ProfileSet = "Video"; + this.videoProfile.Size = new System.Drawing.Size(285, 22); + this.videoProfile.TabIndex = 39; // // audioProfileLabel // - this.audioProfileLabel.Location = new System.Drawing.Point(16, 79); + this.audioProfileLabel.Location = new System.Drawing.Point(16, 52); this.audioProfileLabel.Name = "audioProfileLabel"; this.audioProfileLabel.Size = new System.Drawing.Size(100, 13); this.audioProfileLabel.TabIndex = 27; @@ -223,7 +255,7 @@ // dontEncodeAudio // this.dontEncodeAudio.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.dontEncodeAudio.Location = new System.Drawing.Point(227, 76); + this.dontEncodeAudio.Location = new System.Drawing.Point(44, 75); this.dontEncodeAudio.Name = "dontEncodeAudio"; this.dontEncodeAudio.Size = new System.Drawing.Size(130, 21); this.dontEncodeAudio.TabIndex = 25; @@ -236,30 +268,8 @@ this.videoCodecLabel.Name = "videoCodecLabel"; this.videoCodecLabel.Size = new System.Drawing.Size(90, 13); this.videoCodecLabel.TabIndex = 17; - this.videoCodecLabel.Text = "Video Codec"; + this.videoCodecLabel.Text = "Video Profile"; // - // audioCodec - // - this.audioCodec.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.audioCodec.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.audioCodec.Enabled = false; - this.audioCodec.Location = new System.Drawing.Point(123, 76); - this.audioCodec.Name = "audioCodec"; - this.audioCodec.Size = new System.Drawing.Size(98, 21); - this.audioCodec.TabIndex = 0; - // - // videoCodec - // - this.videoCodec.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.videoCodec.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.videoCodec.Enabled = false; - this.videoCodec.Location = new System.Drawing.Point(123, 16); - this.videoCodec.Name = "videoCodec"; - this.videoCodec.Size = new System.Drawing.Size(98, 21); - this.videoCodec.TabIndex = 0; - // // containerFormatLabel // this.containerFormatLabel.Dock = System.Windows.Forms.DockStyle.Top; @@ -274,7 +284,7 @@ this.containerTypeList.Dock = System.Windows.Forms.DockStyle.Fill; this.containerTypeList.Location = new System.Drawing.Point(3, 59); this.containerTypeList.Name = "containerTypeList"; - this.containerTypeList.Size = new System.Drawing.Size(419, 274); + this.containerTypeList.Size = new System.Drawing.Size(419, 259); this.containerTypeList.TabIndex = 0; // // tabControl1 @@ -285,7 +295,7 @@ this.tabControl1.Location = new System.Drawing.Point(0, 0); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(433, 380); + this.tabControl1.Size = new System.Drawing.Size(433, 356); this.tabControl1.TabIndex = 39; // // tabPage1 @@ -295,7 +305,7 @@ this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(425, 354); + this.tabPage1.Size = new System.Drawing.Size(425, 330); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Encoding Setup"; this.tabPage1.UseVisualStyleBackColor = true; @@ -307,48 +317,18 @@ this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(425, 346); + this.tabPage2.Size = new System.Drawing.Size(425, 330); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "Container type"; this.tabPage2.UseVisualStyleBackColor = true; // - // fileSize - // - this.fileSize.Location = new System.Drawing.Point(110, 19); - this.fileSize.MaximumSize = new System.Drawing.Size(1000, 29); - this.fileSize.MinimumSize = new System.Drawing.Size(64, 29); - this.fileSize.Name = "fileSize"; - this.fileSize.NullString = "Don\'t care"; - this.fileSize.SelectedIndex = 0; - this.fileSize.Size = new System.Drawing.Size(208, 29); - this.fileSize.TabIndex = 38; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(6, 53); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(90, 13); - this.label2.TabIndex = 25; - this.label2.Text = "Splitting:"; - // - // splitSize - // - this.splitSize.Location = new System.Drawing.Point(110, 45); - this.splitSize.MaximumSize = new System.Drawing.Size(1000, 29); - this.splitSize.MinimumSize = new System.Drawing.Size(64, 29); - this.splitSize.Name = "splitSize"; - this.splitSize.NullString = "Dont split"; - this.splitSize.SelectedIndex = 0; - this.splitSize.Size = new System.Drawing.Size(208, 29); - this.splitSize.TabIndex = 38; - // // OneClickConfigPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.tabControl1); this.Name = "OneClickConfigPanel"; - this.Size = new System.Drawing.Size(433, 380); + this.Size = new System.Drawing.Size(433, 356); this.otherGroupBox.ResumeLayout(false); this.otherGroupBox.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.horizontalResolution)).EndInit(); @@ -363,7 +343,6 @@ #endregion private System.Windows.Forms.GroupBox otherGroupBox; - private MeGUI.core.details.video.ProfileControl avsProfileControl; private System.Windows.Forms.Label filesizeLabel; private System.Windows.Forms.CheckBox autoDeint; private System.Windows.Forms.CheckBox signalAR; @@ -373,11 +352,7 @@ private System.Windows.Forms.Label audioProfileLabel; private System.Windows.Forms.CheckBox dontEncodeAudio; private System.Windows.Forms.Label videoCodecLabel; - private System.Windows.Forms.ComboBox videoCodec; private System.Windows.Forms.Label containerFormatLabel; - private MeGUI.core.details.video.ProfileControl audioProfileControl; - private MeGUI.core.details.video.ProfileControl videoProfileControl; - private System.Windows.Forms.ComboBox audioCodec; private System.Windows.Forms.CheckBox preprocessVideo; private System.Windows.Forms.Label label1; private System.Windows.Forms.CheckedListBox containerTypeList; @@ -387,5 +362,8 @@ private MeGUI.core.gui.TargetSizeSCBox splitSize; private MeGUI.core.gui.TargetSizeSCBox fileSize; private System.Windows.Forms.Label label2; + private MeGUI.core.gui.ConfigableProfilesControl avsProfile; + private MeGUI.core.gui.ConfigableProfilesControl audioProfile; + private MeGUI.core.gui.ConfigableProfilesControl videoProfile; } } Index: packages/tools/oneclick/OneClickConfigPanel.resx =================================================================== --- packages/tools/oneclick/OneClickConfigPanel.resx (revision 426) +++ packages/tools/oneclick/OneClickConfigPanel.resx (working copy) @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - \ No newline at end of file + + False + + Index: packages/tools/oneclick/OneClickSettings.cs =================================================================== --- packages/tools/oneclick/OneClickSettings.cs (revision 426) +++ packages/tools/oneclick/OneClickSettings.cs (working copy) @@ -9,6 +9,8 @@ /// public class OneClickSettings : GenericSettings { + public string SettingsID { get { return "OneClick"; } } + public virtual void FixFileNames(Dictionary _) { } public override bool Equals(object obj) { @@ -20,11 +22,6 @@ return base.GetHashCode(); } - public string getSettingsType() - { - return "OneClick"; - } - private string videoProfileName; public string VideoProfileName { Index: packages/tools/oneclick/OneClickWindow.cs =================================================================== --- packages/tools/oneclick/OneClickWindow.cs (revision 426) +++ packages/tools/oneclick/OneClickWindow.cs (working copy) @@ -29,16 +29,19 @@ List audioConfigControl; #region profiles - void ProfileChanged(object sender, Profile prof) + void ProfileChanged(object sender, EventArgs e) { updatePossibleContainers(); } #region OneClick profiles - ISettingsProvider oneClickSettingsProvider = new SettingsProviderImpl2< - MeGUI.packages.tools.oneclick.OneClickConfigPanel, Empty, OneClickSettings, OneClickSettings, int, int>("OneClick", 0, 0); private void initOneClickHandler() { + oneclickProfile.Manager = mainForm.Profiles; + } + + private void initTabs() + { audioTrack = new List(); audioTrack.Add(audioTrack1); audioTrack.Add(audioTrack2); @@ -50,82 +53,18 @@ audioConfigControl = new List(); audioConfigControl.Add(audio1); audioConfigControl.Add(audio2); - - // Init oneclick handlers - ProfilesControlHandler profileHandler = new ProfilesControlHandler( - "OneClick", mainForm, profileControl2, oneClickSettingsProvider.EditSettings, Empty.Getter, - new SettingsGetter(oneClickSettingsProvider.GetCurrentSettings), new SettingsSetter(oneClickSettingsProvider.LoadSettings)); - SingleConfigurerHandler configurerHandler = new SingleConfigurerHandler(profileHandler, oneClickSettingsProvider); - profileHandler.ProfileChanged += new SelectedProfileChangedEvent(OneClickProfileChanged); - profileHandler.ConfigureCompleted += new EventHandler(profileHandler_ConfigureCompleted); - profileHandler.RefreshProfiles(); - - } - private void refreshAssistingProfiles() + void OneClickProfileChanged(object sender, EventArgs e) { - videoProfileHandler.RefreshProfiles(); - audio1.RefreshProfiles(); - audio2.RefreshProfiles(); - avsProfileHandler.RefreshProfiles(); - } - - void profileHandler_ConfigureCompleted(object sender, EventArgs e) - { - refreshAssistingProfiles(); - } - - void OneClickProfileChanged(object sender, Profile prof) - { - if (prof != null) - { - this.Settings = ((OneClickSettings)prof.BaseSettings); - } + this.Settings = (OneClickSettings)oneclickProfile.SelectedProfile.BaseSettings; } #endregion - #region AVS profiles - ISettingsProvider avsSettingsProvider = new SettingsProviderImpl2< - MeGUI.core.gui.AviSynthProfileConfigPanel, MeGUI.core.details.video.Empty, AviSynthSettings, AviSynthSettings, int, int>("AviSynth", 0, 0); - ProfilesControlHandler avsProfileHandler; - private void initAvsHandler() - { - // Init AVS handlers - avsProfileHandler = new ProfilesControlHandler( - "AviSynth", mainForm, profileControl1, avsSettingsProvider.EditSettings, Empty.Getter, - new SettingsGetter(avsSettingsProvider.GetCurrentSettings), new SettingsSetter(avsSettingsProvider.LoadSettings)); - SingleConfigurerHandler configurerHandler = new SingleConfigurerHandler(avsProfileHandler, avsSettingsProvider); - } - #endregion #region Video profiles private VideoCodecSettings VideoSettings { - get { return VideoSettingsProvider.GetCurrentSettings(); } + get { return (VideoCodecSettings)videoProfile.SelectedProfile.BaseSettings; } } - private ISettingsProvider VideoSettingsProvider - { - get { return videoCodecHandler.CurrentSettingsProvider; } - } - MultipleConfigurersHandler videoCodecHandler; - ProfilesControlHandler videoProfileHandler; - private void initVideoHandler() - { - this.videoCodec.Items.AddRange(mainForm.PackageSystem.VideoSettingsProviders.ValuesArray); - try - { - this.videoCodec.SelectedItem = mainForm.PackageSystem.VideoSettingsProviders["x264"]; - } - catch (Exception) { } - // Init Video handlers - videoCodecHandler = - new MultipleConfigurersHandler(videoCodec); - videoProfileHandler = - new ProfilesControlHandler("Video", mainForm, videoProfileControl, - videoCodecHandler.EditSettings, new InfoGetter(delegate() { return new VideoInfo(); }), - videoCodecHandler.Getter, videoCodecHandler.Setter); - videoCodecHandler.Register(videoProfileHandler); - videoProfileHandler.ProfileChanged += new SelectedProfileChangedEvent(ProfileChanged); - } #endregion #region Audio profiles private void initAudioHandler() @@ -168,9 +107,11 @@ InitializeComponent(); - initVideoHandler(); + initTabs(); + + videoProfile.Manager = mainForm.Profiles; initAudioHandler(); - initAvsHandler(); + avsProfile.Manager = mainForm.Profiles; initOneClickHandler(); audioTrack1.StandardItems = audioTrack2.StandardItems = new object[] { "None" }; @@ -332,7 +273,7 @@ } List tempSupportedOutputTypes = this.muxProvider.GetSupportedContainers( - VideoSettingsProvider.EncoderType, audioCodecs.ToArray(), dictatedOutputTypes.ToArray()); + VideoSettings.EncoderType, audioCodecs.ToArray(), dictatedOutputTypes.ToArray()); List supportedOutputTypes = new List(); @@ -376,30 +317,11 @@ { OneClickSettings settings = value; - refreshAssistingProfiles(); + foreach (AudioConfigControl a in audioConfigControl) + a.SelectProfileNameOrWarn(settings.AudioProfileName); - // Do extra defaults config (same code as in OneClickDefaultWindow) - // strings - try - { - foreach (AudioConfigControl a in audioConfigControl) - a.SelectedProfile = settings.AudioProfileName; - } - catch (ProfileCouldntBeSelectedException e) - { - MessageBox.Show("The audio profile '" + e.ProfileName + "' could not be properly configured. Presumably the profile no longer exists.", "Some options misconfigured", MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - - try { videoProfileHandler.SelectedProfile = settings.VideoProfileName; } - catch (ProfileCouldntBeSelectedException e) - { - MessageBox.Show("The video profile '" + e.ProfileName + "' could not be properly configured. Presumably the profile no longer exists.", "Some options misconfigured", MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - try { avsProfileHandler.SelectedProfile = settings.AvsProfileName; } - catch (ProfileCouldntBeSelectedException e) - { - MessageBox.Show("The Avisynth profile '" + e.ProfileName + "' could not be properly configured. Presumably the profile no longer exists.", "Some options misconfigured", MessageBoxButtons.OK, MessageBoxIcon.Warning); - } + videoProfile.SetProfileNameOrWarn(settings.VideoProfileName); + avsProfile.SetProfileNameOrWarn(settings.AvsProfileName); List temp = new List(); List allContainerTypes = muxProvider.GetSupportedContainers(); @@ -433,13 +355,12 @@ } } + //private VideoCodecSettings VideoSettings { get { throw new Exception(); } } - private void goButton_Click(object sender, EventArgs e) { if ((verifyAudioSettings() == null) && (VideoSettings != null) - && (avsSettingsProvider.GetCurrentSettings() != null) && !string.IsNullOrEmpty(input.Filename) && !string.IsNullOrEmpty(workingName.Text)) { @@ -476,7 +397,7 @@ dpp.DirectMuxAudio = muxOnlyAudio.ToArray(); dpp.AudioJobs = aJobs.ToArray(); dpp.AutoDeinterlace = autoDeint.Checked; - dpp.AvsSettings = avsSettingsProvider.GetCurrentSettings(); + dpp.AvsSettings = (AviSynthSettings)avsProfile.SelectedProfile.BaseSettings; dpp.ChapterFile = chapterFile.Filename; dpp.Container = (ContainerType)containerFormat.SelectedItem; dpp.FinalOutput = output.Filename; @@ -617,6 +538,7 @@ { RemoveTrack(); } + } public class OneClickTool : MeGUI.core.plugins.interfaces.ITool { Index: packages/tools/oneclick/OneClickWindow.Designer.cs =================================================================== --- packages/tools/oneclick/OneClickWindow.Designer.cs (revision 426) +++ packages/tools/oneclick/OneClickWindow.Designer.cs (working copy) @@ -35,7 +35,15 @@ this.trackTabPage1 = new System.Windows.Forms.TabPage(); this.audio1 = new MeGUI.packages.tools.oneclick.AudioConfigControl(); this.tabPage2 = new System.Windows.Forms.TabPage(); - this.splitting = new MeGUI.core.gui.TargetSizeSCBox(); + this.avsBox = new System.Windows.Forms.GroupBox(); + this.avsProfile = new MeGUI.core.gui.ConfigableProfilesControl(); + this.ar = new MeGUI.core.gui.ARChooser(); + this.autoDeint = new System.Windows.Forms.CheckBox(); + this.signalAR = new System.Windows.Forms.CheckBox(); + this.outputResolutionLabel = new System.Windows.Forms.Label(); + this.horizontalResolution = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.ARLabel = new System.Windows.Forms.Label(); this.locationGroupBox = new System.Windows.Forms.GroupBox(); this.chapterFile = new MeGUI.FileBar(); this.workingDirectory = new MeGUI.FileBar(); @@ -43,14 +51,7 @@ this.workingDirectoryLabel = new System.Windows.Forms.Label(); this.workingName = new System.Windows.Forms.TextBox(); this.projectNameLabel = new System.Windows.Forms.Label(); - this.avsBox = new System.Windows.Forms.GroupBox(); - this.ar = new MeGUI.core.gui.ARChooser(); - this.profileControl1 = new MeGUI.core.details.video.ProfileControl(); - this.autoDeint = new System.Windows.Forms.CheckBox(); - this.signalAR = new System.Windows.Forms.CheckBox(); - this.outputResolutionLabel = new System.Windows.Forms.Label(); - this.horizontalResolution = new System.Windows.Forms.NumericUpDown(); - this.ARLabel = new System.Windows.Forms.Label(); + this.splitting = new MeGUI.core.gui.TargetSizeSCBox(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.IOGroupbox = new System.Windows.Forms.GroupBox(); this.output = new MeGUI.FileBar(); @@ -58,8 +59,9 @@ this.outputLabel = new System.Windows.Forms.Label(); this.inputLabel = new System.Windows.Forms.Label(); this.targetGroupBox = new System.Windows.Forms.GroupBox(); + this.oneclickProfile = new MeGUI.core.gui.ConfigableProfilesControl(); this.optionalTargetSizeBox1 = new MeGUI.core.gui.TargetSizeSCBox(); - this.profileControl2 = new MeGUI.core.details.video.ProfileControl(); + this.label3 = new System.Windows.Forms.Label(); this.filesizeLabel = new System.Windows.Forms.Label(); this.audioGroupbox = new System.Windows.Forms.GroupBox(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); @@ -77,10 +79,9 @@ this.groupBox1 = new System.Windows.Forms.GroupBox(); this.tabControl2 = new System.Windows.Forms.TabControl(); this.videoGroupBox = new System.Windows.Forms.GroupBox(); - this.videoProfileControl = new MeGUI.core.details.video.ProfileControl(); + this.label4 = new System.Windows.Forms.Label(); + this.videoProfile = new MeGUI.core.gui.ConfigableProfilesControl(); this.addPrerenderJob = new System.Windows.Forms.CheckBox(); - this.videoCodecLabel = new System.Windows.Forms.Label(); - this.videoCodec = new System.Windows.Forms.ComboBox(); this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); this.showAdvancedOptions = new System.Windows.Forms.CheckBox(); this.goButton = new System.Windows.Forms.Button(); @@ -90,9 +91,9 @@ trackTabPage2.SuspendLayout(); this.trackTabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); - this.locationGroupBox.SuspendLayout(); this.avsBox.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.horizontalResolution)).BeginInit(); + this.locationGroupBox.SuspendLayout(); this.tabPage1.SuspendLayout(); this.IOGroupbox.SuspendLayout(); this.targetGroupBox.SuspendLayout(); @@ -112,7 +113,7 @@ trackTabPage2.Location = new System.Drawing.Point(4, 22); trackTabPage2.Name = "trackTabPage2"; trackTabPage2.Padding = new System.Windows.Forms.Padding(3); - trackTabPage2.Size = new System.Drawing.Size(423, 94); + trackTabPage2.Size = new System.Drawing.Size(172, 94); trackTabPage2.TabIndex = 1; trackTabPage2.Text = "Audio track 2"; trackTabPage2.UseVisualStyleBackColor = true; @@ -122,14 +123,14 @@ this.audio2.Dock = System.Windows.Forms.DockStyle.Fill; this.audio2.Location = new System.Drawing.Point(3, 3); this.audio2.Name = "audio2"; - this.audio2.Size = new System.Drawing.Size(417, 88); + this.audio2.Size = new System.Drawing.Size(166, 88); this.audio2.TabIndex = 0; this.audio2.SomethingChanged += new System.EventHandler(this.audio1_SomethingChanged); // // label1 // label1.AutoSize = true; - label1.Location = new System.Drawing.Point(24, 245); + label1.Location = new System.Drawing.Point(24, 236); label1.Name = "label1"; label1.Size = new System.Drawing.Size(47, 13); label1.TabIndex = 37; @@ -141,7 +142,7 @@ this.trackTabPage1.Location = new System.Drawing.Point(4, 22); this.trackTabPage1.Name = "trackTabPage1"; this.trackTabPage1.Padding = new System.Windows.Forms.Padding(3); - this.trackTabPage1.Size = new System.Drawing.Size(423, 94); + this.trackTabPage1.Size = new System.Drawing.Size(433, 94); this.trackTabPage1.TabIndex = 0; this.trackTabPage1.Text = "Audio track 1"; this.trackTabPage1.UseVisualStyleBackColor = true; @@ -151,16 +152,16 @@ this.audio1.Dock = System.Windows.Forms.DockStyle.Fill; this.audio1.Location = new System.Drawing.Point(3, 3); this.audio1.Name = "audio1"; - this.audio1.Size = new System.Drawing.Size(417, 88); + this.audio1.Size = new System.Drawing.Size(427, 88); this.audio1.TabIndex = 0; this.audio1.SomethingChanged += new System.EventHandler(this.audio1_SomethingChanged); // // tabPage2 // + this.tabPage2.Controls.Add(this.avsBox); this.tabPage2.Controls.Add(label1); + this.tabPage2.Controls.Add(this.locationGroupBox); this.tabPage2.Controls.Add(this.splitting); - this.tabPage2.Controls.Add(this.locationGroupBox); - this.tabPage2.Controls.Add(this.avsBox); this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); @@ -169,142 +170,46 @@ this.tabPage2.Text = "Advanced Config"; this.tabPage2.UseVisualStyleBackColor = true; // - // splitting - // - this.splitting.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.splitting.Location = new System.Drawing.Point(128, 237); - this.splitting.MaximumSize = new System.Drawing.Size(1000, 29); - this.splitting.MinimumSize = new System.Drawing.Size(64, 29); - this.splitting.Name = "splitting"; - this.splitting.NullString = "No splitting"; - this.splitting.SelectedIndex = 0; - this.splitting.Size = new System.Drawing.Size(221, 29); - this.splitting.TabIndex = 38; - // - // locationGroupBox - // - this.locationGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.locationGroupBox.Controls.Add(this.chapterFile); - this.locationGroupBox.Controls.Add(this.workingDirectory); - this.locationGroupBox.Controls.Add(this.chapterLabel); - this.locationGroupBox.Controls.Add(this.workingDirectoryLabel); - this.locationGroupBox.Controls.Add(this.workingName); - this.locationGroupBox.Controls.Add(this.projectNameLabel); - this.locationGroupBox.Location = new System.Drawing.Point(8, 6); - this.locationGroupBox.Name = "locationGroupBox"; - this.locationGroupBox.Size = new System.Drawing.Size(437, 95); - this.locationGroupBox.TabIndex = 23; - this.locationGroupBox.TabStop = false; - this.locationGroupBox.Text = "Extra IO"; - // - // chapterFile - // - this.chapterFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.chapterFile.Filename = ""; - this.chapterFile.Filter = "Chapter files (*.txt)|*.txt"; - this.chapterFile.FolderMode = false; - this.chapterFile.Location = new System.Drawing.Point(120, 38); - this.chapterFile.Name = "chapterFile"; - this.chapterFile.ReadOnly = true; - this.chapterFile.SaveMode = false; - this.chapterFile.Size = new System.Drawing.Size(301, 26); - this.chapterFile.TabIndex = 39; - this.chapterFile.Title = null; - // - // workingDirectory - // - this.workingDirectory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.workingDirectory.Filename = ""; - this.workingDirectory.Filter = null; - this.workingDirectory.FolderMode = true; - this.workingDirectory.Location = new System.Drawing.Point(120, 8); - this.workingDirectory.Name = "workingDirectory"; - this.workingDirectory.ReadOnly = true; - this.workingDirectory.SaveMode = false; - this.workingDirectory.Size = new System.Drawing.Size(301, 26); - this.workingDirectory.TabIndex = 38; - this.workingDirectory.Title = null; - this.workingDirectory.FileSelected += new MeGUI.FileBarEventHandler(this.workingDirectory_FileSelected); - // - // chapterLabel - // - this.chapterLabel.Location = new System.Drawing.Point(16, 41); - this.chapterLabel.Name = "chapterLabel"; - this.chapterLabel.Size = new System.Drawing.Size(100, 13); - this.chapterLabel.TabIndex = 36; - this.chapterLabel.Text = "Chapter file"; - // - // workingDirectoryLabel - // - this.workingDirectoryLabel.Location = new System.Drawing.Point(16, 15); - this.workingDirectoryLabel.Name = "workingDirectoryLabel"; - this.workingDirectoryLabel.Size = new System.Drawing.Size(100, 13); - this.workingDirectoryLabel.TabIndex = 32; - this.workingDirectoryLabel.Text = "Working Directory"; - // - // workingName - // - this.workingName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.workingName.Location = new System.Drawing.Point(120, 64); - this.workingName.Name = "workingName"; - this.workingName.Size = new System.Drawing.Size(301, 20); - this.workingName.TabIndex = 30; - this.workingName.TextChanged += new System.EventHandler(this.workingName_TextChanged); - // - // projectNameLabel - // - this.projectNameLabel.Location = new System.Drawing.Point(16, 67); - this.projectNameLabel.Name = "projectNameLabel"; - this.projectNameLabel.Size = new System.Drawing.Size(73, 16); - this.projectNameLabel.TabIndex = 31; - this.projectNameLabel.Text = "Project Name"; - // // avsBox // - this.avsBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.avsBox.Controls.Add(this.avsProfile); this.avsBox.Controls.Add(this.ar); - this.avsBox.Controls.Add(this.profileControl1); this.avsBox.Controls.Add(this.autoDeint); this.avsBox.Controls.Add(this.signalAR); this.avsBox.Controls.Add(this.outputResolutionLabel); this.avsBox.Controls.Add(this.horizontalResolution); + this.avsBox.Controls.Add(this.label2); this.avsBox.Controls.Add(this.ARLabel); - this.avsBox.Location = new System.Drawing.Point(8, 107); + this.avsBox.Dock = System.Windows.Forms.DockStyle.Top; + this.avsBox.Location = new System.Drawing.Point(3, 98); this.avsBox.Name = "avsBox"; - this.avsBox.Size = new System.Drawing.Size(437, 124); + this.avsBox.Size = new System.Drawing.Size(447, 124); this.avsBox.TabIndex = 23; this.avsBox.TabStop = false; this.avsBox.Text = "AviSynth setup"; // + // avsProfile + // + this.avsProfile.Location = new System.Drawing.Point(123, 73); + this.avsProfile.Name = "avsProfile"; + this.avsProfile.ProfileSet = "AviSynth"; + this.avsProfile.Size = new System.Drawing.Size(319, 22); + this.avsProfile.TabIndex = 23; + // // ar // this.ar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.ar.CustomDARs = new MeGUI.core.util.Dar[0]; this.ar.HasLater = true; this.ar.Location = new System.Drawing.Point(120, 42); this.ar.MaximumSize = new System.Drawing.Size(1000, 29); this.ar.MinimumSize = new System.Drawing.Size(64, 29); this.ar.Name = "ar"; this.ar.SelectedIndex = 0; - this.ar.Size = new System.Drawing.Size(213, 29); + this.ar.Size = new System.Drawing.Size(325, 29); this.ar.TabIndex = 22; // - // profileControl1 - // - this.profileControl1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.profileControl1.LabelText = "AVS profile"; - this.profileControl1.Location = new System.Drawing.Point(19, 69); - this.profileControl1.Name = "profileControl1"; - this.profileControl1.Size = new System.Drawing.Size(402, 29); - this.profileControl1.TabIndex = 21; - // // autoDeint // this.autoDeint.AutoSize = true; @@ -318,7 +223,7 @@ // signalAR // this.signalAR.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.signalAR.Location = new System.Drawing.Point(339, 43); + this.signalAR.Location = new System.Drawing.Point(349, 43); this.signalAR.Name = "signalAR"; this.signalAR.Size = new System.Drawing.Size(82, 24); this.signalAR.TabIndex = 5; @@ -359,6 +264,15 @@ 0, 0}); // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(15, 78); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(78, 13); + this.label2.TabIndex = 4; + this.label2.Text = "Avisynth profile"; + // // ARLabel // this.ARLabel.Location = new System.Drawing.Point(16, 48); @@ -367,6 +281,101 @@ this.ARLabel.TabIndex = 4; this.ARLabel.Text = "AR:"; // + // locationGroupBox + // + this.locationGroupBox.Controls.Add(this.chapterFile); + this.locationGroupBox.Controls.Add(this.workingDirectory); + this.locationGroupBox.Controls.Add(this.chapterLabel); + this.locationGroupBox.Controls.Add(this.workingDirectoryLabel); + this.locationGroupBox.Controls.Add(this.workingName); + this.locationGroupBox.Controls.Add(this.projectNameLabel); + this.locationGroupBox.Dock = System.Windows.Forms.DockStyle.Top; + this.locationGroupBox.Location = new System.Drawing.Point(3, 3); + this.locationGroupBox.Name = "locationGroupBox"; + this.locationGroupBox.Size = new System.Drawing.Size(447, 95); + this.locationGroupBox.TabIndex = 23; + this.locationGroupBox.TabStop = false; + this.locationGroupBox.Text = "Extra IO"; + // + // chapterFile + // + this.chapterFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.chapterFile.Filename = ""; + this.chapterFile.Filter = "Chapter files (*.txt)|*.txt"; + this.chapterFile.FolderMode = false; + this.chapterFile.Location = new System.Drawing.Point(120, 38); + this.chapterFile.Name = "chapterFile"; + this.chapterFile.ReadOnly = true; + this.chapterFile.SaveMode = false; + this.chapterFile.Size = new System.Drawing.Size(321, 26); + this.chapterFile.TabIndex = 39; + this.chapterFile.Title = null; + // + // workingDirectory + // + this.workingDirectory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.workingDirectory.Filename = ""; + this.workingDirectory.Filter = null; + this.workingDirectory.FolderMode = true; + this.workingDirectory.Location = new System.Drawing.Point(120, 15); + this.workingDirectory.Name = "workingDirectory"; + this.workingDirectory.ReadOnly = true; + this.workingDirectory.SaveMode = false; + this.workingDirectory.Size = new System.Drawing.Size(321, 26); + this.workingDirectory.TabIndex = 38; + this.workingDirectory.Title = null; + this.workingDirectory.FileSelected += new MeGUI.FileBarEventHandler(this.workingDirectory_FileSelected); + // + // chapterLabel + // + this.chapterLabel.Location = new System.Drawing.Point(16, 41); + this.chapterLabel.Name = "chapterLabel"; + this.chapterLabel.Size = new System.Drawing.Size(100, 13); + this.chapterLabel.TabIndex = 36; + this.chapterLabel.Text = "Chapter file"; + // + // workingDirectoryLabel + // + this.workingDirectoryLabel.Location = new System.Drawing.Point(16, 15); + this.workingDirectoryLabel.Name = "workingDirectoryLabel"; + this.workingDirectoryLabel.Size = new System.Drawing.Size(100, 13); + this.workingDirectoryLabel.TabIndex = 32; + this.workingDirectoryLabel.Text = "Working Directory"; + // + // workingName + // + this.workingName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.workingName.Location = new System.Drawing.Point(120, 64); + this.workingName.Name = "workingName"; + this.workingName.Size = new System.Drawing.Size(324, 20); + this.workingName.TabIndex = 30; + this.workingName.TextChanged += new System.EventHandler(this.workingName_TextChanged); + // + // projectNameLabel + // + this.projectNameLabel.Location = new System.Drawing.Point(16, 67); + this.projectNameLabel.Name = "projectNameLabel"; + this.projectNameLabel.Size = new System.Drawing.Size(73, 16); + this.projectNameLabel.TabIndex = 31; + this.projectNameLabel.Text = "Project Name"; + // + // splitting + // + this.splitting.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.splitting.CustomSizes = new MeGUI.core.util.FileSize[0]; + this.splitting.Location = new System.Drawing.Point(123, 228); + this.splitting.MaximumSize = new System.Drawing.Size(1000, 29); + this.splitting.MinimumSize = new System.Drawing.Size(64, 29); + this.splitting.Name = "splitting"; + this.splitting.NullString = "No splitting"; + this.splitting.SelectedIndex = 0; + this.splitting.Size = new System.Drawing.Size(162, 29); + this.splitting.TabIndex = 38; + // // tabPage1 // this.tabPage1.Controls.Add(this.IOGroupbox); @@ -450,8 +459,9 @@ // this.targetGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.targetGroupBox.Controls.Add(this.oneclickProfile); this.targetGroupBox.Controls.Add(this.optionalTargetSizeBox1); - this.targetGroupBox.Controls.Add(this.profileControl2); + this.targetGroupBox.Controls.Add(this.label3); this.targetGroupBox.Controls.Add(this.filesizeLabel); this.targetGroupBox.Location = new System.Drawing.Point(8, 184); this.targetGroupBox.Name = "targetGroupBox"; @@ -461,10 +471,20 @@ this.targetGroupBox.Text = "Target"; this.targetGroupBox.Enter += new System.EventHandler(this.targetGroupBox_Enter); // + // oneclickProfile + // + this.oneclickProfile.Location = new System.Drawing.Point(123, 19); + this.oneclickProfile.Name = "oneclickProfile"; + this.oneclickProfile.ProfileSet = "OneClick"; + this.oneclickProfile.Size = new System.Drawing.Size(298, 22); + this.oneclickProfile.TabIndex = 25; + this.oneclickProfile.SelectedProfileChanged += new System.EventHandler(this.OneClickProfileChanged); + // // optionalTargetSizeBox1 // this.optionalTargetSizeBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.optionalTargetSizeBox1.CustomSizes = new MeGUI.core.util.FileSize[0]; this.optionalTargetSizeBox1.Location = new System.Drawing.Point(125, 43); this.optionalTargetSizeBox1.MaximumSize = new System.Drawing.Size(1000, 29); this.optionalTargetSizeBox1.MinimumSize = new System.Drawing.Size(64, 29); @@ -474,15 +494,14 @@ this.optionalTargetSizeBox1.Size = new System.Drawing.Size(298, 29); this.optionalTargetSizeBox1.TabIndex = 24; // - // profileControl2 + // label3 // - this.profileControl2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.profileControl2.LabelText = "One Click profile"; - this.profileControl2.Location = new System.Drawing.Point(21, 12); - this.profileControl2.Name = "profileControl2"; - this.profileControl2.Size = new System.Drawing.Size(402, 29); - this.profileControl2.TabIndex = 23; + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(16, 24); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(81, 13); + this.label3.TabIndex = 21; + this.label3.Text = "OneClick profile"; // // filesizeLabel // @@ -512,20 +531,20 @@ this.addTrackToolStripMenuItem, this.removeTrackToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(147, 48); + this.contextMenuStrip1.Size = new System.Drawing.Size(141, 48); this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); // // addTrackToolStripMenuItem // this.addTrackToolStripMenuItem.Name = "addTrackToolStripMenuItem"; - this.addTrackToolStripMenuItem.Size = new System.Drawing.Size(146, 22); + this.addTrackToolStripMenuItem.Size = new System.Drawing.Size(140, 22); this.addTrackToolStripMenuItem.Text = "Add track"; this.addTrackToolStripMenuItem.Click += new System.EventHandler(this.addTrackToolStripMenuItem_Click); // // removeTrackToolStripMenuItem // this.removeTrackToolStripMenuItem.Name = "removeTrackToolStripMenuItem"; - this.removeTrackToolStripMenuItem.Size = new System.Drawing.Size(146, 22); + this.removeTrackToolStripMenuItem.Size = new System.Drawing.Size(140, 22); this.removeTrackToolStripMenuItem.Text = "Remove track"; this.removeTrackToolStripMenuItem.Click += new System.EventHandler(this.removeTrackToolStripMenuItem_Click); // @@ -618,9 +637,10 @@ // // containerFormatLabel // + this.containerFormatLabel.AutoSize = true; this.containerFormatLabel.Location = new System.Drawing.Point(15, 242); this.containerFormatLabel.Name = "containerFormatLabel"; - this.containerFormatLabel.Size = new System.Drawing.Size(92, 13); + this.containerFormatLabel.Size = new System.Drawing.Size(87, 13); this.containerFormatLabel.TabIndex = 38; this.containerFormatLabel.Text = "Container Format"; // @@ -629,21 +649,20 @@ this.containerFormat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.containerFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.containerFormat.Location = new System.Drawing.Point(124, 238); + this.containerFormat.Location = new System.Drawing.Point(124, 239); this.containerFormat.Name = "containerFormat"; - this.containerFormat.Size = new System.Drawing.Size(135, 21); + this.containerFormat.Size = new System.Drawing.Size(127, 21); this.containerFormat.TabIndex = 37; this.containerFormat.SelectedIndexChanged += new System.EventHandler(this.containerFormat_SelectedIndexChanged_1); // // groupBox1 // - this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.ContextMenuStrip = this.contextMenuStrip1; this.groupBox1.Controls.Add(this.tabControl2); - this.groupBox1.Location = new System.Drawing.Point(8, 89); + this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top; + this.groupBox1.Location = new System.Drawing.Point(3, 80); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(437, 139); + this.groupBox1.Size = new System.Drawing.Size(447, 139); this.groupBox1.TabIndex = 35; this.groupBox1.TabStop = false; this.groupBox1.Text = "Audio"; @@ -656,64 +675,51 @@ this.tabControl2.Location = new System.Drawing.Point(3, 16); this.tabControl2.Name = "tabControl2"; this.tabControl2.SelectedIndex = 0; - this.tabControl2.Size = new System.Drawing.Size(431, 120); + this.tabControl2.Size = new System.Drawing.Size(441, 120); this.tabControl2.TabIndex = 32; // // videoGroupBox // - this.videoGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.videoGroupBox.Controls.Add(this.videoProfileControl); + this.videoGroupBox.Controls.Add(this.label4); + this.videoGroupBox.Controls.Add(this.videoProfile); this.videoGroupBox.Controls.Add(this.addPrerenderJob); - this.videoGroupBox.Controls.Add(this.videoCodecLabel); - this.videoGroupBox.Controls.Add(this.videoCodec); - this.videoGroupBox.Location = new System.Drawing.Point(8, 6); + this.videoGroupBox.Dock = System.Windows.Forms.DockStyle.Top; + this.videoGroupBox.Location = new System.Drawing.Point(3, 3); this.videoGroupBox.Name = "videoGroupBox"; - this.videoGroupBox.Size = new System.Drawing.Size(437, 77); + this.videoGroupBox.Size = new System.Drawing.Size(447, 77); this.videoGroupBox.TabIndex = 31; this.videoGroupBox.TabStop = false; - this.videoGroupBox.Text = "Video"; + this.videoGroupBox.Text = "Video Settings"; // - // videoProfileControl + // label4 // - this.videoProfileControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.videoProfileControl.LabelText = "Video Profile"; - this.videoProfileControl.Location = new System.Drawing.Point(12, 42); - this.videoProfileControl.Name = "videoProfileControl"; - this.videoProfileControl.Size = new System.Drawing.Size(415, 29); - this.videoProfileControl.TabIndex = 17; + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(12, 24); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(66, 13); + this.label4.TabIndex = 38; + this.label4.Text = "Video Profile"; // + // videoProfile + // + this.videoProfile.Location = new System.Drawing.Point(121, 19); + this.videoProfile.Name = "videoProfile"; + this.videoProfile.ProfileSet = "Video"; + this.videoProfile.Size = new System.Drawing.Size(319, 22); + this.videoProfile.TabIndex = 17; + this.videoProfile.SelectedProfileChanged += new System.EventHandler(this.ProfileChanged); + // // addPrerenderJob // this.addPrerenderJob.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.addPrerenderJob.AutoSize = true; - this.addPrerenderJob.Location = new System.Drawing.Point(259, 22); + this.addPrerenderJob.Location = new System.Drawing.Point(121, 47); this.addPrerenderJob.Name = "addPrerenderJob"; this.addPrerenderJob.Size = new System.Drawing.Size(127, 17); this.addPrerenderJob.TabIndex = 16; this.addPrerenderJob.Text = "Add pre-rendering job"; this.addPrerenderJob.UseVisualStyleBackColor = true; // - // videoCodecLabel - // - this.videoCodecLabel.Location = new System.Drawing.Point(9, 18); - this.videoCodecLabel.Name = "videoCodecLabel"; - this.videoCodecLabel.Size = new System.Drawing.Size(100, 23); - this.videoCodecLabel.TabIndex = 7; - this.videoCodecLabel.Text = "Codec"; - this.videoCodecLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // videoCodec - // - this.videoCodec.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.videoCodec.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.videoCodec.Location = new System.Drawing.Point(116, 20); - this.videoCodec.Name = "videoCodec"; - this.videoCodec.Size = new System.Drawing.Size(130, 21); - this.videoCodec.TabIndex = 8; - // // openFileDialog // this.openFileDialog.Filter = "IFO Files|*.ifo|VOB Files (*.vob)|*.vob|MPEG-1/2 Program Streams (*.mpg)|*.mpg|Tr" + @@ -768,20 +774,22 @@ this.trackTabPage1.ResumeLayout(false); this.tabPage2.ResumeLayout(false); this.tabPage2.PerformLayout(); - this.locationGroupBox.ResumeLayout(false); - this.locationGroupBox.PerformLayout(); this.avsBox.ResumeLayout(false); this.avsBox.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.horizontalResolution)).EndInit(); + this.locationGroupBox.ResumeLayout(false); + this.locationGroupBox.PerformLayout(); this.tabPage1.ResumeLayout(false); this.IOGroupbox.ResumeLayout(false); this.targetGroupBox.ResumeLayout(false); + this.targetGroupBox.PerformLayout(); this.audioGroupbox.ResumeLayout(false); this.contextMenuStrip1.ResumeLayout(false); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); this.tabControl1.ResumeLayout(false); this.encoderConfigTab.ResumeLayout(false); + this.encoderConfigTab.PerformLayout(); this.groupBox1.ResumeLayout(false); this.tabControl2.ResumeLayout(false); this.videoGroupBox.ResumeLayout(false); @@ -819,17 +827,12 @@ private System.Windows.Forms.TabPage encoderConfigTab; private System.Windows.Forms.GroupBox videoGroupBox; private System.Windows.Forms.CheckBox addPrerenderJob; - private System.Windows.Forms.Label videoCodecLabel; - private System.Windows.Forms.ComboBox videoCodec; private System.Windows.Forms.CheckBox showAdvancedOptions; private System.Windows.Forms.Button goButton; - private MeGUI.core.details.video.ProfileControl profileControl1; - private MeGUI.core.details.video.ProfileControl videoProfileControl; private FileBar input; private FileBar output; private FileBar workingDirectory; private FileBar chapterFile; - private MeGUI.core.details.video.ProfileControl profileControl2; private MeGUI.core.gui.HelpButton helpButton1; private System.Windows.Forms.TabControl tabControl2; private MeGUI.packages.tools.oneclick.AudioConfigControl audio1; @@ -847,7 +850,13 @@ private MeGUI.core.gui.TargetSizeSCBox splitting; private System.Windows.Forms.Label containerFormatLabel; private System.Windows.Forms.ComboBox containerFormat; + private MeGUI.core.gui.ConfigableProfilesControl oneclickProfile; + private MeGUI.core.gui.ConfigableProfilesControl videoProfile; + private MeGUI.core.gui.ConfigableProfilesControl avsProfile; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; } -} \ No newline at end of file +} Index: packages/video/lmp4/lavcConfigurationPanel.cs =================================================================== --- packages/video/lmp4/lavcConfigurationPanel.cs (revision 426) +++ packages/video/lmp4/lavcConfigurationPanel.cs (working copy) @@ -10,11 +10,11 @@ namespace MeGUI.packages.video.lmp4 { - public partial class lavcConfigurationPanel : MeGUI.core.details.video.VideoConfigurationPanel, Gettable + public partial class lavcConfigurationPanel : MeGUI.core.details.video.VideoConfigurationPanel, Editable { #region start / stop - public lavcConfigurationPanel(MainForm mainForm, VideoInfo info) - : base(mainForm, info) + public lavcConfigurationPanel() + : base() { InitializeComponent(); } @@ -175,7 +175,7 @@ /// /// gets / sets the settings currently displayed on the GUI /// - public VideoCodecSettings Settings + public lavcSettings Settings { get { @@ -226,14 +226,11 @@ ls.TemporalMask = this.temporalMask.Value; ls.NbMotionPredictors = lavcNBPredictors.Value; ls.Logfile = this.logfile.Text; - ls.Zones = this.Zones; return ls; } set { - if (!(value is lavcSettings)) - return; - lavcSettings ls = value as lavcSettings; + lavcSettings ls = value; fourCC.SelectedIndex = ls.FourCC; lavcEncodingMode.SelectedIndex = ls.EncodingMode; lavcBitrateQuantizer.Text = ls.BitrateQuantizer.ToString(); @@ -272,7 +269,6 @@ this.spatialMask.Value = ls.SpatialMask; this.temporalMask.Value = ls.TemporalMask; lavcNBPredictors.Value = ls.NbMotionPredictors; - this.Zones = ls.Zones; this.logfile.Text = ls.Logfile; lavcTurbo.Checked = ls.Turbo; } @@ -297,6 +293,9 @@ } } #endregion + } } + + Index: packages/video/lmp4/lavcConfigurationPanel.Designer.cs =================================================================== --- packages/video/lmp4/lavcConfigurationPanel.Designer.cs (revision 426) +++ packages/video/lmp4/lavcConfigurationPanel.Designer.cs (working copy) @@ -214,7 +214,6 @@ this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.advancedTabPage = new System.Windows.Forms.TabPage(); this.tabControl1.SuspendLayout(); - this.zoneTabPage.SuspendLayout(); this.mainTabPage.SuspendLayout(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.meRange)).BeginInit(); @@ -288,17 +287,9 @@ // this.tabControl1.Controls.Add(this.advancedTabPage); this.tabControl1.Size = new System.Drawing.Size(496, 444); - this.tabControl1.Controls.SetChildIndex(this.zoneTabPage, 0); this.tabControl1.Controls.SetChildIndex(this.advancedTabPage, 0); this.tabControl1.Controls.SetChildIndex(this.mainTabPage, 0); // - // zoneTabPage - // - this.zoneTabPage.Controls.Add(this.quantizerMatrixGroupbox); - this.zoneTabPage.Size = new System.Drawing.Size(488, 418); - this.zoneTabPage.Controls.SetChildIndex(this.zonesControl, 0); - this.zoneTabPage.Controls.SetChildIndex(this.quantizerMatrixGroupbox, 0); - // // commandline // this.commandline.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left))); @@ -2695,7 +2686,6 @@ this.Name = "lavcConfigurationPanel"; this.Size = new System.Drawing.Size(496, 528); this.tabControl1.ResumeLayout(false); - this.zoneTabPage.ResumeLayout(false); this.mainTabPage.ResumeLayout(false); this.groupBox1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.meRange)).EndInit(); Index: packages/video/lmp4/lavcSettings.cs =================================================================== --- packages/video/lmp4/lavcSettings.cs (revision 426) +++ packages/video/lmp4/lavcSettings.cs (working copy) @@ -26,6 +26,8 @@ /// public class lavcSettings: VideoCodecSettings { + public static string ID = "LMP4"; + private int mbDecisionAlgo, scd, subpelRefinement, maxQuantDelta, minBitrate, maxBitrate, bufferSize, filesizeTolerance, fieldOrder; private decimal lumiMasking, darkMask, ipFactor, pbFactor, bQuantOffset, quantizerBlur, quantizerCompression, @@ -37,19 +39,11 @@ { get { return false; } } - public override VideoCodec Codec - { - get { return VideoCodec.ASP; } - } - public override VideoEncoderType EncoderType - { - get { return VideoEncoderType.LMP4; } - } /// /// default constructor /// initializes all the variables at the codec's default /// - public lavcSettings():base() + public lavcSettings():base(ID, VideoEncoderType.LMP4) { EncodingMode = 0; BitrateQuantizer = 800; @@ -230,4 +224,4 @@ } #endregion } -} \ No newline at end of file +} Index: packages/video/snow/snowConfigurationPanel.cs =================================================================== --- packages/video/snow/snowConfigurationPanel.cs (revision 426) +++ packages/video/snow/snowConfigurationPanel.cs (working copy) @@ -10,11 +10,11 @@ namespace MeGUI.packages.video.snow { - public partial class snowConfigurationPanel : MeGUI.core.details.video.VideoConfigurationPanel, Gettable + public partial class snowConfigurationPanel : MeGUI.core.details.video.VideoConfigurationPanel, Editable { #region start / stop - public snowConfigurationPanel(MainForm mainForm, VideoInfo info) - : base(mainForm, info) + public snowConfigurationPanel() + : base() { InitializeComponent(); } @@ -130,7 +130,7 @@ /// /// gets / sets the settings currently displayed on the GUI /// - public VideoCodecSettings Settings + public snowSettings Settings { get { @@ -149,14 +149,11 @@ ss.CreditsQuantizer = this.snowCreditsQuantizer.Value; ss.LosslessMode = this.snowLosslessMode.Checked; ss.Logfile = this.logfile.Text; - ss.Zones = this.Zones; return ss; } set { - if (!(value is snowSettings)) - return; - snowSettings ss = value as snowSettings; + snowSettings ss = value; snowEncodingMode.SelectedIndex = ss.EncodingMode; snowQuantizer.Value = ss.Quantizer; snowPredictionMode.SelectedIndex = ss.PredictionMode; @@ -170,7 +167,6 @@ this.snowCreditsQuantizer.Value = ss.CreditsQuantizer; this.snowLosslessMode.Checked = ss.LosslessMode; this.logfile.Text = ss.Logfile; - this.Zones = ss.Zones; } } #endregion @@ -196,3 +192,5 @@ } } + + Index: packages/video/snow/snowConfigurationPanel.Designer.cs =================================================================== --- packages/video/snow/snowConfigurationPanel.Designer.cs (revision 426) +++ packages/video/snow/snowConfigurationPanel.Designer.cs (working copy) @@ -73,10 +73,6 @@ // this.tabControl1.Size = new System.Drawing.Size(446, 337); // - // zoneTabPage - // - this.zoneTabPage.Size = new System.Drawing.Size(438, 311); - // // commandline // this.commandline.Location = new System.Drawing.Point(3, 339); Index: packages/video/snow/snowSettings.cs =================================================================== --- packages/video/snow/snowSettings.cs (revision 426) +++ packages/video/snow/snowSettings.cs (working copy) @@ -27,21 +27,15 @@ [Serializable] public class snowSettings : VideoCodecSettings { + public static readonly string ID = "Snow"; private decimal quantizer, nbMotionPredictors; private int predictionMode, meCompFullpel, meCompHpel, mbComp; private bool losslessMode; - public override VideoCodec Codec - { - get { return VideoCodec.SNOW; } - } - public override VideoEncoderType EncoderType - { - get { return VideoEncoderType.SNOW; } - } + /// /// default contructor, initializes codec default values /// - public snowSettings():base() + public snowSettings():base(ID, VideoEncoderType.SNOW) { EncodingMode = 0; BitrateQuantizer = 700; @@ -105,4 +99,4 @@ } } -} \ No newline at end of file +} Index: packages/video/x264/x264ConfigurationPanel.cs =================================================================== --- packages/video/x264/x264ConfigurationPanel.cs (revision 426) +++ packages/video/x264/x264ConfigurationPanel.cs (working copy) @@ -12,13 +12,8 @@ namespace MeGUI.packages.video.x264 { - public partial class x264ConfigurationPanel : MeGUI.core.details.video.VideoConfigurationPanel, Gettable + public partial class x264ConfigurationPanel : MeGUI.core.details.video.VideoConfigurationPanel, Editable { - public x264ConfigurationPanel() - { - InitializeComponent(); - } - #region variables public static bool levelEnforced; // flag to prevent recursion in EnforceLevels. There's probably a better way to do this. private XmlDocument ContextHelp = new XmlDocument(); @@ -26,12 +21,12 @@ #region start / stop - public x264ConfigurationPanel(MainForm mainForm, VideoInfo info) - : base(mainForm, info) + public x264ConfigurationPanel() + : base() { InitializeComponent(); cqmComboBox1.StandardItems = new string[] { "Flat (none)", "JVT" }; - this.AdvancedToolTips = mainForm.Settings.UseAdvancedTooltips; + this.AdvancedToolTips = MainForm.Instance.Settings.UseAdvancedTooltips; AVCLevels al = new AVCLevels(); this.avcLevel.Items.AddRange(al.getLevels()); } @@ -455,7 +450,7 @@ /// /// gets / sets the settings currently displayed on the GUI /// - public VideoCodecSettings Settings + public x264Settings Settings { get { @@ -521,7 +516,6 @@ xs.Logfile = this.logfile.Text; xs.AdaptiveDCT = adaptiveDCT.Checked; xs.CustomEncoderOptions = customCommandlineOptions.Text; - xs.Zones = this.Zones; if (cqmComboBox1.SelectedIndex > 1) xs.QuantizerMatrixType = 2; else @@ -536,7 +530,7 @@ } set { // Warning! The ordering of components matters because of the dependency code! - x264Settings xs = (x264Settings)value; + x264Settings xs = value; deadzoneInter.Value = xs.DeadZoneInter; deadzoneIntra.Value = xs.DeadZoneIntra; interlaced.Checked = xs.EncodeInterlaced; @@ -601,7 +595,6 @@ x264MinGOPSize.Text = xs.MinGOPSize.ToString(); customCommandlineOptions.Text = xs.CustomEncoderOptions; this.logfile.Text = xs.Logfile; - this.Zones = xs.Zones; cqmComboBox1.SelectedObject = xs.QuantizerMatrix; x264LosslessMode.Checked = xs.Lossless; psnr.Checked = xs.PSNRCalculation; @@ -886,3 +879,5 @@ } } + + Index: packages/video/x264/x264ConfigurationPanel.Designer.cs =================================================================== --- packages/video/x264/x264ConfigurationPanel.Designer.cs (revision 426) +++ packages/video/x264/x264ConfigurationPanel.Designer.cs (working copy) @@ -147,7 +147,6 @@ this.helpButton1 = new MeGUI.core.gui.HelpButton(); this.customCommandlineOptions = new System.Windows.Forms.TextBox(); this.tabControl1.SuspendLayout(); - this.zoneTabPage.SuspendLayout(); this.mainTabPage.SuspendLayout(); this.x264GeneralMiscGroupbox.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.x264NbThreads)).BeginInit(); @@ -195,20 +194,10 @@ this.tabControl1.Controls.Add(this.quantizationTabPage); this.tabControl1.Size = new System.Drawing.Size(510, 429); this.tabControl1.TabIndex = 0; - this.tabControl1.Controls.SetChildIndex(this.zoneTabPage, 0); this.tabControl1.Controls.SetChildIndex(this.quantizationTabPage, 0); this.tabControl1.Controls.SetChildIndex(this.rateControlTabPage, 0); this.tabControl1.Controls.SetChildIndex(this.mainTabPage, 0); // - // zoneTabPage - // - this.zoneTabPage.Controls.Add(this.customCommandlineOptionsLabel); - this.zoneTabPage.Controls.Add(this.customCommandlineOptions); - this.zoneTabPage.Size = new System.Drawing.Size(502, 403); - this.zoneTabPage.Controls.SetChildIndex(this.customCommandlineOptions, 0); - this.zoneTabPage.Controls.SetChildIndex(this.customCommandlineOptionsLabel, 0); - this.zoneTabPage.Controls.SetChildIndex(this.zonesControl, 0); - // // commandline // this.commandline.Location = new System.Drawing.Point(0, 431); @@ -225,13 +214,6 @@ this.mainTabPage.Controls.Add(this.x264CodecGeneralGroupbox); this.mainTabPage.Size = new System.Drawing.Size(502, 403); // - // zonesControl - // - this.zonesControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.zonesControl.MinimumSize = new System.Drawing.Size(323, 289); - this.zonesControl.Size = new System.Drawing.Size(499, 289); - // // x264GeneralMiscGroupbox // this.x264GeneralMiscGroupbox.Controls.Add(this.fourCC); @@ -1806,8 +1788,6 @@ this.Controls.SetChildIndex(this.tabControl1, 0); this.Controls.SetChildIndex(this.commandline, 0); this.tabControl1.ResumeLayout(false); - this.zoneTabPage.ResumeLayout(false); - this.zoneTabPage.PerformLayout(); this.mainTabPage.ResumeLayout(false); this.x264GeneralMiscGroupbox.ResumeLayout(false); this.x264GeneralMiscGroupbox.PerformLayout(); Index: packages/video/x264/x264Settings.cs =================================================================== --- packages/video/x264/x264Settings.cs (revision 426) +++ packages/video/x264/x264Settings.cs (working copy) @@ -28,6 +28,8 @@ [Serializable] public class x264Settings: VideoCodecSettings { + public static string ID = "x264"; + public override void setAdjustedNbThreads(int nbThreads) { base.setAdjustedNbThreads(0); @@ -61,18 +63,10 @@ bFramePyramid, chromaME, adaptiveDCT, lossless, mixedRefs, bRDO, NoFastPSkip, BiME, psnrCalc, noDctDecimate, ssimCalc; string quantizerMatrix; #region constructor - public override VideoCodec Codec - { - get { return VideoCodec.AVC; } - } - public override VideoEncoderType EncoderType - { - get { return VideoEncoderType.X264; } - } /// /// default constructor, initializes codec default values /// - public x264Settings():base() + public x264Settings():base(ID, VideoEncoderType.X264) { deadZoneInter = 21; deadZoneIntra = 11; Index: packages/video/xvid/xvidConfigurationPanel.cs =================================================================== --- packages/video/xvid/xvidConfigurationPanel.cs (revision 426) +++ packages/video/xvid/xvidConfigurationPanel.cs (working copy) @@ -10,12 +10,12 @@ namespace MeGUI.packages.video.xvid { - public partial class xvidConfigurationPanel : MeGUI.core.details.video.VideoConfigurationPanel, Gettable + public partial class xvidConfigurationPanel : MeGUI.core.details.video.VideoConfigurationPanel, Editable { #region start / stop - public xvidConfigurationPanel(MainForm mainForm, VideoInfo info) - : base(mainForm, info) + public xvidConfigurationPanel() + : base() { InitializeComponent(); cqmComboBox1.StandardItems = new string[] { xvidSettings.H263Matrix, xvidSettings.MPEGMatrix }; @@ -166,7 +166,7 @@ /// /// gets / sets the settings currently displayed on the GUI /// - public VideoCodecSettings Settings + public xvidSettings Settings { get { @@ -222,14 +222,11 @@ xs.QuantizerMatrix = cqmComboBox1.SelectedText; xs.CustomEncoderOptions = xvidCustomCommandlineOptions.Text; xs.Logfile = this.logfile.Text; - xs.Zones = Zones; return xs; } set { - if (!(value is xvidSettings)) - return; - xvidSettings xs = (xvidSettings)value; + xvidSettings xs = value; fourCC.SelectedIndex = xs.FourCC; this.xvidTurbo.Checked = xs.Turbo; this.xvidEncodingMode.SelectedIndex = xs.EncodingMode; @@ -281,7 +278,6 @@ cqmComboBox1.SelectedObject = xs.QuantizerMatrix; xvidCustomCommandlineOptions.Text = xs.CustomEncoderOptions; this.logfile.Text = xs.Logfile; - this.Zones = xs.Zones; } } #endregion @@ -312,3 +308,5 @@ } } + + Index: packages/video/xvid/xvidConfigurationPanel.Designer.cs =================================================================== --- packages/video/xvid/xvidConfigurationPanel.Designer.cs (revision 426) +++ packages/video/xvid/xvidConfigurationPanel.Designer.cs (working copy) @@ -130,7 +130,6 @@ this.xvidCustomCommandlineOptions = new System.Windows.Forms.TextBox(); this.quantizerMatrixGroupbox = new System.Windows.Forms.GroupBox(); this.tabControl1.SuspendLayout(); - this.zoneTabPage.SuspendLayout(); this.mainTabPage.SuspendLayout(); this.xvidOtherGroupBox.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nbThreads)).BeginInit(); @@ -168,17 +167,9 @@ // this.tabControl1.Controls.Add(this.advancedTabPage); this.tabControl1.Size = new System.Drawing.Size(500, 458); - this.tabControl1.Controls.SetChildIndex(this.zoneTabPage, 0); this.tabControl1.Controls.SetChildIndex(this.advancedTabPage, 0); this.tabControl1.Controls.SetChildIndex(this.mainTabPage, 0); // - // zoneTabPage - // - this.zoneTabPage.Controls.Add(this.quantizerMatrixGroupbox); - this.zoneTabPage.Size = new System.Drawing.Size(492, 432); - this.zoneTabPage.Controls.SetChildIndex(this.quantizerMatrixGroupbox, 0); - this.zoneTabPage.Controls.SetChildIndex(this.zonesControl, 0); - // // commandline // this.commandline.Location = new System.Drawing.Point(4, 464); @@ -1326,8 +1317,6 @@ this.Name = "xvidConfigurationPanel"; this.Size = new System.Drawing.Size(503, 526); this.tabControl1.ResumeLayout(false); - this.zoneTabPage.ResumeLayout(false); - this.zoneTabPage.PerformLayout(); this.mainTabPage.ResumeLayout(false); this.xvidOtherGroupBox.ResumeLayout(false); this.xvidOtherGroupBox.PerformLayout(); Index: packages/video/xvid/xvidSettings.cs =================================================================== --- packages/video/xvid/xvidSettings.cs (revision 426) +++ packages/video/xvid/xvidSettings.cs (working copy) @@ -27,6 +27,7 @@ /// public class xvidSettings : VideoCodecSettings { + public static readonly string ID = "XviD"; public static readonly string H263Matrix = "H.263"; public static readonly string MPEGMatrix = "MPEG"; @@ -71,15 +72,6 @@ greyscale, interlaced, bottomFieldFirst, lumiMasking; private decimal bframeThreshold, quantizer; private string customQuantizerMatrix; - public override VideoCodec Codec - { - get { return VideoCodec.ASP; } - } - public override VideoEncoderType EncoderType - { - get { return VideoEncoderType.XVID; } - } - public override bool UsesSAR { get { return true; } @@ -89,7 +81,7 @@ /// initializes all the variables at the codec's default (based on the xvid VfW defaults /// public xvidSettings() - : base() + : base(ID, VideoEncoderType.XVID) { EncodingMode = 0; quantizer = 0; @@ -416,4 +408,4 @@ return false; } } -} \ No newline at end of file +}