internal override void Reload(Rainmeter.API api, ref double maxValue) { Name = api.GetMeasureName(); API.Log(API.LogType.Debug, "Mediamonkey.dll: Reloading ChildMeasure=" + Name); base.Reload(api, ref maxValue); string parentName = api.ReadString("PlayerName", "", false).Replace("[", "").Replace("]", ""); IntPtr skin = api.GetSkin(); API.Log(API.LogType.Debug, "Mediamonkey.dll: Looking for ParentMeasure" + parentName + "in skin " + skin + "for ChildMeasure " + Name); // Find parent using name AND the skin handle to be sure that it's the right one. ParentMeasure = null; foreach (ParentMeasure parentMeasure in ParentMeasure.ParentMeasures) { if (parentMeasure.Skin.Equals(skin) && parentMeasure.Name.Equals(parentName)) { API.Log(API.LogType.Debug, "Mediamonkey.dll: Found ParentMeasure " + parentMeasure.Name + " for ChildMeasure " + Name); ParentMeasure = parentMeasure; } } if (ParentMeasure == null) { API.Log(API.LogType.Error, "Mediamonkey.dll: PlayerName=" + parentName + " not valid"); } }
public static void Initialize(ref IntPtr data, IntPtr rm) { Rainmeter.API api = new Rainmeter.API(rm); string mname = api.GetMeasureName(); API.Log(API.LogType.Debug, "Mediamonkey.dll: Initializing Plugin for Measure " + mname); string mmVersion = api.ReadString("MMVersion", ""); string PlayerName = api.ReadString("PlayerName", "", false); string PlayerPath = api.ReadString("PlayerPath", "", false); Measure measure; if (string.IsNullOrEmpty(PlayerName)) { if (string.IsNullOrEmpty(PlayerPath)) { API.Log(API.LogType.Debug, "Mediamonkey.dll: Creating new ParentMeasure " + mname + " for MediaMonkey Version " + mmVersion); switch (mmVersion) { case "4": measure = new ParentMeasure(new MediaMonkey4()); break; case "5": measure = new ParentMeasure(new MediaMonkey5()); break; default: API.Log(API.LogType.Error, "MediaMonkey.dll: MMVersion=" + mmVersion + " not valid or no MMVersion value found, defaulting to Version 4"); measure = new ParentMeasure(new MediaMonkey4()); break; } } else { API.Log(API.LogType.Debug, "Mediamonkey.dll: Creating new ParentMeasure " + mname + " for MediaMonkey Version " + mmVersion + " with path " + PlayerPath); switch (mmVersion) { case "4": measure = new ParentMeasure(new MediaMonkey4(PlayerPath)); break; case "5": measure = new ParentMeasure(new MediaMonkey5(PlayerPath)); break; default: API.Log(API.LogType.Error, "MediaMonkey.dll: MMVersion=" + mmVersion + " not valid or no MMVersion value found, defaulting to Version 4"); measure = new ParentMeasure(new MediaMonkey4(PlayerPath)); break; } } } else { API.Log(API.LogType.Debug, "Mediamonkey.dll: Creating new ChildMeasure " + mname + " for ParentMeasure " + PlayerName); measure = new ChildMeasure(); } data = GCHandle.ToIntPtr(GCHandle.Alloc(measure)); }