public static void Initialize(ref IntPtr measurePtr, IntPtr apiPtr) { RainmeterAPI api = new RainmeterAPI(apiPtr); RainmeterSkinHandler skinHandler = RainmeterSkinHandler.GetSkinHandler(api); skinHandler.M_Initialize(ref measurePtr, api); RainmeterSkinHandler.AddMeasurePtr(measurePtr, skinHandler); }
internal void M_Reload(IntPtr measurePtr, RainmeterAPI api, ref double maxValue) { if (measurePtr == IntPtr.Zero) { return; } GetPluginMeasureType(measurePtr).Reload(api, ref maxValue); }
public PluginSkin(RainmeterSkinHandler skinHandler, RainmeterAPI api) { SkinHandler = skinHandler; // -- We need to remove the last directory from path. var path = api.ReadPath(RainmeterSkinHandler.PluginMeasureName, string.Empty); var dir = Directory.GetParent(path.EndsWith("\\") ? path : string.Concat(path, "\\")); Path = dir.Parent.FullName; }
internal static RainmeterSkinHandler GetSkinHandler(RainmeterAPI api) { IntPtr skinPtr = api.GetSkin(); RainmeterSkinHandler skinHandler; if (!SkinHandlerBySkinPtr.TryGetValue(skinPtr, out skinHandler)) { SkinHandlerBySkinPtr.Add(skinPtr, (skinHandler = new RainmeterSkinHandler(skinPtr, api.GetSkinName(), api.GetSkinWindow()))); } return(skinHandler); }
internal void M_Initialize(ref IntPtr measurePtr, RainmeterAPI api) { var measureName = api.ReadString(PluginMeasureName, string.Empty); var measureType = api.ReadString(PluginMeasureType, string.Empty); var assemblyName = api.ReadString(PluginAssemblyName, string.Empty); var assemblyPath = api.ReadPath(PluginAssemblyName, string.Empty); var assembly = GetAssembly(assemblyPath); var measureTypeType = GetPluginMeasureType(assembly, measureName); if (measureTypeType == null) // -- Error checking. { if (string.IsNullOrEmpty(measureName)) { RainmeterAPI.Log(RainmeterAPI.LogType.Error, $"{PluginMeasureName}= Not found."); } if (string.IsNullOrEmpty(measureType)) { RainmeterAPI.Log(RainmeterAPI.LogType.Error, $"{PluginMeasureType}= Not found."); } if (!string.IsNullOrEmpty(measureName) && !string.IsNullOrEmpty(measureType)) { RainmeterAPI.Log(RainmeterAPI.LogType.Error, $"Missing .dll's"); } // Not sure how bad this is on rainmeter side, but it seems fine. That's the only safe way to handle errors. // Pointer will be reset anyway by refreshin theg skin with fixed errors. measurePtr = IntPtr.Zero; return; } // -- Check if a PluginSkin exist for this type of MeasureType. Create and add if not. if (!PluginSkinByTypes.ContainsKey(measureTypeType)) { var skin = CreatePluginSkin(assembly, measureName, this, api); PluginSkinByTypes.Add(measureTypeType, skin); } var pluginMeasure = CreatePluginMeasure(assembly, measureName, measureType, PluginSkinByTypes[measureTypeType], api); measurePtr = GCHandle.ToIntPtr(GCHandle.Alloc(pluginMeasure)); AddPluginMeasure(measurePtr, PluginSkinByTypes[measureTypeType], pluginMeasure); }
public abstract void Reload(RainmeterAPI api, ref double maxValue);
public PluginMeasure(RainmeterAPI api) { Name = api.GetMeasureName(); }
// -- Add Base-Derived class support. private static PluginMeasure CreatePluginMeasure(Assembly assembly, string measureType, string pluginType, PluginSkin skin, RainmeterAPI api) => (PluginMeasure)Activator.CreateInstance(GetPluginMeasureType(assembly, measureType), new object[] { pluginType, skin, api });
// -- Add Base-Derived class support. private static PluginSkin CreatePluginSkin(Assembly assembly, string measureType, RainmeterSkinHandler skinHandler, RainmeterAPI api) => (PluginSkin)Activator.CreateInstance(GetPluginSkinType(assembly, measureType), new object[] { skinHandler, api });