mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-08-13 11:39:52 +00:00
Implement all functions from the Electron App-API
This commit is contained in:
@@ -86,6 +86,7 @@ namespace ElectronNET.API
|
||||
|
||||
_socket.On("appGetAppPathCompleted", (path) =>
|
||||
{
|
||||
_socket.Off("appGetAppPathCompleted");
|
||||
taskCompletionSource.SetResult(path.ToString());
|
||||
});
|
||||
|
||||
@@ -100,6 +101,8 @@ namespace ElectronNET.API
|
||||
|
||||
_socket.On("appGetPathCompleted", (path) =>
|
||||
{
|
||||
_socket.Off("appGetPathCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(path.ToString());
|
||||
});
|
||||
|
||||
@@ -108,6 +111,593 @@ namespace ElectronNET.API
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public static void Blub2() { }
|
||||
// TODO: Fertig coden
|
||||
//public async static Task<NativeImage> GetFileIconAsync(string filePath)
|
||||
//{
|
||||
// var taskCompletionSource = new TaskCompletionSource<NativeImage>();
|
||||
|
||||
// _socket.On("appGetFileIconCompleted", (results) =>
|
||||
// {
|
||||
// _socket.Off("appGetFileIconCompleted");
|
||||
|
||||
// byte[] test = ((JArray)results).Last.ToObject<byte[]>();
|
||||
|
||||
|
||||
// //object[] result = results as object[];
|
||||
// //NativeImage nativeImage = (NativeImage)result[1];
|
||||
// //taskCompletionSource.SetResult(nativeImage);
|
||||
// });
|
||||
// _socket.Emit("appGetFileIcon", filePath);
|
||||
|
||||
// return await taskCompletionSource.Task;
|
||||
//}
|
||||
|
||||
// TODO: Fertig coden
|
||||
//public async static Task<NativeImage> GetFileIconAsync(string filePath, FileIconOptions fileIconOptions)
|
||||
//{
|
||||
// var taskCompletionSource = new TaskCompletionSource<NativeImage>();
|
||||
|
||||
// _socket.On("appGetFileIconCompleted", (results) =>
|
||||
// {
|
||||
// _socket.Off("appGetFileIconCompleted");
|
||||
|
||||
// object[] result = results as object[];
|
||||
// NativeImage nativeImage = (NativeImage)result[1];
|
||||
// taskCompletionSource.SetResult(nativeImage);
|
||||
// });
|
||||
// _socket.Emit("appGetFileIcon", filePath, JObject.FromObject(fileIconOptions, _jsonSerializer));
|
||||
|
||||
// return await taskCompletionSource.Task;
|
||||
//}
|
||||
|
||||
public static void SetPath(string name, string path)
|
||||
{
|
||||
_socket.Emit("appSetPath", name, path);
|
||||
}
|
||||
|
||||
public async static Task<string> GetVersionAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
_socket.On("appGetVersionCompleted", (version) =>
|
||||
{
|
||||
_socket.Off("appGetVersionCompleted");
|
||||
taskCompletionSource.SetResult(version.ToString());
|
||||
});
|
||||
|
||||
_socket.Emit("appGetVersion");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<string> GetNameAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
_socket.On("appGetNameCompleted", (name) =>
|
||||
{
|
||||
_socket.Off("appGetNameCompleted");
|
||||
taskCompletionSource.SetResult(name.ToString());
|
||||
});
|
||||
|
||||
_socket.Emit("appGetName");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public static void SetName(string name)
|
||||
{
|
||||
_socket.Emit("appSetName", name);
|
||||
}
|
||||
|
||||
public async static Task<string> GetLocaleAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
_socket.On("appGetLocaleCompleted", (locale) =>
|
||||
{
|
||||
_socket.Off("appGetLocaleCompleted");
|
||||
taskCompletionSource.SetResult(locale.ToString());
|
||||
});
|
||||
|
||||
_socket.Emit("appGetLocale");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public static void AddRecentDocument(string path)
|
||||
{
|
||||
_socket.Emit("appAddRecentDocument", path);
|
||||
}
|
||||
|
||||
public static void ClearRecentDocuments()
|
||||
{
|
||||
_socket.Emit("appClearRecentDocuments");
|
||||
}
|
||||
|
||||
public async static Task<bool> SetAsDefaultProtocolClientAsync(string protocol)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appSetAsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appSetAsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Emit("appSetAsDefaultProtocolClient", protocol);
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<bool> SetAsDefaultProtocolClientAsync(string protocol, string path)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appSetAsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appSetAsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Emit("appSetAsDefaultProtocolClient", protocol, path);
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<bool> SetAsDefaultProtocolClientAsync(string protocol, string path, string[] args)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appSetAsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appSetAsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Emit("appSetAsDefaultProtocolClient", protocol, path, args);
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appRemoveAsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appRemoveAsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Emit("appRemoveAsDefaultProtocolClient", protocol);
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appRemoveAsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appRemoveAsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Emit("appRemoveAsDefaultProtocolClient", protocol, path);
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, string[] args)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appRemoveAsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appRemoveAsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Emit("appRemoveAsDefaultProtocolClient", protocol, path, args);
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<bool> IsDefaultProtocolClientAsync(string protocol)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appIsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appIsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Emit("appIsDefaultProtocolClient", protocol);
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<bool> IsDefaultProtocolClientAsync(string protocol, string path)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appIsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appIsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Emit("appIsDefaultProtocolClient", protocol, path);
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<bool> IsDefaultProtocolClientAsync(string protocol, string path, string[] args)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appIsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appIsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Emit("appIsDefaultProtocolClient", protocol, path, args);
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<bool> SetUserTasksAsync(UserTask[] userTasks)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appSetUserTasksCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appSetUserTasksCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Emit("appSetUserTasks", JObject.FromObject(userTasks, _jsonSerializer));
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<JumpListSettings> GetJumpListSettingsAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<JumpListSettings>();
|
||||
|
||||
_socket.On("appGetJumpListSettingsCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appGetJumpListSettingsCompleted");
|
||||
taskCompletionSource.SetResult(JObject.Parse(success.ToString()).ToObject<JumpListSettings>());
|
||||
});
|
||||
|
||||
_socket.Emit("appGetJumpListSettings");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public static void SetJumpList(JumpListCategory[] jumpListCategories)
|
||||
{
|
||||
_socket.Emit("appSetJumpList", JObject.FromObject(jumpListCategories, _jsonSerializer));
|
||||
}
|
||||
|
||||
public async static Task<bool> MakeSingleInstanceAsync(Action<string[], string> newInstanceOpened)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appMakeSingleInstanceCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appMakeSingleInstanceCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Off("newInstanceOpened");
|
||||
_socket.On("newInstanceOpened", (result) =>
|
||||
{
|
||||
JArray results = (JArray)result;
|
||||
string[] args = results.First.ToObject<string[]>();
|
||||
string workdirectory = results.Last.ToObject<string>();
|
||||
|
||||
newInstanceOpened(args, workdirectory);
|
||||
});
|
||||
|
||||
_socket.Emit("appMakeSingleInstance");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public static void ReleaseSingleInstance()
|
||||
{
|
||||
_socket.Emit("appReleaseSingleInstance");
|
||||
}
|
||||
|
||||
public static void SetUserActivity(string type, object userInfo)
|
||||
{
|
||||
_socket.Emit("appSetUserActivity", type, userInfo);
|
||||
}
|
||||
|
||||
public static void SetUserActivity(string type, object userInfo, string webpageURL)
|
||||
{
|
||||
_socket.Emit("appSetUserActivity", type, userInfo, webpageURL);
|
||||
}
|
||||
|
||||
public async static Task<string> GetCurrentActivityTypeAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
_socket.On("appGetCurrentActivityTypeCompleted", (activityType) =>
|
||||
{
|
||||
_socket.Off("appGetCurrentActivityTypeCompleted");
|
||||
taskCompletionSource.SetResult(activityType.ToString());
|
||||
});
|
||||
|
||||
_socket.Emit("appGetCurrentActivityType");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public static void SetAppUserModelId(string id)
|
||||
{
|
||||
_socket.Emit("appSetAppUserModelId", id);
|
||||
}
|
||||
|
||||
public async static Task<int> ImportCertificateAsync(ImportCertificateOptions options)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<int>();
|
||||
|
||||
_socket.On("appImportCertificateCompleted", (result) =>
|
||||
{
|
||||
_socket.Off("appImportCertificateCompleted");
|
||||
taskCompletionSource.SetResult((int)result);
|
||||
});
|
||||
|
||||
_socket.Emit("appImportCertificate", JObject.FromObject(options, _jsonSerializer));
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<ProcessMetric[]> GetAppMetricsAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<ProcessMetric[]>();
|
||||
|
||||
_socket.On("appGetAppMetricsCompleted", (result) =>
|
||||
{
|
||||
_socket.Off("appGetAppMetricsCompleted");
|
||||
var processMetrics = ((JArray)result).ToObject<ProcessMetric[]>();
|
||||
|
||||
taskCompletionSource.SetResult(processMetrics);
|
||||
});
|
||||
|
||||
_socket.Emit("appGetAppMetrics");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<GPUFeatureStatus> GetGpuFeatureStatusAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<GPUFeatureStatus>();
|
||||
|
||||
_socket.On("appGetGpuFeatureStatusCompleted", (result) =>
|
||||
{
|
||||
_socket.Off("appGetGpuFeatureStatusCompleted");
|
||||
var gpuFeatureStatus = ((JObject)result).ToObject<GPUFeatureStatus>();
|
||||
|
||||
taskCompletionSource.SetResult(gpuFeatureStatus);
|
||||
});
|
||||
|
||||
_socket.Emit("appGetGpuFeatureStatus");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<bool> SetBadgeCountAsync(int count)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appSetBadgeCountCompleted", (success) =>
|
||||
{
|
||||
_socket.Off("appSetBadgeCountCompleted");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
_socket.Emit("appSetBadgeCount", count);
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<int> GetBadgeCountAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<int>();
|
||||
|
||||
_socket.On("appGetBadgeCountCompleted", (count) =>
|
||||
{
|
||||
_socket.Off("appGetBadgeCountCompleted");
|
||||
taskCompletionSource.SetResult((int)count);
|
||||
});
|
||||
|
||||
_socket.Emit("appGetBadgeCount");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<bool> IsUnityRunningAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appIsUnityRunningCompleted", (isUnityRunning) =>
|
||||
{
|
||||
_socket.Off("appIsUnityRunningCompleted");
|
||||
taskCompletionSource.SetResult((bool)isUnityRunning);
|
||||
});
|
||||
|
||||
_socket.Emit("appIsUnityRunning");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<LoginItemSettings> GetLoginItemSettingsAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<LoginItemSettings>();
|
||||
|
||||
_socket.On("appGetLoginItemSettingsCompleted", (loginItemSettings) =>
|
||||
{
|
||||
_socket.Off("appGetLoginItemSettingsCompleted");
|
||||
taskCompletionSource.SetResult((LoginItemSettings)loginItemSettings);
|
||||
});
|
||||
|
||||
_socket.Emit("appGetLoginItemSettings");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public async static Task<LoginItemSettings> GetLoginItemSettingsAsync(LoginItemSettingsOptions options)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<LoginItemSettings>();
|
||||
|
||||
_socket.On("appGetLoginItemSettingsCompleted", (loginItemSettings) =>
|
||||
{
|
||||
_socket.Off("appGetLoginItemSettingsCompleted");
|
||||
taskCompletionSource.SetResult((LoginItemSettings)loginItemSettings);
|
||||
});
|
||||
|
||||
_socket.Emit("appGetLoginItemSettings", JObject.FromObject(options, _jsonSerializer));
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public static void SetLoginItemSettings(LoginSettings loginSettings)
|
||||
{
|
||||
_socket.Emit("appSetLoginItemSettings", JObject.FromObject(loginSettings, _jsonSerializer));
|
||||
}
|
||||
|
||||
public async static Task<bool> IsAccessibilitySupportEnabledAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appIsAccessibilitySupportEnabledCompleted", (isAccessibilitySupportEnabled) =>
|
||||
{
|
||||
_socket.Off("appIsAccessibilitySupportEnabledCompleted");
|
||||
taskCompletionSource.SetResult((bool)isAccessibilitySupportEnabled);
|
||||
});
|
||||
|
||||
_socket.Emit("appIsAccessibilitySupportEnabled");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public static void SetAboutPanelOptions(AboutPanelOptions options)
|
||||
{
|
||||
_socket.Emit("appSetAboutPanelOptions", JObject.FromObject(options, _jsonSerializer));
|
||||
}
|
||||
|
||||
public static void CommandLineAppendSwitch(string theSwtich)
|
||||
{
|
||||
_socket.Emit("appCommandLineAppendSwitch", theSwtich);
|
||||
}
|
||||
|
||||
public static void CommandLineAppendSwitch(string theSwtich, string value)
|
||||
{
|
||||
_socket.Emit("appCommandLineAppendSwitch", theSwtich, value);
|
||||
}
|
||||
|
||||
public static void CommandLineAppendArgument(string value)
|
||||
{
|
||||
_socket.Emit("appCommandLineAppendArgument", value);
|
||||
}
|
||||
|
||||
public static void EnableMixedSandbox()
|
||||
{
|
||||
_socket.Emit("appEnableMixedSandbox");
|
||||
}
|
||||
|
||||
public async static Task<int> DockBounceAsync(DockBounceType type)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<int>();
|
||||
|
||||
_socket.On("appDockBounceCompleted", (id) =>
|
||||
{
|
||||
_socket.Off("appDockBounceCompleted");
|
||||
taskCompletionSource.SetResult((int)id);
|
||||
});
|
||||
|
||||
_socket.Emit("appDockBounce", type.ToString());
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public static void DockCancelBounce(int id)
|
||||
{
|
||||
_socket.Emit("appDockCancelBounce", id);
|
||||
}
|
||||
|
||||
public static void DockDownloadFinished(string filePath)
|
||||
{
|
||||
_socket.Emit("appDockDownloadFinished", filePath);
|
||||
}
|
||||
|
||||
public static void DockSetBadge(string text)
|
||||
{
|
||||
_socket.Emit("appDockSetBadge", text);
|
||||
}
|
||||
|
||||
public async static Task<string> DockGetBadgeAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
_socket.On("appDockGetBadgeCompleted", (text) =>
|
||||
{
|
||||
_socket.Off("appDockGetBadgeCompleted");
|
||||
taskCompletionSource.SetResult((string)text);
|
||||
});
|
||||
|
||||
_socket.Emit("appDockGetBadge");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public static void DockHide()
|
||||
{
|
||||
_socket.Emit("appDockHide");
|
||||
}
|
||||
|
||||
public static void DockShow()
|
||||
{
|
||||
_socket.Emit("appDockShow");
|
||||
}
|
||||
|
||||
public async static Task<bool> DockIsVisibleAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
_socket.On("appDockIsVisibleCompleted", (isVisible) =>
|
||||
{
|
||||
_socket.Off("appDockIsVisibleCompleted");
|
||||
taskCompletionSource.SetResult((bool)isVisible);
|
||||
});
|
||||
|
||||
_socket.Emit("appDockIsVisible");
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
// TODO: Menu lösung muss gemacht werden und imeplementiert
|
||||
public static void DockSetMenu()
|
||||
{
|
||||
_socket.Emit("appDockSetMenu");
|
||||
}
|
||||
|
||||
public static void DockSetIcon(string image)
|
||||
{
|
||||
_socket.Emit("appDockSetIcon", image);
|
||||
}
|
||||
|
||||
//public static void DockSetIcon(NativeImage image)
|
||||
//{
|
||||
// _socket.Emit("appDockSetIcon", JObject.FromObject(image, _jsonSerializer));
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
30
ElectronNET.API/Entities/AboutPanelOptions.cs
Normal file
30
ElectronNET.API/Entities/AboutPanelOptions.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class AboutPanelOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The app's name.
|
||||
/// </summary>
|
||||
public string ApplicationName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The app's version.
|
||||
/// </summary>
|
||||
public string ApplicationVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Copyright information.
|
||||
/// </summary>
|
||||
public string Copyright { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Credit information.
|
||||
/// </summary>
|
||||
public string Credits { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The app's build version number.
|
||||
/// </summary>
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
||||
16
ElectronNET.API/Entities/CPUUsage.cs
Normal file
16
ElectronNET.API/Entities/CPUUsage.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class CPUUsage
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of average idle cpu wakeups per second since the last call to
|
||||
/// getCPUUsage.First call returns 0.
|
||||
/// </summary>
|
||||
public int IdleWakeupsPerSecond { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Percentage of CPU used since the last call to getCPUUsage. First call returns 0.
|
||||
/// </summary>
|
||||
public int PercentCPUUsage { get; set; }
|
||||
}
|
||||
}
|
||||
8
ElectronNET.API/Entities/DockBounceType.cs
Normal file
8
ElectronNET.API/Entities/DockBounceType.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
public enum DockBounceType
|
||||
{
|
||||
critical,
|
||||
informational
|
||||
}
|
||||
}
|
||||
12
ElectronNET.API/Entities/FileIconOptions.cs
Normal file
12
ElectronNET.API/Entities/FileIconOptions.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class FileIconOptions
|
||||
{
|
||||
public string Size { get; private set; }
|
||||
|
||||
public FileIconOptions(FileIconSize fileIconSize)
|
||||
{
|
||||
Size = fileIconSize.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
9
ElectronNET.API/Entities/FileIconSize.cs
Normal file
9
ElectronNET.API/Entities/FileIconSize.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public enum FileIconSize
|
||||
{
|
||||
small,
|
||||
normal,
|
||||
large
|
||||
}
|
||||
}
|
||||
82
ElectronNET.API/Entities/GPUFeatureStatus.cs
Normal file
82
ElectronNET.API/Entities/GPUFeatureStatus.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class GPUFeatureStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Canvas
|
||||
/// </summary>
|
||||
[JsonProperty("2d_canvas")]
|
||||
public string Canvas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash
|
||||
/// </summary>
|
||||
[JsonProperty("flash_3d")]
|
||||
public string Flash3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash Stage3D
|
||||
/// </summary>
|
||||
[JsonProperty("flash_stage3d")]
|
||||
public string FlashStage3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash Stage3D Baseline profile
|
||||
/// </summary>
|
||||
[JsonProperty("flash_stage3d_baseline")]
|
||||
public string FlashStage3dBaseline { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Compositing
|
||||
/// </summary>
|
||||
[JsonProperty("gpu_compositing")]
|
||||
public string GpuCompositing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Multiple Raster Threads
|
||||
/// </summary>
|
||||
[JsonProperty("multiple_raster_threads")]
|
||||
public string MultipleRasterThreads { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Native GpuMemoryBuffers
|
||||
/// </summary>
|
||||
[JsonProperty("native_gpu_memory_buffers")]
|
||||
public string NativeGpuMemoryBuffers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Rasterization
|
||||
/// </summary>
|
||||
public string Rasterization { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Video Decode
|
||||
/// </summary>
|
||||
[JsonProperty("video_decode")]
|
||||
public string VideoDecode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Video Encode
|
||||
/// </summary>
|
||||
[JsonProperty("video_encode")]
|
||||
public string VideoEncode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// VPx Video Decode
|
||||
/// </summary>
|
||||
[JsonProperty("vpx_decode")]
|
||||
public string VpxDecode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// WebGL
|
||||
/// </summary>
|
||||
public string Webgl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// WebGL2
|
||||
/// </summary>
|
||||
public string Webgl2 { get; set; }
|
||||
}
|
||||
}
|
||||
15
ElectronNET.API/Entities/ImportCertificateOptions.cs
Normal file
15
ElectronNET.API/Entities/ImportCertificateOptions.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class ImportCertificateOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Path for the pkcs12 file.
|
||||
/// </summary>
|
||||
public string Certificate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Passphrase for the certificate.
|
||||
/// </summary>
|
||||
public string Password {get; set; }
|
||||
}
|
||||
}
|
||||
11
ElectronNET.API/Entities/JumpListCategory.cs
Normal file
11
ElectronNET.API/Entities/JumpListCategory.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using ElectronNET.API.Entities;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
public class JumpListCategory
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public JumpListItem[] Items { get; set; } = new JumpListItem[0];
|
||||
public string Type { get; set; } = "tasks";
|
||||
}
|
||||
}
|
||||
14
ElectronNET.API/Entities/JumpListItem.cs
Normal file
14
ElectronNET.API/Entities/JumpListItem.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class JumpListItem
|
||||
{
|
||||
public string Args { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public int IconIndex { get; set; } = 0;
|
||||
public string IconPath { get; set; } = string.Empty;
|
||||
public string Path { get; set; } = string.Empty;
|
||||
public string Program { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Type {get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
9
ElectronNET.API/Entities/JumpListSettings.cs
Normal file
9
ElectronNET.API/Entities/JumpListSettings.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class JumpListSettings
|
||||
{
|
||||
public int MinItems { get; set; } = 0;
|
||||
|
||||
public JumpListItem[] RemovedItems { get; set; } = new JumpListItem[0];
|
||||
}
|
||||
}
|
||||
36
ElectronNET.API/Entities/LoginItemSettings.cs
Normal file
36
ElectronNET.API/Entities/LoginItemSettings.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class LoginItemSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// true if the app is set to open at login.
|
||||
/// </summary>
|
||||
public bool OpenAtLogin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// true if the app is set to open as hidden at login. This setting is only
|
||||
/// supported on macOS.
|
||||
/// </summary>
|
||||
public bool OpenAsHidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// true if the app was opened at login automatically. This setting is only
|
||||
/// supported on macOS.
|
||||
/// </summary>
|
||||
public bool WasOpenedAtLogin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// true if the app was opened as a hidden login item. This indicates that the app
|
||||
/// should not open any windows at startup.This setting is only supported on macOS.
|
||||
/// </summary>
|
||||
public bool WasOpenedAsHidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// true if the app was opened as a login item that should restore the state from
|
||||
/// the previous session.This indicates that the app should restore the windows
|
||||
/// that were open the last time the app was closed.This setting is only supported
|
||||
/// on macOS.
|
||||
/// </summary>
|
||||
public bool RestoreState { get; set; }
|
||||
}
|
||||
}
|
||||
15
ElectronNET.API/Entities/LoginItemSettingsOptions.cs
Normal file
15
ElectronNET.API/Entities/LoginItemSettingsOptions.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class LoginItemSettingsOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The executable path to compare against. Defaults to process.execPath.
|
||||
/// </summary>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The command-line arguments to compare against. Defaults to an empty array.
|
||||
/// </summary>
|
||||
public string[] Args { get; set; }
|
||||
}
|
||||
}
|
||||
30
ElectronNET.API/Entities/LoginSettings.cs
Normal file
30
ElectronNET.API/Entities/LoginSettings.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class LoginSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// true to open the app at login, false to remove the app as a login item. Defaults
|
||||
/// to false.
|
||||
/// </summary>
|
||||
public bool OpenAtLogin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// true to open the app as hidden. Defaults to false. The user can edit this
|
||||
/// setting from the System Preferences so
|
||||
/// app.getLoginItemStatus().wasOpenedAsHidden should be checked when the app is
|
||||
/// opened to know the current value.This setting is only supported on macOS.
|
||||
/// </summary>
|
||||
public bool OpenAsHidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The executable to launch at login. Defaults to process.execPath.
|
||||
/// </summary>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The command-line arguments to pass to the executable. Defaults to an empty
|
||||
/// array.Take care to wrap paths in quotes.
|
||||
/// </summary>
|
||||
public string[] Args { get; set; }
|
||||
}
|
||||
}
|
||||
33
ElectronNET.API/Entities/MemoryInfo.cs
Normal file
33
ElectronNET.API/Entities/MemoryInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class MemoryInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The maximum amount of memory that has ever been pinned to actual physical RAM.
|
||||
/// On macOS its value will always be 0.
|
||||
/// </summary>
|
||||
public int PeakWorkingSetSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Process id of the process.
|
||||
/// </summary>
|
||||
public int Pid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of memory not shared by other processes, such as JS heap or HTML
|
||||
/// content.
|
||||
/// </summary>
|
||||
public int PrivateBytes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of memory shared between processes, typically memory consumed by the
|
||||
/// Electron code itself
|
||||
/// </summary>
|
||||
public int SharedBytes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of memory currently pinned to actual physical RAM.
|
||||
/// </summary>
|
||||
public int WorkingSetSize {get; set; }
|
||||
}
|
||||
}
|
||||
106
ElectronNET.API/Entities/NativeImage.cs
Normal file
106
ElectronNET.API/Entities/NativeImage.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
// TODO: Fertig coden
|
||||
public class NativeImage
|
||||
{
|
||||
// public static NativeImage CreateEmpty()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public static NativeImage CreateFromBuffer(byte[] buffer)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public static NativeImage CreateFromBuffer(byte[] buffer, CreateFromBufferOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public static NativeImage CreateFromDataURL(string dataURL)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public static NativeImage CreateFromPath(string path)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public void AddRepresentation(AddRepresentationOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public NativeImage Crop(Rectangle rect)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public int GetAspectRatio()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public byte[] GetBitmap()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public byte[] GetBitmap(BitmapOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public byte[] GetNativeHandle()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public Size GetSize()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public bool IsEmpty()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public bool IsTemplateImage()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public NativeImage Resize(ResizeOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public void SetTemplateImage(bool option)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public byte[] ToBitmap(ToBitmapOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public string ToDataURL(ToDataURLOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public byte[] ToJPEG(int quality)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
// public byte[] ToPNG(ToPNGOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
}
|
||||
}
|
||||
25
ElectronNET.API/Entities/ProcessMetric.cs
Normal file
25
ElectronNET.API/Entities/ProcessMetric.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class ProcessMetric
|
||||
{
|
||||
/// <summary>
|
||||
/// CPU usage of the process.
|
||||
/// </summary>
|
||||
public CPUUsage Cpu { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Memory information for the process.
|
||||
/// </summary>
|
||||
public MemoryInfo Memory {get; set;}
|
||||
|
||||
/// <summary>
|
||||
/// Process id of the process.
|
||||
/// </summary>
|
||||
public int Pid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Process type (Browser or Tab or GPU etc).
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
}
|
||||
}
|
||||
12
ElectronNET.API/Entities/UserTask.cs
Normal file
12
ElectronNET.API/Entities/UserTask.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class UserTask
|
||||
{
|
||||
public string Arguments { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int IconIndex { get; set; }
|
||||
public string IconPath { get; set; }
|
||||
public string Program { get; set; }
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,4 @@
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\ipc.js" Link="ElectronHost\api\ipc.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="$(ProjectDir)devCleanup.cmd" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -28,5 +28,167 @@ module.exports = function (socket, app) {
|
||||
var path = app.getPath(name);
|
||||
socket.emit('appGetPathCompleted', path);
|
||||
});
|
||||
socket.on('appGetFileIcon', function (path, options) {
|
||||
if (options) {
|
||||
app.getFileIcon(path, options, function (error, nativeImage) {
|
||||
socket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
app.getFileIcon(path, function (error, nativeImage) {
|
||||
socket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('appSetPath', function (name, path) {
|
||||
app.setPath(name, path);
|
||||
});
|
||||
socket.on('appGetVersion', function () {
|
||||
var version = app.getVersion();
|
||||
socket.emit('appGetVersionCompleted', version);
|
||||
});
|
||||
socket.on('appGetName', function () {
|
||||
var name = app.getName();
|
||||
socket.emit('appGetNameCompleted', name);
|
||||
});
|
||||
socket.on('appSetName', function (name) {
|
||||
app.setName(name);
|
||||
});
|
||||
socket.on('appGetLocale', function () {
|
||||
var locale = app.getLocale();
|
||||
socket.emit('appGetLocaleCompleted', locale);
|
||||
});
|
||||
socket.on('appAddRecentDocument', function (path) {
|
||||
app.addRecentDocument(path);
|
||||
});
|
||||
socket.on('appClearRecentDocuments', function () {
|
||||
app.clearRecentDocuments();
|
||||
});
|
||||
socket.on('appSetAsDefaultProtocolClient', function (protocol, path, args) {
|
||||
var success = app.setAsDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appSetAsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
socket.on('appRemoveAsDefaultProtocolClient', function (protocol, path, args) {
|
||||
var success = app.removeAsDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appRemoveAsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
socket.on('appIsDefaultProtocolClient', function (protocol, path, args) {
|
||||
var success = app.isDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appIsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
socket.on('appSetUserTasks', function (tasks) {
|
||||
var success = app.setUserTasks(tasks);
|
||||
socket.emit('appSetUserTasksCompleted', success);
|
||||
});
|
||||
socket.on('appGetJumpListSettings', function () {
|
||||
var jumpListSettings = app.getJumpListSettings();
|
||||
socket.emit('appGetJumpListSettingsCompleted', jumpListSettings);
|
||||
});
|
||||
socket.on('appSetJumpList', function (categories) {
|
||||
app.setJumpList(categories);
|
||||
});
|
||||
socket.on('appMakeSingleInstance', function () {
|
||||
var success = app.makeSingleInstance(function (args, workingDirectory) {
|
||||
socket.emit('newInstanceOpened', [args, workingDirectory]);
|
||||
});
|
||||
socket.emit('appMakeSingleInstanceCompleted', success);
|
||||
});
|
||||
socket.on('appReleaseSingleInstance', function () {
|
||||
app.releaseSingleInstance();
|
||||
});
|
||||
socket.on('appSetUserActivity', function (type, userInfo, webpageURL) {
|
||||
app.setUserActivity(type, userInfo, webpageURL);
|
||||
});
|
||||
socket.on('appGetCurrentActivityType', function () {
|
||||
var activityType = app.getCurrentActivityType();
|
||||
socket.emit('appGetCurrentActivityTypeCompleted', activityType);
|
||||
});
|
||||
socket.on('appSetAppUserModelId', function (id) {
|
||||
app.setAppUserModelId(id);
|
||||
});
|
||||
socket.on('appImportCertificate', function (options) {
|
||||
app.importCertificate(options, function (result) {
|
||||
socket.emit('appImportCertificateCompleted', result);
|
||||
});
|
||||
});
|
||||
socket.on('appGetAppMetrics', function () {
|
||||
var processMetrics = app.getAppMetrics();
|
||||
socket.emit('appGetAppMetricsCompleted', processMetrics);
|
||||
});
|
||||
socket.on('appGetGpuFeatureStatus', function () {
|
||||
// TS Workaround - TS say getGpuFeatureStatus - but it is getGPUFeatureStatus
|
||||
var x = app;
|
||||
var gpuFeatureStatus = x.getGPUFeatureStatus();
|
||||
socket.emit('appGetGpuFeatureStatusCompleted', gpuFeatureStatus);
|
||||
});
|
||||
socket.on('appSetBadgeCount', function (count) {
|
||||
var success = app.setBadgeCount(count);
|
||||
socket.emit('appSetBadgeCountCompleted', success);
|
||||
});
|
||||
socket.on('appGetBadgeCount', function () {
|
||||
var count = app.getBadgeCount();
|
||||
socket.emit('appGetBadgeCountCompleted', count);
|
||||
});
|
||||
socket.on('appIsUnityRunning', function () {
|
||||
var isUnityRunning = app.isUnityRunning();
|
||||
socket.emit('appIsUnityRunningCompleted', isUnityRunning);
|
||||
});
|
||||
socket.on('appGetLoginItemSettings', function (options) {
|
||||
var loginItemSettings = app.getLoginItemSettings(options);
|
||||
socket.emit('appGetLoginItemSettingsCompleted', loginItemSettings);
|
||||
});
|
||||
socket.on('appSetLoginItemSettings', function (settings) {
|
||||
app.setLoginItemSettings(settings);
|
||||
});
|
||||
socket.on('appIsAccessibilitySupportEnabled', function () {
|
||||
var isAccessibilitySupportEnabled = app.isAccessibilitySupportEnabled();
|
||||
socket.emit('appIsAccessibilitySupportEnabledCompleted', isAccessibilitySupportEnabled);
|
||||
});
|
||||
socket.on('appSetAboutPanelOptions', function (options) {
|
||||
app.setAboutPanelOptions(options);
|
||||
});
|
||||
socket.on('appCommandLineAppendSwitch', function (theSwitch, value) {
|
||||
app.commandLine.appendSwitch(theSwitch, value);
|
||||
});
|
||||
socket.on('appCommandLineAppendArgument', function (value) {
|
||||
app.commandLine.appendArgument(value);
|
||||
});
|
||||
socket.on('appEnableMixedSandbox', function () {
|
||||
app.enableMixedSandbox();
|
||||
});
|
||||
socket.on('appDockBounce', function (type) {
|
||||
var id = app.dock.bounce(type);
|
||||
socket.emit('appDockBounceCompleted', id);
|
||||
});
|
||||
socket.on('appDockCancelBounce', function (id) {
|
||||
app.dock.cancelBounce(id);
|
||||
});
|
||||
socket.on('appDockDownloadFinished', function (filePath) {
|
||||
app.dock.downloadFinished(filePath);
|
||||
});
|
||||
socket.on('appDockSetBadge', function (text) {
|
||||
app.dock.setBadge(text);
|
||||
});
|
||||
socket.on('appDockGetBadge', function () {
|
||||
var text = app.dock.getBadge();
|
||||
socket.emit('appDockGetBadgeCompleted', text);
|
||||
});
|
||||
socket.on('appDockHide', function () {
|
||||
app.dock.hide();
|
||||
});
|
||||
socket.on('appDockShow', function () {
|
||||
app.dock.show();
|
||||
});
|
||||
socket.on('appDockIsVisible', function () {
|
||||
var isVisible = app.dock.isVisible();
|
||||
socket.emit('appDockIsVisibleCompleted', isVisible);
|
||||
});
|
||||
// TODO: Menü Lösung muss noch implementiert werden
|
||||
socket.on('appDockSetMenu', function (menu) {
|
||||
app.dock.setMenu(menu);
|
||||
});
|
||||
socket.on('appDockSetIcon', function (image) {
|
||||
app.dock.setIcon(image);
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=app.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,11 +1,11 @@
|
||||
import {} from 'electron';
|
||||
import { nativeImage as NativeImage } from 'electron';
|
||||
|
||||
module.exports = (socket: SocketIO.Server, app: Electron.App) => {
|
||||
|
||||
socket.on('appQuit', () => {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
|
||||
socket.on('appExit', (exitCode = 0) => {
|
||||
app.exit(exitCode);
|
||||
});
|
||||
@@ -25,7 +25,7 @@ module.exports = (socket: SocketIO.Server, app: Electron.App) => {
|
||||
socket.on('appShow', () => {
|
||||
app.show();
|
||||
});
|
||||
|
||||
|
||||
socket.on('appGetAppPath', () => {
|
||||
const path = app.getAppPath();
|
||||
socket.emit('appGetAppPathCompleted', path);
|
||||
@@ -33,6 +33,221 @@ module.exports = (socket: SocketIO.Server, app: Electron.App) => {
|
||||
|
||||
socket.on('appGetPath', (name) => {
|
||||
const path = app.getPath(name);
|
||||
socket.emit('appGetPathCompleted', path);
|
||||
});
|
||||
socket.emit('appGetPathCompleted', path);
|
||||
});
|
||||
|
||||
// const nativeImages = {};
|
||||
|
||||
// function addNativeImage(nativeImage: Electron.NativeImage) {
|
||||
|
||||
// if(Object.keys(nativeImages).length === 0) {
|
||||
// nativeImage['1'] = nativeImage;
|
||||
// } else {
|
||||
// let indexCount = Object.keys(nativeImages).length + 1;
|
||||
// nativeImage[indexCount] = nativeImage;
|
||||
// }
|
||||
// }
|
||||
|
||||
socket.on('appGetFileIcon', (path, options) => {
|
||||
if(options) {
|
||||
app.getFileIcon(path, options, (error, nativeImage) => {
|
||||
socket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
});
|
||||
} else {
|
||||
app.getFileIcon(path, (error, nativeImage) => {
|
||||
socket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('appSetPath', (name, path) => {
|
||||
app.setPath(name, path);
|
||||
});
|
||||
|
||||
socket.on('appGetVersion', () => {
|
||||
const version = app.getVersion();
|
||||
socket.emit('appGetVersionCompleted', version);
|
||||
});
|
||||
|
||||
socket.on('appGetName', () => {
|
||||
const name = app.getName();
|
||||
socket.emit('appGetNameCompleted', name);
|
||||
});
|
||||
|
||||
socket.on('appSetName', (name) => {
|
||||
app.setName(name);
|
||||
});
|
||||
|
||||
socket.on('appGetLocale', () => {
|
||||
const locale = app.getLocale();
|
||||
socket.emit('appGetLocaleCompleted', locale);
|
||||
});
|
||||
|
||||
socket.on('appAddRecentDocument', (path) => {
|
||||
app.addRecentDocument(path);
|
||||
});
|
||||
|
||||
socket.on('appClearRecentDocuments', () => {
|
||||
app.clearRecentDocuments();
|
||||
});
|
||||
|
||||
socket.on('appSetAsDefaultProtocolClient', (protocol, path, args) => {
|
||||
const success = app.setAsDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appSetAsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appRemoveAsDefaultProtocolClient', (protocol, path, args) => {
|
||||
const success = app.removeAsDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appRemoveAsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appIsDefaultProtocolClient', (protocol, path, args) => {
|
||||
const success = app.isDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appIsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appSetUserTasks', (tasks) => {
|
||||
const success = app.setUserTasks(tasks);
|
||||
socket.emit('appSetUserTasksCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appGetJumpListSettings', () => {
|
||||
const jumpListSettings = app.getJumpListSettings();
|
||||
socket.emit('appGetJumpListSettingsCompleted', jumpListSettings);
|
||||
});
|
||||
|
||||
socket.on('appSetJumpList', (categories) => {
|
||||
app.setJumpList(categories);
|
||||
});
|
||||
|
||||
socket.on('appMakeSingleInstance', () => {
|
||||
const success = app.makeSingleInstance((args, workingDirectory) => {
|
||||
socket.emit('newInstanceOpened', [args, workingDirectory]);
|
||||
});
|
||||
socket.emit('appMakeSingleInstanceCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appReleaseSingleInstance', () => {
|
||||
app.releaseSingleInstance();
|
||||
});
|
||||
|
||||
socket.on('appSetUserActivity', (type, userInfo, webpageURL) => {
|
||||
app.setUserActivity(type, userInfo, webpageURL);
|
||||
});
|
||||
|
||||
socket.on('appGetCurrentActivityType', () => {
|
||||
const activityType = app.getCurrentActivityType();
|
||||
socket.emit('appGetCurrentActivityTypeCompleted', activityType);
|
||||
});
|
||||
|
||||
socket.on('appSetAppUserModelId', (id) => {
|
||||
app.setAppUserModelId(id);
|
||||
});
|
||||
|
||||
socket.on('appImportCertificate', (options) => {
|
||||
app.importCertificate(options, (result) => {
|
||||
socket.emit('appImportCertificateCompleted', result);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('appGetAppMetrics', () => {
|
||||
const processMetrics = app.getAppMetrics();
|
||||
socket.emit('appGetAppMetricsCompleted', processMetrics);
|
||||
});
|
||||
|
||||
socket.on('appGetGpuFeatureStatus', () => {
|
||||
// TS Workaround - TS say getGpuFeatureStatus - but it is getGPUFeatureStatus
|
||||
let x = <any>app;
|
||||
const gpuFeatureStatus = x.getGPUFeatureStatus();
|
||||
socket.emit('appGetGpuFeatureStatusCompleted', gpuFeatureStatus);
|
||||
});
|
||||
|
||||
socket.on('appSetBadgeCount', (count) => {
|
||||
const success = app.setBadgeCount(count);
|
||||
socket.emit('appSetBadgeCountCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appGetBadgeCount', () => {
|
||||
const count = app.getBadgeCount();
|
||||
socket.emit('appGetBadgeCountCompleted', count);
|
||||
});
|
||||
|
||||
socket.on('appIsUnityRunning', () => {
|
||||
const isUnityRunning = app.isUnityRunning();
|
||||
socket.emit('appIsUnityRunningCompleted', isUnityRunning);
|
||||
});
|
||||
|
||||
socket.on('appGetLoginItemSettings', (options) => {
|
||||
const loginItemSettings = app.getLoginItemSettings(options);
|
||||
socket.emit('appGetLoginItemSettingsCompleted', loginItemSettings);
|
||||
});
|
||||
|
||||
socket.on('appSetLoginItemSettings', (settings) => {
|
||||
app.setLoginItemSettings(settings);
|
||||
});
|
||||
|
||||
socket.on('appIsAccessibilitySupportEnabled', () => {
|
||||
const isAccessibilitySupportEnabled = app.isAccessibilitySupportEnabled();
|
||||
socket.emit('appIsAccessibilitySupportEnabledCompleted', isAccessibilitySupportEnabled);
|
||||
});
|
||||
|
||||
socket.on('appSetAboutPanelOptions', (options) => {
|
||||
app.setAboutPanelOptions(options);
|
||||
});
|
||||
|
||||
socket.on('appCommandLineAppendSwitch', (theSwitch, value) => {
|
||||
app.commandLine.appendSwitch(theSwitch, value);
|
||||
});
|
||||
|
||||
socket.on('appCommandLineAppendArgument', (value) => {
|
||||
app.commandLine.appendArgument(value);
|
||||
});
|
||||
|
||||
socket.on('appEnableMixedSandbox', () => {
|
||||
app.enableMixedSandbox();
|
||||
});
|
||||
|
||||
socket.on('appDockBounce', (type) => {
|
||||
const id = app.dock.bounce(type);
|
||||
socket.emit('appDockBounceCompleted', id);
|
||||
});
|
||||
|
||||
socket.on('appDockCancelBounce', (id) => {
|
||||
app.dock.cancelBounce(id);
|
||||
});
|
||||
|
||||
socket.on('appDockDownloadFinished', (filePath) => {
|
||||
app.dock.downloadFinished(filePath);
|
||||
});
|
||||
|
||||
socket.on('appDockSetBadge', (text) => {
|
||||
app.dock.setBadge(text);
|
||||
});
|
||||
|
||||
socket.on('appDockGetBadge', () => {
|
||||
const text = app.dock.getBadge();
|
||||
socket.emit('appDockGetBadgeCompleted', text);
|
||||
});
|
||||
|
||||
socket.on('appDockHide', () => {
|
||||
app.dock.hide();
|
||||
});
|
||||
|
||||
socket.on('appDockShow', () => {
|
||||
app.dock.show();
|
||||
});
|
||||
|
||||
socket.on('appDockIsVisible', () => {
|
||||
const isVisible = app.dock.isVisible();
|
||||
socket.emit('appDockIsVisibleCompleted', isVisible);
|
||||
});
|
||||
|
||||
// TODO: Menü Lösung muss noch implementiert werden
|
||||
socket.on('appDockSetMenu', (menu) => {
|
||||
app.dock.setMenu(menu);
|
||||
});
|
||||
|
||||
socket.on('appDockSetIcon', (image) => {
|
||||
app.dock.setIcon(image);
|
||||
});
|
||||
}
|
||||
@@ -20,9 +20,6 @@ function startSocketApiBridge(port) {
|
||||
appApi = require('./api/app')(socket, app);
|
||||
|
||||
socket.on('createBrowserWindow', (options) => {
|
||||
console.log(options);
|
||||
options.show = true;
|
||||
|
||||
window = new BrowserWindow(options);
|
||||
window.loadURL(loadURL);
|
||||
|
||||
@@ -45,14 +42,14 @@ function startSocketApiBridge(port) {
|
||||
function startAspCoreBackend(electronPort) {
|
||||
portfinder(8000, (error, electronWebPort) => {
|
||||
loadURL = `http://localhost:${electronWebPort}`
|
||||
const arguments = [`/electronPort=${electronPort}`, `/electronWebPort=${electronWebPort}`];
|
||||
const params = [`/electronPort=${electronPort}`, `/electronWebPort=${electronWebPort}`];
|
||||
|
||||
var binPath = path.join(__dirname, 'bin');
|
||||
fs.readdir(binPath, (error, files) => {
|
||||
const exeFiles = files.filter((name) => name.indexOf('.exe') > -1);
|
||||
const exeFileName = exeFiles[0];
|
||||
const apipath = path.join(binPath, exeFileName);
|
||||
apiProcess = process(apipath, arguments);
|
||||
apiProcess = process(apipath, params);
|
||||
|
||||
apiProcess.stdout.on('data', (data) => {
|
||||
var text = data.toString();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ElectronNET.API;
|
||||
using ElectronNET.API.Entities;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ElectronNET.WebApp.Controllers
|
||||
{
|
||||
@@ -21,7 +23,13 @@ namespace ElectronNET.WebApp.Controllers
|
||||
App.IpcMain.On("GetPath", async (args) =>
|
||||
{
|
||||
string pathName = await App.GetPathAsync(PathName.pictures);
|
||||
App.IpcMain.Send("GetPathComplete", pathName);
|
||||
//App.IpcMain.Send("GetPathComplete", pathName);
|
||||
|
||||
var result = await App.GetPathAsync(PathName.exe);
|
||||
//var imagePath = Path.Combine(result, "Electron.png");
|
||||
App.IpcMain.Send("GetPathComplete", result);
|
||||
|
||||
var image = await App.GetFileIconAsync(result);
|
||||
});
|
||||
|
||||
return View();
|
||||
|
||||
Reference in New Issue
Block a user