コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public static bool GetIsPenetrate(UIElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            PenetrationProvider.initializePenetrationProvider(element);

            return((bool)element.GetValue(IsPenetrateProperty));
        }
コード例 #3
0
        public static void SetIsPenetrate(UIElement element, bool value)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            PenetrationProvider.initializePenetrationProvider(element);

            element.SetValue(IsPenetrateProperty, value);
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
 private static void initializePenetrationProvider(UIElement element)
 {
     PenetrationProvider.getPenetrationProviderFormPropertyMetadata(element);
 }