2012-03-26 60 views
0

我使用不同的文本塊創建透明度窗口,但由於顏色取決於用戶的窗口顏色,因此我的文本不總是可讀的。在文本上創建與窗口標題相同的效果

所以我想對文字應用相同的效果,比如我的標題窗口的效果, 它就像一個白色陰影。

謝謝

+0

和什麼問題? – MoonKnight 2012-03-26 08:05:44

+0

我在一個項目中工作,在這個項目中,使用發光效果可以獲得與發光效果一樣的標題窗口aero效果,但這種效果不適用於所有彩色aero窗口。我怎樣才能獲得這種效果的所有顏色爲我的文本可讀? – Gat 2012-03-26 08:09:06

+0

難道你不能建立Windows主題的低調顏色,並建立一個'顏色''字典',當這些主題到位時必須改變? – MoonKnight 2012-03-26 08:16:03

回答

0

這樣做是使用着色器效果最好的方法。我試圖用內置的模糊效果來做到這一點,但似乎他們不與Alpha融合。

下面是我將如何開始並且不代表最終產品的一個示例。基於浮雕效果的HLSL邊框效果。 Example HLSL effect for glass with blending

查看整個圖像以獲得更好的理解。這種效果只會增加2像素的邊框,所以縮放會讓它看起來更糟。

我在寫HLSL時很不好,右邊的代碼只是從http://brooknovak.wordpress.com/2008/09/16/simple-image-filters-written-as-hlsl-pixel-shaders/複製粘貼並修改。

我確定知道HLSL/GLSL的人可以編寫一個可以正常工作的模糊效果。請注意,此效果適用於整個圖像,因此需要知道圖像大小。你應該把它們放在一個常量緩衝區中,並用它們代替硬編碼的500.0的寬度和高度。它們需要是渲染對象的寬度/高度。在我的例子中,它實際上是窗口的整個左半邊,不僅僅是文本的大小,因爲我的XAML看起來像這樣...

<Window x:Class="WpfApplication2.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Height="350" Width="525" 
     Loaded="Window_Loaded" Background="Transparent"> 
    <Grid> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="264*" /> 
      <ColumnDefinition Width="239*" /> 
     </Grid.ColumnDefinitions> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="218*" /> 
      <RowDefinition Height="Auto" /> 
      <RowDefinition Height="Auto" /> 
     </Grid.RowDefinitions> 
     <TextBlock Text="The quick brown fox jumped over the lazy dog." Foreground="White" Background="Transparent" Grid.RowSpan="3" x:Name="PART_TextBlock"/> 
     <TextBox x:Name="PART_TextBox" Grid.Column="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible" AcceptsReturn="True" AcceptsTab="True" /> 
     <TextBlock x:Name="PART_Error" Grid.Column="1" Grid.Row="1"/> 
     <Button Content="Compile &amp; Apply" Grid.Column="1" Grid.Row="2" Padding="4,1" Margin="4" HorizontalAlignment="Center" Click="Button_Click" /> 
    </Grid> 
</Window> 
相關問題