예제 #1
0
        internal Window(
            Func <object> getSyncObj,
            Action <string, string, string> openWindow,
            INavigator navigator,
            IConsole console,
            Func <Engine> getEngine)
        {
            _getEngine  = getEngine;
            Console     = console ?? throw new ArgumentNullException(nameof(console));
            _openWindow = openWindow ?? ((x, y, z) => {});
            Screen      = new Screen
            {
                Width       = 1024,
                Height      = 768,
                AvailWidth  = 1024,
                AvailHeight = 768,
                ColorDepth  = 24,
                PixelDepth  = 24
            };

            InnerWidth  = 1024;
            InnerHeight = 768;
            Navigator   = navigator;

            History  = new History(OnSetState);
            Location = new Location(History, () => _engine.Uri, s => _engine.OpenUrl(s));

            _timers              = new WindowTimers(getSyncObj);
            _timers.OnException += exception => { Console.Log("Unhandled exception in timer handler function: " + exception.ToString()); };

            _eventTarget = new EventTarget(this, () => null, () => _engine.Document);

            _eventTarget.CallDirectEventSubscribers += CallDirectEventSubscribers;
        }
예제 #2
0
        internal Window(
            Func <object> getSyncObj,
            Action <string, string, string> openWindow,
            INavigator navigator)
        {
            _openWindow = openWindow ?? ((x, y, z) => {});
            Screen      = new Screen
            {
                Width       = 1024,
                Height      = 768,
                AvailWidth  = 1024,
                AvailHeight = 768,
                ColorDepth  = 24,
                PixelDepth  = 24
            };

            InnerWidth  = 1024;
            InnerHeight = 768;
            Navigator   = navigator;

            History  = new History(OnSetState);
            Location = new Location(History, () => _engine.Uri, s => _engine.OpenUrl(s));

            _timers              = new WindowTimers(getSyncObj);
            _timers.OnException += exception =>
            {
                if (exception is JavaScriptException jsEx)
                {
                    _engine.Console.Log($"JavaScript error in timer handler function (Line:{jsEx.LineNumber}, Col:{jsEx.Column}, Source: {jsEx.Source}): {jsEx.Error}");
                }
                else
                {
                    _engine.Console.Log("Unhandled exception in timer handler function: " + exception.ToString());
                }
            };

            _eventTarget = new EventTarget(this, () => null, () => _engine.Document);
        }