Last active
July 14, 2022 01:18
-
-
Save grexican/11252656 to your computer and use it in GitHub Desktop.
Windowless Mac App with MonoMac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using MonoMac.Foundation; | |
using MonoMac.AppKit; | |
namespace StatusMenu | |
{ | |
[Register("AppController")] | |
public partial class AppController : NSObject | |
{ | |
public AppController() | |
{ | |
} | |
public override void AwakeFromNib() | |
{ | |
var statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30); | |
statusItem.Menu = statusMenu; | |
statusItem.Image = NSImage.ImageNamed("f3bfd_Untitled-thumb"); | |
statusItem.HighlightMode = true; | |
} | |
partial void HelloWorld(NSObject sender) | |
{ | |
Console.WriteLine("hello world"); | |
} | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WARNING | |
// | |
// This file has been generated automatically by MonoDevelop to store outlets and | |
// actions made in the Xcode designer. If it is removed, they will be lost. | |
// Manual changes to this file may not be handled correctly. | |
// | |
using MonoMac.Foundation; | |
namespace StatusMenu | |
{ | |
partial class AppController | |
{ | |
[Outlet] | |
MonoMac.AppKit.NSMenu statusMenu { get; set; } | |
[Action ("HelloWorld:")] | |
partial void HelloWorld (MonoMac.Foundation.NSObject sender); | |
void ReleaseDesignerOutlets () | |
{ | |
if (statusMenu != null) { | |
statusMenu.Dispose (); | |
statusMenu = null; | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
using MonoMac.Foundation; | |
using MonoMac.AppKit; | |
using MonoMac.ObjCRuntime; | |
namespace StatusMenu | |
{ | |
public partial class AppDelegate : NSApplicationDelegate | |
{ | |
MainWindowController mainWindowController; | |
public AppDelegate() | |
{ | |
} | |
public override void FinishedLaunching(NSObject notification) | |
{ | |
} | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace StatusMenu | |
{ | |
// Should subclass MonoMac.AppKit.NSResponder | |
[MonoMac.Foundation.Register("AppDelegate")] | |
public partial class AppDelegate | |
{ | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>CFBundleIdentifier</key> | |
<string>com.yourcompany.StatusMenu</string> | |
<key>CFBundleName</key> | |
<string>StatusMenu</string> | |
<key>CFBundleVersion</key> | |
<string>1</string> | |
<key>LSMinimumSystemVersion</key> | |
<string>10.6</string> | |
<key>LSUIElement</key> | |
<string>1</string> | |
<key>NSMainNibFile</key> | |
<string>MainMenu</string> | |
<key>NSPrincipalClass</key> | |
<string>NSApplication</string> | |
</dict> | |
</plist> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
using MonoMac.Foundation; | |
using MonoMac.AppKit; | |
using MonoMac.ObjCRuntime; | |
namespace StatusMenu | |
{ | |
class MainClass | |
{ | |
static void Main(string[] args) | |
{ | |
NSApplication.Init(); | |
NSApplication.Main(args); | |
} | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using MonoMac.Foundation; | |
using MonoMac.AppKit; | |
namespace StatusMenu | |
{ | |
public partial class MainWindow : MonoMac.AppKit.NSWindow | |
{ | |
#region Constructors | |
// Called when created from unmanaged code | |
public MainWindow(IntPtr handle) : base (handle) | |
{ | |
Initialize(); | |
} | |
// Called when created directly from a XIB file | |
[Export ("initWithCoder:")] | |
public MainWindow(NSCoder coder) : base (coder) | |
{ | |
Initialize(); | |
} | |
// Shared initialization code | |
void Initialize() | |
{ | |
} | |
#endregion | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace StatusMenu | |
{ | |
// Should subclass MonoMac.AppKit.NSWindow | |
[MonoMac.Foundation.Register("MainWindow")] | |
public partial class MainWindow | |
{ | |
} | |
// Should subclass MonoMac.AppKit.NSWindowController | |
[MonoMac.Foundation.Register("MainWindowController")] | |
public partial class MainWindowController | |
{ | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> | |
<data> | |
<int key="IBDocument.SystemTarget">1080</int> | |
<string key="IBDocument.SystemVersion">12C3006</string> | |
<string key="IBDocument.InterfaceBuilderVersion">2844</string> | |
<string key="IBDocument.AppKitVersion">1187.34</string> | |
<string key="IBDocument.HIToolboxVersion">625.00</string> | |
<object class="NSMutableDictionary" key="IBDocument.PluginVersions"> | |
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> | |
<string key="NS.object.0">2844</string> | |
</object> | |
<object class="NSArray" key="IBDocument.IntegratedClassDependencies"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
<string>NSCustomObject</string> | |
</object> | |
<object class="NSArray" key="IBDocument.PluginDependencies"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | |
</object> | |
<object class="NSMutableDictionary" key="IBDocument.Metadata"> | |
<string key="NS.key.0">PluginDependencyRecalculationVersion</string> | |
<integer value="1" key="NS.object.0"/> | |
</object> | |
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
<object class="NSCustomObject" id="1001"> | |
<string key="NSClassName">MainWindowController</string> | |
</object> | |
<object class="NSCustomObject" id="1003"> | |
<string key="NSClassName">FirstResponder</string> | |
</object> | |
<object class="NSCustomObject" id="1004"> | |
<string key="NSClassName">NSApplication</string> | |
</object> | |
</object> | |
<object class="IBObjectContainer" key="IBDocument.Objects"> | |
<object class="NSMutableArray" key="connectionRecords"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
</object> | |
<object class="IBMutableOrderedSet" key="objectRecords"> | |
<object class="NSArray" key="orderedObjects"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
<object class="IBObjectRecord"> | |
<int key="objectID">0</int> | |
<object class="NSArray" key="object" id="0"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
</object> | |
<reference key="children" ref="1000"/> | |
<nil key="parent"/> | |
</object> | |
<object class="IBObjectRecord"> | |
<int key="objectID">-2</int> | |
<reference key="object" ref="1001"/> | |
<reference key="parent" ref="0"/> | |
<string key="objectName">File's Owner</string> | |
</object> | |
<object class="IBObjectRecord"> | |
<int key="objectID">-1</int> | |
<reference key="object" ref="1003"/> | |
<reference key="parent" ref="0"/> | |
<string key="objectName">First Responder</string> | |
</object> | |
<object class="IBObjectRecord"> | |
<int key="objectID">-3</int> | |
<reference key="object" ref="1004"/> | |
<reference key="parent" ref="0"/> | |
<string key="objectName">Application</string> | |
</object> | |
</object> | |
</object> | |
<object class="NSMutableDictionary" key="flattenedProperties"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
<object class="NSArray" key="dict.sortedKeys"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
<string>-1.IBPluginDependency</string> | |
<string>-2.IBPluginDependency</string> | |
<string>-3.IBPluginDependency</string> | |
</object> | |
<object class="NSArray" key="dict.values"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | |
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | |
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> | |
</object> | |
</object> | |
<object class="NSMutableDictionary" key="unlocalizedProperties"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
<reference key="dict.sortedKeys" ref="0"/> | |
<reference key="dict.values" ref="0"/> | |
</object> | |
<nil key="activeLocalization"/> | |
<object class="NSMutableDictionary" key="localizations"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
<reference key="dict.sortedKeys" ref="0"/> | |
<reference key="dict.values" ref="0"/> | |
</object> | |
<nil key="sourceID"/> | |
<int key="maxID">6</int> | |
</object> | |
<object class="IBClassDescriber" key="IBDocument.Classes"> | |
<object class="NSMutableArray" key="referencedPartialClassDescriptions"> | |
<bool key="EncodedWithXMLCoder">YES</bool> | |
<object class="IBPartialClassDescription"> | |
<string key="className">MainWindowController</string> | |
<string key="superclassName">NSWindowController</string> | |
<object class="IBClassDescriptionSource" key="sourceIdentifier"> | |
<string key="majorKey">IBProjectSource</string> | |
<string key="minorKey">./Classes/MainWindowController.h</string> | |
</object> | |
</object> | |
</object> | |
</object> | |
<int key="IBDocument.localizationMode">0</int> | |
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string> | |
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> | |
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string> | |
<integer value="3000" key="NS.object.0"/> | |
</object> | |
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> | |
<int key="IBDocument.defaultPropertyAccessControl">3</int> | |
</data> | |
</archive> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using MonoMac.Foundation; | |
using MonoMac.AppKit; | |
namespace StatusMenu | |
{ | |
public partial class MainWindowController : MonoMac.AppKit.NSWindowController | |
{ | |
#region Constructors | |
// Called when created from unmanaged code | |
public MainWindowController(IntPtr handle) : base (handle) | |
{ | |
Initialize(); | |
} | |
// Called when created directly from a XIB file | |
[Export ("initWithCoder:")] | |
public MainWindowController(NSCoder coder) : base (coder) | |
{ | |
Initialize(); | |
} | |
// Call to load from the XIB/NIB file | |
public MainWindowController() : base ("MainWindow") | |
{ | |
Initialize(); | |
} | |
// Shared initialization code | |
void Initialize() | |
{ | |
} | |
#endregion | |
//strongly typed window accessor | |
public new MainWindow Window | |
{ | |
get { | |
return (MainWindow)base.Window; | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment