Modules
This commit is contained in:
40
ModuleWeather/Module.cs
Normal file
40
ModuleWeather/Module.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace ModuleWeather;
|
||||
|
||||
public class WeatherModule
|
||||
{
|
||||
public string Name => "Прогноз Погоды";
|
||||
|
||||
public string[] GetCommands() => new[] { "ShowWeather", "Ping" };
|
||||
|
||||
public object Execute(string command, object[] args)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case "ShowWeather":
|
||||
// args[0] — это родительское окно из Ядра
|
||||
var parentWindow = args != null && args.Length > 0 ? args[0] as Window : null;
|
||||
|
||||
var win = new Window
|
||||
{
|
||||
Title = "Окно Погоды",
|
||||
Content = new WeatherView(), // Вставляем наш контрол
|
||||
Width = 350,
|
||||
Height = 250,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner
|
||||
};
|
||||
|
||||
if (parentWindow != null) win.Show(parentWindow);
|
||||
else win.Show();
|
||||
|
||||
return "Окно открыто успешно";
|
||||
|
||||
case "Ping":
|
||||
return "Pong! Модуль погоды активен.";
|
||||
|
||||
default:
|
||||
return "Команда не найдена";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user