WPF File Dialogs

Posted by Julien on February 13th, 2007

Arghhhhhh. What is that ? Are they kidding or what ? WPF is supposed to be the next generation API and the only thing they provide out of the box is that ?

  • Crappy Windows 95 era icons ? CHECK
  • “classic” style drop down boxes and buttons ? CHECK

What a shame really. On Vista this is so lame. I hope they provide something better in the next version of WPF ! Ah well, let’s pinvoke into the new Vista APIs then… 

Luckily, they are providing samples just for that. But why not include it then? Time & quality constraints aren’t really a good excuse when it comes to things used as much as a file dialog.

Drag&Drop Support, Capabilities for FileSupport Dll

Posted by Julien on February 13th, 2007

Today I added drag&drop support. Now you can simply drop a logon file and it will be added to the list of logons. I also added support for logonxp format. It only took me 20 minutes from start to finish, and now logonxp files can be imported and loaded.

I had to modify the interface a bit to add capabilities support. Basically it’s a flag that the dll sets to inform the app what kind of operations it can do. The operations available are:

  • Register (register and un-register the file format)
  • Load (load a logon from a folder)
  • Save (save a logon to a folder)
  • Import (import a compressed logon file)
  • Export (export a logon to a compressed file)

 For example, the logonxp dll supports loading, importing and registering.

I also worked a bit on resource replacement. Basically, as you can have HighDPI images and normal images, if one variant is available and not the other, I automatically use the one provided for both scenarios. The same is true for backgrounds. You can provide several resolutions and it will automatically choose the closest match for other resolutions. The function that does it for backgrounds is kind of limited right now and need a bit of testing but that will do it for the time being.

LogonSwitcher: Logon Preview & more backend work

Posted by Julien on February 13th, 2007

Not much visual work done yesterday, at least not as much as I would have wanted. I added an error background (shown when the file linked in the logon configuration doesn’t exist). I also corrected the footer (now with a correctly aligned Apply button). Finally, I added some elements to the logon preview: the user name and tile.

It’s actually the later that took me quite a lot of time. Somehow, there doesn’t seems to be a public API to programmatically get the user picture. Well, after a bit of tracing I found an exported function in shell32.dll that does just that. The only problem is that it’s not documented…

After quite a long time in the debugger, I finally had something working. Nothing surprising on the way it works, but my relative inexperience with pure win32 programming prevented me to to “get it” much sooner. And I still don’t know what one of the parameters is for. I’ll figure it out later (maybe).

On the backend side, I reorganized the class to apply an existing logon, consolidating it with the one that managed logon resources. I finally added file security & token management (I took a MS sample that nicely encapsulate token & privilege management, and added a class to take care of file access modification). 

Details Panel

Posted by Julien on February 12th, 2007

The LogonSwitcher format supports a few elements about the logon. You can add a version, a copyright year, and an URL (both target and text to show). There is also optional support for a author logo.

Here you can see that I corrected the URL part. It was showing wrong on the last version. Turns out you have to have a textblock inside an url inside another textblock for binding to work. Otherwise, it doesn’t work right. Go figure !

I took the time to add custom selection and mouseover overlay on the logons. It’s very subtle, but I think it looks great :)

Not a lot of background work. Background replacement works, but not other UI elements yet. Crappy restriction on resource updating when linked with mui resources files.

WPF Performance with BitmapEffects

Posted by Julien on February 11th, 2007

 After playing with BitmapEffects a bit, it turns out it’s deadly slow when moving elements with effects applied. The panel I was using was animated on resizing and it slows down the app to a crawl every time it moves…

For WPF version 1, Microsoft hasn’t made BitmapEffects hardware accelerated, so every elements with effects applied goes back to software rendering. Not an option with animated controls, I tell you !

So the animated panel is gone, and I’m now using a simple UniformGrid. It looks so much better with a white glow for text and a dark glow for the background.

You can see that I added UI elements to the logon preview. It doesn’t look exactly like the real thing because some of the bitmaps are actually stretched and I’m not supporting that right now. The search box is now correctly aligned on the right.

On the backend size, I updated the class responsible for extracting default logon UI elements. I’m now duping almost every UI elements shown on the screen (plus a few misc. things such as the startup sound).

Adventures with WPF Part 2 : LogonSwitcher

Posted by Julien on February 10th, 2007

After almost a week of work, it’s starting to look a bit better. I didn’t work a lot on the UI so it’s still kind of messy. It’s still using an animated control as the panel to host logons, but I’m probably going to get rid of it for performance reasons (more on that in next post).

I worked on the backend for most of the week. I now have a nice plugin interface that allow FileSupport dlls to be added to support new file formats. I have rudimentary support for logonvista files, as well as it’s own file format.

Although the LogonSwitcher file format support much more than logonvista at the moment (backgrounds as well as others UI elements), it actually took a lot less time to build thank to XML serialization :)

I tried to make things as flexible as possible, so that I can add new UI elements without having to update every class. Hopefully it will work without too much special cases :)

Note: I know the logonvista is copyrighted by Stardock and they don’t allow other people to use it. I made the FileSupport dll for my one use and I don’t intend to ever distribute it.

Adventures with WPF – Part 1

Posted by Julien on February 5th, 2007

Last week, I started working on a new application to lean WPF. Learning XAML proved to be slightly harder than I imagined. Mainly because there is no “right” way to do things. So I’ve been rewriting it almost every day, every time a little bit better than before :)

Here is what it looked liked after a few hours:

First version

A little bit of customization later:

 

There is still a lot of work to do. I’m just starting to work on the backend. Hopefully I’ll be able to reuse some of the things I did two years ago when working on my .Net SDK for ObjectDock.

.Net Docklet SDK Inner Workings

Posted by Julien on December 25th, 2004

ObjectDock Docklets are DLL programmed in C or C++ that exports a few callbacks functions. These functions are called when a user manipulate the docklet. Building a docklet in .Net directly is impossible as ObjectDock doesn’t support managed code docklets. Thus, you need some kind of “proxy” that knows about .Net docklets and will be able to interact with them, relaying info to ObjectDock as needed.

Here is a picture that summarize the interactions between the different parts (I know, I could have made an UML Class diagram, but hey, it’s Christmas and I wanted a nice looking picture :P )

The Interop Docklet is just a normal docklet that exports all of the possible callbacks functions. Whenever a callback function is called by ObjectDock, the Interop Docklet transmits it to the currently loaded .Net Docklet. The only problem is that you cannot call managed code from unmanaged code directly, you have to use COM to access managed dlls.

Each .Net Docklet should implement the interface IDockletInterface (basically identical to the native docklet callbacks). The Interop docklet knows the GUID of the interface and can create an instance of the .Net Docklet using CoCreateInstance. However, for the call to succeed, the .net docklets have to be registered as COM objects. Asking the user to manually register each plugin with regasm was obviously not an option.

As there is no way (AFAIK) to programmatically register managed COM objects from unmanaged code, the Interop Docklet contains hardcoded info about the DotNetHelper DLL. When the docklet is called for the first time, it write that info in the registry. Then, when a CoCreateInstance call fails, it calls the RegisterDocklets function in DotNetHelper DLL that will walks through the different .Net docklets and try to register them. Problem solved (well almost, but I’ll keep that for another article :) )

The NetDockletHelper DLL also provides the Docklet class that encapsulate SDK functions and keeps the static data associated with each docklet (such as the docklet handle and the different folder paths). Docklet programmer can also use the LOG function from the Util class for debugging purposes.

.Net SDK for ObjectDock

Posted by Julien on December 24th, 2004

I’m looking for people to help me test .Net Support for ObjectDock.

What you will have to do is simply try to build a docklet using the sdk and send me suggestions & bug reports (or not, if you feel evil :) ). The more of the SDK you use, the better, of course, but building a simple docklet will work too.

Here is an explanation of the way I build it and how it works:

Last week, I started working on a way to build ObjectDock docklets in C#. Currently ObjectDock only allows you to build docklet using C/C++. As I have no access to ObjectDock internals, the only way to have docklets using managed code is to build a “proxy” docklet and call into managed code using COM.

The following picture shows the interaction between the different parts. When building a .Net Docklet, the only thing you have to care about is the docklet code itself (the Interop & helper dll are supplied and do not need to be modified).

The API is similar to the native SDK API. Each .Net Docklet has to implement the IDockletInterface interface (basically, the exportable functions from the native API). The native SDK functions are provided through the docklet class found in the DotNetSDK dll (the docklet handle & private data are encapsulated, so it’s somewhat cleaner than the native API).

The interop docklet can be used in two different way: in standalone mode or in multi-docklet mode. In standalone mode, the programmer distributes the interop & helper dlls along with it’s .Net docklet and set the interop to autoload it’s plugin. It’s completely transparent to the user. In multi-docklet mode, you only distribute the .net docklet part (users should have the “runtime”) and users could choose from a selection of docklets the one to load.

If you want to help me test it, drop me a mail.

Merry Christmas everybody :)

TodoList Docklet for ObjectDock – Part 1: Specifications

Posted by Julien on September 21st, 2004

Introduction

f In some past articles, Brad described his idea of a Todo plugin for ObjectDock. Since nobody seems to have taken on the idea, I decided to try to do build it myself.

This article is the first of a series that will describe the process of building the plugin. It will come with the source code. It will be licensed under the Creative Commons Attribution-ShareAlike License.

As I don’t know how long I will be able to work on it, I decided to limit the scope of the docklet (no drag&drop to create new task, no predefined and custom task icons, etc.).

Functional Specification

The following spec is pretty crude and in no way complete (and as always subject to change). I will describe the behavior of the plugin as the user creates a task, modify it and finally delete it.

Creation
A new task is created when the user selects the ‘TodoList Docklet’ in the ‘Add Entry’ right-click menu. The plugin is initialized with the default icon, the task name set to “Click to Edit…”, the priority set to “0 – No Priority” and no description.

Modification
The user will then modify the task to fill the different fields. This is done either by left-clicking the icon or by right-clicking and selecting ‘Edit Task’. The “TodoList Docklet Properties” Dialog is presented to the user (mockup from Visio).

Edit Box Image

The “Name” field contains the name of the task. It is shown when the user moves the mouse over the task icon.

The “Priority” is the priority of the task selected on a scale from 1 to 5. Here are the different icons quickly made by me (by now, you can probably see I’m no artist).

Priority images

The different priority are:

	0. No Priority 	1. Not Urgent 	2. Not Important 	3. Normal 	4. Important 	5. Urgent

The default priority is “0 – No Priority”.

(Got better names ? Comment! )

The “Description” is a more precise description of the task, and is optional.

The default icon (a slightly modified Knotes icon from the crystal icon pack by Everaldo) can be changed by clicking the “Change Image” button (opens the standard ObjectDock “Choose Image” dialog). You can revert to the default icon by pressing the “Default Image” button.

When the user is finished with the editing, he can either ‘save’ the changes by pressing “OK” or cancel the changes (“Cancel”).

The task icon in the dock now looks like this:

Note Example

The priority is shown as an overlay on the task image.

Deletion
When the task is finished or no longer relevant, the user can delete it, either by dragging it off the dock or by right-clicking the icon and choosing ‘Delete Task’.

That’s it for today. In the next article, I will describe the framework for the plugin.