問題描述
我希望將我的一個 C# 應用程序轉移到 Mono 以在 Mac 上使用.目前,我正在嘗試弄清楚如何使它成為一種后臺"進程,但仍然能夠擁有 GUI 元素(我相信這排除了 mono-service
).p>
最終目標是這樣的:
- 為大多數交互設置一個托盤圖標.
- 刪除啟動應用程序通常附帶的??繄D標
- 讓應用程序在啟動時運行.
簡而言之,想想 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 文件放入您的項目文件中,并將其標記為內容.(右鍵->構建動作->內容)
現在是時候移除??繄D標了:
在您的 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:
- Put a tray icon up by the clock for the majority of interactions.
- Remove the dock icon that typically comes with a launched application
- Have the application run on startup.
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
這篇關于僅系統托盤(無??繄D標)應用程序在 Mac 上使用 C#/Mono的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!