IUIVisualizerService question

Dec 22, 2011 at 10:33 PM

Hi are you amenable to making a change to IUIVisualizerService which would allow user code to obtain a handle to the Window returned by the service.

We currently use our own 'window manager' which handles when new windows should be opened.

EG in an app which displays Person info in a window, the window manager (default behaviour) ensures that multiple calls to show the same person (eg John Smith) only open the 1 window. If a window for John Smith is already open it is brought to the top of the visual stack.

Unfortunately, without obtaining the window handle, it is impossible for the window manager to do its job.

Dec 22, 2011 at 11:02 PM

ok, had a bit more time to consider this...

I guess the IUIVisualizerService interface can't return UI objects (eg Window) as that would break unit tests.

So, I want to be able to implement and register a new 'Visualizer Service' which wraps your existing default implementation & can use the default implementation to obtain new Window references when required.

That would require:

  • The default implementation to provide a public method which returns a Window reference.
  • Catel allowing a new Visualizer Service to be registered
  • Getting information about the default implementation so that it can be used in a new implementation

 

Coordinator
Dec 23, 2011 at 9:48 AM

The cool thing about Catel (whether it's cool is up to you, but I think it's cool :)) is that we keep in mind such requirements. Thus, every service that is implemented is extensible, also the UIVisualizerService.

The actual window creation is inside the UIVisualizerService.CreateWindow method. What you can do is this:

protected override Window CreateWindow(Type windowType, object data, EventHandler<UICompletedEventArgs> completedProc, bool isModal)
{
    var window = base.CreateWindow(windowType, data, completedProc, isModal);
    if (window != null)
    {
        // Register the window handle here
    }

    return window;
}

Then you only have to register your own version of the UIVisualizerService (name it WindowAwareUIVisualizerService or something like that), and you are good to go.

Dec 24, 2011 at 4:49 AM

Thanks,

I think it is very cool.