【问题标题】:Open files with mono gtk# on Mac OSX在 Mac OSX 上使用 mono gtk# 打开文件
【发布时间】:2014-03-31 08:45:35
【问题描述】:

我使用 mono 和 gtk# 为 mac 开发了一个应用程序。
问题是默认文件处理程序。 我使用此 Info.plist (sn-p) 注册我的应用程序

...
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>My Filetype</string>
        <key>CFBundleTypeIconFile</key>
        <string>file.icns</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>ext</string>
            <string>EXT</string>
        </array>
        <key>LSIsAppleDefaultForType</key>
        <true/>
    </dict>
</array>
....

它注册正确(图标匹配,打开我的应用程序),但每当我打开文件时出现以下消息:

The document "test.ext" could not be opened. mono cannot open files of this type.

那么我怎样才能让它工作呢?

【问题讨论】:

    标签: c# macos mono gtk#


    【解决方案1】:

    我自己发现的:

    1. https://github.com/mono/monodevelop/tree/master/main/src/addins/MacPlatform/MacInterop 包含到您的项目中。

    2. 使用此代码

      ApplicationEvents.OpenDocuments+= delegate (object sender, ApplicationDocumentEventArgs e) {
          if (e.Documents != null && e.Documents.Count > 0) {
              // e.Documents holds the files
          }
          e.Handled = true;
      };
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-01
      • 1970-01-01
      • 2013-10-18
      • 2013-10-16
      • 1970-01-01
      • 2016-05-11
      • 2013-11-10
      • 1970-01-01
      相关资源
      最近更新 更多