private static PenetrationProvider getPenetrationProviderFormPropertyMetadata(UIElement element) { var metadata = (DataPropertyMetadata <PenetrationProvider>)PenetrationProvider.IsPenetrateProperty.GetMetadata(element); if (metadata.Data == null) { IntPtr handle; if (element is Window) { handle = new WindowInteropHelper((Window)element).Handle; } else { if (PresentationSource.FromVisual(element) is HwndSource source) { handle = source.Handle; } else { return(null); } } PenetrationProvider provider = new PenetrationProvider(handle); provider.Initialize(); return(provider); } else { return(metadata.Data); } }
public static bool GetIsPenetrate(UIElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } PenetrationProvider.initializePenetrationProvider(element); return((bool)element.GetValue(IsPenetrateProperty)); }
public static void SetIsPenetrate(UIElement element, bool value) { if (element == null) { throw new ArgumentNullException(nameof(element)); } PenetrationProvider.initializePenetrationProvider(element); element.SetValue(IsPenetrateProperty, value); }
private static object IsPenetrateCoerceValueCallback(DependencyObject d, object baseValue) { UIElement element = (UIElement)d; var provider = PenetrationProvider.getPenetrationProviderFormPropertyMetadata((UIElement)d); bool targetIsPenetrate = (bool)baseValue; if (provider != null && provider.UpdateWindowPenetration(targetIsPenetrate)) { return(baseValue); } else { return(PenetrationProvider.GetIsPenetrate(element)); } }
private static void initializePenetrationProvider(UIElement element) { PenetrationProvider.getPenetrationProviderFormPropertyMetadata(element); }