Here are two screenshots:
A full-glass window over white background:
http://trotsenko.com.ua/stackoverflow/2010_01_13%20Glass%20Window%20over%20a%20white%20background.png
The same full-glass window over back background:
http://trotsenko.com.ua/stackoverflow/2010_01_13%20The%20same%20Glass%20Window%20over%20a%20Black%20background.png
The question is: in WPF, how do I use TextBlock so that it will be readable on the glass?
I already tried
<DropShadowEffect ShadowDepth="0" BlurRadius="20" Color="White"/> with no acceptable success. (Maybe I did smth wrong ?)
I didn't succeed with <OuterGlowBitmapEffect/> (I think, because bitmap effects are now deprecated. Did I do smth wrong?)
I think you could use the native DrawThemeTextEx() method in dwmapi.dll, but I don't know how to do this in WPF. All examples I found were using WinForms.
Related
I have a wpf application that constantly produces odd straight lines (grey) across the screen.
As the mouse moves around they appear and disappear.
Sorry for the bad description but its hard to describe.
I wonder if there is anything I can do about it.
I have tried a few rendering options and so forth.
<dxg:GridControl SnapsToDevicePixels="True"
and
RenderOptions.ClearTypeHint="Enabled"
RenderOptions.BitmapScalingMode="NearestNeighbor"
RenderOptions.EdgeMode="Aliased"
We have similar issues with big black vertical bars. Only resolved by switching to software only rendering:
System.Windows.Media.RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
I can't seem work out (even though I have seen other apps) how to set the whole background of a WP7 page to a image or colour, like in Panorama for example.
If i set
Grid x:Name="LayoutRoot" Background="#FF0079C1"
Or
<Grid.Background>
<ImageBrush ImageSource="/images/highwaysBack.jpg" Stretch="None" />
</Grid.Background>
it still leaves the top info section either black or white depending on the phone setting.
Many thanks.
That's most likely the System Tray. You can hide that by setting shell:SystemTray.IsVisible="False" on your page.
Make a note that hiding the system tray isn't something you always want to do, as you're hiding info like the battery life. Only do it because you app absolutely has to, like a video game. If it's just a simpler app there shouldn't be a real neeed to hide it.
I created a custom control similar to TabControl. It works nice, except that the text in header items gets blury when I resize the content. It can, for example look like this:
Not only the text, but the box around the text can also get non-vertical. See the blue border around the "General" item:
What is causing this problem? I have set SnapToDevicePixels = True.
Thanks for any ideas!
EDIT:
I'm using .NET 4.0. TextOptions.TextFormattingMode is set to "Display".
The whole problem with fuzzy text and background occurs if I apply a DropShadowEffect effect in the style for ItemsControl which displays the buttons. This is the code for the Effect:
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Direction="0" ShadowDepth="1" BlurRadius="10" Opacity="0.2" Color="Black" />
</Setter.Value>
</Setter>
If this code is not enabled, the the text and the borders get displayed nicely.
I suspect you've said it yourself: SnapToDevicePixels will ruin text rendering if you've resized the text so it displays across pixels. You probably want to keep SnapToDevicePixels="True" on your borders/backgrounds, but turn it off for the text elements.
As for your border... can you post the xaml? I'm guessing that you're not using just a single element with rounded corners - are you drawing the edge of that tab as three separate lines?
There are 2 things to consider:
are you using .NET 3.5 or .NET 4.0? reason why I'm asking is that the text rendering has been changed between the versions. In 4.0 it's a lot better.
Sometime you have to wait a little while until the text get's sharper, so you scroll around, and then after a second the text becomes sharper. That could be as well a reason for you're issue.
Wpf hit testing is pretty good but the only method I found to extend the hit zone is to put a transparent padding area around your object. I can't find any method to add a transparent area arround a Path object. The path is very thin and I would like to enable hit testing if the user clicks near the path. I can't find any method to extend the path object with a transparent area like the image below :
alt text http://img175.imageshack.us/img175/6741/linepadding.png
I tried to used a partially transparent stroke brush but I ran into the problem described here : How can I draw a "soft" line in WPF (presumably using a LinearGradientBrush)?
I also tried to put an adorner over my line but because of WPF anti-aliasing algorithms, the position is way off when I zoom in my canvas and interfere with other objects hit-testing in a bad way.
Any suggestion to extend the hit testing zone would be highly appreciated.
Thanks,
Kumar
Path.Data is a geometry object. The Geometry class has several methods that can help you hit test with tolerance:
GetFlattenedPathGeometry(Double, ToleranceType)
GetOutlinedPathGeometry(Double, ToleranceType)
GetRenderBounds(Pen, Double, ToleranceType)
I think GetRenderBounds will work best for you.
Once you have the geometry (plus a little width) you can call
geometry.FillContains(Point, Double, ToleranceType)
or
geometry.StrokeContains(Pen, Point, Double, ToleranceType)
Out of all of that you should tune the desired hit from your hit test;
You can wrap the Path inside a transparent Border.
In WPF you can create another path with its geometry databound to the first (using Element Binding), but with transparent brush and increased thickness.
Something more or less like this:
<Path x:Name="backPath" Data="{Binding Data, ElementName=mainPath}" StrokeThickness="10" Stroke="Transparent"/>
<Path x:Name="mainPath" Data="{Binding DataFromViewModel}" StrokeThickness="1" Stroke="Red"/>
Note that the main path comes after in XAML, so that it is rendered on top.
I have a few 3D meshes in my WPF application, and I need to add some animations to them, not the typical animations, but rather a sequence of PNG images for creating a graphical animation.
Think of it like I need to add a cartoon animation to the side of a Cube.
I know very well about the Viewport2DVisual3D, but when I replace my normal ModelVisual3D with a Viewport2DVisual3D, I get horrible performance! Around the 5 FPS mark.
As soon as I remove the material with IsVisualHostMaterial set to true, the frame rate is restored to a normal state.
Performance is always a tricky subject, but what I was thinking was creating a Visual Brush with an image source of a WriteableBitmap or RenderTargetBitmap and then draw my PNG's to that sequence.
Does this sound OK, or should I not be getting the poor performance that I'm getting?
Actually, come to think of it, have you tried using this?
<DiffuseMatrial>
<DiffuseMaterial.Brush>
<VisualBrush ...>
<VisualBrush.Visual>
...
I know that MILCore handles VisualBrush by rendering the backing Visual as a separate operation, so I wouldn't be surprised if it worked very efficiently with 3D.
Update
It also occurs to me you might try:
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<DrawingBrush ...>
<DrawingBrush.Drawing>
<ImageDrawing ImageSource="{Binding ...} />
This would bypass the use of Visual entirely and possibly run much faster than Viewport2DVisual3D or VisualBrush.
I haven't yet had a need to dig deeply into WPF's 3D optimizations, but I know that Direct3D is capable of rendering using a writable buffer so if MILCore implements it correctly your idea of WritableBitmap or RenderTargetBitmap have a reasonable chance of working. Vista's Flip 3D is able to make this work with high performance using arbitrary applications (even GDI applications) and also uses a writable buffer.
If that doesn't work, another idea for you is to convert your animation into a video, either the traditional way or by creating a DirectShow stream from a sequence of BitmapFrames.
Hopefully someone else can come along and give you a better answer.
If your PNGs are representing a video stream, why not convert them to a video format at the outset? Creating an AVI from frames is easy. Horses for courses, as they say. It could be the PNG decoder slowing you down.