Valentin's profileValentin Iliescu's SpaceBlogLists Tools Help
    10 February

    Update samples for .NET 3.0

    I have updated the samples for the final version of .NET 3.0
     
     
     
    12 June

    Updated samples for Beta 2

    I have updated some of the samples to .NET Framework 3.0 Beta 2.

    http://www.valil.com/winfx

    20 February

    How to create Aqua Gel Buttons

    The next step in learning Expression Interactive Designer is a classic in any graphic editing program: creating Aqua Gel Buttons.

     (Updated for Expression Interactive Designer March 2006 CTP)

     

    http://www.valil.com/AquaGelButton.zip

     

    Create a new Interactive Designer project.

     

    Add a Button to the scene. Edit its template (Right-click on it -> Edit Template - > Create Empty Template -> OK).

    Add a Grid to the content of the Button. Clear its Width, Height from Properties palette.

    Create 2 rows of equal height (use Layout palette -> Size tab to set the Height to 0.5*).

     

    Add a Rectangle to the Grid’s content.

    This will be the shadow. I have used a rectangle instead of a DropShadowBitmapEffect for 2 reasons: BitmapEffects are not supported in EID yet and you cannot use them in Web Browser Applications because of the security restrictions.

    Check if Row=0, Column=0, RowSpan=2, ColSpan=1 in the Layout palette.

    Clear its Width, Height; set Margin to 1; set RadiusX and RadiusY to 10; set Opacity to 0.3; set the Name to “shadow” in the Properties palette.

    Set its Fill to Black in the Appearance palette.

    Open Transform palette and set in the Position tab X and Y to 1 pixel.

     

    Add another Rectangle to the Grid’s content.

    This will be the background.

    Check if Row=0, Column=0, RowSpan=2, ColSpan=1 in the Layout palette.

    Clear its Width, Height; set Margin to 1; set RadiusX and RadiusY to 10; set the Name to “background” in the Properties palette.

    Right-click on Fill -> Template Binding -> Background.

    Right-click on Stroke -> Template Binding -> BorderBrush.

     

    Add a ContentPresenter to the Grid’s content.

    Check if Row=0, Column=0, RowSpan=2, ColSpan=1 in the Layout palette.

    Clear its Width, Height; set Margin to 1 in the Properties palette.

    Right-click on VerticalAlignment -> Template Binding -> VerticalContentAlignment.

    Right-click on HorizontalAlignment -> Template Binding -> HorizontalContentAlignment.

     

    Add another Rectangle to the Grid’s content.

    This will be the highlight.

    Set RowSpan=1 and check if Row=0, Column=0, ColSpan=1 in the Layout palette.

    Clear its Width, Height; set Margin to 5,3,5,1; set RadiusX and RadiusY to 5; set the Name to “highlight” in Properties palette.

    Set its Fill to LinearGradientBrush in the Appearance palette. Set both start and end color to white. For the end color set its Alpha value to 0 (completely transparent). Make the gradient’s direction vertical (use BrushTransform from the Tools palette to rotate the direction).

     

    Create a new state from the Timeline palette.

    Go to Timeline Properties palette, General tab and add a new trigger. Set “IsEnabled” in the first field and “False” in the second one. A new tab “IsEnabled” is created in the Timeline. Click on it, select background rectangle and set its Background to “LightGray”.

     

    Create a new state from the Timeline palette.

    Go to Timeline Properties palette, General tab and add a new trigger. Set “IsPressed” in the first field and “True” in the second one. A new tab “IsPressed” is created in the Timeline. Click on it and set shadow and highlight rectangles visibility to Collapsed.

     

    Create a new timeline from the Timeline palette, enter “MouseEnter” as the name.

    Go to Timeline Properties palette, General tab and add a new trigger on [Target Element], MouseEnter, Begin.

    In the Timeline palette, set the playhead to 0:00.250.

    Select the shadow rectangle, go to Transform palette and set in the Position tab X and Y to 3.

     

    Create a new timeline from the Timeline palette, enter “MouseLeave” as the name.

    Go to Timeline Properties palette, General tab and add a new trigger on [Target Element], MouseLeave, Begin.

    In the Timeline palette, set the playhead to 0:00.250.

    Select the shadow rectangle, go to Transform palette and set in the Position tab X and Y to 1. 

     

    Now exit from editing template (Timeline palette -> Return Scope to Root).

    Add a couple of buttons and set their templates (Right-click on the Button -> Edit Template -> Apply Resource -> ButtonControlTemplate1).

    Set the background of the buttons to something nice: a solid color or, even better, to a vertical gradient with transition from a color to a lighter version of the same color.
    17 February

    The power of Commands: How to create a simple text editor

    I have started to learn today how to use Expression Graphic/Interactive Designer. A couple of weeks ago, somebody asked in the Avalon forums if the RichTextBox control from the libraries comes with toolbars.

    The answer is no, however it is very simple to create them - the concept of commands is very powerful and Avalon comes with some predefined ones that will make the task very easy.

    http://www.valil.com/RichTextBoxEditor.zip

    The toolbar icons are created using the Graphic Designer and exported as XAML. I am not a graphic designer so if you want slicker icons you can play with the attached icons.xpr file. Just remember to when exporting as XAML to set

    Document Format to ResourceDictionary and Group By to Layers and to manually add Stretch=”Uniform” to every DrawingBrush.

    Create a new Interactive Designer project.

    Add the icon resource file (icons.xaml) to your project (Project menu item -> Add item).

    Link to the resources (Resource palette -> Link to resources -> icons.xaml)

    From the Library palette, add a DockPanel to the scene. Set its Margin property to default (Properties palette -> Margin -> Clear/Default)

    From the Library palette, add a Toolbar to the DockPanel. Set Dock property to Top and Width, Height properties to default.

    Add a new Button to the Toolbar. Set Width, Height properties to default.

    Set Command property to "EditingCommands.ToggleBold"

    Set Tooltip property to "Bold".

    Add a Canvas to the Button. Right-click on it -> Style -> Create Empty Style -> OK.

    Now you are editing the Canvas style. Set both Width and Height to 24 and Margin to 2 (don't worry if the value don't change yet).

    Exit from editing the style (Timeline palette -> Return Scope to Root).

    Set Width, Height, Margin for Canvas to default.

    Apply BoldIcon resource to Background property for Canvas (Background -> Apply Resource -> BoldIcon).

    Repeat the steps for adding the rest of the buttons.

    Set the appropriate commands, icons and tooltips.

    These are the rest of the commands:

    - EditingCommands.ToggleItalic

    - EditingCommands.ToggleUnderline

    - EditingCommands.AlignLeft

    - EditingCommands.AlignCenter

    - EditingCommands.AlignRight

    - EditingCommands.AlignJustify

    - EditingCommands.IncreaseIndentation

    - EditingCommands.DecreaseIndentation

    - EditingCommands.ToggleBullets

    - EditingCommands.ToggleNumbering

    - ApplicationCommands.Undo

    - ApplicationCommands.Redo

    For the Canvases you don't have to edit a new style but to apply the existing one (Right-click on it -> Edit Style -> CanvasStyle1)

    Add Separators between groups of Buttons.

    Add RichTextBox to the Canvas. Set Width, Height to default. Go to DockPanel and set LastChildFill to True.

    That's it.

    These are not the only available commands; explore the documentation for ApplicationCommands and EditingCommands classes if you want to add other features to your editor. And if you are interested to load/save XAML/RTF check this sample: http://blogs.msdn.com/jfoscoding/archive/2006/01/16/513383.aspx

    01 February

    Toronto Code Camp - huge success

    The best event I have participated in! Many thanks to the organizers, volunteers, speakers and attendees.

    I also wanted to thank the people that provided feedback on their forms, it is a great opportunity for me to improve as a speaker!
    11 January

    Toronto Code Camp 2006

    I am going to present Introduction to Windows Presentation Foundation ("Avalon") on Saturday, January 14th at Toronto Code Camp. I am going to focus on basic stuff and my intention is to make the audience understand the major concepts of Avalon and XAML.

     

    http://www.torontocodecamp.com/Sessions/tabid/111/CodecampId/1/SessionId/13/Default.aspx

    09 January

    MVP C#

    I have received  Microsoft MVP Award  -  Visual Developer  - Visual C#.  Woohoo!

    21 December

    Dec 2005 CTP updates

    In case you didn't know, Dec 2005 CTP is out.
    I couldn't find any API differences between Nov CTP and Dec CTP, all the applications recompile without any error, however the resulting binaries are not compatible. Now every application is up to date, including the chess game which didn't have a Nov CTP version.

    See http://www.valil.com/winfx for the binaries.
    The individual links for the binaries:
    http://www.valil.com/winfx/Valil.Chess.WinFX.xbap
    http://www.valil.com/MathEquations/Valil.MathEquations.Sample.xbap
    http://www.valil.com/winfx/ads.html
    http://www.valil.com/winfx/MapBrowser.bin.zip

    I intend to post the updated sources at the beginning of the next year.
    If you really need the source code, send me an email and we'll discuss.


    In my opinion, Avalon is a great piece of software (even if it's in CTP stage) and the forum/newsgroup/blogs/documentation has been an invaluable source of information.
    I want to congratulate the Avalon team and to thank the community (Microsoft employees, Drew Marsh, Michael Latta, Jean-Luc David, David Sklar and others).

    07 November

    Displaying math equations in Avalon

    Lately I have been thinking how to display mathematical equations in Avalon. My wife is math and physics teacher and tutor and now she is thinking about a website where she can post all the things she considers interesting. Of course, being so deeply into Avalon, I was very interested and have been able to convince her to use XAML instead of HTML.
     
    The natural question is: how can you display mathematical equations in Avalon? In HTML you usually use images  - Mozilla can display MathML but IE requires a plug-in, but the safest solution are images. I don't want to use images in Avalon, so the easiest solution is to use custom panels. An equation is in fact some text presented in a specific layout, all you have to do is to create your own custom panels (like for fractions, radicals etc.) and use Measure/ArrangeOverride.
     
    So here is a small sample:
    10 October

    Amazon product links - Avalon version

    I have started to develop a Web Browser application for displaying Amazon product links. The displayed books are the same as the HTML ones from the right side of my website so you can compare them.

    http://www.valil.com/winfx/ads.html

    I think this is a good example of Web Browser Application, it has integration with HTML, WBA can be embedded in an HTML page using an IFrame, this way you can gradually start transition from HTML to Avalon - there is no need to get rid of all your existing HTML code. And you can use client-side scripting to determine if the right version of Avalon is installed on the client machine - an HTML version can be used as a fallback if it's not.
    Also it uses web services - the application connects to a web service to get the book information from Amazon (image, price etc.).

    The next steps to generalize the application so it can be used on any website
    where ASP.NET is installed and to add extra features: editorial/customer reviews visualisation and shooping cart.
    03 October

    Woobah

    The chess game has been updated for September 2005 CTP (the same as the PDC version).

    http://www.valil.com/winfx

    Now the web browser version includes the 2D view which was only available in the full version.
    It seems that there are problems running the application on computers with non US-English locale (many thanks to Florian Kruesch who noticed and sent me a workaround). It's not a bug in the chess game (of course  - how can I doubt that my code is perfect :) ) it's about how Avalon handles the resources.

    I have also posted a video about the chess game. The video was submitted for the Show Off session at PDC 2005 - there were 25 of them, they are all posted on Channel9 . You should watch them, some of them are very interesting.

    P.S. You may wonder why this post is named "woobah". It's how the file extension for avalon web browser applications sounds to me.

    05 September

    Windows Vista Install Fest

    Last weekend I went to the  Windows Vista Install Fest ... very interesting event. I think this is the first time Microsoft organizes a install fest for an operating system in beta stage. Even if I didn't bring a computer to install Vista on (I installed it one week before the event) I have learned a lot of new things from Bruce Cowper. Jean-Luc David promoted his upcoming book Professional WinFX Beta and I had the opportunity to demo the chess game. Barnaby Jeans took some pictures and did some interviews (*shameless plug* here is the part where I am interviewed).
    24 August

    All the cool developers use Speech APIs

    The title of this entry is inspired by Robert's blog http://blogs.msdn.com/robertbrown/ , a guy who's working in speech technologies. Because of his blog I have found out about speech support in WinFX ... and I wanted to be a cool developer  so I have added speech capabilities to the chess game.
     
    I have moved the chess game to a new page:
    The full version has the speech features (the express one doesn't include them because of the security restrictions).
    You can "say" commands to the game - you can play or navigate the game just using your voice.
    Also, the chess engine "talks" - it announces its moves.
    09 August

    Chess Express Application - now deployed

    This is the deployed version of the Chess (the Express version)
     
     
    NOTE: The first time you will load the URL you will get an error, just
    refresh the page.
     
    19 July

    Map browser - update

    In a previous post I was talking about an AVL application implemented as a smart client using Avalon and Indigo. This would be a cool application however I don't have too much spare time so I'm going to freeze the development for an undetermined period of time.
     
    This is the source code for the last version of the MapBrowser (the file is very big - 2 MB!):
    It displays the Toronto map and you can zoom in, zoom out, rect zoom or center.
    12 July

    Chess Express Application - part 2

    I have continued to work for the Express version and this is the latest version.
    It looks good and I have really started to like the concept of Express Applications ... there is no deployment on the client (like HTML) but it is a rich application. In my opinion it could change the way the web looks today.
    NOTE: Unfortunately I am not able to debug Express Applications on my machine (probably due to a bug) so the application will run only when launched from Visual Studio and not when deployed on a web server or by clicking .xapp from bin\Debug. Anyway, I hope you will get an idea of how an Express Application looks and feels.
    20 June

    Update for 2D and 3D Chess

    In both versions I have defined the visual elements (game board, pieces) as separate controls and I put them in a different project for a better modularity.

    The 2D version was still using an old way (CTP Nov 2004) of defining the visual elements, so I switch to DrawingBrush for doing the painting. You would not see any improvements in the final rendering but the code is now much more cleaner and understandable and it would allow me to do some animation ... DrawingBrush is cool! (many thanks to Adam Nathan and his Playing Cards example).

    The 3D version had a problem - the 3D models provided to me had duplicate vertices (each triangle had its own set of vertices and each vertex belonged to just one triangle) and because of that the models didn't have a "smooth" look. I have created a simple program to parse and remove the duplicate vertices and now not only the models are smooth but also the xaml textual representation of the models has been reduced by 80% (and the binary reduced its size to 1/3).

    Both versions are here http://www.valil.com/avalon

    06 June

    Express application

    WinFX Beta 1 has introduces the concept of Express Applications, think something like a ClickOnce app with Internet Zone permissions running in online mode only: hosted in the web browser, no offline mode, no local file IO, no showing up windows etc.

    I have tried to port the 3D chess and make it work as an Express Application and it was more difficult than I expected, I presume the technology is very new and buggy.

    http://www.valil.com/ChessExpress20/ChessExpress.xapp

    NOTE: Sometimes, when loading the application for the first time an error is thrown. If this is happening, try again by clicking again on the link.