Skip to content

Adds a demonstration of BrowserWindow.SetProgressBar. #16

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

Merged
merged 1 commit into from
May 18, 2019
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
29 changes: 29 additions & 0 deletions ElectronNET-API-Demos/Controllers/ProgressBarController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using ElectronNET.API;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace ElectronNET_API_Demos.Controllers
{
public class ProgressBarController : Controller
{
public IActionResult Index()
{
if (HybridSupport.IsElectronActive)
{
Electron.IpcMain.On("set-progress-bar", async (args) =>
{
var mainWindow = Electron.WindowManager.BrowserWindows.First();
mainWindow.SetProgressBar(0.5);
});

Electron.IpcMain.On("clear-progress-bar", async (args) =>
{
var mainWindow = Electron.WindowManager.BrowserWindows.First();
mainWindow.SetProgressBar(-1);
});
}

return View();
}
}
}
2 changes: 2 additions & 0 deletions ElectronNET-API-Demos/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<link rel="import" href="appsysinformation">
<link rel="import" href="clipboard">
<link rel="import" href="pdf">
<link rel="import" href="progressbar">
<link rel="import" href="desktopcapturer">
</head>
<body>
Expand Down Expand Up @@ -61,6 +62,7 @@
<button type="button" id="button-notifications" data-section="notifications" class="nav-button"> Notifications with and without custom <em>image</em></button>
<button type="button" id="button-dialogs" data-section="dialogs" class="nav-button">Use system <em>dialogs</em></button>
<button type="button" id="button-tray" data-section="tray" class="nav-button">Put your app in the <em>tray</em></button>
<button type="button" id="button-progress-bar" data-section="progress-bar" class="nav-button">Show <em>progress</em></button>
</div>

<div class="nav-item u-category-communication">
Expand Down
69 changes: 69 additions & 0 deletions ElectronNET-API-Demos/Views/ProgressBar/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<template class="task-template">
<section id="progress-bar-section" class="section js-section u-category-native-ui">
<header class="section-header">
<div class="section-wrapper">
<h1>
Set Progress Bar
</h1>
<h3>The <code>BrowserWindow.SetProgressBar</code> method in Electron.NET allows you set a progress bar that appers in the task bar.</h3>

<p>This module works in the main process.</p>

<p>You find the sample source code in <code>Controllers\ProgressBarController.cs</code>.</p>
</div>
</header>

<div class="demo">
<div class="demo-wrapper">
<button id="set-progress-bar-toggle" class="js-container-target demo-toggle-button">
Set the Progress Bar in Taskbar
<div class="demo-meta u-avoid-clicks">Supports: Win, macOS, Linux (Unity only)<span class="demo-meta-divider">|</span> Process: Main</div>
</button>
<div class="demo-box">
<div class="demo-controls">
<button class="demo-button" id="set-progress-bar">View Demo</button>
</div>
<p>This demonstrates using the <code>BrowserWindow.SetProgressBar</code> to set the window's progress.</p>
<p>Clicking the demo button will set the progress to 50%.</p>
<h5>Main Process (C#)</h5>
<pre><code class="csharp">var mainWindow = Electron.WindowManager.BrowserWindows.First();
mainWindow.SetProgressBar(0.5);</code></pre>
</div>
</div>
</div>

<div class="demo">
<div class="demo-wrapper">
<button id="clear-progress-bar-toggle" class="js-container-target demo-toggle-button">
Clear the Progress Bar from Taskbar
<div class="demo-meta u-avoid-clicks">Supports: Win, macOS, Linux (Unity only)<span class="demo-meta-divider">|</span> Process: Main</div>
</button>
<div class="demo-box">
<div class="demo-controls">
<button class="demo-button" id="clear-progress-bar">View Demo</button>
</div>
<p>This demonstrates using the <code>BrowserWindow.SetProgressBar</code> to clear the window's progress.</p>
<h5>Main Process (C#)</h5>
<pre><code class="csharp">var mainWindow = Electron.WindowManager.BrowserWindows.First();
mainWindow.SetProgressBar(-1);</code></pre>
</div>
</div>
</div>

<script>
(function () {
const { ipcRenderer } = require("electron");

document.getElementById("set-progress-bar").addEventListener("click", () => {
ipcRenderer.send("set-progress-bar");
});

document.getElementById("clear-progress-bar").addEventListener("click", () => {
ipcRenderer.send("clear-progress-bar");
});
}());
</script>


</section>
</template>
2 changes: 1 addition & 1 deletion ElectronNET-API-Demos/Views/Shell/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ await Electron.Shell.ShowItemInFolderAsync(path);</code></pre>
<p>When the demo button is clicked, the electron website will open in your browser.<p>
<h5>Main Process (C#)</h5>
<pre><code class="csharp">await Electron.Shell.OpenExternalAsync("https://github.com/ElectronNET");</code></pre>
</div>
</div>
</div>
</div>

<script>
(function(){
Expand Down