|
| 1 | +<template class="task-template"> |
| 2 | + <section id="progress-bar-section" class="section js-section u-category-native-ui"> |
| 3 | + <header class="section-header"> |
| 4 | + <div class="section-wrapper"> |
| 5 | + <h1> |
| 6 | + Set Progress Bar |
| 7 | + </h1> |
| 8 | + <h3>The <code>BrowserWindow.SetProgressBar</code> method in Electron.NET allows you set a progress bar that appers in the task bar.</h3> |
| 9 | + |
| 10 | + <p>This module works in the main process.</p> |
| 11 | + |
| 12 | + <p>You find the sample source code in <code>Controllers\ProgressBarController.cs</code>.</p> |
| 13 | + </div> |
| 14 | + </header> |
| 15 | + |
| 16 | + <div class="demo"> |
| 17 | + <div class="demo-wrapper"> |
| 18 | + <button id="set-progress-bar-toggle" class="js-container-target demo-toggle-button"> |
| 19 | + Set the Progress Bar in Taskbar |
| 20 | + <div class="demo-meta u-avoid-clicks">Supports: Win, macOS, Linux (Unity only)<span class="demo-meta-divider">|</span> Process: Main</div> |
| 21 | + </button> |
| 22 | + <div class="demo-box"> |
| 23 | + <div class="demo-controls"> |
| 24 | + <button class="demo-button" id="set-progress-bar">View Demo</button> |
| 25 | + </div> |
| 26 | + <p>This demonstrates using the <code>BrowserWindow.SetProgressBar</code> to set the window's progress.</p> |
| 27 | + <p>Clicking the demo button will set the progress to 50%.</p> |
| 28 | + <h5>Main Process (C#)</h5> |
| 29 | + <pre><code class="csharp">var mainWindow = Electron.WindowManager.BrowserWindows.First(); |
| 30 | +mainWindow.SetProgressBar(0.5);</code></pre> |
| 31 | + </div> |
| 32 | + </div> |
| 33 | + </div> |
| 34 | + |
| 35 | + <div class="demo"> |
| 36 | + <div class="demo-wrapper"> |
| 37 | + <button id="clear-progress-bar-toggle" class="js-container-target demo-toggle-button"> |
| 38 | + Clear the Progress Bar from Taskbar |
| 39 | + <div class="demo-meta u-avoid-clicks">Supports: Win, macOS, Linux (Unity only)<span class="demo-meta-divider">|</span> Process: Main</div> |
| 40 | + </button> |
| 41 | + <div class="demo-box"> |
| 42 | + <div class="demo-controls"> |
| 43 | + <button class="demo-button" id="clear-progress-bar">View Demo</button> |
| 44 | + </div> |
| 45 | + <p>This demonstrates using the <code>BrowserWindow.SetProgressBar</code> to clear the window's progress.</p> |
| 46 | + <h5>Main Process (C#)</h5> |
| 47 | + <pre><code class="csharp">var mainWindow = Electron.WindowManager.BrowserWindows.First(); |
| 48 | +mainWindow.SetProgressBar(-1);</code></pre> |
| 49 | + </div> |
| 50 | + </div> |
| 51 | + </div> |
| 52 | + |
| 53 | + <script> |
| 54 | + (function () { |
| 55 | + const { ipcRenderer } = require("electron"); |
| 56 | +
|
| 57 | + document.getElementById("set-progress-bar").addEventListener("click", () => { |
| 58 | + ipcRenderer.send("set-progress-bar"); |
| 59 | + }); |
| 60 | +
|
| 61 | + document.getElementById("clear-progress-bar").addEventListener("click", () => { |
| 62 | + ipcRenderer.send("clear-progress-bar"); |
| 63 | + }); |
| 64 | + }()); |
| 65 | + </script> |
| 66 | + |
| 67 | + |
| 68 | + </section> |
| 69 | +</template> |
0 commit comments