Ejemplo n.º 1
0
 public void MonitorSourceChangedEventHandler(object sender, SourceChangedEventArgs e)
 {
     lock (_gate)
     {
         _changedSourceQueue.Enqueue(e.ChangedUri);
     }
 }
Ejemplo n.º 2
0
 private void OnSourceChanged(object sender, SourceChangedEventArgs e)
 {
     _currentHwndSource?.RemoveHook(_hook);
     _currentHwndSource = e.NewSource as HwndSource;
     _currentHwndSource?.AddHook(_hook);
     _ttl.ScalingChanged?.Invoke(_ttl.RenderScaling);
 }
Ejemplo n.º 3
0
        private void PresentationSourceChangedHandler(object sender, SourceChangedEventArgs args)
        {
            if (args.NewSource != null)
            {
                var newSource = (HwndSource)args.NewSource;

                source = newSource;

                if (source != null)
                {
                    var notifyDpiChanged = !matrix.Equals(source.CompositionTarget.TransformToDevice);

                    matrix     = source.CompositionTarget.TransformToDevice;
                    sourceHook = SourceHook;
                    source.AddHook(sourceHook);

                    if (notifyDpiChanged)
                    {
                        managedCefBrowserAdapter.NotifyScreenInfoChanged();
                    }
                }
            }
            else if (args.OldSource != null)
            {
                RemoveSourceHook();
            }
        }
        // This method handles the situation where the PresentationSource that
        // contains this OldSchoolMdiChild instance changes.  This will happen
        // the first time, and possibly if someone programatically removes it
        // and inserts it somewhere else.
        private void OnPresentationSourceChanged(object sender, SourceChangedEventArgs e)
        {
            // Destroy our PresentationSource children when we are disconnected.
            if (e.OldSource != null)
            {
                if (_hwndSourceChild != null && !_hwndSourceChild.IsDisposed)
                {
                    _hwndSourceChild.RootVisual = null;
                    _hwndSourceChild.Dispose();
                    _hwndSourceChild = null;
                }
            }

            // Create our PresentationSource children when we are connected.
            HwndSource newSource = e.NewSource as HwndSource;

            if (newSource != null)
            {
                var p = new HwndSourceParameters("MiddleChild", 200, 100);
                p.WindowClassStyle          = 0;
                p.WindowStyle               = WS_OVERLAPPEDWINDOW | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
                p.ExtendedWindowStyle       = 0;
                p.ParentWindow              = newSource.Handle;
                p.HwndSourceHook            = ChildHook;
                _hwndSourceChild            = new HwndSource(p);
                _hwndSourceChild.RootVisual = Child;

                // Show the window for the first time normally.
                ShowWindow(_hwndSourceChild.Handle, SW_SHOWNORMAL); // First time
                SetWindowPos(_hwndSourceChild.Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
            }
        }
Ejemplo n.º 5
0
 static void OnSourceChanged(object sender, SourceChangedEventArgs e)
 {
     var oldSource = e.OldSource as HwndSource;
     var newSource = e.NewSource as HwndSource;
     oldSource?.RemoveHook(SourceHook);
     newSource?.AddHook(SourceHook);
 }
Ejemplo n.º 6
0
 void OnSourceChanged(object sender, SourceChangedEventArgs e)
 {
     Console.WriteLine("Foo");
     if (e.NewSource is HwndSource source)
     {
         _manipulationHandler.HwndSource = source;
     }
 }
Ejemplo n.º 7
0
 private void OnSourceChanged(object sender, SourceChangedEventArgs e)
 {
     if (e.NewSource == null)
     {
         return;
     }
     RefreshCanExecute(CommandProperty, typeof(RoutedCommandButton), this, Command);
 }
Ejemplo n.º 8
0
        private void OnSourceChanged(object sender, SourceChangedEventArgs e)
        {
            this.UnregisterSourceKeyboardInputSink();
            PresentationSource newSource = e.NewSource;

            this.RegisterSourceKeyboardInputSink(newSource as IKeyboardInputSink);
            this._hwndSource = newSource as HwndSource;
            this.StartHwndSourceTracking();
        }
Ejemplo n.º 9
0
        private static void PresenationSourceChangedHandler(object sender, SourceChangedEventArgs sourceChangedEventArgs)
        {
            var src = sourceChangedEventArgs.NewSource as HwndSource;

            if (src != null)
            {
                EnableMouseHorizontalWheelSupport(src.Handle);
            }
        }
 private void SourceChangedEventHandler(Object sender, SourceChangedEventArgs e)
 {
     if (ParentScrollViewer != null)
     {
         ParentScrollViewer.ScrollChanged -= ParentScrollViewer_ScrollChanged;
         ParentScrollViewer.SizeChanged   -= ParentScrollViewer_SizeChanged;
         ParentScrollViewer.Loaded        -= ParentScrollViewer_Loaded;
     }
     ParentScrollViewer = FindParentScrollViewer();
 }
        private static void OnPresentationSourceChanged(object sender, SourceChangedEventArgs e)
        {
            var element = sender as FrameworkElement;

            if (element != null)
            {
                UpdateScrollBarStyles(element);
            }
            PresentationSource.RemoveSourceChangedHandler(element, OnPresentationSourceChanged);
        }
        private void WebView2SourceChanged(object sender, SourceChangedEventArgs e)
        {
            bool isNewDocument = e.IsNewDocument;

            string message =
                "{ \"kind\": \"event\", \"name\": \"SourceChanged\", \"args\": {";

            message += "\"isNewDocument\": " + BoolToString(isNewDocument) + "}" +
                       WebViewPropertiesToJsonString(_eventSourceWebView2) + "}";
            PostEventMessage(message);
        }
Ejemplo n.º 13
0
 private void OnPresentationSourceChanged(object sender, SourceChangedEventArgs args)
 {
     if (args.NewSource == null)
     {
         this.DisonnectFromPresentationSource();
     }
     else
     {
         this.ConnectToPresentationSource(args.NewSource);
     }
 }
Ejemplo n.º 14
0
            protected override void OnSetSource(object source)
            {
                if (OnSetSourceCalled != null)
                {
                    SourceChangedEventArgs args = new SourceChangedEventArgs();

                    args.SourceArg = source;

                    OnSetSourceCalled(this, args);
                }
                base.OnSetSource(source);
            }
Ejemplo n.º 15
0
        void OnSourceChanged(object sender, SourceChangedEventArgs args)
        {
            if (args.OldSource is HwndSource oldSource)
            {
                OnSourceDisconnected(oldSource);
            }

            if (args.NewSource is HwndSource newSource)
            {
                OnSourceConnected(newSource);
            }
        }
Ejemplo n.º 16
0
        void OnSourceChanged(object sender, SourceChangedEventArgs e)
        {
            HwndSource oldSource = e.OldSource as HwndSource;
            HwndSource newSource = e.NewSource as HwndSource;

            if (oldSource != null)
            {
                oldSource.RemoveHook(SourceHook);
            }
            if (newSource != null)
            {
                newSource.AddHook(SourceHook);
            }
        }
Ejemplo n.º 17
0
        private void OnSourceChanged(object sender, SourceChangedEventArgs args)
        {
            var hwndSource = args.OldSource as HwndSource;

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

            hwndSource = args.NewSource as HwndSource;
            if (hwndSource != null)
            {
                OnSourceConnected(hwndSource);
            }
        }
Ejemplo n.º 18
0
            private void OnSourceChanged(object sender, SourceChangedEventArgs e)
            {
                var oldSource = e.OldSource as HwndSource;
                var newSource = e.NewSource as HwndSource;

                if (oldSource != null)
                {
                    oldSource.RemoveHook(new HwndSourceHook(this.SourceHook));
                }

                if (newSource != null)
                {
                    newSource.AddHook(new HwndSourceHook(this.SourceHook));
                }
            }
Ejemplo n.º 19
0
 private void OnSourceChanged(object sender, SourceChangedEventArgs e)
 {
     if (e.NewSource != null && !_hasChildren)
     {
         AddLogicalChild(_impl);
         AddVisualChild(_impl);
         _hasChildren = true;
     }
     else
     {
         RemoveVisualChild(_impl);
         RemoveLogicalChild(_impl);
         _hasChildren = false;
     }
 }
Ejemplo n.º 20
0
        private void OnSourceChanged(object sender, SourceChangedEventArgs e)
        {
            IKeyboardInputSite keyboardInputSite = ((IKeyboardInputSink)this).KeyboardInputSite;

            if (keyboardInputSite != null)
            {
                ((IKeyboardInputSink)this).KeyboardInputSite = null;
                keyboardInputSite.Unregister();
            }
            IKeyboardInputSink sink = source as IKeyboardInputSink;

            if (sink != null)
            {
                ((IKeyboardInputSink)this).KeyboardInputSite = sink.RegisterKeyboardInputSink(this);
            }

            source = e.NewSource;

            if (!isBuildingWindow)
            {
                isBuildingWindow = true;
                HwndSource parent = (HwndSource)e.NewSource;

                try
                {
                    if (hWnd.Handle == IntPtr.Zero)
                    {
                        hWnd = new HandleRef(this, ((INativeHandleContract)contract.Contract).GetHandle());

                        LayoutUpdated    += OnLayoutUpdated;
                        IsEnabledChanged += OnEnabledChanged;
                        IsVisibleChanged += OnVisibleChanged;

                        PostMessage(new HandleRef(null, Handle), 0x9005, parent.Handle, IntPtr.Zero);
                        PostMessage(new HandleRef(null, Handle), 0x9002, IntPtr.Zero, IntPtr.Zero);
                        InvalidateMeasure();
                    }
                }
                finally
                {
                    isBuildingWindow = false;
                }
            }
            else
            {
                Debug.Assert(false);
            }
        }
        private void OnPresentationSourceChanged(object sender, SourceChangedEventArgs e)
        {
            HwndSource oldHwndSource = e.OldSource as HwndSource;

            if (oldHwndSource != null)
            {
                oldHwndSource.RemoveHook(_hook);
            }

            HwndSource newHwndSource = e.NewSource as HwndSource;

            if (newHwndSource != null)
            {
                newHwndSource.AddHook(_hook);
            }
        }
Ejemplo n.º 22
0
        private void OnSourceChanged(object sender, SourceChangedEventArgs e)
        {
            IKeyboardInputSite keyboardInputSite = ((IKeyboardInputSink)this).KeyboardInputSite;

            if (keyboardInputSite != null)
            {
                if (this._fTrusted.Value)
                {
                    new UIPermission(PermissionState.Unrestricted).Assert();
                }
                try
                {
                    ((IKeyboardInputSink)this).KeyboardInputSite = null;
                    keyboardInputSite.Unregister();
                }
                finally
                {
                    if (this._fTrusted.Value)
                    {
                        CodeAccessPermission.RevertAssert();
                    }
                }
            }
            IKeyboardInputSink keyboardInputSink = PresentationSource.CriticalFromVisual(this, false) as IKeyboardInputSink;

            if (keyboardInputSink != null)
            {
                if (this._fTrusted.Value)
                {
                    new UIPermission(PermissionState.Unrestricted).Assert();
                }
                try
                {
                    ((IKeyboardInputSink)this).KeyboardInputSite = keyboardInputSink.RegisterKeyboardInputSink(this);
                }
                finally
                {
                    if (this._fTrusted.Value)
                    {
                        CodeAccessPermission.RevertAssert();
                    }
                }
            }
            this.BuildOrReparentWindow();
        }
Ejemplo n.º 23
0
        private void PresentationSourceChangedHandler(object sender, SourceChangedEventArgs args)
        {
            if (args.NewSource != null)
            {
                var newSource = (HwndSource)args.NewSource;

                source = newSource;

                if (source != null)
                {
                    matrix     = source.CompositionTarget.TransformToDevice;
                    sourceHook = SourceHook;
                    source.AddHook(sourceHook);
                }
            }
            else if (args.OldSource != null)
            {
                RemoveSourceHook();
            }
        }
Ejemplo n.º 24
0
        private static void OnSourceChanged(object sender, SourceChangedEventArgs e)
        {
            if (e.NewSource == null)
            {
                return;
            }

            if (!(sender is ContextMenu menu))
            {
                return;
            }

            if (LogicalTreeHelper.GetParent(menu) is Popup popup)
            {
                var binding = new Binding {
                    Path   = new PropertyPath(PopupAnimationProperty),
                    Source = menu
                };
                popup.SetBinding(Popup.PopupAnimationProperty, binding);
            }
        }
Ejemplo n.º 25
0
 private void OnPresentationSourceChanged(object sender, SourceChangedEventArgs e)
 {
     if (e.OldSource != null && e.NewSource != null)
     {
         return;
     }
     if (e.OldSource != null)
     {
         if (_backgroundDispatcher == null)
         {
             return;
         }
         _backgroundDispatcher.BeginInvoke(new Action(DisconnectHostedVisualFromSourceWorker));
     }
     else
     {
         if (e.NewSource == null)
         {
             return;
         }
         if (!_initializedOnce)
         {
             _initializedOnce = true;
             if (_backgroundDispatcher == null)
             {
                 var dispatcherName = DispatcherGroup;
                 if (string.IsNullOrEmpty(dispatcherName))
                 {
                     dispatcherName = "ElementContainer" + Guid.NewGuid();
                 }
                 _backgroundDispatcher = BackgroundDispatcher.GetBackgroundDispatcher(dispatcherName, StackSize);
             }
             _backgroundDispatcher.BeginInvoke(new Action(CreateHostedVisualWorker));
         }
         else
         {
             _backgroundDispatcher.BeginInvoke(new Action(ConnectHostedVisualToSourceWorker));
         }
     }
 }
Ejemplo n.º 26
0
        private void OnSourceChanged(object sender, SourceChangedEventArgs e)
        {
            // Remove ourselves as an IKeyboardInputSinks child of our previous
            // containing window.
            IKeyboardInputSite keyboardInputSite = ((IKeyboardInputSink)this).KeyboardInputSite;

            if (keyboardInputSite != null)
            {
                // Derived classes that implement IKeyboardInputSink should support setting it to null.
                ((IKeyboardInputSink)this).KeyboardInputSite = null;

                keyboardInputSite.Unregister();
            }

            // Add ourselves as an IKeyboardInputSinks child of our containing window.
            IKeyboardInputSink source = PresentationSource.CriticalFromVisual(this, false /* enable2DTo3DTransition */) as IKeyboardInputSink;

            if (source != null)
            {
                ((IKeyboardInputSink)this).KeyboardInputSite = source.RegisterKeyboardInputSink(this);
            }

            BuildOrReparentWindow();
        }
Ejemplo n.º 27
0
 private void OnSourceChanged(object sender, SourceChangedEventArgs e)
 {
     // This means that the element has been added or remvoed from its source.
     _stylusPlugInCollectionImpl.UpdateState(_element);
 }
 private void SourceChangedEventHandler(Object sender, SourceChangedEventArgs e)
 {
     ParentScrollViewer = FindParentScrollViewer();
 }
Ejemplo n.º 29
0
 private void OnPresentationSourceChanged(object sender, SourceChangedEventArgs args)
 {
     this.HwndSource = ScreenLocation.FindTopLevelHwndSource((UIElement)sender);
     this.TryUpdateLocation();
 }
Ejemplo n.º 30
0
 private void SourceChangedEventHandler(Object sender, SourceChangedEventArgs e)
 {
     ParentScrollViewer  = FindParentScrollViewer();
     _presentationSource = null;
 }
Ejemplo n.º 31
0
        private void OnSourceChanged(object sender, SourceChangedEventArgs e)
        {
            // Remove ourselves as an IKeyboardInputSinks child of our previous
            // containing window.
            IKeyboardInputSite keyboardInputSite = ((IKeyboardInputSink)this).KeyboardInputSite;
            if (keyboardInputSite != null)
            {
                if (_fTrusted.Value == true)
                {
                    new UIPermission(PermissionState.Unrestricted).Assert(); //BlessedAssert:
                }

                try
                {
                    // Derived classes that implement IKeyboardInputSink should support setting it to null.
                    ((IKeyboardInputSink)this).KeyboardInputSite = null;

                    keyboardInputSite.Unregister();
                }
                finally
                {
                    if (_fTrusted.Value == true)
                    {
                        CodeAccessPermission.RevertAssert();
                    }
                }
            }

            // Add ourselves as an IKeyboardInputSinks child of our containing window.
            IKeyboardInputSink source = PresentationSource.CriticalFromVisual(this, false /* enable2DTo3DTransition */) as IKeyboardInputSink;
            if(source != null)
            {
                if (_fTrusted.Value == true)
                {
                    new UIPermission(PermissionState.Unrestricted).Assert(); //BlessedAssert:
                }

                try
                {
                    ((IKeyboardInputSink)this).KeyboardInputSite = source.RegisterKeyboardInputSink(this);
                }
                finally
                {
                    if (_fTrusted.Value == true)
                    {
                        CodeAccessPermission.RevertAssert();
                    }
                }
            }

            BuildOrReparentWindow();
        }
 // This should only be invoked on a text control in Overtype mode being tracked for presentation source 
 // changes. Connecting or disconnecting from a window fires this notification.
 private static void OnSourceChanged(object sender, SourceChangedEventArgs args)
 {
     OnToggleInsert(sender, null);
 }
Ejemplo n.º 33
0
        private void OnSourceChanged(object sender, SourceChangedEventArgs e)
        {
            HwndSource newSource = null;
            HwndSource oldSource = null;

            new UIPermission(PermissionState.Unrestricted).Assert(); // BlessedAssert
            try
            {
                newSource = e.NewSource as HwndSource;
                oldSource = e.OldSource as HwndSource;
            }
            finally
            {
                UIPermission.RevertAssert();
            }

            UpdateSource(oldSource, newSource);

            // Clean up the old source changed event handler that was connected with UiScope.
            if (oldSource != null && UiScope != null)
            {
                // Remove the source changed event handler here.
                // Ohterwise, we'll get the leak of the SourceChangedEventHandler.
                // New source changed event handler will be added by getting OnGotFocus on new UiScope.
                PresentationSource.RemoveSourceChangedHandler(UiScope, new SourceChangedEventHandler(OnSourceChanged));
            }
        }