views:

39

answers:

1

Hi,

I am currently experimenting with the ChildWindowDialog and with prism I have created a controller class. I would like my popup to be displayed on all the screen (a bit like fullscreen mode). I have HtmlPage.Window.Eval() below but I am not sure if this is the correct thing to do. One of the reasons it feels wrong is I have no idea how to test this class in the future. Also, I have coupled the controller to the Browser class which will mean I could not reuse it in a WPF app.

public class GalleryCoverFlowChildWindowController
{
    private readonly IEventAggregator _eventAggregator;
    private readonly IUnityContainer _container;

    public GalleryCoverFlowChildWindowController(IEventAggregator eventAggregator, IUnityContainer container)
    {
        _eventAggregator = eventAggregator;
        _container = container;
        _eventAggregator.GetEvent<GalleryCoverViewPopupEvent>().Subscribe(PopupShow, ThreadOption.UIThread, true, Filter);
    }

    private bool Filter(string obj)
    {
        return true;
    }

    private void PopupShow(string obj)
    {
        var galleryPopup = _container.Resolve<GalleryCoverFlowChildWindow>();
        galleryPopup.Width = (double)System.Windows.Browser.HtmlPage.Window.Eval("screen.availWidth");
        galleryPopup.Height = (double)System.Windows.Browser.HtmlPage.Window.Eval("screen.availHeight");
        galleryPopup.Show();
    }
}

JD.

A: 

To resolve the issue with coupling, I created a ScreenService and injected it in via Unity. That way I do not have a dependency on DOM. This will make testing the code easier.

Any thoughts?

JD