Archive for category Community

Integration of Caliburn.Micro and Telerik’s Silverlight controls

I’ve wrote already about how to use Telerik’s RadTabControl with Caliburn.Micro and profit from Caliburn’s conventions. That post is still getting considerable attention in my blog and also there are people are asking in Caliburn’s discussion list about such kind of integration. So, I’ve decided to spend some of my time and provide a more coherent experience in this domain. Rob Eisenberg suggested to create a dedicated project for it and, why not, to create a NuGet package. That sounded very interesting for me as it would allow me to scratch another itch – the NuGet package manager. We’ve been using it in our projects with great success but I have never explored the part with creation and publication of packages.

How do you get it

Caliburn.Micro.Telerik source code on GitHub. Feel free to pull the code & use only parts you need. There are two main classes, you can copy&paste them in your projects. If you want to contribute, I’d appreciate a push request with new conventions, better code samples or bug fixes. Report issues if you’ve found any…

Caliburn.Micro.Telerik as a NuGet package. “Add  Library Package Reference …” from Visual Studio & start using it. My package has a dependency on Caliburn.Micro.1.1.0 so you can just reference it and Caliburn will be pulled in automatically.

What’s in

First of all, conventions. I’ve put inside conventions we’ve been using in our projects and plan to add more. So far there are conventions for:

  • RadTabControl
  • RadBusyIndicator
  • RadDateTimePicker (affects also RadTimePicker and RadDatePicker)

Then you have a basic implementation of IWindowManager, the RadWindowManager class. Nothing fancy, pretty basic stuff. And I plan to extend it to offer also an unified interface to Telerik’s custom dialogs like Confirm, Alert and Prompt.

And third, there are two sample projects, one showing how to use conventions and other makes use of RadWindowManager.

How to use conventions

Add a line in your Bootstrapper’s Configure() method to enable conventions:

public class AppBootstrapper : Bootstrapper<IShell>
{
   protected override voidConfigure() {
        // …

        TelerikConventions.Install();
    }

Check it out and let me know if you found it useful or how it’s possible to make it better…

16 Comments

The best User Group meeting I’ve attended so far – Geneva JUG on Scala & Akka

Today’s meeting of Geneva JUG was the most entertaining User Group meeting I’ve attended. Excellent speakers, great topics, mind-blowing ideas…

Iulian Dragos had an introductory talk about Scala. This isn’t my first meeting with Scala, but today I’ve “got it” a bit more. Not at the level to wiling to use it and start writing apps, but I’ve understood some ideas and concepts behind it. For me it sometimes looked like C# with all the ‘language noise’ stripped down as it has some language constructs very similar with dynamics, vars and functions in C#. And also it remembered me a bit about Boo, a strongly-typed language based on .NET runtime. Nice language with interesting features that failed to get enough traction in .NET world.

Oh, and then was the Jonas Bonèr, talking about Akka. What a great talk. As I’ve been diving deeper last weeks in distributed systems (and using NServiceBus to get some parts of architecture right) it was a real eye opener. Jonas was talking about three main problems in distributed world – scalability, fault-tolerance and remote interactions. Those concepts are pretty platform agnostic. But for me, living mostly in .NET word, it was very entertaining to see how things are implementing using other language on a different platform. Jonas, like a magician, where pulling from pockets akka pieces and concepts – one greater that another. And I should admit it’s something I’ve never seen in .NET. Scala’s flexibility and extensibility allows getting really complex things wrapped in a clean syntax and simple flow. Things like new async syntax in C# 5 are looking now as badly put shortcuts and “not so sweet” syntactic sugar when compared to what Scala has to offer.

And a big thanks to organizers of this session. Keep up rolling, guys…

Leave a Comment

Had a good evening yesterday at Geneva JUG…

The session was truly entertaining. David Gageot (@dgageot) talked about Git and Mockito. 

The talk about Git was interesting. I’m using already DVCS (Git grace to GitHub and Mercurial because of better Windows experience) but I’m very far from being an advanced Git user. Learnt few tweaks, both for Git and for presenting. It was interesting to see how David started presentation about git by showing an advanced feature, bisecting, for an auditory that was for most not familiar with DVCS and Git. Also enjoyed looking at reactions when you’re showing them how they can be more productive. I’ve seen people being very impressed, asking questions. But also seen reactions like “subversion is simpler” to “I enjoy a coffee while updating my working copy with svn". And (a true horror story, it’s almost 2011) some people are still using CVS.

Then there was an intro to Mockito, a mocking framework for Java. It is very similar by idea and syntax to Rhino.Mocks and Moq from .NET world. Just, a Java penalty, mocks a little bit more verbose when compared with C#. And, surprise, no XML during whole presentation. Kidding :)

I was very pleased to listen to David. Really passionate about software development, productivity and best practices…

Leave a Comment

mGitHub Sample Application. Using Caliburn.Micro to build Windows Phone 7 applications

* mGitHub.SampleApp on GitHub

** mGitHub – the real app – is available in Marketplace

The story

I’ve been very excited when Microsoft announced a new & shiny mobile platform, the Windows Phone 7. Mostly because it gave me the chance to explore new things using very familiar tools: Visual Studio 2010, C# and Silverlight. I never had enough time to start digging in this area. When I’ve read that Rob Eisenberg announced a Caliburn.Micro contest and having lost the passion for doing my job at company I’m working now, I’ve decided to participate.

I’ve decided to go with an interesting idea – writing a WP7 app to work with GitHub. Mainly because I’m sure that I will use such app myself. GitHub is an awesome service that lets you host and collaborate on your projects freely once they are open source or if you want private projects you can have it too for a fee. I like idea and this sample application so much, the whole development process went so smooth and easy so that I’ve decided, along with participation in CM contest and publishing sources of my sample app on GitHub, to continue developing it by adding more features to offer a complete and user friendly application to work with GitHub (later about this).

The app

mGitHub.SampleApp allows to browse few preselected projects and repositories on GitHub. You can see user/repository details, navigate trough user’s own repositories, watched repositories, view contributors and so on…

The use of Caliburn.Micro, which is (not only) a MVVM framework, implies that application is View Model driven. Main screen is baked by a view model, then everything else – application flow, user interactions, service calls are done within View Model classes (with few small inclusions of WP7 navigation model, view based).

WP7 controls like Panorama and Pivot were also used with MVVM in mind. For example, here is the code for main View Model that is serving a Panorama-based view:

public class MainPageViewModel : Screen {
    public MainPageViewModel(MostViewedViewModel mostViewed,
                             FavoritesViewModel favorites,
                             AboutViewModel about)
    {
        MostViewed = mostViewed;
        Favorites = favorites;
        About = about;
    }

    public FavoritesViewModel Favorites { get; protected set; }
    public MostViewedViewModel MostViewed { get; protected set; }
    public AboutViewModel About { get; protected set; }
}

So, here we’re just injecting our View Models for individual Panorama pages in MainPageViewModel and then SimpleContainer takes care to provide required instances. Since in a Panorama control all pages are visible (active), we’re using a simple Screen (from CM) as our base class for our VM. Then, this is how the panorama view is defined:

        <controls:Panorama Title="mGitHub sample app "> <controls:Panorama.Background> <ImageBrush ImageSource="PanoramaBackground.jpg"/> </controls:Panorama.Background> <controls:PanoramaItem x:Name="Favorites" Header="my favorites" /> <controls:PanoramaItem x:Name="MostViewed" Header="interesting" /> <controls:PanoramaItem x:Name="About" Header="about" /> </controls:Panorama> 

It’s nice and clean, with very good separation of concerns: each panorama page has it’s own View and a corresponding View Model. The work to glue it together is done by Caliburn.

The Pivot is a bit different. This control is basically a well known TabControl, it has headers and only one item is active at a time. For a PivotViewModel we’ll use a Conductor class with one active item:

[SurviveTombstone]
public class PivotViewModel : Conductor<IScreen>.Collection.OneActive {
}

Then the two application Pivots, UserPivotViewModel and RepositoryPivotViewModel will just ask from container the view models of individual pages and add them to Items collection of Conductor class:

[SurviveTombstone]
public class UserPivotViewModel : PivotViewModel {
    private readonly UserDetailsViewModel details;
    private readonly UserRepositoriesViewModel repositoriesViewModel;
    private readonly UserWatchingViewModel watchingViewModel;

    public UserPivotViewModel(UserDetailsViewModel details,
                              UserRepositoriesViewModel repositoriesViewModel,
                              UserWatchingViewModel watchingViewModel)
    {
        this.details = details;
        this.repositoriesViewModel = repositoriesViewModel;
        this.watchingViewModel = watchingViewModel;
    }
    protected override void OnInitialize()
    {
        base.OnInitialize();

        Items.Add(details);
        Items.Add(repositoriesViewModel);
        Items.Add(watchingViewModel);

        ActivateItem(details);
    }

The view, again, is very simple, grace of Caliburn.Micro magic:

        <controls:Pivot x:Name="Items" Title="{Binding PivotTitle}" SelectedItem="{Binding ActiveItem, Mode=TwoWay}"> <controls:Pivot.HeaderTemplate> <DataTemplate> <TextBlock Text="{Binding DisplayName}" /> </DataTemplate> </controls:Pivot.HeaderTemplate> </controls:Pivot> 

That’s why I enjoy using this framework, it makes some development tasks extremely simple.

Also, application make use of INavigationService,  wrapper API for Launchers/Choosers and is aware of Thombstoning. I tried to keepcode small enough to be easily followed and read, so it will not be too hard to find those places in project’s source code…

Another (probably interesting) piece of code in this project is communication with GitHub using their API. It’s not exactly the IGitHubHost service that I want to highlight, it’s pretty trivial. Take a look at two wrappers around RequestProcessor class, both added in order to improve User Experience when working with mGitHub.SampleApp on the phone:

  • ProgressAwareRequestProcessor – will show a view with PerformanceProgressBar during any remote call
  • CachingRequestProcessor – providing a extremely simplistic data cache, storing requests and their results

These wrappers are registered in container and View Models even don’t know about their abilities, for them it’s just issuing a call and displaying a result. Separation of concerns is always good principle to follow…

Screenshots

Few screenshots, to get the sense of how UI looks like:

12

34

 

Final notes

This application surely contains bugs, it probably has few strange design decisions and graphics are done by professional developer (me). But it works. It serves it’s main purpose to show how you can write an application for Windows Phone 7 using Caliburn.Micro. And I had a lot of fun working on it…

I’ll surely improve this sample, fix reported bugs and will listen carefully to improvement ideas. So, any feedback is welcome.

But in the meantime, I’m doing everything possible to release a real application to Marketplace that will be called mGitHub and will offer essentially improved experience and more features. So, if you like the idea, if you like GitHub and will most likely use the app on your phone, I would be glad to hear from you. Next time when I’ll be planning features your feedback will be considered.

This application weren’t tested on a real phone. I’m counting the hours until my hands will get the ordered Samsung Omnia 7 and I’ll be testing this app on real hardware. If everything goes well, expect yearly next week a feedback (and probably fixes & improvements) after using the app on WP7 device.

Code of this application is licensed under MIT license and available on GitHub.

Credits

Thanks to:

Special thanks to:

  • my friend Dumitru Cantemir for helping me with some code.
  • my daughter, for letting her dad working on this app. Even if sometimes it was …

DadAtWork

3 Comments

Flirting with Java community

Despite my enthusiasm about finding and participating in a regional .NET user group,  the Alt.NET Suisse haven’t got enough traction to keep on rolling and now it’s actually not functioning.

So, to keep my community-and-knowledge-hungry spirit quiet, I keep visiting regional Java User Groups. The last two session I’ve took part where on some emerging topics, not strictly related to Java. For me, a .NET developer, that is a ticket to visit these meetings.

The “Not only SQL (NoSQL)” session at JUG Lausanne on September 9, was interesting not by presentation about NoSQL and the hype around it, but by half-way discussion that hijacked permanently the presentation. But at the end, it was not a bad thing. It was very interesting to hear how people are planning to use or already using NoSQL in real world projects.

Hibernate – strategies for caching and data loading” was yesterday at JUG Geneve. The topic was somewhat familiar for me, as we’re using extensively NHibernate in our projects. Initially, NHibernate was a .NET port of popular Java ORM – Hibernate. They are still very similar in concepts, features and scope, but I do see that NHibernate got new features that were not ported from his big brother. Linq provider, Futures, fluent/code mapping are first that are coming in my mind.

Few random thoughts and impressions after the session:

  • nothing new for me, but a good recapitulation of options available to improve performance of your data layer
  • I do like C# over Java as a general purpose programming language. It’s easier to read, laconic and just cleaner when compared to Java
  • are the Java guys really struck into XML? I’ve seen yesterday more XML than in whole last few months
  • Alain Helaili, the presenter, used dynaTrace to show how various tweaks are affecting performance in test cases. It’s a kind of instrumentation framework for Java that has an integration point with Hibernate. Functionality is in some parts similar to latest improvements in Visual Studio 2010, IntelliTrace debugging. And it’s a typical example of “developer oriented interface” with all corresponding usability quirks

Overall, I’m very pleased meeting Java community. Looking forward to next sessions that are not too java-centric to make interest for a mere .NET Developer.

2 Comments

Fluent Ribbon and Prism

I would like to show an example of application that is about how to use Fluent Ribbon control together with Prism (aka Composite WPF). Our team is using this combination for some time already; although, with various degrees of success: the Fluent Ribbon is not enough mature (but pretty stable) and my personal relation with Prism is kind of love/hate. The Castle Winsor is starring as IoC Container of choice.

The code is not something extraordinary by any means. You can find lots of similar samples for other controls in the net. It’s just a sample how to use these libraries together.

In this example I’ve set next scenario: a module (or another part of application) wants to add new RibbonTabItem to existing Ribbon without having a direct reference to it. Also, application should support activation/deactivation and removing of Tabs.

The basics are pretty straightforward: pick/write an IRegion, write an adapter to work as a mediator between it and control being extended, profit!..

I’ve decided to use an existing Region to serve as host for tabs – SingleActiveRegion. It seems to fit well expected behavior.

Two classes that I wrote are RibbonRegionAdapter and RibbonRegionSyncBehavior. The behavior class is used to synchronize the Tabs collection of the Ribbon with Views and ActiveViews collections of the SingleActiveRegion. Adapter serves only to instantiate the region and attach the behavior.

Also, this solution uses Castle Windsor to wire up all things. The WindsorBootstrapper class wires up an application based on Prism v2.2 and Castle.

I’ll not publish the the code here, you can “git clone …” it from repository on GitHub. Or, from the same place, you have the option to download sources.

Future plans include few more regions (Backstage, RibbonTabItem) and may be some tests.

Solution specifics:

  • Prism v2.2
  • Fluent Ribbon rev. 51299
  • Castle Windsor 2.1.1
  • VS 2010 & NET 4.0

Disclaimer: code is provided “AS IS”. It may contain bugs and not be written in best possible way. I’m not a Prism specialist by any means. Any help is welcome if somebody can improve this code or wants to contribute for a more meaningful example…

4 Comments

Microsoft TechDays 2010, Geneva. Day 1

A small write up about my experience at TechDays 2010, Geneva, Switzerland. Kind of random thoughts and superficial impressions about visited sessions.

Windows Azure platform

Depending on your requirements can be a cost efficient deployment option. Not sure about development side of things. If it’s covering 80% of your requirements nicely, what about 20% cases it’s not covering? Most of MS technologies/frameworks are hardly known as being extensible.

SQL Azure & Azure storage

Will it play nicely with NHibernate? I’ve seen mentions on the net that all NHibernate tests are passing on Azure platform. Would like to see a real app.

“Tables” as a document store are interesting. Is it supporting Map/Reduce?

Silverlight 4

After few releases and years it will be on par with WPF (as of 4.0/2010).

I’m loving choice of platforms: PC, web and mobile.

Windows Phone 7

I’m a Windows Phone 7 developer! C# & XAML everywhere. VS 2010 & known tools/process. Not convinced on new UI concept. Don’t like the strong accent on social networking. During presentation had a temptation to stand up and ask: “can it make a call?”.

Silverlight 4 Advanced

Definitely, in a few years Silverlight will be on par with features with WPF.

Nice presentation, learned few tricks in Blend and VS 2010. Presenter looked and worked like a real developer.

 

Microsoft Surface & Multi-touch experience

I’ve skipped a session and took a chance to play with Microsoft Surface installed by one of (i think) sponsors in the hall. I’ve started playing with it between sessions and missed completely beginning of new one. Dropped it and played one hour with Surface and a HP branded mono-block with multi-touch screen.

Multi-touch is working great on Surface: few games, Paint, Maps. Few very basic, specific apps with “intuitive" interactions. I’d like to see how it works in a more business/data analysis/LOB app. But I’m rather skeptical. They had some kind of “business” app on the Surface but it doesn’t worked because some physical “tags” where missing.

HPs with multi-touch screens: Windows 7 is not a multi-touch friendly platform. You can create small nice “photo viewer” applications but this will not make a revolution – the platform is mouse+keyboard oriented. You can look at iPhone/iPad, where the platform is built on and for multi-touch. Windows Phone 7 is a multi-touch platform with few pre-defined styles for basic controls & specific navigation features.

Found a bug with multi-touch – you cannot close a window by pressing “X” button when the screen is maximized. Probably a hardware issue.

And I haven’t found how to show a context menu (right mouse click) in Windows 7 using a “touch”. As I said previously, the platform is not touch oriented.

Conclusion: Touch interfaces offer good user experience in specific devices and apps. Very specialized and artificially limited. But for “traditional” apps it’s not a good choice. And don’t forget the whole Web. Keyboard and mouse are here to stay.

Leave a Comment

Have been in the aliens camp. Twice…

Recently, in my desire to learn something new and get closer to local community of software developers, I have visited few meetings of Java User Group in Lausanne. You may ask, what can attract a .NET developer in Java community? For me it was mainly the themes what were discussed. First one I’ve attended was about Groovy and Grails – new dynamic language and a framework that are running on JVM. The second was a nice session about Scala – static, OO programming language that also integrates nicely some features from functional programming world.

So, sessions I’ve attended wasn’t really about Java, but about new programming languages. I’ve read somewhere, that in order to be a better programmer you have to learn a new language every year. Well, honestly, I’m not sure that I’d be able to learn new language that doesn’t fits in my tool belt and it’s not used daily. So, I’ve considered that the least I can do is familiarize, even superficially, with new programming languages and concepts.

I enjoyed very much both presentations.

I’m not sold over dynamic languages yet. I’m not sure it will work in a big, “enterprisey” project. But may be it’s because I don’t have any experience using it.

But I liked very much some concepts from Scala – mixins, traits and few other things are just mind blowing! The language is very clean and concise.

But, even without some of these features backed in .NET/C#, I think that development platform from Microsoft offers more for an “average” software developer. Productivity, tooling support, training. It’s only because MS has more resources to do it…

2 Comments

ALT.NET Swiss community – it’s running!

Running with scissors

Yesterday I have participated at my second meeting of ALT.NET community in Switzerland. The ALT.NET Swiss group was running for some time, but I’ve discovered it recently, after being contacted by Frédéric SCHÄFER from OCTO Technology. He started the group and has been organizing meetings in Lausanne and Geneva. Many thanks Frédéric and keep up a good job!

First meeting I attended was about WPF and Model-View-ViewModel pattern implementation. It was held by Frédéric SCHÄFER. He took a simple WPF application and slowly modified it to use MVVM pattern. That got us better separation of concerns and maid application more testable.

The yesterday’s meeting was for me a special one, I was one of the speakers.

I’ve talked briefly about how the MVVM pattern is used with WPF, showed a "classical" implementation of it and after that presented some improvements over that. The initial ViewModel had INotifyPropertyChanged  implemented and used ICommand to respond to UI actions initiated by view. For two properties and a command there was a lot of "ceremony" – code being there just to comply with implementation requirements. At the end of the session, by using two frameworks(BLToolkit and Caliburn) , I’ve managed to reduce the volume of the code by the half while maintaining initial functionality. Why is this important? Shorter code means less place to make a mistake, hide a bug, it’s faster to read and understand. I will write a separate blog post about my solution.

The other speaker was Daniel Vaughan, the author of Calcium SDK. He spoke about Calcium SDK, which is a set of additional services and modules built on top of the Prism (Composite WPF) and few Visual Studio templates to make creation of composite application easier. After that, he talked about compile time validation of WPF’s binding expressions. This, being a real headache for WPF developers, was addressed by Daniel by using template engine backed into Visual Studio – T4. His solution is very interesting. He generates some metadata classes with static properties and after that uses them in binding expressions. I’m still not sold on the whole idea, but I should spend some time playing with it. But presentation was nice, thanks Daniel!

It was a great evening. It’s always interesting to meet people with different set of skills and experience, you can look at known problems from other angles, getting suggestions or criticism. Or you just can learn something new.

Special thanks to Atif Aziz and Cargill International SA for hosting the session.

Update: published the code on GitHub.

3 Comments

Follow

Get every new post delivered to your Inbox.