Get all WinRT application from regular Desktop application. Part 2.

Let’s continue with WinRT APIs. On the previous post I described how to get all WinRT application. Now I’m going to get some data from these applications. Continue reading

Advertisements

Get all WinRT application from regular Desktop application. Part 1.

Today I’ve been solving interesting task. All my investigation I’ll write on this article. A problem is following: there is a regular C# application which should display all installed WinRT application per user.

There is a whole section of all WinRT APIs for Windows 8 that are able to be called from a regular C# application on MSDN. This one includes a PackageManager class which allows getting all installed packages.

Access WinRT API from Console application.

First step, create a usual Console application.

Then we need reference a Window.dll. However, in the desktop projects Windows tab doesn’t appear by default. For this we need manually add following lines to csproj file.

After that step a new tab will appear:

Now we can try to get all WinRT installed packages. However, when we build that we will have following error:

The type ‘System.Collections.Generic.IEnumerable`1<T0>’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.

Unfortunately this assembly doesn’t present on reference tab. For this you need add this assembly from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5 folder.

Get all installed WinRT application per user.

We will get installed Metro/Modern packages per user because on same computer different users can install different applications. All this information is available by PackageManager class.

var packageManager = new PackageManager();
var metroApps = packageManager.FindPackagesForUser(WindowsIdentity.GetCurrent().User.Value);

That’s all and really simple, isn’t it? 😉

Hide inactive cursor behavior.

In this article I’ll explain one way how to hide a cursor after n-seconds of inactivity though WPF behavior mechanism. Same effect you can observe on almost any video player — if you don’t touch a mouse for the few seconds, cursor will disappear.

First of all, what is a behavior?

A behavior encapsulates pieces of functionality into a reusable component, which we later on can attach to an element in a view. Emphasis is on reusable. Behaviors also have the benefit of keeping the MVVM pattern intact, since we can move code from code behind to behaviors. You can find a good introduction on the behaviors, type of behaviors in a great article of Robert Hedgate.

Implementation though attached behavior.

Advantage of attached behavior is that it can be used in a native windows store app. Disadvantage is that it does not show up in Blend under behaviors, and thus cannot be attached if you are using Blend. In my case it’s very important to have possibility of using it on windows store app.

In the implementation of the behavior we have 4 dependency properties:

  • Interval — time interval after which cursor should be hided.
  • IsEnabled — enable or disable behavior functionality.
  • ActiveCursor — cursor type when it’s not active.
  • InactiveCursor — cursor type when it’s active.

Logic isn’t really complicated so you just can download it from my Bitbucket.

My podcast list.

This article is not a deep technical but it would be useful for .net developers. Today I would like to write about my podcast list and hope I’ll get a feedback with podcasts which are good for you.

So what actually I’ve on my iPhone:

.Net-development:

  • .NET Rocks (English) — this is my favourite .NET podcast also this one is the oldest one. There is a lot of new information, always fun and interesting. Carl Franklin and Richard Campbell are doing a great job.
  • herding {code} (English) — also interesting and useful podcast with a variety range of topics.
  • Dot Band (Russian) — this podcast first of all interesting because I can get feedback about .NET rumours in Ukrainian community.
  • Hanselminutes (English) — no comments, this is just a Scott Hanselman!
  • Radio-T (Russian) — an interesting podcast about IT world trends.

Because I’m not a native English speaker my list also includes some of the English learning podcast:

If you need more, Scott Hanselman also has a great list of .Net podcasts. You can find it here.

I’m pretty sure that there are lots of other good podcasts. However, this list gives me a lot of interesting and new information. Also our time schedule is not as flexible as we want, however I can listen this whole list on a week. Unfortunately for now I don’t have a time to add one more a good podcast.

I’ll try to keep this list up-to-date.

MailMessage tool for sending any attachments at Windows Phone.

Just for fun or maybe every C# developer should play with Windows Phone; however I’ve started to develop my Windows Phone application. I wouldn’t say about an idea of the application, but as usual there are an email sending and some social functions.

I was really surprised that EmailComposeTask can’t send any types of attachments and EVER html! The reason of it is that all Tasks at Windows Phone SDK are limited by 64k (for example EmailComposeTask’s message body can’t exit of this size).

So I was thinking about following approach:

  • send data to a web service that forwards the file to an email address;
  • upload file to the some cloud storage;

Fortunately I’ve found a great tool which solved all these obstacles. This is a MailMessage (now there is a 1.2.1 version). You can easily send any type of attachments (pdf, mp3, wav, mp4, avi, bmp, txt, zip, jpg, png…) from your application and ever html with the MailMessage library.


Also it has an extremely fast and good support (which is on my opinion the one of the significant characteristic of good tool). I don’t want to add some code example here because everything what you need you can find at product page.

Thanks for the great tool!

Team Foundation Service at the cloud. Setup continuous integration with Microsoft and non-Microsoft test provider

Today I’d like to write about a new offer from Microsoft — Team Foundation Service in the cloud. For now everything is free so this is a great time to play with this technology.

After great success of cloud-version source control I was 100% sure that Microsoft has to react and give their service. Especially because they have already a good product like TFS (after Perforce I really love TFS J). As I said for now TFS is a preview so everything is free. At 2013 a new price will be announcing. However, free plan will include max 5 users at system and some limit for builds (which in my opinion — ideally for small start-ups and freelancers). Previously I used Dropbox + SVN for all my freelance/home projects. Then I’ve switched almost everything to Bitbucket. However, all of this solutions don’t have continuous integrations, test runner and project planning (especially for agile, where TFS always was much-much better then jira).

In this article I’d like to show how easily we can create a simple application, host it at TFS in the cloud, setup continuous integration for each check-in and use not Microsoft test framework. Continue reading

XP days in Kiev, Ukraine

Few days ago (on November, 16-17) I was at one of the biggest Ukraine conference related to agile engineering practices. The main topics were Unit Testing, TDD, Continuous Integration, BDD, Code Review, Refactoring, Acceptance Testing and etc. More about conference you can read here and about all session here.

This time there were a lot of different speakers of over the all country the word, such as UK, Norway, Switzerland, the Netherlands, Poland, Sweden, of course Ukraine and even Australia and USA.

Comparable to Belgium our Ukraine IT events of course are not so interesting and technically high. However, just we can do it better! J First day of conference wasn’t really good. And unfortunately, I’ve chose English speaker’s scene where wasn’t really interesting. However, second day was much-much better! Here I’d like to emphasize just three fantastic lectures on my opinion:

  • The frustrated architect (Simon Brown, UK) — the speaker was very enthusiastic. No agile dogmas, only real examples about the role of software architecture in agile.
  • Enabling TDD in BigData world (Vyacheslav Moskalenko, Ukraine) — there was only own expedience from his project about NoSQL solutions, ways to test it and TDD for big data. It was interesting for me, especially because I’ve never worked with this kind of project. Hope to solve this misunderstanding soon J
  • Agile Anti-Patterns (by Sander Hoogendoorn, Netherlands) — absolutely awesome lecture and speaker! It was very inspiring, energetic and fun, lots of fun! I’m waiting for video from this session and would like to show some dogmatic agile “experts”. Because I’m a little bit tied from “Agile projects can’t fail! And waterfall projects always fail because it’s waterfall”. Especially, if you are doing agile + TDD — you don’t have a choose, only success J This speaker told us about a lot of dogmas which people just doing only because they think it will be real agile. I like his critics (especially because I’m “2 days certificated scrum master” as Sander said). And I’m completely agreed that people are doing a lot of this crap, just because other ways it would be true agile!

Now I’m waiting for the videos from the conference and will try to add it ASAP to this post.

At the end, XP days was successful at my opinion. Thank a lot to all people how it did. Hope to join as a speaker someday.