Modules
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using VisionAsist.SDK;
|
||||
using System.Threading.Tasks;
|
||||
namespace VisionAsist.Models;
|
||||
|
||||
|
||||
|
||||
public class Core
|
||||
{
|
||||
public static TrigerCore triger = new();
|
||||
@@ -17,8 +21,7 @@ public class Core
|
||||
// Подписываемся на событие новых слов
|
||||
triger.OnRecognized += word =>
|
||||
{
|
||||
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
||||
Console.InputEncoding = System.Text.Encoding.UTF8;
|
||||
|
||||
Console.WriteLine(word); // печатаем сразу, как распознано
|
||||
TextAsist = triger.RecognizedText;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System.Collections.ObjectModel;
|
||||
using VisionAsist.Models;
|
||||
using VisionAsist.SDK;
|
||||
|
||||
namespace VisionAsist.ViewModels;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -39,6 +43,29 @@ public class SettingsViewModel : ViewModelBase
|
||||
|
||||
private void OpenSettings(string moduleName)
|
||||
{
|
||||
Console.WriteLine($"Нажата кнопка модуля: {moduleName}");
|
||||
string dllPath = Path.Combine(AppContext.BaseDirectory, "Modules", moduleName, "Module.dll");
|
||||
if (File.Exists(dllPath))
|
||||
{
|
||||
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
||||
Console.InputEncoding = System.Text.Encoding.UTF8;
|
||||
Assembly assembly = Assembly.LoadFrom(dllPath);
|
||||
var type = assembly.GetTypes().FirstOrDefault(t =>
|
||||
typeof(IModule).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract);
|
||||
if (type != null)
|
||||
{
|
||||
// 4. Создаем экземпляр класса (WeatherModule)
|
||||
var module = (IModule)Activator.CreateInstance(type)!;
|
||||
Console.WriteLine($"Успешно загружен модуль: {module.Name}");
|
||||
|
||||
// 5. Запускаем команду и передаем текущее окно (this) в качестве родителя
|
||||
var result = module.Execute("ShowWeather", new object[] { this });
|
||||
Console.WriteLine($"Ответ модуля: {result}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("В DLL не найден класс, реализующий VisionAsist.SDK.IModule!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,12 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.3.11"/>
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.11"/>
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.11"/>
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.11"/>
|
||||
<PackageReference Include="Avalonia" Version="11.3.12" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.12" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.12" />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.12" />
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.11">
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.12">
|
||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||
</PackageReference>
|
||||
@@ -25,4 +25,8 @@
|
||||
<PackageReference Include="NAudio" Version="2.3.0" />
|
||||
<PackageReference Include="Vosk" Version="0.3.38" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VisionAsist.SDK\VisionAsist.SDK.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user