Windows 上的 GTK#:如何让桌面 alpha 混合工作?
主题。我发现这个< /a> 并翻译成下面的代码。但它只显示一个深蓝色的矩形,根本没有透明度。
class MainClass
{
public static void Main (string[] args)
{
Application.Init();
Gtk.Window w = new Gtk.Window(Gtk.WindowType.Toplevel);
w.ExposeEvent += new ExposeEventHandler(w_ExposeEvent);
w.DeleteEvent += new DeleteEventHandler(w_DeleteEvent);
w.Decorated = false;
w.BorderWidth = 20;
w.AppPaintable = true;
w.Colormap = w.Screen.RgbaColormap;
w.Show();
Application.Run();
}
static void w_ExposeEvent(object o, ExposeEventArgs args)
{
Context context = CairoHelper.Create(args.Event.Window);
context.SetSourceRGBA(0.0, 0.0, 50.0, 0.2);
context.Operator = Operator.Source;
context.Paint();
}
static void w_DeleteEvent(object o, DeleteEventArgs args)
{
Application.Quit();
}
}
Subj. I found this and translated into code below. But it shows only a dark-blue rectangle with no transparency at all.
class MainClass
{
public static void Main (string[] args)
{
Application.Init();
Gtk.Window w = new Gtk.Window(Gtk.WindowType.Toplevel);
w.ExposeEvent += new ExposeEventHandler(w_ExposeEvent);
w.DeleteEvent += new DeleteEventHandler(w_DeleteEvent);
w.Decorated = false;
w.BorderWidth = 20;
w.AppPaintable = true;
w.Colormap = w.Screen.RgbaColormap;
w.Show();
Application.Run();
}
static void w_ExposeEvent(object o, ExposeEventArgs args)
{
Context context = CairoHelper.Create(args.Event.Window);
context.SetSourceRGBA(0.0, 0.0, 50.0, 0.2);
context.Operator = Operator.Source;
context.Paint();
}
static void w_DeleteEvent(object o, DeleteEventArgs args)
{
Application.Quit();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论