Contents tagged with WinFX
Now sitting here at LAX and reflecting over what we have experienced during the PDC 2008 the last few days. We learned a lot about technical stuff and what’s growing up in Redmond, but I think the most important stuff is what’s happening to the software business in large. With Windows Azure as the first large scale service host and with the number of online services that Microsoft will release in the upcoming years we have a real challenge to adapt to these new business models. Not only Microsoft is running this way, just look at Amazon and others, but Microsoft have such an effect on a large number of users.
We are going to see how our business models will be changed in a few years, and it is time to start thinking about this now. Ok, now you say; I know SOA, I can make web services…but it’s not all about that it’s just the technology that will be used. But it’s fine as long as you know the technology you’re right on track. Several of the PDC sessions was about how to architect solutions for the cloud, which is somewhat different than having your services on premise. If you haven’t watched them I urge you to do so.
Another thing that was really evident at the PDC was that the imperative programming paradigm will and can be replaced with more declarative programming and functional programming. This will be painful for a lot of developers, including me. Same here, you better get to start adapting to this. You have no-code XAML workflows, F# and last but not least Oslo to start with. Of course we will have standard old imperative languages for a long time to come, but you should know when to use other approaches, and knowing about this will be a competitive advantage for you.
This is what I have been thinking about since PDC ended and i know I don’t cover it all here, but it’s just to give you a hint of where the winds are blowing…
Now I have to kill a few hours here at LAX before a long flight home to my beloved family. See ya around.
When .NET 2.0 was introduced, quite a long time ago, the whole System.Xml namespace was re-written, due to the poor performance of the System.Xml implementation. Despite the fact that the CLR 2.0 has been around for a few years there are still implementations using CLR 1.x and especially the XSL transformation bits, since that part is completely re-written and marked as obsolete.
But note that they are only being marked as obsolete! You can still compile and run most of the code with just a compiler warning. The old .NET 1.1 classes are still in the CLR 2.0, so you can convert your XSL transformations piece by piece and start using .NET 2.0 or even .NET 3.5 since it is based on .CLR 2.0 (read this post by Scott Hanselman to get a better understanding).
Just make sure that you test everything really thoroughly before putting it in production, since it is not supported.
I am currently moving one of our large applications to .NET 3.5, which has been working really smooth using .NET 1.1, but now I want to use Visual Studio 2008 and C# 3.0 in the upcoming versions. We will eventually upgrade the XSL transformation parts to use the XslCompiledTransform class, but until then we have to stick with the .NET 1.1 classes.
I have stumbled upon a few weird things that stopped working after making the upgrade, not all XSL transformations work out fine. The XSLT not() function stopped working in several XSLT files. This is due to that Microsoft has re-written even these old obsolete classes, not just moved them to a new namespace.
For example I have this XSL snippet, which works fine under a .NET 1.1 compiled environment, which I use to mark alternating lines in different colors.
xsl:if test="not(position() mod 2)">...
In .NET 2.0+ I get an System.InvalidCastException when transforming the XSLT, using the old XSLT transformation classes.
A quick look using the Reflector tool shows us that they have changed the Not function in the BooleanFunctions class (MS.Internal.Xml.XPath.BooleanFunctions in .NET 2.0 and System.Xml.XPath.BooleanFunctions in .NET 1.1). The .NET 1.1 converts the result of the inner expression using the safe Convert.ToBoolean while the .NET 2.0 implementation uses an explicit cast (bool) to convert the result.
The result of the mod operation is a double according to the MS.Internal.Xml.XPath.NumericExpr.GetValue method in .NET 2.0 and System.Xml.XPath.NumericExpr.getValue in .NET 1.1. Both of them are implicitly casted to objects before casted to booleans.
// .NET 2.0 not() implementation !((bool) query); // .NET 1.1 not() implementation !Convert.ToBoolean(query);
The same is for all numeric operations (plus, minus, multiplication, division, modulus and negate) inside the not() XSLT function.
I guess we can't expect a fix for this, even if it would be welcome. But now you know it!
The problem above was solved with this expression instead:
xsl:if test="(position() mod 2) = 0">
P.S. To get rid of the compiler warnings, insert these pragma directives in your C# code:
#pragma warning disable 0618 // Disable warning CS0618 from here // your code goes here #pragma warning restore 0618
A few months ago I wrote about the Architecture Journal Reader, a great demonstration app for a "occasionally-connected" Windows Presentation Foundation, WPF, application. I asked for source code and more samples like this, and sometimes dreams come true.
Today Tim Sneath announced the public availability of a News Reader SDK and a Syndicated Client Experiences (SCE) Starter Kit and source code for it. At the same time the team created a MSDN Magazine reader application using the starter kit. The SCE is built upon the Microsoft Sync Framework and .NET 3.0.
You can now create your own rich user interfaces using WPF and RSS feeds, with support for offline reading.
Microsoft has released a new Windows Presentation Foundation demo sample that is a reader application for The Architecture Journal. The Architecture Journal is a quarterly online magazine focused on IT-architecture and contains nice articles and gives you some good reading. It is available online and as PDF (why not XPS?).
The Architecture Journal Reader is a WPF sample, very much like the New York Times Reader that was one of the first killer-apps for WPF, that you can use for offline reading of The Architecture Journal.
I really like this kind of applications. It has a rich, but simple user interface, with the look and feel of a paper magazine. You have a front page of each issue with small abstracts of the articles, all adjusting to the size of your window. You can easily click on an article and continue reading it.
The article also looks like a "real" magazine, instead of writing the text from left to right filling out the whole page it's divided into columns with a nice image layout, which gives you a good reading experience on the screen. You can adjust the text size easily and write your own annotations, either using text or ink. If you don't have time to read the article you can send it to your Reading List for later reading.
The application is based on RSS feeds with an extension namespace and the articles in News Industry Text Format (NITF).
Download it here and try it out for yourself. I hope the source code will be released.
I love to see more of these applications and I think this is what the future will look like for news papers and magazines.
Windows Presentation Foundation, WPF
The XPS classes is a part of the Windows Presentation Foundation, WPF, and is found under the System.Windows.Xps namespace. The Open Packaging Convention classes, used to manipulate the packages is found under the System.IO.Packaging namespace.
To get you started with creating XPS documents with the .NET 3.0 Framework you should read the January 2006 article in the MSDN Magazine by Bob Watson which explains it all. It contains everything you need to know from reading to writing to signing XPS documents.
XPS and XAML
With XAML, Extensible Application Markup Language, you can create nice interfaces and documents using either an XML editor or Microsoft Expression Blend or Design which can export documents to XAML. The .NET 3.0 Framework contains built-in functionality to convert from XAML to XPS which means that if you are building XAML applications you can easily make print functionality into it.
Since XPS is a fixed page format and WPF applications use a flow document style you have to convert your application interface into pages. Luckily the flow documents contains a paginator interface which divides your flow document into pages. Feng Yuan, XPS guru, shows you how to do this and even include margins, headers and footers in a blog post.
Not much code in this post, there are already enough, but with the links provided above you should get started pretty easy.
Next post int this series will look at some good XPS utilities for editing, browsing and manipulating XPS files.
I initially had some trouble installing Microsoft Silverlight on Windows Vista. It all installed perfectly without any warnings (not during setup nor in the Windows logs), but I could not get the Silverlight 1.0 beta applications to run. I guess that it had something to do with having installed WPF/E betas installed.
To get it to work this is what I did...
1: Start a command prompt using elvated privilegies
Click the Start button, enter "command", right click Command Prompt and select Run as administrator and the click Continue in the User Account Control dialog.
2: Navigate to "c:\Program Files\Microsoft Silverlight" and then write "regsvr32 npctrl.dll" and hit enter
A confirmation dialog should appear if everything is ok.
3: Try a Silverlight application, like this one.
Silverlight (formerly known as WPF/E) is heavily discussed right now, and I really like what I see..
I'm not going to dig in deep here instead I recommend you to read Scott Hanselman's post on the .NET Ecosystem which I find great. He has put it all into context and thats when I get really excited...
This part in the Dissecting XPS series will take off were we ended part 3, by looking into how the actual content is marked up.
The content is contained in the FixedPage element and it is marked up by three different elements
- the Path element which specified a geometry filled with a brush
- the Glyphs element which represents text
- the Canvas element which groups elements together
The Path element
1: Path Stroke="#000000" StrokeThickness="10">
3: LinearGradientBrush MappingMode="Absolute" StartPoint="0,0" EndPoint="0,8" SpreadMethod="Reflect">
5: GradientStop Color="#333311" Offset="0.0" />
6: GradientStop Color="#3333FF" Offset="1.0" />
12: PathFigure StartPoint="50,50" IsClosed="true">
13: PolyLineSegment Points="250,50 150,250" />
The Path element syntax contains several advanced features and allows you to create advanced vector graphics including lines, curves, arcs, beziers etc. Read more in the XPS Specification  or at Feng Yuans blog (here an example of radial gradient brushes). If you are familiar with the XAML elements then this will be a piece of cake .
The Glyph element
1: Glyphs Fill="#000000" FontRenderingEmSize="48"
4: UnicodeString="Hello World!"
5: FontUri="../../../Resources/Fonts/arial.ttf" />
The sample above also requires that we have a Font part (the .TTF file), a relationship to the Font part in the FixedPage and that the TTF Content Type is present in the [Content_Types].xml file.
As the Path element the Glyph element is very powerful and allows you to do really advanced typing in any kind of written language. You may also apply any kind of brush to fill the glyphs.
The Canvas element
The Canvas element groups other elements (Paths, Glyphs or other Canvas elements) together to either group the elements into units or to apply properties to each child or ancestor of the unit, for example opacity.
By now you should be able to create your own XPS file using just Notepad and a ZIP program. Up next in the series is some more information on the XPS document properties.
Further reading and references
 XPS Specification Dissecting XPS - part 1 - The basics Dissecting XPS - part 2 - Inside the XPS document Dissecting XPS - part 3 - the Fixed Document The blog of Feng Yuan - master of XPS  WPF/XAML Graphics
Side note: Windows Vista uses XPS as it's internal printer spooling.
The first beta of Design was a real disappointment for me, since all pixel editing and all Live Effects was removed. Beta 2 is still only vector editing but the Live Effects are there. The focus seems to be the Design/Blend/XAML/WPF integration to start with, which is fine but the technical previews of Design (then called Interactive Designer) really had it wen you could combine vector and pixel layers.
Today I start my two weeks vacation and I thought I should summarize this year. The year of 2006 has been characterized, for me, as the year of Betas and Technology Previews. I have been trying to involve myself as much as possible in the all the goodies flowing out of Redmond.
Internet Explorer 7
The new version of Internet Explorer is the application this year that will have most impact in the short run on users. More standardized and a slicker interface with support of for example blogs.
Windows Vista, the long awaited new operating system from Microsoft was released in November. I have been fiddling with the different betas, mostly on Virtual PC's. Short after the RTM I decided to replace my XP Media Center with Vista Ultimate. I'm not that satisfied yet due to lack of drivers; NVIDIA have not yet released a Vista driver that works fine, like the ones on XP.
Vista is overall pretty good, it has some nice features like the new Media Center, DVD writer software, a better photo management application... The interface has intensively discussed but I think it's not that revolutionary. I think the Explorer interface is really bad, navigation is not that good. I'll stick with Total Commander!
I will not upgrade my development laptop for a couple of months until all the issues with development in Visual Studio is sorted out, and I have no need for it - XP works fine.
The .NET Framework, has come in a new version - 3.0. But it's not a complete new .NET Framework, it's "just" .NET 2.0 with WinFX. But it's good - really good. You now can create really awesome appliactions with a nice user interface.
Office System 2007
The Office System 2007 with the client applications such as Word, Excel and PowerPoint and the server applications like SharePoint is by far the most interesting new applications this year for me. I have been into the betas and release candidates and been satisified since the first install. A complete new interface of the client applications that really impress and a SharePoint that finally allows us developers to do some nice stuff. SharePoint 2003, the previous version, was not that good for us developers and lacked a lot of functionality in the first version which has now come back. Someone said that Microsoft need at least three versions before they get it right :-)
The new Outlook 2007 and OneNote 2007 are two really impressive applications.
Microsoft has been really nice to us developers this year with a new and improved MSDN, more samples and tutorials than ever. Visual Studio 2005 has finally gotten an upgrade, Service Pack 1, that fixes most of the random crashes and hang-ups.
The Visual Studio 2005 SDK has also evolved with the support for making your own designers using the DSL Tools - I think that ISV's will now have the opportunity to make their applications more customizable.
The Microsoft Expression Suite
The Expression Suite from Microsoft was from my view the most surprising set of applications from Redmond. The Expression programs is applications for design, design of applications and design of web sites. The Commuity Technology Previews that has been released during the year has been really good, except for the last one this december, in which the removed some of the nice and interesting stuff from Expression Design.
The Microsoft Live approach has been interesting, with a new portal (never fancied MSN), a new search engine and a whole set of web based applications. Most of them are still in beta and it will be really nice to see where this path leads.
There has been a lot more that has been installed and uninstalled on my machines during this year, like Exchange 2007 and the Live applications, and it has been really exciting. You can find some of them on Codeplex, the Microsoft open source site.
What about next year?
Yes, what about next year? I will not predict too much but for me the focus will be on SharePoint 2007, which will open up a whole new set of opportunities for my company. I really loook forward to see what will happen to the Expression suite and I will start to nibble on the Longhorn Server.
To all of you:
Merry Christmas and a Happy New Year