Electron Mac Title Bar On Electron For Windows



Draggable region. By default, the frameless window is non-draggable. Apps need to specify -webkit-app-region: drag in CSS to tell Electron which regions are draggable (like the OS's standard titlebar), and apps can also use -webkit-app-region: no-drag to exclude the non-draggable area from the draggable region. Now when you run the application on a Mac, the menu bar will have three submenus named Electron, File, and View. Electron.NET also supports native system file dialogs.

This article provides a walkthrough for developing and deploying an application with Electron.NET.

Topics covered include:

Electron webview. This is a simple Electron application to create a webview. Features: Responsive window; Remember the window dimensions when reopening; Menu & keyboard shortcuts for MacOs; No title bar; Home button; Print function; MacOS, Windows and Linux executable with an app icon; DMG installer for Mac; This Electron webview application. Line 1: First, you import the app and BrowserWindow modules of the electron package to be able to manage your application's lifecycle events, as well as create and control browser windows. Line 3: After that, you define a function that creates a new browser window with node integration enabled, loads index.html file into this window (line 12.

  • Modifying the default ASP. NET Core application to use Electron.NET
  • Using Visual Studio Code to debug ASP. NET Razor pages
  • Implementing native UI elements such as message boxes, system file dialogs, and custom application menus
  • Adding third-party MVC controls
  • Building deployment media for other platforms

Recently, I had the honor of presenting this topic at the NDC Oslo online event. Here is my presentation in blog form, with a source code link at the end of the article.

What is Electron?

Electron is a framework that supports the development of desktop applications using web technologies such as the Chromium rendering engine and the Node.js runtime. Supported operating systems include Windows, macOS, and Linux. Chances are you have used at least one of these applications, which were all developed using Electron:

  • Visual Studio Code
  • Slack
  • Discord
  • Skype
  • GitHub Desktop
  • Twitch

Electron leverages familiar standards such as HTML, CSS, and JavaScript. But what if you are a .NET developer accustomed to working in C#? That's where Electron.NET comes in.

What is Electron.NET?

Electron.NET is a wrapper around a 'normal' Electron application with an embedded ASP. NET Core application. It is an open-source project that allows .NET developers to invoke native Electron APIs using C#. Electron.NET consists of two components:

  1. A NuGet package that adds Electron APIs to an ASP. NET Core project
  2. A .NET Core command-line extension that builds and launches applications for Windows, macOS, and Linux platforms.

Electron.NET requires prior installation of the following software:

I relied on Electron.NET to develop the C1DataEngine Workbench, a cross-platform tool that supports the creation and visualization of data analysis workspaces managed by the ComponentOne DataEngine library for .NET Standard. I initially planned to make this a standard Electron application that communicated with the library via shell commands that called out to a .NET Core global tool. But once I discovered Electron.NET, I was able to eliminate the shell commands and call the library directly.

See the C1DataEngine Workbench Application in Action - included with ComponentOne Service Components

Download the latest version of ComponentOne Studio Enterprise

Download Now!

Create an ASP. NET Core Web Application

For this exercise, I'm using Visual Studio Code running on a Mac. First, open a terminal window and run the following commands to create a new project called Processes.

When prompted by Visual Studio Code, say Yes to load the required assets for the project. Press F5 to build and run the application, opening a browser on the default ASP. NET Core welcome page, hosted on localhost:5001. Close the page, return to VS Code and stop debugging.

Electronize It!

Now let's turn our boilerplate ASP. NET Core project into an Electron application. This step involves adding a NuGet package to the project file, inserting some initialization code, and installing a command-line tool to perform builds. First, open the file Processes.csproj and insert a package reference for the Electron.NET API hosted on nuget.org:

Save the file, then restore packages when prompted to do so by VS Code. This action gives you immediate access to Intellisense for subsequent modifications to the code.

Next, edit Program.cs and insert a using statement for the newly added package:

Locate the static method CreateHostBuilder and insert the following two lines before the call to UseStartup:

The first line is necessary. The second is convenient during development, as it allows detailed error messages to be displayed.

Edit Startup.cs and insert the following using statements:

Locate the Configure method and add the following lines to the end of its body:

Finally, add the following method to the Startup class to create the main Electron window:

Since our application consists of a single window, we handle the OnClosed event to terminate the application if the user closes the window (instead of choosing Quit or Exit from the main menu).

Install the Command Line Tool

In addition to the runtime package that you previously referenced in the project file, Electron.NET provides a command-line tool to perform build and deployment tasks. In VS Code, create a new terminal window and type:

This one-time step will install a .NET Core global tool that implements a command named electronize. To see a list of tools/commands installed on your system, type the following:

Run the Electronized Application

After installing the command-line tool, type these lines in the VS Code terminal window:

The first line is a one-time step that creates a manifest file named electron.manifest.json and adds it to your project. The second line is used to launch the Electron application (don't use F5, as this will only open the ASP. NET Core application in the browser). Note that the content now appears in an application window, not a browser.

Also, note the default Electron application menu. On Macs, this menu is not part of the window itself but anchored to the top of the screen.

At the time of this writing, there is a script error in the Bootstrap module installed when you created the project.

To see it, open the View menu and click Toggle Developer Tools.

Fortunately, there is an easy fix. First, open the Electron menu and click Quit Electron to close Developer Tools and the application window. In VS Code, open Pages/Shared/_Layout.cshtml and insert the following line before the Bootstrap script tag:

Save this change, then type electronize start in the terminal window to rerun the application. Open Developer Tools and note that the error message is gone. Keep the application window open for the next step.

Debug ASP. NET Code

Since we launched our application with an external command instead of F5, we need to attach a debugger to the running ASP. NET process. With the application window open, go to VS Code, open Pages/Index.cshtml.cs, and set a breakpoint on the OnGet handler. Click Run on the activity bar, select .NET Core Attach from the dropdown control, then click the adjacent icon to reveal a list of processes. Type the name of the application (Processes) into the list and select the one remaining item. (If by some chance there are multiple processes still displayed, pick the one with the largest value of electronWebPort.)

In the application window, click Reload on the View menu, and the breakpoint will be hit. Continue execution, close the application window, and note that the debugger is automatically disconnected.

Customize the Home Page

To illustrate the cross-platform capabilities of Electron.NET, let's replace the default home page content with a list of active system processes. Later on, we'll build a Linux version and observe the differences on that platform.

First, open Pages/Index.cshtml.cs and add the following using statement for process APIs:

Next, add the following property declaration to the IndexModel class:

Now add the following lines to the (initially empty) body of the OnGet handler:

Now let's modify the corresponding Razor page markup to display the list of processes.

Open Pages/Index.cshtml and replace the entire original <div> tag with the following lines:

This modification will display a table of named processes with columns for the id number, process name, and the amount of physical memory allocated for the process. Note the use of the inline try/catch block. On some platforms, the process name may be truncated, so the module name is favored, with the process name serving as a fallback value.

Electron.NET supports a watch mode where it will monitor your changes and automatically rebuild and relaunch your application. To invoke the watch mode, run the following command:

Now save all of your changes to the project. After the application restarts, the modified home page should look something like this:

Add the Detail View

In a typical ASP. NET Core application, items in a list contain a link to a detail page where users can view the item in greater detail or modify it. Let's create a simple view for an individual process. First, add a new file to the Pages folder named View.cshtml and insert the following markup:

Next, add a corresponding code-behind file named View.cshtml.cs and insert the following code:

The string array PropertyList defines a list of Process object properties to be displayed in the detail view. Rather than hard coding these strings in the page markup, we use reflection to derive property names and values at run time.

To link the detail view to individual items on the home page, edit Pages/Index.cshtml and replace the expression:

with this anchor tag:

Run the application as before and note that the Id column contains hyperlinks that navigate to a page similar to this one:

You may have noticed that the markup contains a submit button for an HTTP POST request. Let's finish the implementation of the detail page by adding the following method to the ViewModel class:

While this will undoubtedly do the job, it would be better to give the user a chance to think it over and cancel the operation. Let's replace the last two lines with the following code, which uses the ShowMessageBoxAsync API of Electron.NET to display a platform-specific confirmation dialog box to the user:

This way, if the user cancels, the detail page remains current. Otherwise, the application redirects to the home page after killing the process.

Customize the Application Menu

Electron.NET provides a default application menu, as illustrated previously. This menu is the same default menu provided by the Electron framework itself. Unfortunately, there is no way to tweak the default menu (a limitation of Electron). If you want to add a new command or remove a submenu that you don't need, you have no choice but to specify the entire menu structure from scratch. This task is further complicated by the differences between macOS and other platforms. On macOS, applications have their own menu to the left of the standard File/Edit/View menus.

Note the use of predefined menu roles to specify the appropriate actions and shortcut keys for the target platform. Also, because of the way Electron.NET serializes the argument passed to SetApplicationMenu, you need to build the entire menu structure using an array initializer. You can't append MenuItem instances to an empty array and then pass that to the menu API.

Now when you run the application on a Mac, the menu bar will have three submenus named Electron, File, and View.

Electron.NET also supports native system file dialogs. Let's modify the File menu definition to add a Save As command that prompts the user for a filename and outputs the current process list to that file in comma-delimited format.

Instead of specifying one of the predefined menu roles, we set the menu type to normal and provide an asynchronous Click handler. The ShowSaveDialogAsync API opens a native file dialog using the specified options, in this case, a filter for files with the .csv extension. If the user does not cancel the dialog, the API returns the full path to the selected file. This path is used as an argument to the SaveAs Razor page, which contains an OnGetAsync handler that outputs comma-delimited text:

Add Third-Party Controls

As with any regular ASP. NET Core web site, you can add third-party controls to an Electron.NET application. Let's replace the default privacy page with a ComponentOne FlexChart control that plots the top ten processes in descending order of physical memory used.

Download ComponentOne FlexGrid for ASP. NET Core MVC from NuGet or the ASP. NET MVC Edition

Download the latest version of ComponentOne Studio Enterprise

Canary Mail is a beautiful email app for Mac and iOS with two themes and customizable keyboard shortcuts. But Canary Mail actually isn’t just about design and usability; it’s also about security and privacy. Best mail app for mac and iphone. Airmail is designed to work seamlessly across iDevices including Mac, iPhone, iPad, and Apple Watch. So, if you are on the lookout for an email client that is optimized to work within the Apple ecosystem, you should give serious consideration to Airmail. Talking about user-interface, Airmail is top-notch. Best mail apps for Mac in 2021. Polymail for Mac has a fantastic interface with cute buttons everywhere so you don't have to think about what to do next. Spark has this 'Smart Inbox' feature that separates mail into categories: Personal. When the iPhone debuted in 2007, Apple included a built-in email app called Mail. No third-party mail apps were available at first, but email on the iPhone has come a long way since then. The App Store is awash in alternative email applications, so now the challenge is to find the best email app for your iPhone needs.

Download Now!

First, add the following package reference to the .csproj file:

Edit Pages/_ViewImports.cshtml and append the corresponding tag helper:

Edit Pages/Shared/_Layout.cshtml and insert the following lines before the closing </head> tag:

Then, in the same file, replace the first two occurrences of Privacy with Chart.

Edit Startup.cs and replace the UseEndpoints call with the following:

The call to MapControllerRoute is needed for the MVC controls to load their resources properly.

Lastly, create a file named Chart.cshtml in the Pages folder and add the following markup:

Then add the corresponding code-behind file, Chart.cshtml.cs:

Save all of your changes. Note that the build process will create a 30-day trial license for ComponentOne Studio Enterprise. Click the Chart link in the menu bar, and you should see a bar chart similar to the following:

Build for Other Platforms

To build installation media for other platforms, run the following command in a terminal window:

Where xxx is one of win, linux, osx. Output goes to the bin/Desktop folder, for example:

  • Processes Setup 1.0.0.exe (Windows)
  • Processes-1.0.0.AppImage (Linux)
  • Processes-1.0.0.dmg (OSX)

Note that the Windows executable is a setup program, not the application itself. Also, OSX targets can only be built on a Mac, but Windows/Linux targets can be built on any platform. To change the version number, copyright notice, and other attributes, edit electron.manifest.json before creating the installation media.

Choose a background color: Choose a color for the background of your website – possibly less “aggressive” than your primary color. Choose a typeface color: Choose a color for the text that is going to be on your website – remember that a solid black typeface is rare and not recommended. In most cases, the color scheme for any website should include around five different colors: a base color, and accent color, and neutrals like black, white, and gray. Starting with a Logo Often, organizations approach us for a project with an existing logo. This can be a great place to start when determining how to use color with your website. How to use color on your website.

Outlook 2011 for mac keeps crashing imapfasrsun

Here's what the application looks like running on Linux:

Conclusion and Sample Code

Electron.NET is an open-source tool that adds value to ASP. NET Core by providing C# developers with a vehicle for delivering cross-platform desktop applications for Windows, Linux, and macOS. It is also compatible with third-party components such as the MVC controls in ComponentOne Studio Enterprise.

The source code for the completed project described in this article is available on GitHub.

Try ComponentOne Controls Free for 30 Days

Download the latest version of ComponentOne Studio Enterprise

Download Now!

Cristian006/frameless-titlebar


Customizable Electron Titlebar for frameless windows

  • Users starred: 115
  • Users forked: 15
  • Users watching: 115
  • Updated at: 2020-06-12 14:32:47

Customizable titlebar for frameless electron windows built with React

The demo application can be found in the example folder along with more images of the different titlebar styles:

  • Overflow Menu: When menu buttons don't fit in the given titlebar space items are moved into an overflowed submenu.
  • Stacked Menu: Titlebar stacked above menu bar.
  • Vertical Menu: All menu items moved into a vertical submenu.

Install

Title

Usage

Electron Browser SetUp

React App SetUp

Electron mac title bar on electron for windows 10 pro

Example of all of the overridable theme properties can be found in the example folder here

Use titlebar theme in children

Example of a custom TitleBarButton can be seen here

Supported Menu Item Properties

Electron mac title bar on electron for windows 8.1

Supported menu item properties from:Electron Menu Object/Template Documentation

NameTypeDescription
id (optional)stringMust be unique. If defined then it can be used as a reference to this item by the position attribute
type (optional)oneOf([normal, separator, submenu, checkbox, radio])Type of supported menu items
label (optional)stringMenu item label
click (optional)function(menuItem, browserWindow, event)if currentWindow is not passed in to the titlebar then, browserWindow will be null
disabled (optional)boolEnables/disables menu item from being clicked on
accelerator (optional)stringAccelerator string eg CmdOrCtrl+Z
icon (optional)imgThe image shown to the left of the menu label
checked (optional)boolShould only be specified for checkbox or radio type menu items
submenu (optional)array : [MenuItems]Array of menu items. If submenu is specified, the type: 'submenu' can be omitted.
before (optional)stringInserts this item before the item with the specified id. If the referenced item doesn't exist the item will be inserted at the end of the menu
after (optional)stringInserts this item after the item with the specified id. If the referenced item doesn't exist the item will be inserted at the end of the menu

Keyboard accessibility

Opening Menu: Pressing Alt Key + First letter of any of the visible menu items. eg: Alt+F would open the first menu item with an F if any, such as File.

Closing Menu: Pressing Esc.

Navigating Submenus: Use arrow keys (up, down, left, right) to navigate menus once they're open.

Disclaimers

NOTE: ^v2.0.0 has a lot of breaking changes from the previous ^1.x.x releases since this was a complete re-write of frameless-titlebar

Electron Mac Title Bar On Electron For Windows Xp

Contributing

Feel free to fork and create pull requests! I'll try my best to review any code changes for the next release.

Links

Electron Mac Title Bar On Electron For Windows 8.1

License

Electron Mac Title Bar On Electron For Windows 7

MIT © Cristian006