Skip to content

Commit fc2cf62

Browse files
first init
1 parent 2ea652f commit fc2cf62

File tree

149 files changed

+3736
-23334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+3736
-23334
lines changed

ElectronNET-API-Demos/.bowerrc

Lines changed: 0 additions & 3 deletions
This file was deleted.
273 KB
Binary file not shown.
1.25 KB
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace ElectronNET_API_Demos.Controllers
4+
{
5+
public class AboutController : Controller
6+
{
7+
public IActionResult Index()
8+
{
9+
return View();
10+
}
11+
}
12+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System.Linq;
2+
using Microsoft.AspNetCore.Mvc;
3+
using ElectronNET.API;
4+
using ElectronNET.API.Entities;
5+
6+
namespace ElectronNET_API_Demos.Controllers
7+
{
8+
public class AppSysInformationController : Controller
9+
{
10+
public IActionResult Index()
11+
{
12+
if(HybridSupport.IsElectronActive)
13+
{
14+
Electron.IpcMain.On("app-info", async (args) =>
15+
{
16+
string appPath = await Electron.App.GetAppPathAsync();
17+
18+
var mainWindow = Electron.WindowManager.BrowserWindows.First();
19+
Electron.IpcMain.Send(mainWindow, "got-app-path", appPath);
20+
});
21+
22+
Electron.IpcMain.On("sys-info", async (args) =>
23+
{
24+
string homePath = await Electron.App.GetPathAsync(PathName.home);
25+
26+
var mainWindow = Electron.WindowManager.BrowserWindows.First();
27+
Electron.IpcMain.Send(mainWindow, "got-sys-info", homePath);
28+
});
29+
30+
Electron.IpcMain.On("screen-info", async (args) =>
31+
{
32+
var display = await Electron.Screen.GetPrimaryDisplayAsync();
33+
34+
var mainWindow = Electron.WindowManager.BrowserWindows.First();
35+
Electron.IpcMain.Send(mainWindow, "got-screen-info", display.Size);
36+
});
37+
}
38+
39+
return View();
40+
}
41+
}
42+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using ElectronNET.API;
3+
using System.Linq;
4+
5+
namespace ElectronNET_API_Demos.Controllers
6+
{
7+
public class ClipboardController : Controller
8+
{
9+
public IActionResult Index()
10+
{
11+
if (HybridSupport.IsElectronActive)
12+
{
13+
Electron.IpcMain.On("copy-to", (text) =>
14+
{
15+
Electron.Clipboard.WriteText(text.ToString());
16+
});
17+
18+
Electron.IpcMain.On("paste-to", async (text) =>
19+
{
20+
Electron.Clipboard.WriteText(text.ToString());
21+
string pasteText = await Electron.Clipboard.ReadTextAsync();
22+
23+
var mainWindow = Electron.WindowManager.BrowserWindows.First();
24+
Electron.IpcMain.Send(mainWindow, "paste-from", pasteText);
25+
});
26+
}
27+
28+
return View();
29+
}
30+
}
31+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using ElectronNET.API;
3+
using ElectronNET.API.Entities;
4+
5+
namespace ElectronNET_API_Demos.Controllers
6+
{
7+
public class CrashHangController : Controller
8+
{
9+
public IActionResult Index()
10+
{
11+
if (HybridSupport.IsElectronActive)
12+
{
13+
Electron.IpcMain.On("process-crash", async (args) =>
14+
{
15+
string viewPath = $"http://localhost:{BridgeSettings.WebPort}/crashhang/processcrash";
16+
17+
var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath);
18+
browserWindow.WebContents.OnCrashed += async (killed) =>
19+
{
20+
var options = new MessageBoxOptions("This process has crashed.")
21+
{
22+
Type = MessageBoxType.info,
23+
Title = "Renderer Process Crashed",
24+
Buttons = new string[] { "Reload", "Close" }
25+
};
26+
var result = await Electron.Dialog.ShowMessageBoxAsync(options);
27+
28+
if (result.Response == 0)
29+
{
30+
browserWindow.Reload();
31+
}
32+
else
33+
{
34+
browserWindow.Close();
35+
}
36+
};
37+
});
38+
39+
Electron.IpcMain.On("process-hang", async (args) =>
40+
{
41+
string viewPath = $"http://localhost:{BridgeSettings.WebPort}/crashhang/processhang";
42+
43+
var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath);
44+
browserWindow.OnUnresponsive += async () =>
45+
{
46+
var options = new MessageBoxOptions("This process is hanging.")
47+
{
48+
Type = MessageBoxType.info,
49+
Title = "Renderer Process Hanging",
50+
Buttons = new string[] { "Reload", "Close" }
51+
};
52+
var result = await Electron.Dialog.ShowMessageBoxAsync(options);
53+
54+
if (result.Response == 0)
55+
{
56+
browserWindow.Reload();
57+
}
58+
else
59+
{
60+
browserWindow.Close();
61+
}
62+
};
63+
});
64+
}
65+
66+
return View();
67+
}
68+
69+
public IActionResult ProcessCrash()
70+
{
71+
return View();
72+
}
73+
74+
public IActionResult ProcessHang()
75+
{
76+
return View();
77+
}
78+
}
79+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace ElectronNET_API_Demos.Controllers
4+
{
5+
public class DesktopCapturerController : Controller
6+
{
7+
public IActionResult Index()
8+
{
9+
return View();
10+
}
11+
}
12+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System.Linq;
2+
using Microsoft.AspNetCore.Mvc;
3+
using ElectronNET.API;
4+
using ElectronNET.API.Entities;
5+
6+
namespace ElectronNET_API_Demos.Controllers
7+
{
8+
public class DialogsController : Controller
9+
{
10+
public IActionResult Index()
11+
{
12+
if(HybridSupport.IsElectronActive)
13+
{
14+
Electron.IpcMain.On("select-directory", async (args) => {
15+
var mainWindow = Electron.WindowManager.BrowserWindows.First();
16+
var options = new OpenDialogOptions
17+
{
18+
Properties = new OpenDialogProperty[] {
19+
OpenDialogProperty.openFile,
20+
OpenDialogProperty.openDirectory
21+
}
22+
};
23+
24+
string[] files = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options);
25+
Electron.IpcMain.Send(mainWindow, "select-directory-reply", files);
26+
});
27+
28+
Electron.IpcMain.On("error-dialog", (args) =>
29+
{
30+
Electron.Dialog.ShowErrorBox("An Error Message", "Demonstrating an error message.");
31+
});
32+
33+
Electron.IpcMain.On("information-dialog", async (args) =>
34+
{
35+
var options = new MessageBoxOptions("This is an information dialog. Isn't it nice?")
36+
{
37+
Type = MessageBoxType.info,
38+
Title = "Information",
39+
Buttons = new string[] { "Yes", "No" }
40+
};
41+
42+
var result = await Electron.Dialog.ShowMessageBoxAsync(options);
43+
44+
var mainWindow = Electron.WindowManager.BrowserWindows.First();
45+
Electron.IpcMain.Send(mainWindow, "information-dialog-reply", result.Response);
46+
});
47+
48+
Electron.IpcMain.On("save-dialog", async (args) =>
49+
{
50+
var mainWindow = Electron.WindowManager.BrowserWindows.First();
51+
var options = new SaveDialogOptions
52+
{
53+
Title = "Save an Image",
54+
Filters = new FileFilter[]
55+
{
56+
new FileFilter { Name = "Images", Extensions = new string[] {"jpg", "png", "gif" } }
57+
}
58+
};
59+
60+
var result = await Electron.Dialog.ShowSaveDialogAsync(mainWindow, options);
61+
Electron.IpcMain.Send(mainWindow, "save-dialog-reply", result);
62+
});
63+
}
64+
65+
return View();
66+
}
67+
}
68+
}
Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics;
4-
using System.Linq;
5-
using System.Threading.Tasks;
6-
using Microsoft.AspNetCore.Mvc;
7-
using ElectronNET_API_Demos.Models;
1+
using Microsoft.AspNetCore.Mvc;
82

93
namespace ElectronNET_API_Demos.Controllers
104
{
@@ -14,24 +8,5 @@ public IActionResult Index()
148
{
159
return View();
1610
}
17-
18-
public IActionResult About()
19-
{
20-
ViewData["Message"] = "Your application description page.";
21-
22-
return View();
23-
}
24-
25-
public IActionResult Contact()
26-
{
27-
ViewData["Message"] = "Your contact page.";
28-
29-
return View();
30-
}
31-
32-
public IActionResult Error()
33-
{
34-
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
35-
}
3611
}
37-
}
12+
}

0 commit comments

Comments
 (0)