Exemplo n.º 1
0
        public void Dispose()
        {
            _configManager.RemovePropertyChangeListener(OnEvent_ConfigManager_PositionChange);

            var chatLocation = _overlay.Location;

            _configManager.SetProperty("behaviour.frame.chat.position.x", chatLocation.X);
            _configManager.SetProperty("behaviour.frame.chat.position.y", chatLocation.Y);

            var chatSize = _overlay.Size;

            _configManager.SetProperty("behaviour.frame.chat.size.width", chatSize.Width);
            _configManager.SetProperty("behaviour.frame.chat.size.height", chatSize.Height);

            _manager.UISynchronizer.RunSync(() => _overlay.Close());

            _manager.DisposeUIElement(OverlayUIId);
            _moveCallback.Dispose();
            _resizeCallback.Dispose();

            _manager        = null;
            _overlay        = null;
            _configManager  = null;
            _moveCallback   = null;
            _resizeCallback = null;
        }
Exemplo n.º 2
0
        public void Dispose()
        {
            _cefOverlay.Browser.OnBrowserInitialized  -= Browser_BrowserInitialized;
            _cefOverlay.Browser.OnBrowserLoadPage     -= Browser_BrowserLoadPage;
            _cefOverlay.Browser.OnBrowserLoadPageDone -= Browser_BrowserLoadPageDone;

            _configManager = null;
            _cefOverlay    = null;
            _container     = null;
        }
Exemplo n.º 3
0
        public BrowserAPIManager(
            CefOverlayForm overlay,
            IUISynchronizer uiSynchronizer
            )
        {
            _overlay      = overlay ?? throw new ArgumentNullException(nameof(overlay));
            _synchronizer = uiSynchronizer ?? throw new ArgumentNullException(nameof(uiSynchronizer));

            RegisterAPI(new GobchatBrowserAPI(this));
        }
Exemplo n.º 4
0
        public void Initialize(ApplicationStartupHandler handler, IDIContext container)
        {
            _container         = container ?? throw new ArgumentNullException(nameof(container));
            _configManager     = _container.Resolve <IConfigManager>();
            _browserAPIManager = _container.Resolve <IBrowserAPIManager>();

            var uiManager = _container.Resolve <IUIManager>();

            _cefOverlay = uiManager.GetUIElement <CefOverlayForm>(AppModuleChatOverlay.OverlayUIId);

            _cefOverlay.Browser.OnBrowserLoadPage     += Browser_BrowserLoadPage;
            _cefOverlay.Browser.OnBrowserLoadPageDone += Browser_BrowserLoadPageDone;
            _cefOverlay.Browser.OnBrowserInitialized  += Browser_BrowserInitialized;
        }
Exemplo n.º 5
0
        private void InitializeUI()
        {
            _overlay = _manager.CreateUIElement(OverlayUIId, () => new CefOverlayForm());
            _overlay.Show(); //initializes all properties
            _overlay.Visible = false;

            _configManager.AddPropertyChangeListener("behaviour.frame.chat", true, true, OnEvent_ConfigManager_PositionChange);

            _moveCallback = new DelayedCallback(TimeSpan.FromSeconds(1), () =>
            {
                var location = _overlay.Location;
                if (IsFrameOnScreens(_overlay.DesktopBounds))
                {
                    _configManager.SetProperty("behaviour.frame.chat.position.x", location.X);
                    _configManager.SetProperty("behaviour.frame.chat.position.y", location.Y);
                    _configManager.DispatchChangeEvents();
                }
                else // restore last location and size from config
                {
                    UpdateFormPosition();
                }
            });

            _resizeCallback = new DelayedCallback(TimeSpan.FromSeconds(1), () =>
            {
                var size = _overlay.Size;
                if (IsFrameOnScreens(_overlay.DesktopBounds))
                {
                    _configManager.SetProperty("behaviour.frame.chat.size.width", size.Width);
                    _configManager.SetProperty("behaviour.frame.chat.size.height", size.Height);
                    _configManager.DispatchChangeEvents();
                }
                else // restore last location and size from config
                {
                    UpdateFormPosition();
                }
            });

            _overlay.Move        += (s, e) => _moveCallback.Call();
            _overlay.SizeChanged += (s, e) => _resizeCallback.Call();

            _overlay.Browser.OnBrowserLoadPageDone += (s, e) =>
            {
                if (!_overlay.Visible)
                {
                    _manager.UISynchronizer.RunSync(() => _overlay.Visible = true);
                }
            };

            if (_manager.TryGetUIElement <INotifyIconManager>(AppModuleNotifyIcon.NotifyIconManagerId, out var trayIcon))
            {
                //trayIcon.Icon = Gobchat.Resource.GobTrayIconOff;

                trayIcon.OnIconClick += (s, e) => _overlay.Visible = !_overlay.Visible;

                var menuItemHideShow = new ToolStripMenuItem();
                menuItemHideShow.Text    = _overlay.Visible ? Resources.Module_NotifyIcon_UI_Hide : Resources.Module_NotifyIcon_UI_Show;
                menuItemHideShow.Click  += (s, e) => _overlay.Visible = !_overlay.Visible;
                _overlay.VisibleChanged += (s, e) => menuItemHideShow.Text = _overlay.Visible ? Resources.Module_NotifyIcon_UI_Hide : Resources.Module_NotifyIcon_UI_Show;
                trayIcon.AddMenu("overlay.showhide", menuItemHideShow);

                var menuItemReload = new ToolStripMenuItem(Resources.Module_NotifyIcon_UI_Reload);
                menuItemReload.Click += (s, e) => _overlay.Reload();
                trayIcon.AddMenu("overlay.reload", menuItemReload);

                var menuItemFrameReset = new ToolStripMenuItem(Resources.Module_NotifyIcon_UI_Reset);
                menuItemFrameReset.Click += (s, e) => ResetFrameToDefaultLocation();
                trayIcon.AddMenu("overlay.reset", menuItemFrameReset);

#if DEBUG
                var menuItemDevTool = new ToolStripMenuItem("DevTool");
                menuItemDevTool.Click += (s, e) => _overlay.Browser.ShowDevTools();
                trayIcon.AddMenuToGroup("debug", "overlay.devtool", menuItemDevTool);
#endif
            }

            _overlay.Visible = false;
        }