diff --git a/InfoPanel.Contract/IPanelData.cs b/InfoPanel.Contract/IPanelData.cs deleted file mode 100644 index 229a846..0000000 --- a/InfoPanel.Contract/IPanelData.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace InfoPanel.Contract -{ - public interface IPanelData //interface that both the plugin loader and each plugin must implement - { - Task GetData(); - } -} diff --git a/InfoPanel.Contract/PanelData.cs b/InfoPanel.Contract/PanelData.cs deleted file mode 100644 index 20851f0..0000000 --- a/InfoPanel.Contract/PanelData.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace InfoPanel.Contract -{ - //this is the main data object that will be returned from each plugin - public class PanelData - { - public string CollectionName { get; set; } //name of the collection. Added this in case if there are multiple values that need to be sent by the plugin - public IEnumerable EntryList { get; set; } //list of entries - } - - public class Entry - { - public string Name { get; set; } //name of entry (Would be something like "Fan Speed", "CPU Usage", "Water Temp",... - public string Value { get; set; } //The result value. Now while it only accepts strings, you can use something like double.TryParse() to get the value out - } - -} diff --git a/InfoPanel.Plugins.Loader/InfoPanel.Plugins.Loader.csproj b/InfoPanel.Plugins.Loader/InfoPanel.Plugins.Loader.csproj new file mode 100644 index 0000000..e1c6008 --- /dev/null +++ b/InfoPanel.Plugins.Loader/InfoPanel.Plugins.Loader.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/InfoPanel.Plugins.Loader/PluginExtensions.cs b/InfoPanel.Plugins.Loader/PluginExtensions.cs new file mode 100644 index 0000000..dce3d30 --- /dev/null +++ b/InfoPanel.Plugins.Loader/PluginExtensions.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace InfoPanel.Plugins.Loader +{ + public static class PluginExtensions + { + public static string Id(this IPlugin panelData) + { + return panelData.ToString(); + } + } +} diff --git a/InfoPanel.Plugins.Loader/PluginLoadContext.cs b/InfoPanel.Plugins.Loader/PluginLoadContext.cs new file mode 100644 index 0000000..3aab75c --- /dev/null +++ b/InfoPanel.Plugins.Loader/PluginLoadContext.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.Loader; +using System.Text; +using System.Threading.Tasks; + +namespace InfoPanel.Plugins.Loader +{ + public class PluginLoadContext : AssemblyLoadContext + { + private AssemblyDependencyResolver _resolver; + + public PluginLoadContext(string pluginPath) + { + _resolver = new AssemblyDependencyResolver(pluginPath); + } + + protected override Assembly Load(AssemblyName assemblyName) + { + string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName); + if (assemblyPath != null) + { + return LoadFromAssemblyPath(assemblyPath); + } + + return null; + } + + protected override IntPtr LoadUnmanagedDll(string unmanagedDllName) + { + string libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName); + if (libraryPath != null) + { + return LoadUnmanagedDllFromPath(libraryPath); + } + + return IntPtr.Zero; + } + } +} diff --git a/InfoPanel.Plugins.Loader/PluginLoader.cs b/InfoPanel.Plugins.Loader/PluginLoader.cs new file mode 100644 index 0000000..4226497 --- /dev/null +++ b/InfoPanel.Plugins.Loader/PluginLoader.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace InfoPanel.Plugins.Loader +{ + public class PluginLoader + { + public void test(string folder) + { + var plugins= Directory.GetFiles(folder, "InfoPanel.*.dll"); + IEnumerable commands = plugins.SelectMany(pluginPath => + { + Assembly pluginAssembly = LoadPlugin(pluginPath); + return CreateCommands(pluginAssembly); + }).ToList(); + + //foreach (var command in commands) + //{ + // Trace.WriteLine(command); + // var panelDatas = command.GetData(); + // foreach(var panelData in panelDatas) + // { + // Trace.WriteLine(panelData.CollectionName); + // foreach(var item in panelData.EntryList) + // { + // Trace.WriteLine($"{item.Name}: {item.Value} {item.Unit}"); + // } + // } + //} + } + + public IEnumerable InitializePlugin(string pluginPath) + { + Assembly pluginAssembly = LoadPlugin(pluginPath); + return CreateCommands(pluginAssembly); + } + + + static Assembly LoadPlugin(string pluginPath) + { + PluginLoadContext loadContext = new(pluginPath); + return loadContext.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(pluginPath))); + } + + static IEnumerable CreateCommands(Assembly assembly) + { + int count = 0; + + foreach (Type type in assembly.GetTypes()) + { + if (typeof(IPlugin).IsAssignableFrom(type)) + { + if (Activator.CreateInstance(type) is IPlugin result) + { + count++; + yield return result; + } + } + } + + if (count == 0) + { + string availableTypes = string.Join(",", assembly.GetTypes().Select(t => t.FullName)); + throw new ApplicationException( + $"Can't find any type which implements ICommand in {assembly} from {assembly.Location}.\n" + + $"Available types: {availableTypes}"); + } + } + + + } +} diff --git a/InfoPanel.Plugins.Simulator/InfoPanel.Plugins.Simulator.csproj b/InfoPanel.Plugins.Simulator/InfoPanel.Plugins.Simulator.csproj new file mode 100644 index 0000000..9d7c3f4 --- /dev/null +++ b/InfoPanel.Plugins.Simulator/InfoPanel.Plugins.Simulator.csproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0-windows + enable + enable + + + + + + + + + diff --git a/InfoPanel.Plugins.Simulator/Program.cs b/InfoPanel.Plugins.Simulator/Program.cs new file mode 100644 index 0000000..8fd8447 --- /dev/null +++ b/InfoPanel.Plugins.Simulator/Program.cs @@ -0,0 +1,50 @@ +using InfoPanel.Plugins; +using InfoPanel.Plugins.Loader; + +PluginLoader pluginLoader = new(); + +//\InfoPanel\InfoPanel.Plugins.Simulator\bin\Debug\net8.0-windows +var plugins = pluginLoader.InitializePlugin("..\\..\\..\\..\\InfoPanel.VolumePlugin\\bin\\x64\\Debug\\net8.0-windows\\InfoPanel.Extras.dll"); + +List loadedPlugins = []; + +foreach (var plugin in plugins) +{ + loadedPlugins.Add(plugin); + plugin.Initialize(); +} + +new Task(async () => +{ + while (true) + { + foreach (var plugin in loadedPlugins) + { + await plugin.UpdateAsync(); + } + await Task.Delay(300); + } +}).Start(); + +while (true) +{ + Console.Clear(); + + foreach (var plugin in loadedPlugins) + { + Console.Write("-"); + Console.WriteLine($"{plugin.Name} ({plugin.GetType().FullName})"); + var panelDatas = plugin.GetData(); + + foreach (var panelData in panelDatas) + { + Console.Write("--"); + Console.WriteLine($"{panelData.Name}: {panelData.Value}{panelData.Unit}"); + } + + Console.WriteLine(); + } + + Thread.Sleep(10); +} + diff --git a/InfoPanel.Plugins/IPlugin.cs b/InfoPanel.Plugins/IPlugin.cs new file mode 100644 index 0000000..77a5484 --- /dev/null +++ b/InfoPanel.Plugins/IPlugin.cs @@ -0,0 +1,11 @@ +namespace InfoPanel.Plugins +{ + public interface IPlugin + { + string Name { get; } + void Initialize(); + List GetData(); + Task UpdateAsync(); + void Close(); + } +} diff --git a/InfoPanel.Plugins/IPluginSensor.cs b/InfoPanel.Plugins/IPluginSensor.cs new file mode 100644 index 0000000..ee14992 --- /dev/null +++ b/InfoPanel.Plugins/IPluginSensor.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace InfoPanel.Plugins +{ + public enum IPluginSensorValueType + { + Double, + String + } + + public interface IPluginSensor + { + string Id { get; } + string Name { get; } + IPluginSensorValueType ValueType { get; } + object Value { get; set; } + string? Unit { get; } + } +} diff --git a/InfoPanel.Contract/InfoPanel.Contract.csproj b/InfoPanel.Plugins/InfoPanel.Plugins.csproj similarity index 84% rename from InfoPanel.Contract/InfoPanel.Contract.csproj rename to InfoPanel.Plugins/InfoPanel.Plugins.csproj index fa71b7a..9d1c41f 100644 --- a/InfoPanel.Contract/InfoPanel.Contract.csproj +++ b/InfoPanel.Plugins/InfoPanel.Plugins.csproj @@ -4,6 +4,7 @@ net8.0 enable enable + AnyCPU;x64 diff --git a/InfoPanel.VolumePlugin/InfoPanel.Extras.csproj b/InfoPanel.VolumePlugin/InfoPanel.Extras.csproj new file mode 100644 index 0000000..0c0bbbd --- /dev/null +++ b/InfoPanel.VolumePlugin/InfoPanel.Extras.csproj @@ -0,0 +1,28 @@ + + + + net8.0-windows + enable + enable + true + x64 + + + + + + + + + + + false + runtime + + + + + + + + diff --git a/InfoPanel.VolumePlugin/VolumePlugin.cs b/InfoPanel.VolumePlugin/VolumePlugin.cs new file mode 100644 index 0000000..8ca1e77 --- /dev/null +++ b/InfoPanel.VolumePlugin/VolumePlugin.cs @@ -0,0 +1,35 @@ +using InfoPanel.Plugins; +using NAudio.CoreAudioApi; + +namespace InfoPanel.Extras +{ + public class VolumePlugin : IPlugin + { + private MMDeviceEnumerator? _deviceEnumerator; + private readonly VolumeSensor _volumeSensor = new(); + + string IPlugin.Name => "Volume Plugin"; + + void IPlugin.Initialize() + { + _deviceEnumerator = new MMDeviceEnumerator(); + } + + void IPlugin.Close() + { + _deviceEnumerator?.Dispose(); + } + + List IPlugin.GetData() + { + return [_volumeSensor]; + } + + Task IPlugin.UpdateAsync() + { + using var defaultDevice = _deviceEnumerator?.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia); + _volumeSensor.Value = Math.Round((defaultDevice?.AudioEndpointVolume.MasterVolumeLevelScalar ?? 0) * 100); + return Task.CompletedTask; + } + } +} diff --git a/InfoPanel.VolumePlugin/VolumeSensor.cs b/InfoPanel.VolumePlugin/VolumeSensor.cs new file mode 100644 index 0000000..e812078 --- /dev/null +++ b/InfoPanel.VolumePlugin/VolumeSensor.cs @@ -0,0 +1,19 @@ +using InfoPanel.Plugins; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace InfoPanel.Extras +{ + internal class VolumeSensor() : IPluginSensor + { + public string Id => "volume"; + public string Name => "Master Volume"; + public IPluginSensorValueType ValueType => IPluginSensorValueType.Double; + public object Value { get; set; } = 0; + public string? Unit => "%"; + + } +} diff --git a/InfoPanel.VolumePlugin/WeatherPlugin.cs b/InfoPanel.VolumePlugin/WeatherPlugin.cs new file mode 100644 index 0000000..dafda7d --- /dev/null +++ b/InfoPanel.VolumePlugin/WeatherPlugin.cs @@ -0,0 +1,147 @@ +using InfoPanel.Plugins; +using IniParser; +using IniParser.Model; +using OpenWeatherMap.Standard; +using System.Diagnostics; +using System.Reflection; + +namespace InfoPanel.Extras +{ + public class WeatherPlugin : IPlugin + { + private readonly Stopwatch _stopwatch = new(); + + private Current? _current; + private string? _city; + + private readonly WeatherSensor _name = new("name", "Name", IPluginSensorValueType.String, "-"); + private readonly WeatherSensor _weather = new("weather", "Weather", IPluginSensorValueType.String, "-"); + private readonly WeatherSensor _weatherDesc = new("weather_desc", "Weather Description", IPluginSensorValueType.String, "-"); + private readonly WeatherSensor _weatherIcon = new("weather_icon", "Weather Icon", IPluginSensorValueType.String, "-"); + private readonly WeatherSensor _weatherIconUrl = new("weather_icon_url", "Weather Icon URL", IPluginSensorValueType.String, "-"); + + private readonly WeatherSensor _temp = new("temp", "Temperature", IPluginSensorValueType.Double, 0, "°C"); + private readonly WeatherSensor _maxTemp = new("max_temp", "Maximum Temperature", IPluginSensorValueType.Double, 0, "°C"); + private readonly WeatherSensor _minTemp = new("min_temp", "Minimum Temperature", IPluginSensorValueType.Double, 0, "°C"); + private readonly WeatherSensor _pressure = new("pressure", "Pressure", IPluginSensorValueType.Double, 0, "hPa"); + private readonly WeatherSensor _seaLevel = new("sea_level", "Sea Level", IPluginSensorValueType.Double, 0, "hPa"); + private readonly WeatherSensor _groundLevel = new("ground_level", "Ground Level", IPluginSensorValueType.Double, 0, "hPa"); + private readonly WeatherSensor _feelsLike = new("feels_like", "Feels Like", IPluginSensorValueType.Double, 0, "°C"); + private readonly WeatherSensor _humidity = new("humidity", "Humidity", IPluginSensorValueType.Double, 0, "%"); + + private readonly WeatherSensor _windSpeed = new("wind_speed", "Wind Speed", IPluginSensorValueType.Double, 0, "m/s"); + private readonly WeatherSensor _windDeg = new("wind_deg", "Wind Degree", IPluginSensorValueType.Double, 0, "°"); + private readonly WeatherSensor _windGust = new("wind_gust", "Wind Gust", IPluginSensorValueType.Double, 0, "m/s"); + + private readonly WeatherSensor _clouds = new("clouds", "Clouds", IPluginSensorValueType.Double, 0, "%"); + + private readonly WeatherSensor _rain = new("rain", "Rain", IPluginSensorValueType.Double, 0, "mm/h"); + private readonly WeatherSensor _snow = new("snow", "Snow", IPluginSensorValueType.Double, 0, "mm/h"); + + string IPlugin.Name => "Weather Plugin"; + + void IPlugin.Initialize() + { + Assembly assembly = Assembly.GetExecutingAssembly(); + var configPath = $"{assembly.ManifestModule.FullyQualifiedName}.ini"; + + var parser = new FileIniDataParser(); + IniData config; + if (!File.Exists(configPath)) + { + config = new IniData(); + config["Weather Plugin"]["APIKey"] = ""; + config["Weather Plugin"]["City"] = "Singapore"; + parser.WriteFile(configPath, config); + }else + { + config = parser.ReadFile(configPath); + + var apiKey = config["Weather Plugin"]["APIKey"]; + _city = config["Weather Plugin"]["City"]; + + if(!string.IsNullOrEmpty(apiKey) && !string.IsNullOrEmpty(_city)) + { + _current = new(apiKey, OpenWeatherMap.Standard.Enums.WeatherUnits.Metric); + } + } + } + + void IPlugin.Close() + { + } + + List IPlugin.GetData() + { + return [ + _name, + _weather, + _weatherDesc, + _weatherIcon, + _weatherIconUrl, + _temp, + _maxTemp, + _minTemp, + _pressure, + _seaLevel, + _groundLevel, + _feelsLike, + _humidity, + _windSpeed, + _windDeg, + _windGust, + _clouds, + _rain, + _snow + ]; + } + + async Task IPlugin.UpdateAsync() + { + // Update weather data every minute + if (!_stopwatch.IsRunning || _stopwatch.ElapsedMilliseconds > 60000) + { + Trace.WriteLine("WeatherPlugin: Getting weather data"); + await GetWeather(); + _stopwatch.Restart(); + } + } + + private async Task GetWeather() + { + if(_current == null) + { + return; + } + + var result = await _current.GetWeatherDataByCityNameAsync("Singapore"); + + if (result != null) + { + _name.Value = result.Name; + _weather.Value = result.Weathers[0].Main; + _weatherDesc.Value = result.Weathers[0].Description; + _weatherIcon.Value = result.Weathers[0].Icon; + _weatherIconUrl.Value = $"https://openweathermap.org/img/wn/{result.Weathers[0].Icon}@2x.png"; + + _temp.Value = result.WeatherDayInfo.Temperature; + _maxTemp.Value = result.WeatherDayInfo.MaximumTemperature; + _minTemp.Value = result.WeatherDayInfo.MinimumTemperature; + _pressure.Value = result.WeatherDayInfo.Pressure; + _seaLevel.Value = result.WeatherDayInfo.SeaLevel; + _groundLevel.Value = result.WeatherDayInfo.GroundLevel; + _feelsLike.Value = result.WeatherDayInfo.FeelsLike; + _humidity.Value = result.WeatherDayInfo.Humidity; + + _windSpeed.Value = result.Wind.Speed; + _windDeg.Value = result.Wind.Degree; + _windGust.Value = result.Wind.Gust; + + _clouds.Value = result.Clouds.All; + + _rain.Value = result.Rain.LastHour; + _snow.Value = result.Snow.LastHour; + } + } + } +} diff --git a/InfoPanel.VolumePlugin/WeatherSensor.cs b/InfoPanel.VolumePlugin/WeatherSensor.cs new file mode 100644 index 0000000..cfaf6f6 --- /dev/null +++ b/InfoPanel.VolumePlugin/WeatherSensor.cs @@ -0,0 +1,19 @@ +using InfoPanel.Plugins; +using OpenWeatherMap.Standard.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace InfoPanel.Extras +{ + internal class WeatherSensor(string id, string name, IPluginSensorValueType valueType, object value, string? unit = null): IPluginSensor + { + public string Id => id; + public string Name => name; + public IPluginSensorValueType ValueType => valueType; + public object Value { get; set; } = value; + public string? Unit => unit; + } +} diff --git a/InfoPanel.sln b/InfoPanel.sln index 4e53ce8..fd001ad 100644 --- a/InfoPanel.sln +++ b/InfoPanel.sln @@ -5,7 +5,13 @@ VisualStudioVersion = 17.6.33815.320 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfoPanel", "InfoPanel\InfoPanel.csproj", "{59D47BC5-EBEE-48EC-BCF4-09C4BB0A31A8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfoPanel.Contract", "InfoPanel.Contract\InfoPanel.Contract.csproj", "{336F46A0-A634-4B65-9082-DA9C00313658}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InfoPanel.Extras", "InfoPanel.VolumePlugin\InfoPanel.Extras.csproj", "{DABE7840-A86C-410D-B420-29C716A0A9FA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InfoPanel.Plugins", "InfoPanel.Plugins\InfoPanel.Plugins.csproj", "{903C16DD-BF96-44B7-B058-17F587194E89}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InfoPanel.Plugins.Simulator", "InfoPanel.Plugins.Simulator\InfoPanel.Plugins.Simulator.csproj", "{2573766B-535D-49FC-867F-5255568A1940}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InfoPanel.Plugins.Loader", "InfoPanel.Plugins.Loader\InfoPanel.Plugins.Loader.csproj", "{299B147B-6B0C-430F-9B91-AC1FB80AAF95}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -29,18 +35,54 @@ Global {59D47BC5-EBEE-48EC-BCF4-09C4BB0A31A8}.Release|x64.Build.0 = Release|x64 {59D47BC5-EBEE-48EC-BCF4-09C4BB0A31A8}.Release|x86.ActiveCfg = Release|Any CPU {59D47BC5-EBEE-48EC-BCF4-09C4BB0A31A8}.Release|x86.Build.0 = Release|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Debug|Any CPU.Build.0 = Debug|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Debug|x64.ActiveCfg = Debug|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Debug|x64.Build.0 = Debug|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Debug|x86.ActiveCfg = Debug|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Debug|x86.Build.0 = Debug|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Release|Any CPU.ActiveCfg = Release|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Release|Any CPU.Build.0 = Release|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Release|x64.ActiveCfg = Release|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Release|x64.Build.0 = Release|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Release|x86.ActiveCfg = Release|Any CPU - {336F46A0-A634-4B65-9082-DA9C00313658}.Release|x86.Build.0 = Release|Any CPU + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Debug|x64.ActiveCfg = Debug|x64 + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Debug|x64.Build.0 = Debug|x64 + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Debug|x86.ActiveCfg = Debug|Any CPU + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Debug|x86.Build.0 = Debug|Any CPU + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Release|Any CPU.Build.0 = Release|Any CPU + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Release|x64.ActiveCfg = Release|Any CPU + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Release|x64.Build.0 = Release|Any CPU + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Release|x86.ActiveCfg = Release|Any CPU + {DABE7840-A86C-410D-B420-29C716A0A9FA}.Release|x86.Build.0 = Release|Any CPU + {903C16DD-BF96-44B7-B058-17F587194E89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {903C16DD-BF96-44B7-B058-17F587194E89}.Debug|Any CPU.Build.0 = Debug|Any CPU + {903C16DD-BF96-44B7-B058-17F587194E89}.Debug|x64.ActiveCfg = Debug|x64 + {903C16DD-BF96-44B7-B058-17F587194E89}.Debug|x64.Build.0 = Debug|x64 + {903C16DD-BF96-44B7-B058-17F587194E89}.Debug|x86.ActiveCfg = Debug|Any CPU + {903C16DD-BF96-44B7-B058-17F587194E89}.Debug|x86.Build.0 = Debug|Any CPU + {903C16DD-BF96-44B7-B058-17F587194E89}.Release|Any CPU.ActiveCfg = Release|Any CPU + {903C16DD-BF96-44B7-B058-17F587194E89}.Release|Any CPU.Build.0 = Release|Any CPU + {903C16DD-BF96-44B7-B058-17F587194E89}.Release|x64.ActiveCfg = Release|Any CPU + {903C16DD-BF96-44B7-B058-17F587194E89}.Release|x64.Build.0 = Release|Any CPU + {903C16DD-BF96-44B7-B058-17F587194E89}.Release|x86.ActiveCfg = Release|Any CPU + {903C16DD-BF96-44B7-B058-17F587194E89}.Release|x86.Build.0 = Release|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Debug|x64.ActiveCfg = Debug|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Debug|x64.Build.0 = Debug|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Debug|x86.ActiveCfg = Debug|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Debug|x86.Build.0 = Debug|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Release|Any CPU.Build.0 = Release|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Release|x64.ActiveCfg = Release|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Release|x64.Build.0 = Release|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Release|x86.ActiveCfg = Release|Any CPU + {2573766B-535D-49FC-867F-5255568A1940}.Release|x86.Build.0 = Release|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Debug|Any CPU.Build.0 = Debug|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Debug|x64.ActiveCfg = Debug|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Debug|x64.Build.0 = Debug|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Debug|x86.ActiveCfg = Debug|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Debug|x86.Build.0 = Debug|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Release|Any CPU.ActiveCfg = Release|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Release|Any CPU.Build.0 = Release|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Release|x64.ActiveCfg = Release|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Release|x64.Build.0 = Release|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Release|x86.ActiveCfg = Release|Any CPU + {299B147B-6B0C-430F-9B91-AC1FB80AAF95}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/InfoPanel/App.xaml.cs b/InfoPanel/App.xaml.cs index 4272355..e4deb65 100644 --- a/InfoPanel/App.xaml.cs +++ b/InfoPanel/App.xaml.cs @@ -1,5 +1,6 @@ using InfoPanel.Models; using InfoPanel.Monitors; +using InfoPanel.Plugins.Loader; using InfoPanel.Services; using InfoPanel.Utils; using InfoPanel.ViewModels; @@ -8,7 +9,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Win32; -using Prise.DependencyInjection; using Sentry; using System; using System.Collections.Generic; @@ -36,9 +36,6 @@ public partial class App : System.Windows.Application //.ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)); }) .ConfigureServices((context, services) => { - //add plugins - services.AddPrise(); - // App Host services.AddHostedService(); @@ -116,7 +113,7 @@ void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptio SentrySdk.CaptureException(e.Exception); // If you want to avoid the application from crashing: - e.Handled = true; + //e.Handled = true; } protected override void OnExit(ExitEventArgs e) @@ -202,9 +199,7 @@ protected override async void OnStartup(StartupEventArgs e) await StartPanels(); - - //var video = new VideoBackgroundItem("C:\\Users\\Habib\\Desktop\\88inchENG\\video\\rani.mp4"); - //await video.Test(); + testPlugin(); } private void OnSessionEnding(object sender, SessionEndingEventArgs e) @@ -337,9 +332,8 @@ private void DisplayWindow_Closed(object? sender, EventArgs e) public void testPlugin() { - // var pluginPath = Path.Combine(AppContext.BaseDirectory, "plugins"); //set the path where people should put plugins. I chose a folder called plugins in the same directory as the exe - - //var scanResult = await this._pluginLoader.FindPlugin(pluginPath); + var pluginLoader = new PluginLoader(); + pluginLoader.test("plugins"); } } } diff --git a/InfoPanel/Drawing/PanelDraw.cs b/InfoPanel/Drawing/PanelDraw.cs index 0b7d756..3ec77ae 100644 --- a/InfoPanel/Drawing/PanelDraw.cs +++ b/InfoPanel/Drawing/PanelDraw.cs @@ -7,8 +7,6 @@ using System.Drawing.Drawing2D; using System.Linq; using System.Numerics; -using System.Windows.Media.Media3D; -using Windows.Graphics.Imaging; namespace InfoPanel.Drawing { diff --git a/InfoPanel/InfoPanel.csproj b/InfoPanel/InfoPanel.csproj index 8026b42..cba0aea 100644 --- a/InfoPanel/InfoPanel.csproj +++ b/InfoPanel/InfoPanel.csproj @@ -2,18 +2,17 @@ WinExe - net8.0-windows10.0.17763.0 + net8.0-windows enable true true Resources\Images\favicon.ico - x64;AnyCPU + x64 $(AssemblyVersion) $(AssemblyVersion) 1.2.8.0 False en - AnyCPU Resources\app.manifest @@ -160,7 +159,6 @@ - @@ -170,6 +168,11 @@ + + + + + @@ -258,4 +261,12 @@ + + diff --git a/InfoPanel/Services/BeadaPanelTask.cs b/InfoPanel/Services/BeadaPanelTask.cs index d8611c4..17941a3 100644 --- a/InfoPanel/Services/BeadaPanelTask.cs +++ b/InfoPanel/Services/BeadaPanelTask.cs @@ -12,8 +12,6 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; -using System.Windows.Forms; -using Windows.Storage.Streams; namespace InfoPanel { diff --git a/InfoPanel/Utils/SensorMapping.cs b/InfoPanel/Utils/SensorMapping.cs index f3e8f2f..7c7810b 100644 --- a/InfoPanel/Utils/SensorMapping.cs +++ b/InfoPanel/Utils/SensorMapping.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Windows.Media.Capture.Core; namespace InfoPanel.Utils {