我希望将我的一个 C# 应用程序转移到 Mono 以在 Mac 上使用.目前,我正在尝试弄清楚如何使它成为一种后台"进程,但仍然能够拥有 GUI 元素(我相信这排除了 mono-service
).p>
最终目标是这样的:
简而言之,想想 Dropbox 应用程序的工作原理.我想要那种类型的 GUI,但要使用 Mono/Mac 应用程序.
我相信这通常是通过在应用程序包的 Info.plist 中设置 LSUIElement = 1
来完成的.但是,我没有运气.我认为这可能与从应用程序包中启动我的应用程序的 mono
命令有关.一旦应用程序启动 mono
我假设它不会级联到进一步的应用程序启动.不过,这纯粹是猜测.
有人对此有任何想法吗?谢谢.
我有你的答案:
首先,添加一个状态栏图标(Win Forms中通知图标的替代品):
NSStatusItem sItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);sItem.Menu = 通知菜单;sItem.Image = NSImage.FromStream(System.IO.File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/notify-icon.icns"));sItem.HighlightMode = true;
notifyMenu 是您的 NSMenu 实例,作为通知图标的上下文菜单条.
并将使用 Icon Composer 制作的 ICNS 文件放入您的项目文件中,并将其标记为内容.(右键->构建动作->内容)
现在是时候移除停靠图标了:
在您的 info.plist 文件中.创建一个新的 Boolean 类型项目并将其命名为LSUIElement"并将值设置为 YES.
希望有帮助.问候,佩曼·莫尔塔扎维
I'm looking to move one of my C# applications over to Mono for use on the Mac. Currently, I'm trying to figure out how to make it a sort of "background" process, but still have the ability to have GUI elements (I believe this rules out mono-service
).
The ultimate goal is this:
In short, just think of how the Dropbox app works. I want that type of GUI, but with a Mono / Mac app.
I believe this is typically accomplished by setting LSUIElement = 1
in the application bundle's Info.plist. However, I've had no luck with it. I think it may have something to do with the mono
command launching my application from within the app bundle. Once the app launches mono
I'm assuming it doesn't cascade to further application launches. That is a pure guess, though.
Does anyone have any ideas on this? Thanks.
I have your answer:
First, to add a Status bar icon (alternative of Notify Icon in Win Forms):
NSStatusItem sItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
sItem.Menu = notifyMenu;
sItem.Image = NSImage.FromStream(System.IO.File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/notify-icon.icns"));
sItem.HighlightMode = true;
notifyMenu is your instance of NSMenu as a means of context menu strip for your notify icon.
and put your ICNS file made using Icon Composer in your project files and flag it as Content. (right click->build action->content)
Now It is time to remove dock icon:
on your info.plist file. make a new Boolean type item and name it "LSUIElement" and set the value to YES.
Hope it helps. Regards, Peyman Mortazavi
这篇关于仅系统托盘(无停靠图标)应用程序在 Mac 上使用 C#/Mono的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!