Exemple #1
0
 private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
 {
     if (!e.IsLoading && browser.Address != "about:blank" && !flags.HasFlag(NotificationFlags.ManualDisplay))
     {
         this.InvokeSafe(() => {
             Visible = true; // ensures repaint before moving the window to a visible location
             timerDisplayDelay.Start();
         });
     }
 }
Exemple #2
0
        public FormNotification(FormBrowser owner, PluginManager pluginManager, NotificationFlags flags)
        {
            InitializeComponent();

            this.owner   = owner;
            this.plugins = pluginManager;
            this.flags   = flags;

            owner.FormClosed += (sender, args) => Close();

            browser = new ChromiumWebBrowser("about:blank")
            {
                MenuHandler     = new ContextMenuNotification(this, !flags.HasFlag(NotificationFlags.DisableContextMenu)),
                LifeSpanHandler = new LifeSpanHandler()
            };

            #if DEBUG
            browser.ConsoleMessage += BrowserUtils.HandleConsoleMessage;
            #endif

            browser.IsBrowserInitializedChanged += Browser_IsBrowserInitializedChanged;
            browser.LoadingStateChanged         += Browser_LoadingStateChanged;
            browser.FrameLoadEnd += Browser_FrameLoadEnd;

            if (!flags.HasFlag(NotificationFlags.DisableScripts))
            {
                notificationJS = ScriptLoader.LoadResource(NotificationScriptFile);
                browser.RegisterAsyncJsObject("$TD", new TweetDeckBridge(owner, this));

                if (plugins != null)
                {
                    pluginJS = ScriptLoader.LoadResource(PluginManager.PluginNotificationScriptFile);
                    browser.RegisterAsyncJsObject("$TDP", plugins.Bridge);
                }
            }

            panelBrowser.Controls.Add(browser);

            if (flags.HasFlag(NotificationFlags.AutoHide))
            {
                Program.UserConfig.MuteToggled += Config_MuteToggled;
                Disposed += (sender, args) => Program.UserConfig.MuteToggled -= Config_MuteToggled;

                if (Program.UserConfig.MuteNotifications)
                {
                    PauseNotification();
                }
            }

            mouseHookDelegate = MouseHookProc;

            Disposed += FormNotification_Disposed;
        }