如何在 MS Windows 上加载 GTK Sharp 主题 [英] How to load a GTK Sharp theme on MS Windows

查看:16
本文介绍了如何在 MS Windows 上加载 GTK Sharp 主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 MS Windows 上使用 Xamarin Studio 5.4 编写 GTK Sharp (v2.12) 应用程序.安装的 Mono 版本是 3.2.3(但我使用 .Net 工具链编译,因为 Xamarin 不允许我使用 Mono 工具链编译).

I'm programming a GTK Sharp (v2.12) application using Xamarin Studio 5.4 on MS Windows. The installed Mono version is 3.2.3 (but I'm using the .Net tool chain to compile, because Xamarin doesn't allow me to compile using the Mono toolchain).

情况是,当我从 Xamarin Studio 或使用 Mono 运行应用程序时,我有一个相对漂亮的外观 &感觉,但是当我使用.Net(双击可执行文件)运行应用程序时,外观和感觉很糟糕.

The case is that when I run the application from the Xamarin Studio or using Mono, then I have a relatively nice look & feel, but when I run the application using .Net (doing double click on the executable) then the look & feel is horrible.

我试图欺骗应用程序以加载一个像样的主题...但是当我从 .Net 执行此操作时它什么也没做(但当我使用 Mono 时很容易看到更改).

I've tried to trick the application to load a decent theme... but it does nothing when I do it from .Net (but when I'm using Mono then it's easy to see the changes).

这是我尝试过但不起作用的代码(我有 GTK 主题 rc 文件的本地副本):

This is the code I've tried but that does not work (I have a local copy of the GTK themes rc files):

// It works on Mono, but not on .Net
Gtk.Rc.Parse("Resources/GTK/windows-theme.gtkrc");

我也尝试过:

// This does not work at all (on MS Windows)
Gtk.Settings.Default.ThemeName = "MS-Windows";

但这并没有改变任何东西,即使使用 Mono 引擎.

But this does not change anything, even using the Mono engine.

这是使用 Mono 时应用程序的外观:

This is how the application looks using Mono:

以及它在 .Net 引擎下运行的样子:

And how it looks running under the .Net engine:

感谢您的关注:).

推荐答案

好吧,我已经找到了我的问题的答案:D.

Well, I've found the answer to my question :D .

我没有尝试加载特定的 GTK 主题,但解决了它以使 .Net 正常工作,而无需复制程序目录中的所有 DLL 文件.

I didn't try to load a specific GTK theme, but solved it to make .Net working properly without having to copy all the DLL files in the program directory.

我在 Xamarin 开发论坛中找到了这个帖子:

I've found this thread in the Xamarin development forums:

在此线程中,Xamarin 开发人员解释了他们如何解决依赖项加载问题.关键是在 Application.Init() 调用之前调用 CheckWindowsGTK 方法.CheckWindowsGTK 在此文件中定义,来自 Monodevelop 来源:

In this thread Xamarin developers explain how they solve the dependencies loading problem. The key is to call the CheckWindowsGTK method before the Application.Init() call. The CheckWindowsGTK is defined in this file from the Monodevelop sources:

提示:只有当程序在 Windows 上运行时才调用 CheckWindowsGTK,这一点很重要.

HINT: It's important to call CheckWindowsGTK only if the program is running on Windows.

这篇关于如何在 MS Windows 上加载 GTK Sharp 主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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