June 2007 - Posts - Rudi Grobler

June 2007 - Posts

XPE Weekly (28 June 2007)

For this week's edition of XPE Weekly I decided to start off by posting a link to an excellent article to convince the unbelievers... Mike Hall answers some common questions by developers to why they should use XPE

http://msdn2.microsoft.com/en-us/embedded/aa731327.aspx

Tips

Use the forum

This is probably the most important tip I can ever give: USE THE FORUM. If you have any problem, ask the experts... Sean Liming, Desi Richards, Andy Allred and many more are active members answering questions daily!!!

http://forums.microsoft.com/embeddedwindows/default.aspx?siteid=47

How to log into XPE automatically

A very common question is: I created my image and now I have to log into windows using a user name and password. How do I log in automatically? Before building the image, add the "Automatic Logon" component or at runtime, select start -> Run and type the following: Control userpasswords2 and then un-tick "User must enter user name and password to use this computer"

Design Templates

When you start building XPE images and you are not sure which component to add, start by using the Design Templates. They are very useful and add all the basic components needed. One of these that I often use is the Kiosk/Gaming Console template. It adds the following to your image: Basic TCP/IP Networking, IE, DirectX 9.0c, Audio, Local Printing and Dial-up support.

Links

The following blogs are very useful:

Mike Hall

http://blogs.msdn.com/mikehall

Konstantin Morozov

http://km-dev.blogspot.com/

Sean Liming

http://www.seanliming.com/

And that is all for this week's edition. If you have any question please feel free to email me at rudi@cme.co.za. I am also busy writing a tutorial on how to build a basic XPE image as training at the company where I currently work. I will publish this in a later edition if there is a demand?

Posted by rudi | with no comments
Filed under:

WPF Roundup

Found the following interesting links while surfing the web:

Snack Tutorials for the Hungry

Celso Gomes (The developer responsible for the awesome demo applications shipped with blend), has now created a website full of tutorials relating to WPF and Silverlight.

http://www.nibblestutorials.net/

How to create "Vista Style" button templates

Found a nice article on how to create "Vista Style" button templates on the Expression Teams blog

http://blogs.msdn.com/expression/archive/2007/06/08/creating-a-vista-style-button-template.aspx

Interacting with 2D on 3D

Found an interesting article showing how to interact with 2D components on a 3D surface

http://blogs.msdn.com/wpf3d/archive/2006/12/12/interacting-with-2d-on-3d-in-wpf.aspx

If you have time: Petzold vs. Nathan

A lengthy discussion on whose WPF book is better...

http://blogs.msdn.com/adam_nathan/archive/2007/04/30/petzold-vs-nathan.aspx

 

Posted by rudi | with no comments
Filed under:

Yahoo! Messenger for Vista Clone

Avatar

The following Hands-on lab describes how to create a very basic clone of the Yahoo! Messenger for Vista.

Hands-on Lab

http://dotnet.org.za/files/folders/members/entry190337.aspx

Required Images

http://dotnet.org.za/blogs/rudi/Avatar.gif

http://dotnet.org.za/blogs/rudi/YahooLogo.gif

Notes:

Transparancy doesn't preform very well under windows XP. In XP the transparancy is handled by the CPU (Software) and not by the GPU (Hardware)

[EDIT]

For anybody who hasn't seen what the new messenger looks like, have a look at the following website:

http://www.frogdesign.com/case-study/yahoo-messenger-for-windows-vista.html

Please also note that this is a very basic attempt to recreate what I can deduct from the pictures. I am only trying to proof to myself how the transparancy works and to test the performance. I am in no way tring to make my own messenger or steel there design. I think Yahoo and Frog Design did a excellent design. I am looking forward to testing it out when it gets released. Also note that I am not a how-to writter and that this HOL is very basic. It only tells you which UIElements to add and what settings to change to get it looking similar.

Posted by rudi | with no comments
Filed under:

Mono + Silverlight = Moonlight

A new project is launched by the mono project to support silverlight. Visit the following site for a status update:

http://www.mono-project.com/Moonlight

Moonlight

Posted by rudi | with no comments
Filed under:

Orcas, play nice with Blend!

Since installing Orcas on my pc, I have discovered that blend can't read projects opened and converted by using Orcas C#... This was a huge pain and I eventually has to reinstall my C# 2005... I just stumbled upon a link to a program called BlendConfigurator that actually solves this problem...

 http://blogs.msdn.com/expression/archive/2007/05/29/working-with-visual-studio-code-name-orcas-and-expression-blend.aspx

 

Posted by rudi | with no comments
Filed under: ,

Outlook 2007 Clone using WPF?

A great new hands-on lab is posted by microsoft showing how to create a WPF clone of the Outlook UI

http://www.microsoft.com/switzerland/msdn/de/events/hol/wpf.mspx

Posted by rudi | with no comments
Filed under:

How to filter a list

I have a list of blogs and I want to be able to filter these items by just typing leters contained in the title of these blogs and the list box must then only show the items which contains these leters...

I started by creating a List<string> of blogs

List<string> blogs;

The next step is to initialize this list and add some content...

blogs = new List<string>();
blogs.Add("Zlatan's Blog ");

My WPF window contains a TextBox names txtSearch and a ListBox named lbItems. Next, you have to bind the blogs list to the ListBox

lbItems.ItemsSource = blogs;

Now is a good time to save and test. A list of all the blogs previously added should now be displayed. Next step is to add a ICollectionView

ICollectionView view;

Next we have to find the defualt view for this array

view = CollectionViewSource.GetDefaultView(blogs);

We also need to add two delegates, the first delegate is for Filter


view.Filter = delegate(object obj
{
    
if string.IsNullOrEmpty(txtSearch.Text))
      
return true
    
string str obj.ToString();
    
if (string.IsNullOrEmpty(str)) 
      
return false;

    
int index str.IndexOftxtSearch.Text0StringComparison.InvariantCultureIgnoreCase); 
    
return index > -1
};

This delegate checks the provided item if it contains any part of the provided search string (txtSearch). Lastly, we need to add another delegate for the TextChanged event of the txtSearch to refresh the view

txtSearch.TextChanged += delegate
{
    view.Refresh
();
};

And that is all that is needed to automatically filter the items based on the provided part of text.

Posted by rudi | 2 comment(s)
Filed under:

DotNet Reader Released...

As requested by Armand, I have uploaded the DotNet Reader. Please note that this application was only for my own education. Flowdocuments are a very intersting subject in WPF and to truly explore its rich functionalaty you need a simple senario that emphasizes the How and not that What. What could be more simple than RSS? So I thought... While RSS is a very simple concept and relativly easy to implement. It has some very interesting and usefull features. Most of us are aware of what RSS is so I will skip the RSS 101 but I just want to mention 2 new things that I have learned about RSS while doing this project:

How to enable IE7 to automatically discover RSS feeds from a website

IE7 has a Feeds button in the tool bar that is by default disabled. When a website exposes it feeds, the button lights up and allow the user to view the feed. What is also new in IE7 is that the RSS feed is not only viewed as XML but is actually automatically formated. To allow IE7 to discover the feed, a link tag must be added to the <head> section

<link rel="..." type="application/rss+xml" title="My feeds" href="rss.xml"/>

RSS feeds can be treated as lists

Normally feeds are viewed in reverse chronological order. If you expose a list of technologies that you currently find interesting and allow members to link to this feed, use Simple List Extensions(SLE) to sort and order these items. Various sorting and grouping keys can be defined. By adding the following to the <channel> section enables SLE

<cf:treatAs>list</cf:treatAs>

Have a look at the eBay search results for some examples

Because the reader is more aout the FlowDocument and less about how I implemented my RSS reader, I decided to borrow a RSS implementation from a silverlight application called the Socializer.I have commmented out all the FOAF stuff and only left the implementation of the feed reader. I then disabled the reading of the rss using HttpWebRequest and rather hard coded it to read a local copy of a RSS feed. I have tested the web implementation and it works. A later version might rather link to the web but for now, I decided to only read a local copy of the RSS feeds.

I also added a dummy Flicker control to display how to add dynamic content to a flow document. Currently this is only a dummy control that rotates between two photos at a 10 second interval (I hope Andre won't charge me royalties for using 2 of his Flicker photos :-).

this program was created using Expersion Blender beta 2 and Visual C# 2005 Express. It should also compile in Orcas. to run this application you either need Vista or XP with .NET framework 3.0 installed. I haven't thoroughly tested this application, so please keep that in mind when using it and enjoy...

 Download the reader here: http://dotnet.org.za/files/folders/186390/download.aspx

Posted by rudi | with no comments
Filed under: ,

DotNet.org.za News Reader

After the huge success of the New York Times Reader, three more big media companies have released web/desktop news readers utilizing WPF. The Daily Mail in the UK, Forbes and Seattle Post Intelligencer has all released some excellent news readers based on the same design as New York Times Reader. The new FlowDocument provides unlimited control over how documents can be displayed. I decided to test this theory and write my own News Reader/RSS Feed reader based on FlowDocument and document some of the common problems I ran into. Also note that this application was written in less than 2 hours. It has no online/offline features yet but can display all the feeds from dotnet.org.za.

One of the things that took the longest for me to figure out had nothing even to-do with the FlowDocument. The RSS feeds have html embedded into the description field and to decode that back into XAML and display it in a FlowDocument had me struggling. I finally found a very nice library that converted html to XAML:

http://wpf.netfx3.com/files/folders/developer/entry816.aspx

string XAML = HTMLConverter.HtmlToXamlConverter.ConvertHtmlToXaml(text, false);

MemoryStream memory = new MemoryStream(XAML.Length);

StreamWriter writer = new StreamWriter(memory);

writer.Write(XAML);

writer.Flush();

memory.Seek(0, SeekOrigin.Begin);

 

Section obj = System.Windows.Markup.XamlReader.Load(memory) as Section;

feeds.Blocks.Add(obj);

 

The following code takes the HTML from the RSS feed and loads it into the HTML-to-XAML converter. The resulting XAML is then converted into a Section. I then add the section to the blocks of the FlowDocument.

I only had to make one small change to the conversion library. I removed the formatting of the Span token to allow all my paragraphs to be displayed with the same font and not use the font from the feed.

I also added a style for the Paragraph object in the XAML to format each blog entry's font setting

<Style  TargetType="{x:Type Paragraph}">

   <Setter Property="Paragraph.FontFamily" Value="Georgia" />

   <Setter Property="Paragraph.FontSize" Value="11" />

   <Setter Property="TextBlock.TextWrapping" Value="Wrap" />

   <Setter Property="Paragraph.Margin" Value="5,10,5,10" />

</Style>

 

Here is a simple screen cap of how the final application looked:

News Reader

Feature enhancement might include:

  • Online/Offline
  • Link to Flicker, Photobucket, Facebook and download dynamic content based on member profiles?
Posted by rudi | 3 comment(s)
Filed under:

What is the difference between WPF on XP and Vista

Last night I wanted to try and find out what the difference is between XP and Vista’s implementation of WPF. I found an excellent blog by Tim Sneath were he summarized the following as the major differences:

·         With DWM and a WDDM-class display driver, video RAM is virtualized so you don’t have to worry about WPF being forced into a software rendering mode because it’s run out of headroom;

·         3D anti-aliasing is available on Windows Vista with a WDDM driver;

·         There’s work done to integrate with other parts of the platform that take advantage of the MIL, so for example the Magnifier accessibility tool in Windows Vista scales up WPF applications using vectors rather than bitmaps;

·         WPF animations on Windows Vista should be smooth and tear free if the DWM is enabled;

·         The tablet PC APIs expose a few minor Windows Vista-specific features relating to gesture support.

·         When remoting between two machines running Windows Vista and DWM, the client-side rendering of a WPF app will be hardware accelerated. No hardware acceleration occurs if one or more of the machines is running Windows XP; bitmap remoting will be used. The performance difference can quite significant depending on the visual complexity/use of animations in the app.

He also reiterated that there’s no XP version and then another Vista version but that thy actually have identical codebase.

 

Posted by rudi | with no comments
Filed under: ,

XPE Weekly (12 June 2007)

Welcome to the second edition of the XPE weekly newsletter. After some positive response and loads of emails requesting the download URL for the trail edition of XPE, I decided to post this URL for the trail edition:

http://www.microsoft.com/downloads/details.aspx?FamilyID=dacd1722-256b-48c5-91c1-af6062340efc&displaylang=en

Blue screen of death

We all hate to see the blue screen of death but no one can deny that they sometimes provide valuable information on how to solve the problem. The following 2 errors are the most common blue screens when building a XPE image:

STOP CODE 6B

If your runtime bug checks, or blue screens the first time you boot into it and it errors with bug check code 6B, this indicates that you left out a necessary file system component. For instance, if you have satisfied your file system component requirement in Target Designer by adding the file allocation table (FAT) component, but the destination partition has NTFS, then you will receive this error. You will also see this error if you only added NTFS, but your system required FAT. There are four file system components in the database: FAT, NTFS, CDFS (for CDs) and UDFS (for DVDs). If you wish, you can add all four components. They will not conflict with each other.

Note: The FAT component is for FAT16 and FAT32.

STOP CODE 7B

If your runtime bug checks, or blue screens the first time you boot into it and it errors with bug check code 7B, this indicates that you left out a critical boot device. This boot device could include one of the following components: a disk drive, an Integrated Drive Electronics (IDE) controller, a primary IDE channel, a secondary IDE channel, a PCI bus, or another boot device.

The two most common causes:

You have built the hardware configuration yourself without using the tools to query the target machine for its devices.

You used ta.exe in the bios on the target machine but it returned information that could not be found in the database. This means you could have missed a critical device in the configuration process. If you know the specific component or one that is compatible, such as a generic driver that is in the database, try adding one of these components into your configuration and build the runtime again.

Try one of the following solutions:

Use tap.exe instead of ta.exe. Using tap can be virtually foolproof and it will determine all devices necessary. You can only run tap from Windows 2000 or Windows XP. Tap will query the registry to identify the correct devices that Windows Setup determined would be best for that machine. Another downside to tap is that it will pull in any devices that it used to install in that machine but were subsequently removed, as well as pull in some software enumerated devices into your configuration that you may not want or need. If this happens, delete the unnecessary component from your configuration.

The second solution would be to examine device manager in a safe build successfully installed on the target machine. For instance, if you already have Windows XP or Windows 2000 installed, open device manager and identify the critical device listed in Device Manager that is missing from your configuration in Target Designer. Then locate the device with the same display name in Target Designer and add it to your configuration.

[Taken from MSDN article]

Feature Pack 2008 - Update Rollup 1.0

Want to run a WPF application on your XPE installation? Download the newly released Feature Pack 20008. Some of the new features include:  .NET 3.0, WMP 11, IE7, etc...

http://www.microsoft.com/downloads/details.aspx?FamilyID=70a79e6f-ce42-45c7-add2-52f57959ecf2&DisplayLang=en

Deployment tip

If you want to install XPe using WinPE over a network then your network must have a DHCP server. Not all companies use a DHCP server. I found a very handy application that "emulates" a DHCP server and allow you to easily deploy your XPE images over a network setup

http://tftpd32.jounin.net/

That is all for this week's edition. For any queries or suggestions, email me at rudi@cme.co.za

 

Posted by rudi | with no comments
Filed under:

Animation 101

Last night I was working on the GUI for Impilo Health Management and decided to try out WPF animation. Because the KIOSK application is designed for a touch screen environment, I wanted on top of the menu buttons a little animation that fist showed the word "Touch" and after a second hide the "Touch" and write "Here". This was very easy using WPF and blend. I just added a timeline and hidden the "Here" for 1 second and then hidden the "Touch" and replaced it with the now visible "Here". The only thing I could not setup only using blend was to change the storyboard to repeat forever? I unfortunately needed to change the XAML to enable this feature:

<Storyboard x:Key="AnimateBtn" RepeatBehavior="Forever">

For more information visit http://www.codeplex.com/Impilo

Posted by rudi | with no comments
Filed under: ,

XPE Weekly (05 June 2007)

Welcome to the first edition of Windows XP Embedded Weekly… Based on popularity, this might only be a monthly or bi-weekly updated post so the name might still change! I will start by answering two of the most common questions briefly:

Q) What is Windows XP Embedded

A) XPe is a componentized version of Windows XP Professional. It uses the exact same binaries.

Q) Why should I use XPe

A) Smaller footprint, Win32 API Support & Embedded enabling features are just some of the advantages

Tips & Tricks

The following tips & tricks might be usefull building your first image:

TAP a "pure" XPProSP2 installation

Do not run the 16-bit version of Target Analyzer (TA.EXE) under DOS. Do not run the 32-bit version of Target Analyzer (TAP.EXE) under a Windows PE (or BartPE) boot. Do not run TAP on a XP Home or Pro installation that has been updated with drivers or other patches.

Install Windows XP Professional with Service Pack 2 (XPProSP2) on the system, and do not update any drivers. Leave them as-is. That is the absolute best way to generate the most "pure" Devices.PMQ file for use in the next recommendation. I have had nothing but issues with TAP when run under a Windows PE environment (let alone TA in a DOS one).

Yes, still do this even if you have 3, 4, 5+ "Unknown Devices" under Device Manager in XPProSP2, or if you normally update drivers. As long as the XPProSP2 installation can boot on its own (meaning the storage driver and other core components work), this is the "pure" Devices.PMQ file you want.

Do not worry about having all or the latest drivers installed in XPProSP2 for Target Analyzer. The PCI vendor/ID information will result in updated drivers in the Component Database being used when you build a target. In fact, I've found that sometimes updating the driver in XPProSP2 (e.g., the ViA Ultra ATA Bus Master driver) and then seemingly importing its "equivalent" SLD component into the Component Database (e.g., from ViAEmbedded.COM) does not work as it should. It's far better to stick with the "older" driver under XPProSP2 when TAP runs, than what you have updated in your Component Database.

Regarding missing drivers and, therefore, devices missed by TAP that don't make it into your Device.PMQ and, subsequent, SLD file, just manually add them to your target. The First Boot Agent (FBA) will automatically configure any missing devices as long as their components were included in the target. So just because they weren't setup under XPProSP2 when TAP was run doesn't mean they won't be available in XPE -- because that's the job of the FBA, to find all hardware and setup such devices.

To summarize, the focus of the Device.PMQ is to get a full set of "pure" components that will let XPE boot. Running the 32-bit version of Target Analyzer (TAP) under a "pure" (no added drivers/software) Windows XP Professional with Service Pack 2 (XPPProSP2) is the best recommendation I can make given 50+ hours of trial and error with 3 different SBC/Mini-ITX systems.

Fixed Disk CompactFlash boot requirement

This is one of the most grossly overlooked aspects of XP Embedded, and virtually ignored in Microsoft's own documentation. Unlike DOS (including Windows 9x) and Linux, the NT loader (NTLDR) has some very picky requirements on CompactFlash boot.

First off, the more well-known fact is the reality that the CompactFlash must be connected to an ATA channel. I knew this from the get-go, and made sure I had SBC/Mini-ITX systems with either ATA-to-CompactFlash logic on-PCB, or an external ATA-to-CompactFlash adapter.

Secondly, and far less well understood, is the fact that the CompactFlash must appear as a "fixed disk" with a "partition" and not as a "removable" device. I use the terms "partition" and "removable" explicitly as they would appear under NT5 (2000/XP)'s DiskPart utility. Boot Windows XP, Windows PE or BartPE and run DiskPart to see the format type.

There is a lot of commentary out there that an ATA-to-CompactFlash adapter removes this requirement. This is completely false. It's not geometry, ATA format or other issue -- it's the way the CompactFlash device itself presents. Now for DOS or Linux, it has no issue. But for Windows XP, the NTLDR absolute does not want to boot from anything that identifies itself as a "removable" device.

The reasons for this stem from countless, legacy NT design flaws and other ways to prevent (or at least inhibit) copying of a NT system that still plagues NT5+ (2000/XP). I won't go into the extensive technical reasons. But even if you use an alternative master boot record (MBR) and even some disk translating bootstrap, there appears to be no way around the issue.

In a nutshell, the "fixed disk" format is incompatible with "normal consumer usage," so you cannot find them anywhere but from a few CompactFlash vendors as a specialized OEM/Industrial part. And even then, it's typically an added P/N for the "fixed" configuration. E.g., SimpleTech's part numbers are typically of the form SLCFxxxJ-F (the "-F" suffix meaning "fixed" configuration).

The good news is that these devices typically come from the factory with the bootstrap already setup with the bootstrap for NTLR. So it's just a matter of copying over the file tree. No need to run BOOTPREP or any other utility. I mean, and side note/rant here, isn't it ironic that you have to use a set of 16-bit DOS utilities like BOOTPREP, which is always an issue in supporting a 32-bit OS like NT which may differ in geometry, hardware access, etc...?

Taken from BS Blog

Links

Windows XP Embedded Wiki

https://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsXPEmbedded

Windows XP Embedded SP2 Feature Pack 2007

http://www.microsoft.com/downloads/details.aspx?FamilyID=9bdf1dea-a37e-4d25-83df-aabbaa78914f&displaylang=en

And that is all for the first edition… If you need a copy of XPe Trail Edition or have any questions, please email me at rudi@cme.co.za. Any suggestions on how to improve the blog or any subjects that need to be covered would be appreciated…

Posted by rudi | with no comments
Filed under:

XPE Weekly?

For the last 2 Years I've been using Windows XP Embedded very extensively. A quick search on our Pastel showed that we sold +/- 2400 licenses in the last financial year. I have build and debugged various system and learned some very interesting tips and tricks. I was wondering if any of the dotnet.org members would be interested in blogs about XPE?

Posted by rudi | 2 comment(s)
Filed under:

LINQing a VS2005 Application

I have an already existing VS2005 application to which I want to add LINQ support. The following 2 changes enable LINQ:

  • Edit the .csproj file and replace

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

with

<Import Project="$(ProgramFiles)\LINQ Preview\Misc\Linq.targets" />

This enable Implicit Typed Local Variable using the VAR keyword, Anonymous Types and Extension Methods. Lambda Expressions and Collection initializers seems to work even if you don't edit the .csproj file.

  • To enable LINQ queries add the following

using System.Query

Posted by rudi | with no comments
Filed under: