예제 #1
0
        public void OnClose( bool isFinilizing )
        {
            if ( Instance != IntPtr.Zero )
            {
                // We do not even need to care about WebCore.DestroyView,
                // if we reached here from a finalizer. The WebCore keeps
                // a reference of all created views. We would not reach
                // here from a finalizer if the core is not dying too.
                if ( !isFinilizing )
                {
                    if ( hookAdded )
                    {
                        if ( hwndSource != null )
                        {
                            hwndSource.RemoveHook( HandleMessages );
                            hookAdded = false;
                        }

                        ComponentDispatcher.ThreadFilterMessage -= OnThreadFilterMessage;
                    }

                    this.ClearDelegates();

                    controlLayer = null;
                    toolTip = null;

                    this.Loaded -= OnLoaded;
                    this.Unloaded -= OnUnloaded;
                    this.IsEnabledChanged -= OnIsEnabledChanged;

                    WebCore.DestroyView( this );

                    GC.SuppressFinalize( this );
                }

                Instance = IntPtr.Zero;
            }
        }
예제 #2
0
        /// <summary>
        /// Creates and initializes an instance of <see cref="WebControl"/> and its underlying web view.
        /// </summary>
        public WebControl()
        {
            if ( this.IsSourceControl )
                this.SetValue( WebControl.IsSourceControlPropertyKey, true );

            controlLayer = new WebControlInvalidLayer( this );
            this.IsEnabledChanged += OnIsEnabledChanged;

            if ( DesignerProperties.GetIsInDesignMode( this ) )
                return;

            toolTip = new ToolTip();
            selectionHelper = new SelectionHelper( this, OnWebSelectionChanged );

            InitializeCore();
            InitializeDelegates( this.Instance );
            InitializeCommandBindings();

            findRequestRandomizer = new Random();

            this.Loaded += OnLoaded;
            this.Unloaded += OnUnloaded;

            needsResize = false;
            flushAplha = true;
        }