示例#1
0
        public AdvertisingControl()
        {
            InitializeComponent();

            DWebBrowserEvents2_Event browser = webBrowser.ActiveXInstance as DWebBrowserEvents2_Event;

            //Workaround which allows to minimize showing time of wait cursor when WebBrowser navigating.
            updateCursor = () => Dispatcher.Invoke(Mouse.UpdateCursor);

            if (browser != null)
            {
                browser.NewWindow3    += webBrowser_NewWindow3;
                browser.NavigateError += browser_NavigateError;

                browser.StatusTextChange += browser_StatusTextChange;
                browser.TitleChange      += browser_TitleChange;

                IEClients.ForEach(client => client.ProxyChanged += () =>
                {
                    if (!isAnimationPlayed)
                    {
                        timer.Interval = 1;
                        timer.Stop();
                        timer.Start();
                    }
                });

                timer.Elapsed += (sender, e) =>
                {
                    updateNumber++;

                    timer.Interval = RefreshInterval.TotalMilliseconds;
                    if (!IsIEUsingProxy)
                    {
                        webBrowser.Navigate(string.Format(adsUri, Context.Get <IVersionProvider>().Version.ToString(), updateNumber));

                        if (!isAnimationPlayed)
                        {
                            isAnimationPlayed = true;
                            Action action = () => Dispatcher.BeginInvoke(new Action(() => PlayAnimation("ExpandControl")));
                            action.RunWithDelay(loadAdvertisingTimeout);
                        }
                    }
                };

                timer.Start();
            }
        }
示例#2
0
 private void webBrowser_NewWindow3(ref object ppDisp, ref bool cancel, uint flags, string urlContext, string url)
 {
     IEClients.ForEach(client => client.Proxy = null);
 }