DCSIMG
Janiv Ratson's Blog

Janiv Ratson's Blog

.NET (especially WPF) and Technologies issues I have time to cover

על הבלוג

These postings are provided "AS IS" with no warranties, and confer no rights.

Janiv LinkedIn Profile

Locations of visitors to this page

My Blog Barcode

Interesting Blogs

.NET Framework Targeting Error (.NET Framework Client Profile)

Two of my colleagues: Alon Nativ and Ziv Farjun have found an interesting, yet confusing, issue in Visual Studio 2010 and .NET Framework 4.

They work on a .NET Framework 4 solution which includes few .NET Framework 4 projects. To test the project they created a Console Application project, added a reference to their other projects, used the appropriate namespace, and created a class that is defined in one of their projects. Everything is made by the (old) book. However, the project failed to build.

The error they got was: The type or namespace name "name" does not exist in the namespace "namespace". (Are you missing an assembly reference?)

The problem occurred because the new Console Application targeted the.NET Framework 4 Client Profile (which is the default for this project template) while the other projects targeted the full .NET Framework version 4.

.NET Framework Client Profile

The .NET Framework 4 Client Profile is a subset of the .NET Framework 4 that is optimized for client applications. It provides functionality for most client applications and it enables faster deployment and a smaller install package for applications that target the .NET Framework 4 Client Profile.

Applications that target the .NET Framework 4 Client Profile typically improve the deployment experience by having smaller download sizes and quicker install times. An application that targets the .NET Framework 4 Client Profile has a smaller redistribution package that installs the minimum set of client assemblies on the user's computer, without requiring the full version of the .NET Framework 4 to be present.

The list of the reference assemblies included in the .NET Framework 4 Client Profile can be found here.

Several project templates in Visual Studio 2010 target the .NET Framework 4 Client Profile. The following is a list of some project templates in Visual Studio 2010 that target the .NET Framework 4 Client Profile by default:

  • WPF Application

  • WPF Browser Application

  • WPF Custom Control Library

  • WPF User Control Library

  • Windows Forms Application

  • Windows Forms Control Library

  • Console Application

  • Empty Project

  • Window Service

If you attempt to reference an assembly in your project that is not included in the .NET Framework Client Profile, Visual Studio will display an error message. That is what happened to my colleagues.

Common errors include the following:

  • The type or namespace name "name" does not exist in the namespace "namespace". (Are you missing an assembly reference?)

  • Type "typename" is not defined.

  • Could not resolve assembly "assembly". The assembly is not listed as part of the "profile" Profile.

These errors can result from different actions:

  • You have referenced an assembly that is not Included in the Client Profile

  • You have referenced a project or assembly that targets a different version of the .NET Framework

  • You have re-targeted a project to a different version of the .NET Framework

  • You have re-targeted a project to a different version of the .NET Framework and references do not resolve

We fixed it by setting the Console Application project to target the full .NET Framework version 4 instead of the .NET Framework 4 Client Profile subset library. Here is how you do it.
Other solutions for other .NET Framework targeting errors can be found here.


EAVB_YTINPBKIEU

The Easiest Way to Add a Splash Screen to Your WPF Application

It has been a long time …

WPF applications do not start immediately. When an application is being loaded, there’s a delay while the CLR initializes the .NET environment and then starts the application.
Splash screens are typically used to notify the user that the application is in the process of loading.

The easiest way to add a splash screen to your WPF application is to have Visual Studio 2008 SP1 or later and to follow these steps:

1. Add an image file to your project. (you can use the BMP, GIF, JPEG, PNG or TIFF format)  .
2. Select the file in the Solution Explorer. 
3. Change the Build Action to SplashScreen.

The next time you run the application, the image will be shown immediately. Once the runtime environment is ready, and after the Application_Startup method has finished, your application’s first window appears, and the splash screen fades away within 300 milliseconds.

To remove the splash screen from your application you may either set the image’s Build Action to None or exclude the image from your project.

If you want to change the default fadeout duration (300 milliseconds), you’d have to take control over the SplashScreen.

First of all, locate the Main method within your App.g.cs file. Assuming you have followed the easy steps mentioned above to add the splash screen, your code will look something like this:

   1: /// <summary>
   2: /// Application Entry Point.
   3: /// </summary>
   4: [System.STAThreadAttribute()]
   5: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
   6: public static void Main() 
   7: {
   8:     SplashScreen splashScreen = new SplashScreen("mySplashScreenImg.jpg");
   9:     splashScreen.Show(true);
  10:     TestSplash.App app = new TestSplash.App();
  11:     app.InitializeComponent();
  12:     app.Run();
  13: }

The Show(true) call displays the splash screen image. The true parameter tells the application to close the splash screen automatically.

Modify the code to include the following:

   1: /// <summary>
   2: /// Application Entry Point.
   3: /// </summary>
   4: [System.STAThreadAttribute()]
   5: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
   6: public static void Main() 
   7: {
   8:     SplashScreen splashScreen = new SplashScreen("mySplashScreenImg.jpg");
   9:     splashScreen.Show(false); //false to close the splash screen manually
  10:     TestSplash.App app = new TestSplash.App();
  11:     app.InitializeComponent();
  12:     splashScreen.Close(TimeSpan.FromMilliseconds(5000)); //five seconds fade out !
  13:     app.Run();
  14: }

Now the splash screen’s fade out animation will take 5 seconds.

Embedding and Communicating with the Macromedia Flash Player in WPF

 

Embedding the Macromedia Flash Player ActiveX control is a relatively simple way to do the following:

  • Add functionality, graphics, or animation to your WPF application.
  • Extend the capabilities of your stand-alone Macromedia Flash application (such as adding file I/O capabilities to Macromedia Flash).
  • Use existing flash resources in your WPF application (i.e. Use Banners in your WPF application)

Before you decide to embed the Macromedia Flash Player ActiveX control within your WPF application, however, there are a number of things that you should consider:

  • Macromedia does not officially support embedding the Macromedia Flash Player ActiveX control within a Windows application. This means that future versions of the player may not work with your application.
  • It requires users to install the Macromedia Flash Player ActiveX control on their computers. This can be done by installing the player within Microsoft Internet Explorer. Although it is technically possible to distribute the player, that is restricted by the player's end-user license agreement. If you need to distribute the Macromedia Flash Player ActiveX control, contact Macromedia for permission.
  • Because it uses ActiveX technology, it works only on Windows OS.
  • Versions of the Macromedia Flash Player prior to version 6 did not support embedding within Windows applications. Users need version 6.0r79 or higher.

The easiest way to use the Macromedia Flash Player ActiveX control within your WPF applications is to create a WPF user control that will wrap the Flash Player.
As WPF currently does not support such a wrapper, we will use another wrapper of type WindowsFormsHost.
We’ll learn how to display Flash Player media within WPF application by following 4 major steps.

Step 1. Creating a WPF User Control Library

Our final goal would be having a WPF user control that would play Flash media files (swf/flv). Therefore, our first step is to create the WPF User Control Library that would wrap it all, and will be used by any WPF window or page.

1. Create a new WPF User Control Library project (mine was named MyBlogUserControls)

CreateTheWPFProject 

2. Add a new WPF User Control

AddWPFUserControl

3. Add a Uri property and a Loaded event to your new WPF User Control

public Uri Source { get; set; }     

private void FlashPlayer_Loaded(object sender, RoutedEventArgs e)
{

}
Step 2. Creating a Windows Forms User Control

As WPF does not support hosting an ActiveX control directly but Windows Forms does, we will use the Crossbow technology to host the Flash Player within our WPF application. We will add the Macromedia Flash Player ActiveX Control to our toolbox, and will wrap it within a Windows Forms User Control.

1. In your new project, add a reference to the WindowsFormsIntegration namespace (from the .NET tab)

AddWindowsFormsIntegrationRef

2. Add a new Windows Forms User Control to your project

AddWinFormsUserControl 

3. Open the new Windows Form User Control in design mode, and make sure the Toolbox toolbar is visible.

4. Right Click the toolbar within the All Windows Forms tab of the Toolbox toolbar and select the “Choose Items…” menu option.

ToolboxContextMenu

5. The Choose Toolbox Items dialog is opened. Go to COM Components tab, scroll down to the Shockwave Flash Object item and check it. Press OK.
If this item is not listed, make sure that the Macromedia Flash Player ActiveX control is installed on your system.

ChooseToolboxItems

6. Now you should have a Shockwave Flash Object within the All Windows Forms tab of the Toolbox toolbar

ShowaveInToolbox

7. Add the flash object to your Windows Forms User Control by dragging it, set its size according to your needs (if size is static), and name it (i.e. axShockwaveFlash).

8. Go to the Windows Form User Control source code and add Flash Player methods

public partial class WFFlashPlayer : UserControl
{
        public WFFlashPlayer()
        {
            InitializeComponent();
        }

        public new int Width 
        {
            get{ return axShockwaveFlash.Width; }
            set{ axShockwaveFlash.Width = value; }
        }

        public new int Height 
        {
            get{ return axShockwaveFlash.Height; }
            set{ axShockwaveFlash.Height = value; }
        }

        public void LoadMovie(string strPath)
        {
            axShockwaveFlash.LoadMovie(0, strPath);            
        }
       
        public void Play()
        {            
            axShockwaveFlash.Play();
        }

        public void Stop()
        {
            axShockwaveFlash.Stop();
        }        
}
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

Once we’ve completed this step, we have a Windows Forms User Control that wraps a Flash Player. Now we need to make it a WPF user control.

Step 3. Wrapping the Windows Forms User Control within our new WPF User Control using Crossbow

1. Open the WPF User Control XAML file.

2. Name the main Grid (or any other WPF container you’d like)

<UserControl x:Class="MyBlogUserControls.FlashPlayer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="300" Width="300" Loaded="FlashPlayer_Loaded">
    
    <Grid Name="FlashPlayerGrid">            
    </Grid>
</UserControl>
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

3. Open the WPF User Control Source Code.

4. Fill the Loaded event body with code to host the Windows Forms Flash Player, load the movie and play it

public partial class FlashPlayer : UserControl
{
        public FlashPlayer()
        {
            InitializeComponent();
        }

        public Uri Source { get; set; }     

        private void FlashPlayer_Loaded(object sender, RoutedEventArgs e)
        {
            WindowsFormsHost host = new WindowsFormsHost();
            WFFlashPlayer player = new WFFlashPlayer();
                        
            //the Windows Forms Host hosts the Flash Player
            host.Child = player;

            //the WPF Grid hosts the Windows Forms Host
            FlashPlayerGrid.Children.Add(host);

            //set size
            player.Width = (int)Width;
            player.Height = (int)Height;

            //load & play the movie
            player.LoadMovie(Source.AbsoluteUri);
            player.Play();
        }
}

Step 4. Using the new WPF Flash Player Control

Let’s use our new Flash Player within a WPF application.

1. Create a new WPF Application.

2. Add a reference to your User Controls Library (mine was MyBlogUserControls)

3. Open your Window’s XAML file.

4. Add the WPF User Control Library namespace to the Window Object

<Window x:Class="WPFLibTester.FirstPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:MyBlogUserControls;assembly=MyBlogUserControls"
    Title="FirstPage" Height="800" Width="800">
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

5. Add the WPF Flash Player to your window and set its source and size

<Window x:Class="WPFLibTester.FirstPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:MyBlogUserControls;assembly=MyBlogUserControls"
    Title="FirstPage" Height="800" Width="800">
    <Grid>        
        <controls:FlashPlayer Source="http://www.sothink.com/product/swfquicker/samples/specialEffect/Art_studio.swf" 
                  Width="700" Height="600" ></controls:FlashPlayer>
    </Grid>
</Window>
 

That’s it. I’ve covered here three methods from the Shockwave Flash Media Object. Of course you can communicate with any of the Flash Object API methods, by calling them from your Windows Forms User Control wrapper.

If you have troubles setting your Adobe Flash Player, you may find help here.

Enjoy.

Prototyping a WPF-3D game design workflow using TrueSpace 3D, Expression Blend 3 with SketchFlow

Interesting article on SketchFlow by Don Burnett:
http://www.uxmagic.com/blog/post/2009/07/12/Prototyping-a-WPF-3D-game-design-workflow-using-TrueSpace-3D-Expression-Blend-3-with-Sketchflow-and-exporting-the-prototype-XNA-Game-Studio.aspx

Background 

"Expression Studio’s Blend 3 With SketchFlow is an amazing tool. I have known about SketchFlow for a very long time (since March 2008. Microsoft had worked on gathering idea for it and spent a lot time on the concept, from customer feedback as early as 2006-2007 (maybe even before that). It has been in the works for a very long time with a huge amount of planning on the Expression team’s part.

While it is not UML, Sketchflow gives the same benefits and more. You can literally take a wireframe graphic to completed design all in the same tool. The player lets you share your work with your clients and fellow team members, let them mark up comments and make enhancements and changes and doesn’t require you to even be inside of blend. You could share it as a file (really a WPF based application)  or even on the web on a shared website using Silverlight."

 

WPF Localization Guidance

When you limit your product's availability to only one language, you limit your potential customer base to a fraction of our world’s 6.67 billion population. If you want your applications to reach a global audience, cost-effective localization of your product is one of the best and most economical ways to reach more customers.
It is imperative to define a globalization strategy early in the development lifecycle, in order to more quickly accommodate demands for future product releases that can reach global markets.

Application localization is not a trivial task for any type of application scenario. The process is based on a few core principles that apply to WPF as they do to any other type of client application with a user interface.
It is important for developers to understand the basic concepts of regional data display, locale-specific user interface customization and how to serve localized resources in both static and dynamic fashion. These concepts are very similar for most client applications but the actual process of localizing the static user interface components tends to vary between environments and WPF introduces yet another approach to resource localization for XAML resources.

Rick Strahl & Michele Leroux Bustamante have published a Localization Guidance whitepaper (June 2009). It starts with a quick review of general localization considerations for completeness, discusses how the .NET Framework handles resources for all applications, and then focuses specifically on localization scenarios for WPF explaining some of the trade-offs within each approach.
This whitepaper is complete and may be updated according to YOUR feedbacks.
Download it (and some source code) here: WPF Localization Guidance Whitepaper.

You may also be interested in Microsoft's WPF Globalization and Localization Overview, which has a lot in common with RIck and Michele's guidance.
And how would you implement the the translation of application resources into localized versions for the specific cultures that the application supports?
When you localize in WPF, you use the APIs in the System.Windows.Markup.Localizer namespace. These APIs power the LocBaml Tool Sample command-line tool, which was developed by Microsoft to present a sample that uses some of the localization APIs and illustrates how you might write a localization tool.

There is also the CodePlex WPF Localizationan Extention project which is a (FREE) stable extension project to localize any type of DependencyProperties on DependencyObjects.

As you can see, there are many (and good) ways to implement localization in WPF project. If you know any other great localization tools, please share it with us.
Thanks,
J.

Hardware Acceleration in WPF

Recently I’ve been getting several questions on hardware acceleration. Some people are running performance profiling tools and noticing that although it indicates that their application is running in hardware, the application is still taxing the CPU. This may seem confusing, so I will try to give some background in this posting.

History

Windows developers have been using the same display technologies for more than 15 years. A standard Windows application relies on two well-worn parts of the Windows operating system to create its user interface:

  • User32 - provides the familiar Windows look and feel for elements such as windows, buttons, text boxes, and so on.
  • GDI/GDI+ - provides drawing support for rendering shapes, text, and images at the cost of additional complexity (and often lackluster performance).

Over the years, both technologies have been refined, and the APIs that developers use to interact with them have changed dramatically. But behind the scenes the same parts of the Windows operating system are used. Newer frameworks simply deliver better interaction wrappers.

WPF still relies on User32 for certain services, such as handling and routing input and sorting out which application owns which portion of screen real estate.

DirectX

DirectX began as a cobbled-together, error-prone toolkit for creating games on the Windows platform. Its design mandate was speed, and so Microsoft worked closely with video card vendors to give DirectX the hardware acceleration needed for complex textures, special effects such as partial transparency, and three-dimensional graphics.
DirectX is now an integral part of Windows, with support for all modern video cards. However, the programming API for DirectX still reflects its roots as a game developer’s toolkit, and therefore is rarely used in traditional types of Windows applications.

more info

WPF Rendering

The internal architecture of WPF has two rendering pipelines, hardware and software.

Hardware Rendering Pipeline: One of the most important factors in determining WPF performance is that it is render bound—the more pixels you have to render, the greater the performance cost. However, The more rendering that can be offloaded to the graphics processing unit (GPU), the more performance benefits you can gain.

Software Rendering Pipeline: The WPF software rendering pipeline is entirely CPU bound. WPF implements an optimized, fully-featured software rasterizer (Rasterisation is the task of taking an image described in a vector graphics format and converting it into a raster image (pixels or dots) for output on a video display or printer, or for storage in a bitmap file format.). Fallback to software is seamless any time application functionality cannot be rendered using the hardware rendering pipeline.

The biggest performance issue you will encounter when rendering in software mode is related to fill rate, which is defined as the number of pixels that you are rendering. If you are concerned about performance in software rendering mode, try to minimize the number of times a pixel is redrawn. For example, if you have an application with a blue background, which then renders a slightly transparent image over it, you will render all of the pixels in the application twice. As a result, it will take twice as long to render the application with the image than if you had only the blue background.

Forcing Software Rendering

Depending on the machine configuration and the application, software-based rendering is sometimes faster than hardware.
A new API was presented in .NET 3.5 SP1 to allow developers to force software rendering in their application (per window) instead of using the GPU. This should provide developers a much better alternative than setting the global registry key and affecting all WPF applications.

   1: private void OnLoaded(object sender, EventArgs e)
   2:         {
   3:             if (ForceSoftware)
   4:             {
   5:                 HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
   6:                 HwndTarget hwndTarget = hwndSource.CompositionTarget;
   7:  
   8:                 // this is the new WPF API to force render mode. 
   9:                 hwndTarget.RenderMode = RenderMode.SoftwareOnly;
  10:             }
  11:         }

The RenderMode enumeration may be either Default (use hardware rendering, if possible, otherwise use software rendering) or SoftwareOnly (use software rendering).

Display Driver Model

WPF provides better performance under the Windows Vista operating system, where it can take advantage of the new Windows Vista Display Driver Model (WDDM). WDDM offers several important enhancements beyond the Windows XP Display Driver Model (XPDM). Most importantly, WDDM allows several GPU operations to be scheduled at once, and it allows video card memory to be paged to normal system memory if you exceed what’s available on the video card.
WPF offers some sort of hardware acceleration to all WDDM (Windows Vista) drivers and to XPDM (Windows XP) drivers that were created after November 2004, which is when Microsoft released new driver development guidelines.

Level of Support

The goal of WPF is to offload as much of the work as possible on the video card so that complex graphics routines are render-bound (limited by the GPU) rather than processor-bound (limited by your computer’s CPU).
WPF is intelligent enough to use hardware optimizations where possible, but it has a software fallback for everything. So if you run a WPF application on a computer with a legacy video card, the interface will still appear the way you designed it. Of course, the software alternative may be much slower, so you’ll find that computers with older video cards won’t run rich WPF applications very well, especially ones that incorporate complex animations or other intense graphical effects. You might want to consider a design that allows your application to seamlessly switch features when running on different hardware, so that it can take full advantage of each different hardware configuration.

To achieve this, WPF provides functionality to determine the graphics capability of a system at runtime. Graphics capability is determined by categorizing the video card as one of three rendering capability tiers. WPF exposes an API that allows an application to query the rendering capability tier. Your application can then take different code paths at run time depending on the rendering tier supported by the hardware.

The features of the graphics hardware that most impact the rendering tier levels are:

  • Video RAM The amount of video memory on the graphics hardware determines the size and number of buffers that can be used for compositing graphics.

  • Pixel Shader A pixel shader is a graphics processing function that calculates effects on a per-pixel basis. Depending on the resolution of the displayed graphics, there could be several million pixels that need to be processed for each display frame.

  • Vertex Shader A vertex shader is a graphics processing function that performs mathematical operations on the vertex data of the object.

  • Multitexture Support Multitexture support refers to the ability to apply two or more distinct textures during a blending operation on a 3D graphics object. The degree of multitexture support is determined by the number of multitexture units on the graphics hardware.

The pixel shader, vertex shader, and multitexture features are used to define specific DirectX version levels, which, in turn, are used to define the different rendering tiers in WPF.

The features of the graphics hardware determine the rendering capability of a WPF application. The WPF system defines three rendering tiers:

  • Rendering Tier 0
    A rendering tier value of 0 means that there is no graphics hardware acceleration available for the application on the device. At this tier level, developers should assume that all graphics will be rendered by software with no hardware acceleration. This tier's functionality corresponds to a DirectX version that is less than 7.0.

  • Rendering Tier 1
    A rendering tier value of 1 means that there is partial graphics hardware acceleration available on the video card. 

    The following features and capabilities are hardware accelerated for rendering tier 1:

    • 2D rendering
    • 3D rasterization
    • 3D anisotrophic filtering
    • 3D mip mapping

    The following graphics hardware features define rendering tier 1:

    • DirectX version (7.0 =< ver < 9.0)
    • Video RAM (>= 30MB),
    • Multitexture units (>= 2)


  • Rendering Tier 2
    A rendering tier value of 2 means that most of the graphics features of WPF should use hardware acceleration. 

    The following features and capabilities are hardware accelerated for rendering tier 2:

    • Tier 1 features
    • Radial gradients
    • 3D lighting calculations
    • Text rendering
    • 3D anti-aliasing

    The following graphics hardware features define rendering tier 2:

    • DirectX version (>= 9.0)
    • Video RAM (>= 120MB)
    • Pixel shader (version >= 2.0)
    • Vertex shader (version >= 2.0)
    • Multitexture units (>= 4)

RenderCapability.Tier Property

The Tier property allows you to retrieve the rendering tier at application run time. You might choose to scale down
complex effects in the user interface, depending on the level of hardware acceleration that’s available in the client.
There’s one trick, the rendering tier corresponds to the high-order word of the Tier property, so to extract its value from the Tier property, you need to shift it 16 bits:

int renderingTier = (RenderCapability.Tier >> 16);

No Acceleration

The following features and capabilities are not hardware accelerated:

  • Bitmap effects
  • Printed content
  • Rasterized content that uses RenderTargetBitmap
  • Tiled content that uses TileBrush
  • Surfaces that exceed the maximum texture size of the graphics
  • Any operation whose video RAM requirement exceeds the memory of the graphics hardware
  • Layered windows (only on XP)

Graphics Rendering Registry Settings

WPF provides registry settings for troubleshooting, debugging, and product support purposes. However, because changes to the registry affect all WPF applications, your application should never alter these registry keys automatically, or during installation.

Disable Hardware Acceleration Option

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\DisableHWAcceleration]

The disable hardware acceleration option enables you to turn off (set its DOWRD value to 1) hardware acceleration for debugging and test purposes. When you see rendering artifacts in an application, try turning off hardware acceleration. If the artifact disappears, the problem might be with your video driver.
A value of 0 enables hardware acceleration.

Maximum Multisample Value

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\MaxMultisampleType]

The maximum multisample value enables you to adjust the maximum amount of anti-aliasing of 3-D content (0-16).
WPF defaults to 0 for XPDM drivers and 4 for WDDM drivers.

Required Video Driver Date Setting

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\RequiredVideoDriverDate]

In November, 2004, Microsoft released a new version of the driver testing guidelines; the drivers written after this date offer better stability. By default, WPF will use the hardware acceleration pipeline for these drivers and will fall back to software rendering for XPDM drivers published before this date.

The required video driver date setting enables you to specify an alternate minimum date for XPDM drivers. You should only specify a date earlier than November, 2004 if you are confident that your video driver is stable enough to support WPF.

Use Reference Rasterizer Option

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\UseReferenceRasterizer]

The use reference rasterizer option enables you to force WPF into a simulated hardware rendering mode for debugging: WPF goes into hardware mode, but uses the Microsoft Direct3D reference software rasterizer, d3dref9.dll, instead of an actual hardware device.

more info

WPF Performance Profiling Tools

WPF provides (in the Windows SDK tool) a suite of performance profiling tools (WPFPerf.exe) that allow you to analyze the run-time behavior of your application and determine the types of performance optimizations you can apply.

  • Event Trace - Use for analyzing events and generating event log files.
  • Perforator - Use for analyzing rendering behavior.
  • Trace Viewer - Record, display, and browse Event Tracing for Windows (ETW) log files in a WPF user-interface format.
  • Visual Profiler - Use for profiling the use of WPF services, such as layout and event handling, by elements in the visual tree.
  • Working Set Viewer - Use for analyzing the working set characteristics of your application.

more info

DirectX Diagnostic Tool

The DirectX Diagnostic Tool (~\Windows\System32\Dxdiag.exe) is designed to help you troubleshoot DirectX-related issues.

more info

Sources:

digiTweet – an Open Source WPF Desktop Twitter Client

I love Twitter.  Like many users I have moved away from the website to a client application (Powerful software, combined with the cloud – sound familiar?).

I used to tweet using TweetDeck and twhirl which can be loaded on every PC, Mac or Ubuntu machine. However, being a .NET and WPF guy, there are a few things that bug me about most Twitter clients.

  • Most of the Twitter clients run in AIR, being a great cross-platform (I use Windows only) light-weight (not so light) applications. I’m sure the amazing .NET community can do it better.
  • Being a cross-platform application, they give up all the great Windows stuff, especially Windows 7.
  • Being a .NET guy, I’m partial to apps that are build with .NET, especially WPF, and I would love to see a Twitter client written in WPF or Silverlight.

Now, the only solution to my bothers is the developer community to want it happen. They got the power. This brings us to digiTweet.
digiTweet is an Open Source project, sponsored initially by my team at Microsoft Canada in conjunction with friends at Digiflare.

DigiTweet is obviously a desktop application for Twitter.  It is built completely using .NET technologies and takes particular advantage of the power of WPF. Additionally, DigiTweet will be implementing several Windows 7 specific features in the coming weeks.
You can sneak preview it on flickr.

Why do we need another Twitter client? I think that a WPF powered application, combined with the power of Windows can provide Twitter users with an amazing experience.
This is why the DigiTweet application is an open source project at Codeplex. It brings many innovative developers to contribute to making this the best Twitter client for Windows (and hopefully showcase what WPF can do along the way).

So, give digiTweet a try.  More importantly, download the code and try make it better.

You can also follow digiTweet’s progress on Twitter @digi_tweet.

Janiv.

Offline WPF .Net Framework 4.0 documentation

Microsoft has published MSDN docs that are scoped only for WPF 4.0. 

Want fast WPF help (from the WPF SDK team members) without an internet connection?

Download the WPF CHM.

IMPORTANT! If you open the CHM and cannot view content, do the following to resolve the issue:
- Right-click the CHM file, and then click "Properties".
- Click "Unblock".
- Double-click the .chm file to open the file.

 

Janiv.

General Download of VS2010 / .NET Framework 4.0 Beta 1

Great news.
Beta 1, which has been available to MSDN subscribers since Monday, is now available to everyone.

You can download the following installations from the Visual Studio 2010 and .NET Framework 4 Beta Homepage:

Visual Studio Team System 2010 Team Suite Beta 1
Visual Studio Team Foundation Server 2010 Beta 1
Visual Studio 2010 Professional Beta 1
.NET Framework 4 Beta 1

You can find a detailed walk through of Beta 1 here (by Jason Zander).

  
This beta does have full setup available so you can provision it yourself. The product is designed to work cleanly with VS2008, however like any pre-release software you should be careful about using the product on your main machine.

If you want to give Microsoft feedbacks, do it through Visual Studio 2010 / .NET Framework 4 Beta 1 Forums.


 

Hello, Hola, مرحبا, Bonjour, 喂, Привет, Hallo, こんにちは, Hej, हैलो, Ciao

Back to English ...

Hello Everyone! Welcome to the new kid in the Microsoft Israel Community.
It is kind of scary to open a new blog nowadays, as there are only 1.4M new blog posts every day (June 2008), but I believe it is time to share my knowledge and thoughts with you.

So what is this blog going to be about? That presumably will develop as I do, but my initial idea (and dare I say niche) is to focus on UI development and WPF, with occasional technology stuff thrown in.
I’ll use this blog to share news stories I find interesting, show some source code from interesting projects, share some tips and tricks, carry weighty discussions on relevant issues, and maybe more.
My great challenge will be to make this blog a touch more interesting than just a knowledge base.

So Bookmark this blog, email to a friend/colleague or add its RSS feed, and let’s hit the road for our long trip. And of course, this blog is intended for you, so if at any point you have any comments or suggestions, please let me know so that I can make improvements.

Until next time …
J.