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] More features, more interfaces, some optimizations #28

Merged
merged 21 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
cf3cf97
💾 Feat(PluginCard): Click plugin card to open plugin detail window.
Dynesshely May 21, 2023
7e97db5
💾 Feat(PluginsServer): Now can use `Send`, `Broadcast` functions.
Dynesshely May 22, 2023
18ea769
💾 Feat(PluginsSystem): Move messages processor into `PluginsNetwork`.
Dynesshely May 22, 2023
cb329ee
💾 Feat(NetworkHelper): Enhanced `NetworkHelper`.
Dynesshely May 24, 2023
1377eac
🔧 Fix(Settings_PerformenceView): Fixed selected network interfaces di…
Dynesshely May 24, 2023
0fff383
🎇 Style: Enhanced codes.
Dynesshely May 24, 2023
ba2dd61
💾 Feat(DeviceCard): Wider and larger.
Dynesshely May 24, 2023
a7e0549
🎇 Style(DevicesNetwork): Better codes.
Dynesshely May 24, 2023
065b46d
🎇 Style(DeviceCard): Shorter string cutter for device name.
Dynesshely May 24, 2023
66e2288
💾 Feat(PluginDetailWindow): If not running on `MS-Windows`, use theme…
Dynesshely May 26, 2023
ed9e47d
💾 Feat(PluginDetailWindow): Use `try-catch` to catch error in setting…
Dynesshely May 26, 2023
5ebc5af
🎇 Style(WebManager): Cut usings.
Dynesshely May 28, 2023
c430a52
💾 Feat(Views, ViewModels): New window `PluginsLaunchWindow`.
Dynesshely May 28, 2023
c680dfb
💾 Feat(HotKeyManager): Enable global hot key manager and init at star…
Dynesshely May 28, 2023
353bf83
💾 Feat(HotKeyManager): Decoupling the view part.
Dynesshely May 30, 2023
2b6b3f6
💾 Feat(Program): Init `HotKeyManager` instance app scope.
Dynesshely May 30, 2023
773ee0b
💾 Feat(PluginsLaunchWindow): Accept on hide action, register hot key …
Dynesshely May 30, 2023
a211c39
💾 Feat(PluginsLaunchWindow): Close at app exiting.
Dynesshely May 30, 2023
4c68cd7
💾 Feat(PluginsLaunchWindow): Default with top most set to true.
Dynesshely May 30, 2023
e7fd002
💾 Feat(App): Global plugins launch window instance in program, and in…
Dynesshely May 30, 2023
26bd227
💾 Feat(MainWindow): More info in tray icon tip text.
Dynesshely Jun 14, 2023
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
12 changes: 6 additions & 6 deletions Data/GlobalInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ internal static class GlobalInfo

internal const string UpdateSavePath = "./Update/";

internal const string configFilePath = $"{ConfigPath}config.json";
internal const string IconBase64FileName = "KitX.Base64.txt";

internal const string pluginsListConfigFilePath = $"{ConfigPath}plugins.json";
internal const int LastBreakAfterExit = 2000;

internal const string activitiesDataBaseFilePath = $"{DataPath}Activities.db";
private const string configFilePath = $"{ConfigPath}config.json";

internal const string thirdPartLicenseFilePath = $"{AssetsPath}ThirdPartLicense.md";
private const string pluginsListConfigFilePath = $"{ConfigPath}plugins.json";

internal const string IconBase64FileName = "KitX.Base64.txt";
private const string activitiesDataBaseFilePath = $"{DataPath}Activities.db";

internal const int LastBreakAfterExit = 2000;
private const string thirdPartLicenseFilePath = $"{AssetsPath}ThirdPartLicense.md";

internal static string ConfigFilePath => configFilePath.GetFullPath();

Expand Down
21 changes: 20 additions & 1 deletion Helper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Common.BasicHelper.IO;
using Avalonia.Threading;
using Common.BasicHelper.IO;
using Common.BasicHelper.Utils.Extensions;
using KitX_Dashboard.Data;
using KitX_Dashboard.Managers;
Expand Down Expand Up @@ -172,6 +173,24 @@ public static void StartUpCheck()

#endregion

#region 初始化热键系统

Program.HotKeyManager = new HotKeyManager().Hook();

#endregion

#region 初始化持久的窗口

Program.SignalTasksManager.SignalRun(nameof(SignalsNames.MainWindowInitSignal), () =>
{
Dispatcher.UIThread.Post(() =>
{
Program.PluginsLaunchWindow = new();
});
});

#endregion

}

/// <summary>
Expand Down
10 changes: 6 additions & 4 deletions KitX Dashboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationIcon>Assets\KitX-Icon-256x.ico</ApplicationIcon>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>

<PropertyGroup>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
<Version>3.23.04.$([System.DateTime]::UtcNow.Date.Subtract($([System.DateTime]::Parse("2005-06-06"))).TotalDays)</Version>
Expand All @@ -19,10 +21,6 @@
<DefineConstants>IsBuild4WindowsPlatform</DefineConstants>
</PropertyGroup>

<!--<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="6.0.0-*" />
</ItemGroup>-->

<!--用于将依赖移动到 Libraries 目录, 使根目录更加整洁-->
<PropertyGroup>
<BeautySharedRuntimeMode>False</BeautySharedRuntimeMode>
Expand Down Expand Up @@ -57,6 +55,9 @@
<AvaloniaXaml Remove="Languages\ru-ru.axaml" />
<AvaloniaXaml Remove="Languages\zh-cn.axaml" />
<AvaloniaXaml Remove="Languages\zh-tw.axaml" />
</ItemGroup>

<ItemGroup>
<AvaloniaXaml Remove="FakesAssemblies\**" />
<Compile Remove="FakesAssemblies\**" />
<EmbeddedResource Remove="FakesAssemblies\**" />
Expand Down Expand Up @@ -102,6 +103,7 @@
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.2.1" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="SharpHook" Version="4.2.0" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.5.1" />
</ItemGroup>
<ItemGroup>
Expand Down
77 changes: 77 additions & 0 deletions Managers/HotKeyManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Common.BasicHelper.Utils.Extensions;
using SharpHook;
using SharpHook.Native;
using System;
using System.Collections.Generic;

namespace KitX_Dashboard.Managers;

internal class HotKeyManager
{
private const int keysLimitation = 5;

private readonly Queue<KeyCode>? keyPressed;

private readonly Dictionary<string, Action<KeyCode[]>>? hotKeyHandlers;

public HotKeyManager()
{
keyPressed = new();

hotKeyHandlers = new();
}

public HotKeyManager Hook()
{
var hook = new TaskPoolGlobalHook();

hook.KeyPressed += (_, args) =>
{
keyPressed!.Enqueue(args.Data.KeyCode);

if (keyPressed!.Count > keysLimitation)
_ = keyPressed.Dequeue();

VerifyKeys();
};

hook.RunAsync();

return this;
}

private void VerifyKeys()
{
var index = 0;

var tmpList = new KeyCode[keysLimitation];

keyPressed!.ForEach(x =>
{
tmpList[index] = x;

++index;

}, true);

foreach (var handler in hotKeyHandlers!.Values)
handler.Invoke(tmpList);
}

public HotKeyManager RegisterHotKeyHandler(string name, Action<KeyCode[]> handler)
{
hotKeyHandlers!.Add(name, handler);

return this;
}

public HotKeyManager UnregisterHotKeyHandler(string name)
{
if (hotKeyHandlers!.TryGetValue(name, out _))
{
hotKeyHandlers.Remove(name);
}

return this;
}
}
13 changes: 6 additions & 7 deletions Managers/WebManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Common.BasicHelper.Core.TaskSystem;
using KitX_Dashboard.Network;
using KitX_Dashboard.Network;
using Serilog;
using System;
using System.Collections.ObjectModel;
Expand All @@ -9,16 +8,16 @@ namespace KitX_Dashboard.Managers;

public class WebManager : IDisposable
{
public WebManager()
{
NetworkInterfaceRegistered = new();
}

internal PluginsServer? pluginsServer;
internal DevicesDiscoveryServer? devicesDiscoveryServer;

internal ObservableCollection<string>? NetworkInterfaceRegistered;

public WebManager()
{
NetworkInterfaceRegistered = new();
}

/// <summary>
/// 开始执行网络相关服务
/// </summary>
Expand Down
Loading