Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anaghsharma/ambar-xamarin
A macOS Menu Bar app built with Xamarin and C#
https://github.com/anaghsharma/ambar-xamarin
macos macos-app macos-menubar macosx popover popup xamarin xamarin-mac xamarin-macos
Last synced: 3 months ago
JSON representation
A macOS Menu Bar app built with Xamarin and C#
- Host: GitHub
- URL: https://github.com/anaghsharma/ambar-xamarin
- Owner: AnaghSharma
- License: mit
- Created: 2017-06-05T15:30:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-21T18:23:39.000Z (over 3 years ago)
- Last Synced: 2024-10-25T08:14:55.115Z (3 months ago)
- Topics: macos, macos-app, macos-menubar, macosx, popover, popup, xamarin, xamarin-mac, xamarin-macos
- Language: C#
- Homepage:
- Size: 521 KB
- Stars: 63
- Watchers: 5
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ambar-Xamarin
Ambar is a macOS Menu Bar app developed with Xamarin and C#. This project aims to show developing a menu bar app for macOS in C#.
### Update
Using Ambar as the base, I was able to build [Carol - a minimal and beautiful lyrics app for macOS](https://github.com/AnaghSharma/Carol-Xamarin). Check it out.## Why
It is for the folks wanting to start developing for macOS/iOS/tvOS/watchOS but do not want to delve into Swift/Obj-C and are already comfortable with C# and .Net technologies.## Tools Required
1. Visual Studio for Mac
2. Xcode## Steps
Here is how you can do it -
1. In Xcode, delete Window Controller Scene from `Main.storyboard` and provide Storyboard ID to View Controller.
2. Add new entry in info.plist - `Application is agent (UIElement)` with its value set to `Yes` to make the app behave as a ghost.
3. Create a Menu Bar status item using `CreateStatusItem()` method of `NSStatusBar`.
4. Handle status bar icon for dark and light theme using `Template` property of `NSImage`.
5. Handle event handling of status item using `Selector` class of `ObjCRuntime`.
6. Show a popover using `NSPopover` and its `Show()` method.
7. Make popover show on demand and hide when user moves on using `NSEvent` and a custom class.
8. In Xcode, add a button to View Controller and create an action `QuitApplication` by `control + drag`. In VS, call `Terminate` method of `NSApplication`.Unless stated otherwise, everything is done in Visual Studio for Mac.
## To-do
- [x] Add a Contextual Menu to show options.
- [x] Add a **Launch at Login** setting.
- [x] Add a **About** window.## Contribute
If you think this project can be improved to show more of what can be done using Xamarin and C#, you are welcome to contribute. If you build something epic using it, just let me [know](https://twitter.com/AnaghSharma).