Thursday, 17 May 2012

Programming Windows - 6th Edition

I still remember reading Programming Windows 5th edition in our college. The book was very thorough and gave a nice introduction to all the Windows programming concepts, although we were more interested in API we could use to get the password text on a window or hacking the key strokes ;-)

But it's been a long time. That was the PC era. Now we have tablets and mobile ruling our lives. New toys for new era. And so we have a new book from our guru Charlez Petzold on how to program these toys.

http://www.charlespetzold.com/blog/2012/05/Programming-Windows-6th-Edition-Preview-Ebook-Is-Here.html

What is interesting about book's offer it is only $10, but the book is not yet finished yet - only 7 chapters. Windows 8 is still under consumer preview - and so I think the book is following the release cycle of Windows 8. We live in interesting times.

I am buying this book, are you? Link to buy

Edit: Well I just bought it.

Kinect Resources

Started learning how to program Kinect. Must say we live in interesting times.
Links:
- Project done at NUS using Kinect: http://hci.comp.nus.edu.sg/?page_id=273

Books:
- Free e-book at i-Programmer
http://www.i-programmer.info/ebooks/practical-windows-kinect-in-c.html

- Meet the Kinect



- Beginning Kinect Programming with Microsoft Kinect SDK




Monday, 14 May 2012

Links to Debugging Resources

This is a post to store all links to videos, blogs, PDFs relating to debugging .NET applications. I have become particularly interested in this area and getting down to details such heaps, clr-stacks, GC, analyzing dumps is so much fun!

- Tess Ferrandez:

Previously an ASP.NET escalation engineer at Microsoft, based in Sweden, now working in developer evangelism team. But still her blog has some very good info. to get started with debugging. You should check out the labs she has posted on her blog which show how to resolve performance problems.

> Blog: If broken it is, fix it you should
> (video) Session: Debugging .NET Applications with WinDbg, Developer Conference, Sweden 2009



 - Channel 9

More recently there are 6 videos posted on Channel 9 around .NET debugging by Bradl Golnaz. I have seen two and they look good.
Diagnosing Application Issues - 01 You can find links to all the videos on this link.

- MSDN
Delay's Blog: This post has some good links to other valuable posts.

- PDFs

SOS – “Son of Strike” introduction by Mark Smith.

...more links to be added soon...

ASP.NET MVC Web Sites (for study)


Today found out Suteki Shop at this address: http://code.google.com/p/sutekishop/

Since it is open-source and uses the technologies such as ASP.NET MVC3, MVC Contrib, NHibernate, Windsor; it would be interesting to look at.

Another one is Nerd Dinner. http://www.nerddinner.com/. Its source can be found here: http://nerddinner.codeplex.com/

Happy MVCing! 

Wednesday, 2 May 2012

WPF: Dynamic Menu

In one of projects I am working on, we have a requirement of showing ‘recent files’ used by the application. The files used by the application are XML files – no custom extension.

Our goal is:

 image

For this task we need the following things:
- a RecentFiles class:
    - should contain the list of recent files
    - should have methods to load/save the list to disk (persistence)
    - should have methods to add a recent file used or delete a non-existing file
- a MenuItem (with children) to show the list

Here is the RecentFiles class:

public partial class RecentFiles
    {
          private ObservableCollection<string> filesField;
          public ObservableCollection<string> Files
          {
              get
              {
                   return this.filesField;
              }
              set
              {
                  this.filesField = value;
          }

          //members for persistence – Load, Save
         //you can find the full class definition in attachments
}

In the Windows.cs, we have a view model WindowViewModel having a property named AppRecentFiles.

Code in WindowViewModel:
      public RecentFiles AppRecentFiles { get; set; }

Code in Windows.cs:
     this._mainWindowViewModel = new MainWindowViewModel();
      this.DataContext = this._mainWindowViewModel;

Now the XAML part:

<MenuItem x:Name="mnuRecentFiles" Header="_Recent Files" ItemsSource="{Binding AppRecentFiles.Files}">
    <MenuItem.Resources>
        <Style TargetType="MenuItem">
            <Setter Property="Command" Value="{Binding ElementName=mnuRecentFiles, Path=DataContext.RecentFileChosenCommand}" />
            <Setter Property="CommandParameter" Value="{Binding}" />
        </Style>
    </MenuItem.Resources>
</MenuItem>


And you are done with the basic infrastructure.

Now all we have to do is:
- add an item to the AppRecentFiles.Files list whenever we load a new file (from the Load option in menu). Tip: add the new item at top of list so that it shows as first item on the menu.
- remove file from list if the user selects a file from 'recent files’ is not found, perhaps after a confirmation message box
- load the recent files by using RecentFiles.LoadFromFile() method – usually done during Window load or app start
- and save (persist) the list by calling RecentFiles.SaveToFile() on App close or window close

Shorts - week 3, 2022

Post with links to what I am reading: 1. A very good post on different aspects of system architecture: https://lethain.com/introduction-to-a...