Sl.ayer's lair

It looks like you're writing a blog...

Silverlight, meet Shell.Application

Silverlight 4 is coming, and with it a controversial ability to call local automation objects. In this post, I will review some of the standard automation objects that can be used from Silverlight 4.

Shell.Application

Shell Automation enables access to features of Windows shell. This includes displaying standard dialogs, arranging windows, starting applications, starting and stopping services, and more.

Probably the most useful function of Shell.Application is ShellExecute. Using ShellExecute, it’s possible to run executable or open or print a document.

dynamic shell = ComAutomationFactory.CreateObject("Shell.Application");
shell.ShellExecute("notepad.exe", "", "", "open", 1);

More...


“Scratch”, WriteableBitmap Sample

Screen I have a new addition to my samples gallery. This sample was inspired by a question I answered on the silverlight.net community forums. The idea of creating a “scratchable” surface intrigued me, so I decided to make a full-blown sample utilizing WritabeBitmap.

It took me about 8 hours from start to finish to implement the sample. Most of it I spent fussing over the application’s look-and-feel and getting the brushes to work properly. Some of my failed experiments with brushes produced very interesting, almost impressionistic-looking, results.

The ideas I considered for development, but not included in the sample: changing brush shape depending on stroke’s velocity; rotating brush based on the angle of the stroke; and multi-touch support.


If you’re building a Silverlight application for Facebook, you have two choices: (1) build a stand alone application and use Facebook Connect for authentication, or (2) create a canvas application that will appear on a Facebook site and use the parameters passed to iframe to establish a session. The former is well covered in the Facebook Toolkit documentation, but I couldn’t find any examples of how to embed a Silverlight application within a Facebook iframe. It took a few days worth of research and experiments to get it right and I hope this post will be helpful to anyone who is working on Silverlight canvas application for Facebook.

Embedding Silverlight into Facebook canvas

I know three ways of embedding Silverlight application into a Facebook canvas.Fbss

(1) Select the IFrame option for Render Method in Canvas section of the application settings and embed the Silverlight application inside the iframed page using standard methods (object tag, silverlight.js, etc.).  (2) Use <fb:iframe> tag in fbml based canvas. (3) Use fbml tag <fb:silverlight>. The <fb:silverlight> tag would be the preferred method, but according to the Facebook wiki, the tag is not implemented at this time. That leaves only options 1 and 2 available – embed Silverlight in iframe.  Whether you go with IFrame canvas or use <fb:iframe> tag in fbml, the following steps are the same:

More...


Styled Silverlight buttons

Button

I spent some time recently going through some of my older projects and consolidating different button styles I’ve designed over time into a single project.

You can see the results in this Silverlight sample application.


Comic Composer for Facebook

If you visited my projects page then you know about silverlight comic builder I am working on. Comic Composer for Facebook is the latest development bringing user created comics strips to Facebook platform. I am currently looking for beta testers to help me to prepare application for general release. Please, leave your comments and suggestions in this post.

  • Comic Composer for Facebook
  • Facebook Toolkit
  • Image tools


  • It is a common task for developers creating add-ons for World of Warcraft to process wow lua files on the server side. YouPVP, for example, receives lua files generated by an add-on and parses battlegrounds data into the database. Since I was building a website on an asp.net platform, I needed lua parser in C#. Unfortunately, after spending some time on the internet, I couldn’t find any .net solutions that would work for me, so I wrote my own. If you need to parse warcraft lua files in a .net environment, I hope you will find my LuaParse class to be useful.


    Color picker control for Silverlight

    colorpickr

    I am a bit of a fan of colors and consequently of color pickers. First release of Silverlight didn’t provide much help with control development and my first color picker was very simple: four sliders, one for each of the color components of RGBA color.

    With release of Silverlight 3.0 developers have a choice of the color pickers made by the enthusiasts and companies specializing in Silverlight controls.

    Unfortunately, the only kind of color pickers I could find are based on SV+H model. I figure it is due to Microsoft products favoring that type of color picker. Personally, I prefer HS+V color pickers, commonly used in Adobe products, so I had to sit down and build one myself.

    Color picker was my first custom control and quite expectedly I ran into some issues during development, but it was a good learning experience.

    Color picker is free to use in any projects. Have fun.


    Introduction

    Did you cheer when you found out that ATL 3.0 would support ActiveX control hosting? I did. This functionality was at the top of my wish list for ATL. ATL 3.0 has finally arrived. What now? In one news group, I saw the following question: "How do I resize ActiveX controls hosted by Composite Control?” The answer to this question is very simple, but the reasoning behind it is not. Therefore, I decided to write this article to share my knowledge of the inner workings of ATL’s hosting of ActiveX controls.

    How does ATL implement the hosting of ActiveX controls

    If you will look in ATL code, you will notice that code for CComCompositeControl takes less then two hundred lines. How is it possible to fit all hosting support into two hundred lines of code? Well, the answer is quite simple--CComCompositeControl does not have support for ActiveX hosting. The real hero behind the scenes is CAxHostWindow.

    CAxHostWindow implements necessary interfaces in order to support the hosting of common ActiveX controls (including windowless) and Microsoft Web Browser control. In case you do not need to host a Web Browser control, you can define _ATL_NO_DOCHOSTUIHANDLER in your project and save about 4K in release dll. CAxHostWindow derives from CWindowImpl, and this means it needs a window to operate. CAxHostWindow can host only one control at a time, and as a result, one CAxHostWindow is required for each hosted control. Without going into all the aspects of implementation (look into atlhost.h for more details), I would like to concentrate here on the way CAxHostWindow handles WM_SIZE and WM_PAINT.

    More...

    There are two major methods that you can use to support control containment in your control using ATL 3.0. One method is to use the support provided by ATL, namely CAxHostWindow. The other method is to write everything from scratch. By far, using ATL is easier then writing tons of code yourself, but what if CAxHostWindow doesn’t support the functionality that you need? Is following the second method your only option? Most likely, the answer is no. In most cases, the result can be achieved just by extending the functionality of CAxHostWindow, which I will be discussing as the main topic in this article.

    The most obvious way to extend the functionality of CAxHostWindow is to modify its code in atlhost.h, but it should be done with care because changes you make will reflect on every user of CAxHostWindow, such as Composite Control. An alternative solution is to derive a new class from CAxHostWindow and override its methods and message handlers. Below, I will demonstrate in more detail how to modify CAxHostWindow to support new functionality.

    More...

    Introduction

    Initially, this article was intended as a tutorial for the creation of ActiveX controls. However, this subject is well covered by articles in magazines and on the Internet. So, instead, I have decided to concentrate on one aspect of control creation, which can make your control look and interact with the user better.

    What is Hot Tracking?

    For the purposes of this article, hot tracking will be the process when a UI element reacts to the cursor, entering or leaving its extent, by changing it appearance. Hot tracking is not a new concept; it has been used in computer games for years. For example, a game I made five years ago for Windows 3.1 had support for hot tracking built-in as a standard feature. Recently, with help from Internet Explorer, MS Office and other software, hot tracking is becoming a standard in user interfaces. In fact, many UI and non-UI concepts made their first appearance in computer games, but this is a separate discussion. Considering the abovementioned, supporting hot tracking in your control may sound like a good idea. So, without further delay, let's get to the point.

    More...