public void MonitorSourceChangedEventHandler(object sender, SourceChangedEventArgs e) { lock (_gate) { _changedSourceQueue.Enqueue(e.ChangedUri); } }
private void OnSourceChanged(object sender, SourceChangedEventArgs e) { _currentHwndSource?.RemoveHook(_hook); _currentHwndSource = e.NewSource as HwndSource; _currentHwndSource?.AddHook(_hook); _ttl.ScalingChanged?.Invoke(_ttl.RenderScaling); }
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); } }
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); }
void OnSourceChanged(object sender, SourceChangedEventArgs e) { Console.WriteLine("Foo"); if (e.NewSource is HwndSource source) { _manipulationHandler.HwndSource = source; } }
private void OnSourceChanged(object sender, SourceChangedEventArgs e) { if (e.NewSource == null) { return; } RefreshCanExecute(CommandProperty, typeof(RoutedCommandButton), this, Command); }
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(); }
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); }
private void OnPresentationSourceChanged(object sender, SourceChangedEventArgs args) { if (args.NewSource == null) { this.DisonnectFromPresentationSource(); } else { this.ConnectToPresentationSource(args.NewSource); } }
protected override void OnSetSource(object source) { if (OnSetSourceCalled != null) { SourceChangedEventArgs args = new SourceChangedEventArgs(); args.SourceArg = source; OnSetSourceCalled(this, args); } base.OnSetSource(source); }
void OnSourceChanged(object sender, SourceChangedEventArgs args) { if (args.OldSource is HwndSource oldSource) { OnSourceDisconnected(oldSource); } if (args.NewSource is HwndSource newSource) { OnSourceConnected(newSource); } }
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 args) { var hwndSource = args.OldSource as HwndSource; if (hwndSource != null) { OnSourceDisconnected(hwndSource); } hwndSource = args.NewSource as HwndSource; if (hwndSource != null) { OnSourceConnected(hwndSource); } }
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 void OnSourceChanged(object sender, SourceChangedEventArgs e) { if (e.NewSource != null && !_hasChildren) { AddLogicalChild(_impl); AddVisualChild(_impl); _hasChildren = true; } else { RemoveVisualChild(_impl); RemoveLogicalChild(_impl); _hasChildren = false; } }
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); } }
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(); }
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(); } }
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); } }
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)); } } }
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(); }
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(); }
private void OnPresentationSourceChanged(object sender, SourceChangedEventArgs args) { this.HwndSource = ScreenLocation.FindTopLevelHwndSource((UIElement)sender); this.TryUpdateLocation(); }
private void SourceChangedEventHandler(Object sender, SourceChangedEventArgs e) { ParentScrollViewer = FindParentScrollViewer(); _presentationSource = null; }
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); }
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)); } }