Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pull Request] Crequency/KitX#278 #2

Merged
merged 5 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions TestPlugin.CSharp/Controller.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using KitX.Contract.CSharp;
using KitX.Web.Rules;
using KitX.Shared.Plugin;
using KitX.Shared.WebCommand;
using System.Text.Json;

namespace TestPlugin.CSharp;
Expand Down Expand Up @@ -30,7 +31,7 @@ public void Execute(Command cmd)

public List<Function> GetFunctions()
{
return new();
return [];
}

public void SetSendCommandAction(Action<Command> action) => sendCommandAction = action;
Expand All @@ -44,4 +45,9 @@ public void SetWorkPath(string path)
{
Console.WriteLine($"Work path: {path}");
}

public void SetCommandsSendBuffer(ref Queue<Command> commands)
{
throw new NotImplementedException();
}
}
4 changes: 2 additions & 2 deletions TestPlugin.CSharp/TestPlugin.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>Preview</LangVersion>
Expand All @@ -19,7 +19,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\KitX Contracts\KitX.Contract.CSharp\KitX.Contract.CSharp.csproj" />
<ProjectReference Include="..\..\..\KitX Standard\KitX Contracts\KitX.Contract.CSharp\KitX.Contract.CSharp.csproj" />
</ItemGroup>

</Project>
2 changes: 0 additions & 2 deletions TestPlugin.WPF.Core/Assets/Descr/zh-cn.md

This file was deleted.

93 changes: 26 additions & 67 deletions TestPlugin.WPF.Core/Controller.cs
Original file line number Diff line number Diff line change
@@ -1,82 +1,41 @@
using KitX.Contract.CSharp;
using KitX.Web.Rules;
using KitX.Shared.WebCommand;
using KitX.Shared.WebCommand.Details;
using System;
using System.Collections.Generic;
using System.Windows;

namespace TestPlugin.WPF.Core
{
public class Controller : IController
{
private readonly MainWindow mainwin;

public Controller(MainWindow mainwin)
{
this.mainwin = mainwin;
}

public void End()
{
mainwin.Close();
}
namespace TestPlugin.WPF.Core;

public void Pause()
{
mainwin.Hide();
}
public class Controller(MainWindow mainwin) : IController
{
private readonly MainWindow mainwin = mainwin;

public void Start()
{
mainwin.Show();
}
public PluginWorkingDetail? WorkingDetail { get; set; }

public List<Function> GetFunctions()
{
return new List<Function>()
{
new Function()
{
DisplayNames = new Dictionary<string, string>()
{
{ "zh-cn", "你好, 世界!" },
{ "en-us", "Hello, World!" }
},
Parameters = new Dictionary<string, Dictionary<string, string>>()
{
{
"par1",
new Dictionary<string, string>()
{
{ "zh-cn", "参数1" },
{ "en-us", "Parameter1" }
}
}
},
ParametersType = new List<string>()
{
"void"
},
HasAppendParameters = false,
ReturnValueType = "void"
}
};
}
public void End()
{
mainwin.Close();
}

public void Execute(Command command)
{
public void Pause()
{
mainwin.Hide();
}

}
public void Start()
{
mainwin.Show();
}

public void SetRootPath(string path)
public void Execute(Command command)
{
if (command.FunctionName.Equals("HelloKitX"))
{
MessageBox.Show($"SetRootPath({path})");
MessageBox.Show("Hello KitX !");
}
}

public void SetSendCommandAction(Action<Command> action) => mainwin.sendCommandAction = action;
public void SetWorkingDetail(PluginWorkingDetail workingDetail) => WorkingDetail = workingDetail;

public void SetWorkPath(string path)
{
MessageBox.Show($"SetWorkPath({path})");
}
}
public void SetSendCommandAction(Action<Request> action) => mainwin.sendCommandAction = action;
}
16 changes: 11 additions & 5 deletions TestPlugin.WPF.Core/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TestPlugin.WPF.Core"
mc:Ignorable="d" SizeToContent="WidthAndHeight"
Title="TestPlugin.WPF.Core - MainWindow" Background="#FF3873D9">
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="TestPlugin.WPF.Core - MainWindow"
Background="#FF3873D9"
SizeToContent="WidthAndHeight"
mc:Ignorable="d">
<Grid>
<TextBlock Text="Hello KitX!" HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="36" Margin="200,150" Foreground="White"/>
<TextBlock Margin="200,150"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="36"
Foreground="White"
Text="Hello KitX!"/>
</Grid>
</Window>
Loading