private static bool UpdateSourceOfElement(DependencyObject doTarget, DependencyObject doAncestor, DependencyObject doOldParent) { bool calledOut = false; PresentationSource realSource = FindSource(doTarget); PresentationSource cachedSource = CriticalGetPresentationSourceFromElement(doTarget, CachedSourceProperty); if (cachedSource != realSource) { doTarget.SetValue(CachedSourceProperty, new SecurityCriticalDataForMultipleGetAndSet <PresentationSource>(realSource)); SourceChangedEventArgs args = new SourceChangedEventArgs(cachedSource, realSource); args.RoutedEvent = SourceChangedEvent; if (InputElement.IsUIElement(doTarget)) { ((UIElement)doTarget).RaiseEvent(args); } else if (InputElement.IsContentElement(doTarget)) { ((ContentElement)doTarget).RaiseEvent(args); } else { ((UIElement3D)doTarget).RaiseEvent(args); } calledOut = true; } return(calledOut); }
protected override void OnSetSource (object source) { if (OnSetSourceCalled != null) { SourceChangedEventArgs args = new SourceChangedEventArgs (); args.SourceArg = source; OnSetSourceCalled (this, args); } base.OnSetSource (source); }
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(); } }
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); } }
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)); }
private static bool UpdateSourceOfElement(DependencyObject doTarget, DependencyObject doAncestor, DependencyObject doOldParent) { bool calledOut = false; PresentationSource realSource = FindSource(doTarget); PresentationSource cachedSource = CriticalGetPresentationSourceFromElement(doTarget, CachedSourceProperty); if (cachedSource != realSource) { doTarget.SetValue(CachedSourceProperty, new SecurityCriticalDataForMultipleGetAndSet<PresentationSource>(realSource)); SourceChangedEventArgs args = new SourceChangedEventArgs(cachedSource, realSource); args.RoutedEvent=SourceChangedEvent; if (InputElement.IsUIElement(doTarget)) { ((UIElement)doTarget).RaiseEvent(args); } else if (InputElement.IsContentElement(doTarget)) { ((ContentElement)doTarget).RaiseEvent(args); } else { ((UIElement3D)doTarget).RaiseEvent(args); } calledOut = true; } return calledOut; }
private void OnPresentationSourceChanged(object sender, SourceChangedEventArgs args) { if (args.NewSource == null) { this.DisconnectFromPresentationSource(); } else { this.ConnectToPresentationSource(args.NewSource); } }
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) { if (source != null && sourceHook != null) { source.RemoveHook(sourceHook); source = null; } } }
private static void PresenationSourceChangedHandler(object sender, SourceChangedEventArgs sourceChangedEventArgs) { var src = sourceChangedEventArgs.NewSource as HwndSource; if (src != null) { EnableMouseHorizontalWheelSupport(src.Handle); } }
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); } }
// 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); } }