예제 #1
0
        protected virtual void Dispose(bool isdisposing)
        {
            // No longer reference event listeners:
            ConsoleMessage      = null;
            FrameLoadStart      = null;
            FrameLoadEnd        = null;
            LoadError           = null;
            LoadingStateChanged = null;
            Rendering           = null;

            // No longer reference handlers:
            this.SetHandlersToNull();

            if (isdisposing)
            {
                if (BrowserSettings != null)
                {
                    BrowserSettings.Dispose();
                    BrowserSettings = null;
                }

                PresentationSource.RemoveSourceChangedHandler(this, PresentationSourceChangedHandler);

                // Release internal event listeners:
                Loaded            -= OnLoaded;
                GotKeyboardFocus  -= OnGotKeyboardFocus;
                LostKeyboardFocus -= OnLostKeyboardFocus;

                // Release internal event listeners for Drag Drop events:
                DragEnter -= OnDragEnter;
                DragOver  -= OnDragOver;
                DragLeave -= OnDragLeave;
                Drop      -= OnDrop;

                IsVisibleChanged -= OnIsVisibleChanged;

                if (tooltipTimer != null)
                {
                    tooltipTimer.Tick -= OnTooltipTimerTick;
                }

                if (CleanupElement != null)
                {
                    CleanupElement.Unloaded -= OnCleanupElementUnloaded;
                }

                foreach (var disposable in disposables)
                {
                    disposable.Dispose();
                }
                disposables.Clear();
                UiThreadRunAsync(() => WebBrowser = null);
            }

            Cef.RemoveDisposable(this);

            RemoveSourceHook();

            managedCefBrowserAdapter = null;
        }
예제 #2
0
        protected virtual void Dispose(bool isdisposing)
        {
            PresentationSource.RemoveSourceChangedHandler(this, PresentationSourceChangedHandler);

            BrowserSettings.Dispose();

            BrowserSettings = null;
            ResourceHandler = null;

            Loaded -= OnLoaded;

            GotKeyboardFocus  -= OnGotKeyboardFocus;
            LostKeyboardFocus -= OnLostKeyboardFocus;

            IsVisibleChanged -= OnIsVisibleChanged;

            Cef.RemoveDisposable(this);

            foreach (var disposable in disposables)
            {
                disposable.Dispose();
            }
            disposables.Clear();

            UiThreadRunAsync(() => WebBrowser = null);
            managedCefBrowserAdapter          = null;
            ConsoleMessage = null;
            FrameLoadStart = null;
            FrameLoadEnd   = null;
            LoadError      = null;
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                PresentationSource.RemoveSourceChangedHandler(this, SourceChangedEventHandler);
            }
        }
예제 #4
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         FocusTracker.Instance.TrackFocus -= new EventHandler <TrackFocusEventArgs>(this.OnTrackFocus);
         PresentationSource.RemoveSourceChangedHandler(this, new SourceChangedEventHandler(this.OnSourceChanged));
         this.StopHwndSourceTracking();
     }
     base.Dispose(disposing);
 }
        private static void OnPresentationSourceChanged(object sender, SourceChangedEventArgs e)
        {
            var element = sender as FrameworkElement;

            if (element != null)
            {
                UpdateScrollBarStyles(element);
            }
            PresentationSource.RemoveSourceChangedHandler(element, OnPresentationSourceChanged);
        }
예제 #6
0
 protected override void DisposeManagedResources()
 {
     if (this.Element == null)
     {
         return;
     }
     PresentationSource.RemoveSourceChangedHandler((IInputElement)this.Element, new SourceChangedEventHandler(this.OnPresentationSourceChanged));
     this.Element.LayoutUpdated -= new EventHandler(this.OnLayoutUpdated);
     this.HwndSource             = (HwndSource)null;
     this.Element = (UIElement)null;
 }
예제 #7
0
파일: HwndHost.cs 프로젝트: z2516305651/wpf
        /// <summary>
        ///     Disposes this object.
        /// </summary>
        /// <param name="disposing">
        ///     true if called from explisit Dispose; and we free all objects managed and un-managed.
        ///     false if called from the finalizer; and we free only un-managed objects.
        /// </param>
        /// <remarks>
        ///     Derived classes should override this if they have additional
        ///     cleanup to do.  The base class implementation should be called.
        ///     Note that the calling thread must be the dispatcher thread.
        ///     If a window is being hosted, that window is destroyed.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            if (_isDisposed == true)
            {
                return;
            }


            if (disposing)
            {
                // Verify the thread has access to the context.
#pragma warning suppress 6519
                VerifyAccess();


                // Remove our subclass.  Even if this fails, it will be forcably removed
                // when the window is destroyed.
                if (_hwndSubclass != null)
                {
                    // Check if it is trusted (WebOC and AddInHost), call CriticalDetach to avoid the Demand.
                    if (_fTrusted.Value == true)
                    {
                        _hwndSubclass.CriticalDetach(false);
                    }
                    else
                    {
                        _hwndSubclass.RequestDetach(false);
                    }

                    _hwndSubclass = null;
                }

                // Drop the hooks so that they can be garbage-collected.
                _hooks = null;

                // We no longer need to know about the source changing.
                PresentationSource.RemoveSourceChangedHandler(this, new SourceChangedEventHandler(OnSourceChanged));
            }

            if (_weakEventDispatcherShutdown != null) // Can be null if the static ctor failed ... see WebBrowser.
            {
                _weakEventDispatcherShutdown.Dispose();
                _weakEventDispatcherShutdown = null;
            }

            DestroyWindow();

            _isDisposed = true;
        }
예제 #8
0
        public void Dispose()
        {
            _textView.GotAggregateFocus         -= OnTextViewGotAggregateFocus;
            _textView.LostAggregateFocus        -= OnTextViewLostAggregateFocus;
            _textView.VisualElement.SizeChanged -= OnElementSizeChanged;
            this.SizeChanged -= OnElementSizeChanged;

            if (_findAdornmentLayer != null)
            {
                ((UIElement)_findAdornmentLayer).LayoutUpdated -= FindAdornmentCanvas_LayoutUpdated;
            }

            _model.Dispose();
            PresentationSource.RemoveSourceChangedHandler(this, OnPresentationSourceChanged);
        }
예제 #9
0
        protected void Deactivate()
        {
            if (!m_activated)
            {
                return;
            }

            var hwndSource = PresentationSource.FromVisual(m_connector) as HwndSource;

            if (hwndSource != null)
            {
                OnSourceDisconnected(hwndSource);
            }

            PresentationSource.RemoveSourceChangedHandler(m_connector, OnSourceChanged);
            m_activated = false;
        }
예제 #10
0
        internal static void AddPresentationSourceCleanupAction(UIElement element, Action handler)
        {
            SourceChangedEventHandler relayHandler = (SourceChangedEventHandler)null;

            relayHandler = (SourceChangedEventHandler)((sender, args) =>
            {
                if (args.NewSource != null)
                {
                    return;
                }
                if (!element.Dispatcher.HasShutdownStarted)
                {
                    handler();
                }
                PresentationSource.RemoveSourceChangedHandler((IInputElement)element, relayHandler);
            });
            PresentationSource.AddSourceChangedHandler((IInputElement)element, relayHandler);
        }
예제 #11
0
        protected virtual void Dispose(bool disposing)
        {
            PresentationSource.RemoveSourceChangedHandler(this, OnSourceChanged);
            Dispatcher.ShutdownFinished -= OnDispatcherShutdown;

            if (null != observer)
            {
                //    observer.Execute -= ExecutedRoutedCommandHandler;
                //    observer.CanExecute -= CanExecuteRoutedCommandHandler;
                observer = null;
            }

            if (null != contract)
            {
                contract.Dispose();
                contract = null;
            }

            hWnd = new HandleRef(null, IntPtr.Zero);
        }
예제 #12
0
        public void Dispose()
        {
            _textView.GotAggregateFocus         -= OnTextViewGotAggregateFocus;
            _textView.LostAggregateFocus        -= OnTextViewLostAggregateFocus;
            _textView.VisualElement.SizeChanged -= OnElementSizeChanged;
            this.SizeChanged -= OnElementSizeChanged;

            if (_findAdornmentLayer != null)
            {
                ((UIElement)_findAdornmentLayer).LayoutUpdated -= FindAdornmentCanvas_LayoutUpdated;
            }

            if (_textFormattingMap != null)
            {
                _textFormattingMap.FormatMappingChanged -= UpdateBorderColors;
            }

            this.Loaded -= Dashboard_Loaded;

            _model.Dispose();
            PresentationSource.RemoveSourceChangedHandler(this, OnPresentationSourceChanged);
        }
예제 #13
0
        /// <summary>
        /// Remove this StylusPlugInCollection from the StylusPlugInCollectionList when it the last
        /// element is removed for this collection.
        /// </summary>
        private void EnsureEventsUnhooked()
        {
            if (this.Count == 0)
            {
                // Unhook events.
                _element.IsEnabledChanged        -= _isEnabledChangedEventHandler;
                _element.IsVisibleChanged        -= _isVisibleChangedEventHandler;
                _element.IsHitTestVisibleChanged -= _isHitTestVisibleChangedEventHandler;
                if (_renderTransformChangedEventHandler != null)
                {
                    _element.RenderTransform.Changed -= _renderTransformChangedEventHandler;
                }
                PresentationSource.RemoveSourceChangedHandler(_element, _sourceChangedEventHandler);
                _element.LayoutUpdated -= _layoutChangedEventHandler;

                // Disable processing of the queue during blocking operations to prevent unrelated reentrancy
                // which a call to Lock() can cause.
                ExecuteWithPotentialDispatcherDisable(() =>
                {
                    // Make sure we are unhooked from PenContexts if we don't have any plugins.
                    _stylusPlugInCollectionImpl.Unhook();
                });
            }
        }
예제 #14
0
        protected virtual void Dispose(bool isdisposing)
        {
            //Check if alreadty disposed
            if (Interlocked.Increment(ref disposeCount) == 1)
            {
                // No longer reference event listeners:
                ConsoleMessage      = null;
                FrameLoadStart      = null;
                FrameLoadEnd        = null;
                LoadError           = null;
                LoadingStateChanged = null;
                Rendering           = null;

                // No longer reference handlers:
                this.SetHandlersToNull();

                if (isdisposing)
                {
                    browser = null;
                    if (BrowserSettings != null)
                    {
                        BrowserSettings.Dispose();
                        BrowserSettings = null;
                    }

                    PresentationSource.RemoveSourceChangedHandler(this, PresentationSourceChangedHandler);

                    // Release internal event listeners:
                    Loaded            -= OnLoaded;
                    SizeChanged       -= OnActualSizeChanged;
                    GotKeyboardFocus  -= OnGotKeyboardFocus;
                    LostKeyboardFocus -= OnLostKeyboardFocus;

                    // Release internal event listeners for Drag Drop events:
                    DragEnter -= OnDragEnter;
                    DragOver  -= OnDragOver;
                    DragLeave -= OnDragLeave;
                    Drop      -= OnDrop;

                    IsVisibleChanged -= OnIsVisibleChanged;

                    if (tooltipTimer != null)
                    {
                        tooltipTimer.Tick -= OnTooltipTimerTick;
                    }

                    if (CleanupElement != null)
                    {
                        CleanupElement.Unloaded -= OnCleanupElementUnloaded;
                    }

                    if (managedCefBrowserAdapter != null)
                    {
                        managedCefBrowserAdapter.Dispose();
                        managedCefBrowserAdapter = null;
                    }


                    browserInitialized = false;
                    UiThreadRunAsync(() =>
                    {
                        SetCurrentValue(IsBrowserInitializedProperty, false);
                        WebBrowser = null;
                    });
                }

                Cef.RemoveDisposable(this);

                RemoveSourceHook();
            }
        }