系统托盘只(不停靠图标)的应用程序在Mac上使用C#/单声道 [英] System Tray only (no dock icon) application using C# / Mono on Mac

查看:187
本文介绍了系统托盘只(不停靠图标)的应用程序在Mac上使用C#/单声道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找移动我的C#应用​​程序之一到单在Mac上使用。目前,我试图找出如何使一种背景的过程,但仍然有有GUI元素的能力(我相信这排除了单服务)。

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).

的最终目标是这样的:


  1. 把托盘图标了由时钟,为广大的相互作用。

  2. 删除通常带有一个启动的应用程序停靠栏图标

  3. 对应用程序启动时运行。

  1. Put a tray icon up by the clock for the majority of interactions.
  2. Remove the dock icon that typically comes with a launched application
  3. Have the application run on startup.

在短,只是觉得怎么 Dropbox的应用的作品。我想这类型的GUI,但具有单声道/ Mac应用程序。

In short, just think of how the Dropbox app works. I want that type of GUI, but with a Mono / Mac app.

我相信这通常是通过在应用程序包的Info.plist设置 LSUIElement = 1 完成。不过,我已经与它没有运气。我认为它可能有一些做的命令从应用程序包内启动我的申请。一旦应用程序启动我假设它不会级联到进一步的应用程序启动。这是一个纯粹的猜测,虽然。

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.

推荐答案

我有你的答案:

首先,添加一个状态栏图标(通知在Win图标形式替代):

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 是NSMenu的实例作为上下文菜单条,为您的通知图标的方法。

notifyMenu is your instance of NSMenu as a means of context menu strip for your notify icon.

和把你的 ICNS 的文件进行使用的图标作曲在您的项目文件和其标记为内容。 (右键点击 - >建设行动 - >内容)

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:

在你Info.plist文件。创建一个新的布尔的项目类型并将其命名为 LSUIElement 和值设置为

on your info.plist file. make a new Boolean type item and name it "LSUIElement" and set the value to YES.

希望它帮助。
问候,
Peyman Mortazavi

Hope it helps. Regards, Peyman Mortazavi

这篇关于系统托盘只(不停靠图标)的应用程序在Mac上使用C#/单声道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆