如何使对Aero的玻璃背景WPF文本可读? [英] How to make WPF text on Aero glass background readable?

查看:566
本文介绍了如何使对Aero的玻璃背景WPF文本可读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序,在一个航空玻璃背景绘制文本。问题是,根据所显示的背后我的应用程序,画在玻璃背景可以成为文字难读彻头彻尾的不可能的阅读。

I have a WPF app that draws text on an Aero glass background. The problem is that based on what is displayed behind my application, the text drawn on the glass background can become hard-to-read to downright-impossible-to-read.

正如你可以在下面的截图中看到,在保存撤消重复的文本块变得很难看,如果窗口<强>背后我的应用程序是黑暗的。

As you can see in the following screenshot, the Save, Undo and Redo text blocks become hard to read if the window behind my application is dark.

现在,微软的应用程序,如Word,解决这个问题有一种落后的文字模糊,你可以在未来的截图中看到:

Now, Microsoft applications, such as Word, solve this with a kind of blur behind text, as you can see in the next screenshot:

我听说有一些Win32 API调用我可以得到这个工作。然而,这只是传闻对我来说,在这一点上,我没有任何事实来支持这件事。

I've heard there is some kind of Win32 API call I can make to get this to work. However, that is just hearsay to me at this point, I have no facts to back that up.

我已经尝试了一些不同的WPF特有的东西来近似什么字呢:

I've tried a few different WPF-specific things to approximate what Word does:

  • 删除文本的阴影
  • 在文本与烤一片模糊透明图像(而不是的TextBlock

这些都不给我有用的结果,他们都期待pretty的糟糕。有谁知道的任何方法,WPF或Win32的,那我可以用它来绘制文本微软确实在玻璃上的方式()?

None of those give me usable results, they all look pretty crummy. Does anyone know of any method, WPF or Win32, that I could use to draw text the way Microsoft does on glass (i.e., readable)?

推荐答案

我是能够解决这个无的Win32(需要.NET 3.5)。

I was able to solve this without Win32 (requires .NET 3.5).

 <Grid>
     <TextBlock Foreground="Black" HorizontalAlignment="Center" Margin="0,10,30,0" Text="Text that should be visible on Aero Glass">
         <TextBlock.Effect>
            <BlurEffect Radius="15" KernelType="Gaussian">                                                                    
            </BlurEffect>                                        
         </TextBlock.Effect>
      </TextBlock>
      <TextBlock HorizontalAlignment="Center" Foreground="White" Margin="0,10,30,0" Text="Text that should be visible on Aero Glass">
      </TextBlock>
 </Grid>

这code的加倍文字和模糊的是更远的背后,Z-指数明智的文字版本的效果。工程就像一个魅力对我来说。

This code has the effect of doubling up text and blurring the version of the text that is farther behind, Z-index wise. Works like a charm for me.

有一点需要注意:
这似乎工作最好的,如果文本颜色为白色,而模糊的颜色是黑色。它看起来并不那么好周围的其他方法。好消息是,它看起来不错,无论你有什么Aero玻璃窗口的后面。

One thing to note:
This seems to work best if the text color is white and the blur color is black. It doesn't look so good the other way around. The good news is it looks good regardless of what is behind your Aero Glass window.

这篇关于如何使对Aero的玻璃背景WPF文本可读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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