Wednesday 27 October 2010

Assassin's Creed Brotherhood

Assassin is coming Assassin's Creed Brotherhood :-)

Converting WPF to XBAP (PRISM 2.2)

One day I had to make a conversion from WPF (PRISM 2.2) desktop application to XBAP application. Task which seems to be straightforward took me more time that I expected. I encountered some problems and I want to share all my conclusions and experiences.

My original approach in WPF desktop app (PRISM 2.2) is:
  1. No StartupUri attribute in App.xaml 
  2. Regions are defined in Shell.xaml e.g. cal:RegionManager.RegionName="{x:Static common:RegionNames.DocRegion}"
  3. App.xaml.cs / OnStartup creates and runs UnityBootstrapper
  4. UnityBootstrapper registers Modules, Types, creates ShellPresentationModel + Shell
Basically UnityBootstrapper is responsible for creating/instantiating the Shell.

WPF => XBAP conversion
Step 1.
Instead of using App.xaml.cs and

   1:     protected override void OnStartup(StartupEventArgs e) 
   2:     {
   3:        base.OnStartup(e);
   4:        UnityBootstrapper bootstrapper = new Bootstrapper();
   5:        bootstrapper.Run();
   6:     } 

 I had to use App.xaml and StartupUri="..." attribute.
Step 2.
I had to remove all my XAML region references cal:RegionManager.RegionName="..." and replace them with RegionManager.SetRegionName(..., ....). XBAP application (with StartupUri attribute) creates Shell before creating Bootstrapper, so at this stage application is not aware of existence of RegionManager.

   1:      public partial class Shell : Page, IShellView
   2:      {
   3:          public Shell()
   4:          {
   5:              Bootstrapper bootstrapper = new Bootstrapper(this);
   6:              InitializeComponent();
   7:              bootstrapper.Run();
   8:          }
  10:          //...
  12:      }

Step 3.
I had to populate the constructor of my Shell with Bootstrapper and pass Shell reference into Bootstrapper to make region registering process (step 2) possible.

   1:  public class Bootstrapper : UnityBootstrapper
   2:      {
   3:          private IShell shell;
   5:          public Shell Shell
   6:          {
   7:              get { return shell as Shell; }
   8:          }
  10:          public Bootstrapper(IShell shell)
  11:          {
  12:              shell = shell;
  13:          }
  15:          //...
  17:          protected override DependencyObject CreateShell()
  18:          {
  19:              ShellPresentationModel presenter = Container.Resolve<ShellPresentationModel>();
  20:              ShellView.Model = presenter;
  22:              RegionManager.SetRegionName(ShellView.DocRegionControl,
  23:                  RegionNames.DocRegion);
  25:              //...
  27:              return ShellView;
  28:          }
  29:      } 

Useful links:

Engadget - ExoPC Slate review

Looks promising ExoPC Slate review -- Engadget :-)

Sunday 17 October 2010

Seagate 500GB / ST3500320AS firmware SD15

I bought two Seagate HDDs and one of them died few months ago (my HDD acquired the power of invisibility). :-( My first thought was 'There has to be the first time', so I accepted it (2 partitions were gone) without looking for a solution. When my second HDD died I was devastated, especially that the second one contained all my photos, documents and programming stuff. This time I decided to dig and find out what and why happened, because it is impossible to loose two HDDs in 2-3 months period.
I found out plenty of solutions and I decided to follow one of them.
I bought Nokia CA-42 cable (<£3) + a box of single cables from Maplin (8 cables per box <£3).

You have to decompose a female end of your cable (picture below) to acquire a connector which you can use for your Nokia cable.

My cable wasn't the original one so I wasn't able to identify the endings (GND, RX, TX) based on the reconnaissance performed on the USB end. I had to spent some time searching/testing and this is the final working solution: BLUE means RX, BLACK means GND, WHITE means TX. If you want to connect it to your bricked HDD you have to connect BLACK to GND jumper, BLUE to TX jumper and WHITE to RX jumper.

When your cable is prepared you can move to the next step which you can find for example there: 
Remember to read everything carefully before you start the whole procedure.
Good Luck!