Popup 类
来源:百度文库 编辑:神马文学网 时间:2024/04/28 02:42:17
[DefaultProperty("Child"), DefaultEvent("Opened"), ContentProperty("Child"), Localizability(LocalizationCategory.None)] public class Popup : FrameworkElement, IAddChild { // Fields private DispatcherOperation _asyncCreate; private DispatcherTimer _asyncDestroy; private BitVector32 _cacheValid = new BitVector32(0); private " href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet<>">SecurityCriticalDataForSet" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot ; private PositionInfo _positionInfo; private PopupSecurityHelper _secHelper = new PopupSecurityHelper(); public static readonly DependencyProperty AllowsTransparencyProperty = Window.AllowsTransparencyProperty.AddOwner(typeof(Popup), new FrameworkPropertyMetadata(BooleanBoxes.FalseBox, new PropertyChangedCallback(Popup.OnAllowsTransparencyChanged), new CoerceValueCallback(Popup.CoerceAllowsTransparency))); private const int AnimationDelay = 150; internal static TimeSpan AnimationDelayTime = new TimeSpan(0, 0, 0, 0, 150); public static readonly DependencyProperty ChildProperty = DependencyProperty.Register("Child", typeof(UIElement), typeof(Popup), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(Popup.OnChildChanged))); private static readonly EventPrivateKey ClosedKey = new EventPrivateKey(); internal static RoutedEventHandler CloseOnUnloadedHandler; public static readonly DependencyProperty CustomPopupPlacementCallbackProperty = DependencyProperty.Register("CustomPopupPlacementCallback", typeof(CustomPopupPlacementCallback), typeof(Popup), new FrameworkPropertyMetadata(null)); public static readonly DependencyProperty HasDropShadowProperty = HasDropShadowPropertyKey.DependencyProperty; private static readonly DependencyPropertyKey HasDropShadowPropertyKey = DependencyProperty.RegisterReadOnly("HasDropShadow", typeof(bool), typeof(Popup), new FrameworkPropertyMetadata(BooleanBoxes.FalseBox, null, new CoerceValueCallback(Popup.CoerceHasDropShadow))); public static readonly DependencyProperty HorizontalOffsetProperty = DependencyProperty.Register("HorizontalOffset", typeof(double), typeof(Popup), new FrameworkPropertyMetadata(0.0, new PropertyChangedCallback(Popup.OnOffsetChanged))); [CommonDependencyProperty] public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register("IsOpen", typeof(bool), typeof(Popup), new FrameworkPropertyMetadata(BooleanBoxes.FalseBox, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(Popup.OnIsOpenChanged), new CoerceValueCallback(Popup.CoerceIsOpen))); private static readonly EventPrivateKey OpenedKey = new EventPrivateKey(); [CommonDependencyProperty] public static readonly DependencyProperty PlacementProperty = DependencyProperty.Register("Placement", typeof(PlacementMode), typeof(Popup), new FrameworkPropertyMetadata(PlacementMode.Bottom, new PropertyChangedCallback(Popup.OnPlacementChanged)), new ValidateValueCallback(Popup.IsValidPlacementMode)); public static readonly DependencyProperty PlacementRectangleProperty = DependencyProperty.Register("PlacementRectangle", typeof(Rect), typeof(Popup), new FrameworkPropertyMetadata(Rect.Empty, new PropertyChangedCallback(Popup.OnOffsetChanged))); public static readonly DependencyProperty PlacementTargetProperty = DependencyProperty.Register("PlacementTarget", typeof(UIElement), typeof(Popup), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(Popup.OnPlacementTargetChanged))); [CommonDependencyProperty] public static readonly DependencyProperty PopupAnimationProperty = DependencyProperty.Register("PopupAnimation", typeof(PopupAnimation), typeof(Popup), new FrameworkPropertyMetadata(PopupAnimation.None, null, new CoerceValueCallback(Popup.CoercePopupAnimation)), new ValidateValueCallback(Popup.IsValidPopupAnimation)); internal static readonly >" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/System.Windows.UncommonField<>">UncommonField<" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Collections.Generic.List<>">List> >" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/RegisteredPopupsField:System.Windows.UncommonField >">RegisteredPopupsField = new >.UncommonField>();" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/System.Windows.UncommonField<>">UncommonField<" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Collections.Generic.List<>">List
>(); private const double RestrictPercentage = 0.75; public static readonly DependencyProperty StaysOpenProperty = DependencyProperty.Register("StaysOpen", typeof(bool), typeof(Popup), new FrameworkPropertyMetadata(BooleanBoxes.TrueBox, new PropertyChangedCallback(Popup.OnStaysOpenChanged))); internal const double Tolerance = 0.01; public static readonly DependencyProperty VerticalOffsetProperty = DependencyProperty.Register("VerticalOffset", typeof(double), typeof(Popup), new FrameworkPropertyMetadata(0.0, new PropertyChangedCallback(Popup.OnOffsetChanged))); // Events public event EventHandler Closed { add { base.EventHandlersStoreAdd(ClosedKey, value); } remove { base.EventHandlersStoreRemove(ClosedKey, value); } } public event EventHandler Opened { add { base.EventHandlersStoreAdd(OpenedKey, value); } remove { base.EventHandlersStoreRemove(OpenedKey, value); } } internal event EventHandler PopupCouldClose; // Methods static Popup() { EventManager.RegisterClassHandler(typeof(Popup), Mouse.LostMouseCaptureEvent, new MouseEventHandler(Popup.OnLostMouseCapture)); UIElement.VisibilityProperty.OverrideMetadata(typeof(Popup), new FrameworkPropertyMetadata(VisibilityBoxes.CollapsedBox, null, new CoerceValueCallback(Popup.CoerceVisibility))); } private static object AsyncCreateWindow(object arg) { Popup popup = (Popup) arg; popup._asyncCreate = null; popup.CreateWindow(true); return null; } internal override bool BlockReverseInheritance() { return (base.TemplatedParent == null); } [SecurityTreatAsSafe, SecurityCritical] private void BuildWindow(Visual targetVisual) { base.CoerceValue(AllowsTransparencyProperty); base.CoerceValue(HasDropShadowProperty); this.IsTransparent = this.AllowsTransparency; int x = (this._positionInfo == null) ? 0 : this._positionInfo.X; int y = (this._positionInfo == null) ? 0 : this._positionInfo.Y; this._secHelper.BuildWindow(x, y, targetVisual, this.IsTransparent, new HwndSourceHook(this.PopupFilterMessage), new AutoResizedEventHandler(this.OnWindowResize)); } private void CancelAsyncCreate() { if (this._asyncCreate != null) { this._asyncCreate.Abort(); this._asyncCreate = null; } } private void CancelAsyncDestroy() { if (this._asyncDestroy != null) { this._asyncDestroy.Stop(); this._asyncDestroy = null; } } private void ClearDropOpposite() { this._cacheValid[8] = false; } private static void CloseOnUnloaded(object sender, RoutedEventArgs e) { ((Popup) sender).IsOpen = false; } private static object CoerceAllowsTransparency(DependencyObject d, object value) { if (!((Popup) d)._secHelper.IsChildPopup) { return value; } return BooleanBoxes.FalseBox; } private static object CoerceHasDropShadow(DependencyObject d, object value) { return BooleanBoxes.Box(SystemParameters.DropShadow && ((Popup) d).AllowsTransparency); } private static object CoerceIsOpen(DependencyObject d, object value) { if ((bool) value) { Popup reference = (Popup) d; if (!reference.IsLoaded && (VisualTreeHelper.GetParent(reference) != null)) { reference.RegisterToOpenOnLoad(); return BooleanBoxes.FalseBox; } } return value; } private static object CoercePopupAnimation(DependencyObject o, object value) { if (!((Popup) o).AllowsTransparency) { return PopupAnimation.None; } return value; } private static object CoerceVisibility(DependencyObject d, object value) { return VisibilityBoxes.CollapsedBox; } [SecurityTreatAsSafe, SecurityCritical] private void CreateNewPopupRoot() { if (this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value == null) { this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value = new PopupRoot(); base.AddLogicalChild(this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value); this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.SetupLayoutBindings(this); } } public static void CreateRootPopup(Popup popup, UIElement child) { if (popup == null) { throw new ArgumentNullException("popup"); } if (child == null) { throw new ArgumentNullException("child"); } object parent = null; parent = LogicalTreeHelper.GetParent(child); if (parent != null) { throw new InvalidOperationException(SR.Get("CreateRootPopup_ChildHasLogicalParent", new object[] { child, parent })); } parent = VisualTreeHelper.GetParent(child); if (parent != null) { throw new InvalidOperationException(SR.Get("CreateRootPopup_ChildHasVisualParent", new object[] { child, parent })); } Binding binding = new Binding("PlacementTarget"); binding.Mode = BindingMode.OneWay; binding.Source = child; popup.SetBinding(PlacementTargetProperty, binding); popup.Child = child; binding = new Binding("VerticalOffset"); binding.Mode = BindingMode.OneWay; binding.Source = child; popup.SetBinding(VerticalOffsetProperty, binding); binding = new Binding("HorizontalOffset"); binding.Mode = BindingMode.OneWay; binding.Source = child; popup.SetBinding(HorizontalOffsetProperty, binding); binding = new Binding("PlacementRectangle"); binding.Mode = BindingMode.OneWay; binding.Source = child; popup.SetBinding(PlacementRectangleProperty, binding); binding = new Binding("Placement"); binding.Mode = BindingMode.OneWay; binding.Source = child; popup.SetBinding(PlacementProperty, binding); binding = new Binding("StaysOpen"); binding.Mode = BindingMode.OneWay; binding.Source = child; popup.SetBinding(StaysOpenProperty, binding); binding = new Binding("CustomPopupPlacementCallback"); binding.Mode = BindingMode.OneWay; binding.Source = child; popup.SetBinding(CustomPopupPlacementCallbackProperty, binding); binding = new Binding("IsOpen"); binding.Mode = BindingMode.OneWay; binding.Source = child; popup.SetBinding(IsOpenProperty, binding); } private void CreateWindow(bool asyncCall) { this.ClearDropOpposite(); Visual target = this.GetTarget(); if ((target != null) && PopupSecurityHelper.IsVisualPresentationSourceNull(target)) { if (!asyncCall) { this._asyncCreate = base.Dispatcher.BeginInvoke(DispatcherPriority.Input, new DispatcherOperationCallback(Popup.AsyncCreateWindow), this); } } else { if (this._positionInfo != null) { this._positionInfo.MouseRect = Rect.Empty; this._positionInfo.ChildSize = Size.Empty; } bool flag = !this._secHelper.IsWindowAlive(); if (flag) { this.BuildWindow(target); this.CreateNewPopupRoot(); } UIElement child = this.Child; if (this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.Child != child) { this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.Child = child; } this.UpdatePlacementTargetRegistration(null, this.PlacementTarget); this.UpdateTransform(); if (flag) { this.SetRootVisualToPopupRoot(); } else { this.UpdatePosition(); } this.ShowWindow(); this.OnOpened(EventArgs.Empty); } } [SecurityTreatAsSafe, SecurityCritical] private void DestroyWindow() { if (this._secHelper.IsWindowAlive()) { this._secHelper.DestroyWindow(new HwndSourceHook(this.PopupFilterMessage), new AutoResizedEventHandler(this.OnWindowResize)); this.ReleasePopupCapture(); this.OnClosed(EventArgs.Empty); this.UpdatePlacementTargetRegistration(this.PlacementTarget, null); } } private void EstablishPopupCapture() { if ((!this._cacheValid[1] && (this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value != null)) && (!this.StaysOpen && (Mouse.Captured == null))) { Mouse.Capture(this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value, CaptureMode.SubTree); this._cacheValid[1] = true; } } private void FirePopupCouldClose() { if (this.PopupCouldClose != null) { this.PopupCouldClose(this, EventArgs.Empty); } } internal void ForceClose() { if (this._asyncDestroy != null) { this.CancelAsyncDestroy(); this.DestroyWindow(); } } private Rect GetBounds(Point[] interestPoints) { double num2; double num4; double x = num2 = interestPoints[0].X; double y = num4 = interestPoints[0].Y; for (int i = 1; i < interestPoints.Length; i++) { double num6 = interestPoints[i].X; double num7 = interestPoints[i].Y; if (num6 < x) { x = num6; } if (num6 > num2) { num2 = num6; } if (num7 < y) { y = num7; } if (num7 > num4) { num4 = num7; } } return new Rect(x, y, num2 - x, num4 - y); } private Point[] GetChildInterestPoints(PlacementMode placement) { UIElement child = this.Child; if (child == null) { return InterestPointsFromRect(new Rect()); } Point[] pointArray = InterestPointsFromRect(new Rect(new Point(), child.RenderSize)); UIElement target = this.GetTarget() as UIElement; if (((target != null) && !IsAbsolutePlacementMode(placement)) && (((FlowDirection) target.GetValue(FrameworkElement.FlowDirectionProperty)) != ((FlowDirection) child.GetValue(FrameworkElement.FlowDirectionProperty)))) { SwapPoints(ref pointArray[0], ref pointArray[1]); SwapPoints(ref pointArray[2], ref pointArray[3]); } Vector animationOffset = this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.AnimationOffset; GeneralTransform transform = TransformToClient(child, this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value); for (int i = 0; i < 5; i++) { transform.TryTransform(pointArray[i] - animationOffset, out pointArray[i]); } return pointArray; } [SecurityTreatAsSafe, SecurityCritical] private static void GetMouseCursorSize(out int width, out int height, out int hotX, out int hotY) { int num8; int num9; hotY = num8 = 0; hotX = num9 = num8; width = height = num9; IntPtr cursor = SafeNativeMethods.GetCursor(); if (cursor != IntPtr.Zero) { width = height = 0x10; NativeMethods.ICONINFO piconinfo = new NativeMethods.ICONINFO(); bool flag = true; try { UnsafeNativeMethods.GetIconInfo(new HandleRef(null, cursor), out piconinfo); } catch (Win32Exception) { flag = false; } if (flag) { NativeMethods.BITMAP bm = new NativeMethods.BITMAP(); int num = 0; new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); try { num = UnsafeNativeMethods.GetObject(piconinfo.hbmMask.MakeHandleRef(null), Marshal.SizeOf(typeof(NativeMethods.BITMAP)), bm); } finally { CodeAccessPermission.RevertAssert(); } if (num != 0) { int num2 = (bm.bmWidth * bm.bmHeight) / 8; byte[] lpvBits = new byte[num2 * 2]; if (UnsafeNativeMethods.GetBitmapBits(piconinfo.hbmMask.MakeHandleRef(null), lpvBits.Length, lpvBits) != 0) { bool flag2 = false; if (piconinfo.hbmColor.IsInvalid) { flag2 = true; num2 /= 2; } bool flag3 = true; int index = num2; index--; while (index >= 0) { if ((lpvBits[index] != 0xff) || (flag2 && (lpvBits[index + num2] != 0))) { flag3 = false; break; } index--; } if (flag3) { width = bm.bmWidth; height = bm.bmHeight; hotX = piconinfo.xHotspot; hotY = piconinfo.yHotspot; } else { int num4 = 0; while (num4 < num2) { if ((lpvBits[num4] != 0xff) || (flag2 && (lpvBits[num4 + num2] != 0))) { break; } num4++; } int num5 = bm.bmWidth / 8; int num6 = (index % num5) * 8; index /= num5; int num7 = (num4 % num5) * 8; num4 /= num5; width = (num6 - num7) + 1; height = (index - num4) + 1; hotX = piconinfo.xHotspot - num7; hotY = piconinfo.yHotspot - num4; } } } piconinfo.hbmColor.Dispose(); piconinfo.hbmMask.Dispose(); } } } private Rect GetMouseRect(PlacementMode placement) { NativeMethods.POINT mouseCursorPos = this._secHelper.GetMouseCursorPos(this.GetTarget()); if (placement == PlacementMode.Mouse) { int num; int num2; int num3; int num4; GetMouseCursorSize(out num, out num2, out num3, out num4); return new Rect((double) mouseCursorPos.x, (double) (mouseCursorPos.y - 1), (double) Math.Max(0, num - num3), (double) Math.Max(0, (num2 - num4) + 2)); } return new Rect((double) mouseCursorPos.x, (double) mouseCursorPos.y, 0.0, 0.0); } private static int GetNumberOfCombinations(PlacementMode placement) { switch (placement) { case PlacementMode.Bottom: case PlacementMode.Mouse: case PlacementMode.Top: return 2; case PlacementMode.Right: case PlacementMode.AbsolutePoint: case PlacementMode.RelativePoint: case PlacementMode.MousePoint: case PlacementMode.Left: return 4; case PlacementMode.Custom: return 0; } return 1; } private Point[] GetPlacementTargetInterestPoints(PlacementMode placement) { if (this._positionInfo == null) { this._positionInfo = new PositionInfo(); } Rect placementRectangle = this.PlacementRectangle; UIElement target = this.GetTarget() as UIElement; Vector vector = new Vector(this.HorizontalOffset, this.VerticalOffset); if ((target == null) || IsAbsolutePlacementMode(placement)) { if ((placement == PlacementMode.Mouse) || (placement == PlacementMode.MousePoint)) { if (this._positionInfo.MouseRect == Rect.Empty) { this._positionInfo.MouseRect = this.GetMouseRect(placement); } placementRectangle = this._positionInfo.MouseRect; } else if (placementRectangle == Rect.Empty) { placementRectangle = new Rect(); } vector = this._secHelper.GetTransformToDevice().Transform(vector); placementRectangle.Offset(vector); return InterestPointsFromRect(placementRectangle); } if (placementRectangle == Rect.Empty) { if ((placement != PlacementMode.Relative) && (placement != PlacementMode.RelativePoint)) { placementRectangle = new Rect(0.0, 0.0, target.RenderSize.Width, target.RenderSize.Height); } else { placementRectangle = new Rect(); } } placementRectangle.Offset(vector); Point[] pointArray = InterestPointsFromRect(placementRectangle); Visual rootVisual = GetRootVisual(target); GeneralTransform transform = TransformToClient(target, rootVisual); for (int i = 0; i < 5; i++) { transform.TryTransform(pointArray[i], out pointArray[i]); pointArray[i] = this._secHelper.ClientToScreen(rootVisual, pointArray[i]); } return pointArray; } private PointCombination GetPointCombination(PlacementMode placement, int i, out PopupPrimaryAxis axis) { bool menuDropAlignment = SystemParameters.MenuDropAlignment; switch (placement) { case PlacementMode.Relative: case PlacementMode.AbsolutePoint: case PlacementMode.RelativePoint: case PlacementMode.MousePoint: axis = PopupPrimaryAxis.Horizontal; if (!menuDropAlignment) { if (i == 0) { return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopLeft); } if (i == 1) { return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight); } if (i == 2) { return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft); } if (i == 3) { return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomRight); } break; } if (i != 0) { if (i == 1) { return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopLeft); } if (i == 2) { return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomRight); } if (i == 3) { return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft); } break; } return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight); case PlacementMode.Bottom: case PlacementMode.Mouse: axis = PopupPrimaryAxis.Horizontal; if (!menuDropAlignment) { if (i == 0) { return new PointCombination(InterestPoint.BottomLeft, InterestPoint.TopLeft); } if (i == 1) { return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft); } break; } if (i != 0) { if (i == 1) { return new PointCombination(InterestPoint.TopRight, InterestPoint.BottomRight); } break; } return new PointCombination(InterestPoint.BottomRight, InterestPoint.TopRight); case PlacementMode.Center: axis = PopupPrimaryAxis.None; return new PointCombination(InterestPoint.Center, InterestPoint.Center); case PlacementMode.Right: case PlacementMode.Left: axis = PopupPrimaryAxis.Vertical; menuDropAlignment |= this.DropOpposite; if ((!menuDropAlignment || (placement != PlacementMode.Right)) && (menuDropAlignment || (placement != PlacementMode.Left))) { if (i == 0) { return new PointCombination(InterestPoint.TopRight, InterestPoint.TopLeft); } if (i == 1) { return new PointCombination(InterestPoint.BottomRight, InterestPoint.BottomLeft); } if (i == 2) { return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight); } if (i == 3) { return new PointCombination(InterestPoint.BottomLeft, InterestPoint.BottomRight); } break; } if (i == 0) { return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight); } if (i == 1) { return new PointCombination(InterestPoint.BottomLeft, InterestPoint.BottomRight); } if (i == 2) { return new PointCombination(InterestPoint.TopRight, InterestPoint.TopLeft); } if (i != 3) { break; } return new PointCombination(InterestPoint.BottomRight, InterestPoint.BottomLeft); case PlacementMode.Top: axis = PopupPrimaryAxis.Horizontal; if (!menuDropAlignment) { if (i == 0) { return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft); } if (i == 1) { return new PointCombination(InterestPoint.BottomLeft, InterestPoint.TopLeft); } break; } if (i != 0) { if (i == 1) { return new PointCombination(InterestPoint.BottomRight, InterestPoint.TopRight); } break; } return new PointCombination(InterestPoint.TopRight, InterestPoint.BottomRight); default: axis = PopupPrimaryAxis.None; return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopLeft); } return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight); } private void GetPopupRootLimits(out Rect targetBounds, out Rect screenBounds, out Size limitSize) { PlacementMode placement = this.Placement; Point[] placementTargetInterestPoints = this.GetPlacementTargetInterestPoints(placement); targetBounds = this.GetBounds(placementTargetInterestPoints); screenBounds = this.GetScreenBounds(targetBounds); PopupPrimaryAxis primaryAxis = GetPrimaryAxis(placement); limitSize = new Size(double.PositiveInfinity, double.PositiveInfinity); switch (primaryAxis) { case PopupPrimaryAxis.Horizontal: { Point point = placementTargetInterestPoints[0]; Point point2 = placementTargetInterestPoints[2]; Vector vector = (Vector) (point2 - point); vector.Normalize(); if ((!this.IsTransparent || double.IsNaN(vector.X)) || (Math.Abs(vector.X) < 0.01)) { limitSize.Height = Math.Max(0.0, Math.Max((double) (screenBounds.Bottom - targetBounds.Bottom), (double) (targetBounds.Top - screenBounds.Top))); return; } if (this.IsTransparent && (Math.Abs(vector.Y) < 0.01)) { limitSize.Width = Math.Max(0.0, Math.Max((double) (screenBounds.Right - targetBounds.Right), (double) (targetBounds.Left - screenBounds.Left))); return; } break; } case PopupPrimaryAxis.Vertical: { Point point3 = placementTargetInterestPoints[0]; Point point4 = placementTargetInterestPoints[1]; Vector vector2 = (Vector) (point4 - point3); vector2.Normalize(); if ((!this.IsTransparent || double.IsNaN(vector2.X)) || (Math.Abs(vector2.Y) < 0.01)) { limitSize.Width = Math.Max(0.0, Math.Max((double) (screenBounds.Right - targetBounds.Right), (double) (targetBounds.Left - screenBounds.Left))); return; } if (this.IsTransparent && (Math.Abs(vector2.X) < 0.01)) { limitSize.Height = Math.Max(0.0, Math.Max((double) (screenBounds.Bottom - targetBounds.Bottom), (double) (targetBounds.Top - screenBounds.Top))); } break; } } } private static PopupPrimaryAxis GetPrimaryAxis(PlacementMode placement) { switch (placement) { case PlacementMode.Relative: case PlacementMode.Bottom: case PlacementMode.AbsolutePoint: case PlacementMode.RelativePoint: case PlacementMode.Mouse: case PlacementMode.MousePoint: case PlacementMode.Top: return PopupPrimaryAxis.Horizontal; case PlacementMode.Right: case PlacementMode.Left: return PopupPrimaryAxis.Vertical; } return PopupPrimaryAxis.None; } private static Visual GetRootVisual(Visual child) { DependencyObject obj2; DependencyObject reference = child; while ((obj2 = VisualTreeHelper.GetParent(reference)) != null) { reference = obj2; } return (reference as Visual); } private Rect GetScreenBounds(Rect boundingBox) { if (this._secHelper.IsChildPopup) { return this._secHelper.GetParentWindowRect(); } NativeMethods.RECT rc = new NativeMethods.RECT(0, 0, 0, 0); IntPtr handle = SafeNativeMethods.MonitorFromRect(ref PointUtil.FromRect(boundingBox), 2); if (handle != IntPtr.Zero) { NativeMethods.MONITORINFOEX info = new NativeMethods.MONITORINFOEX(); info.cbSize = SecurityHelper.SizeOf(typeof(NativeMethods.MONITORINFOEX)); SafeNativeMethods.GetMonitorInfo(new HandleRef(null, handle), info); rc = info.rcMonitor; } return PointUtil.ToRect(rc); } private Visual GetTarget() { Visual placementTarget = this.PlacementTarget; if (placementTarget == null) { placementTarget = VisualTreeHelper.GetContainingVisual2D(VisualTreeHelper.GetParent(this)); } return placementTarget; } protected internal override DependencyObject GetUIParentCore() { if (base.Parent == null) { UIElement placementTarget = this.PlacementTarget; if ((placementTarget != null) && (this.IsOpen || this._secHelper.IsWindowAlive())) { return placementTarget; } } return base.GetUIParentCore(); } private object HandleDeactivateApp(object arg) { if (!this.StaysOpen) { this.IsOpen = false; } this.FirePopupCouldClose(); return null; } private void HideWindow() { bool flag = this.SetupAnimations(false); this.SetHitTestable(false); this.ReleasePopupCapture(); this._asyncDestroy = new DispatcherTimer(DispatcherPriority.Input); this._asyncDestroy.Tick += delegate (object sender, EventArgs args) { this._asyncDestroy.Stop(); this._asyncDestroy = null; this.DestroyWindow(); }; this._asyncDestroy.Interval = flag ? AnimationDelayTime : TimeSpan.Zero; this._asyncDestroy.Start(); if (!flag) { this._secHelper.HideWindow(); } } internal override bool IgnoreModelParentBuildRoute(RoutedEventArgs e) { return ((base.Parent == null) && (e.RoutedEvent != Mouse.LostMouseCaptureEvent)); } private static Point[] InterestPointsFromRect(Rect rect) { return new Point[] { rect.TopLeft, rect.TopRight, rect.BottomLeft, rect.BottomRight, new Point(rect.Left + (rect.Width / 2.0), rect.Top + (rect.Height / 2.0)) }; } private static bool IsAbsolutePlacementMode(PlacementMode placement) { switch (placement) { case PlacementMode.AbsolutePoint: case PlacementMode.Mouse: case PlacementMode.MousePoint: case PlacementMode.Absolute: return true; } return false; } internal static bool IsRootedInPopup(Popup parentPopup, UIElement element) { object parent = LogicalTreeHelper.GetParent(element); if ((parent == null) && (VisualTreeHelper.GetParent(element) != null)) { return false; } if (parent != parentPopup) { return false; } return true; } private static bool IsValidPlacementMode(object o) { PlacementMode mode = (PlacementMode) o; if (((((mode != PlacementMode.Absolute) && (mode != PlacementMode.AbsolutePoint)) && ((mode != PlacementMode.Bottom) && (mode != PlacementMode.Center))) && (((mode != PlacementMode.Mouse) && (mode != PlacementMode.MousePoint)) && ((mode != PlacementMode.Relative) && (mode != PlacementMode.RelativePoint)))) && (((mode != PlacementMode.Right) && (mode != PlacementMode.Left)) && (mode != PlacementMode.Top))) { return (mode == PlacementMode.Custom); } return true; } private static bool IsValidPopupAnimation(object o) { PopupAnimation animation = (PopupAnimation) o; if (((animation != PopupAnimation.None) && (animation != PopupAnimation.Fade)) && (animation != PopupAnimation.Slide)) { return (animation == PopupAnimation.Scroll); } return true; } protected override Size MeasureOverride(Size availableSize) { return new Size(); } private static void OnAllowsTransparencyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { d.CoerceValue(PopupAnimationProperty); } private static void OnChildChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Popup popup = (Popup) d; UIElement oldValue = (UIElement) e.OldValue; UIElement newValue = (UIElement) e.NewValue; if ((popup. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value != null) && popup.IsOpen) { popup. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.Child = newValue; } popup.RemoveLogicalChild(oldValue); popup.AddLogicalChild(newValue); popup.Reposition(); } protected virtual void OnClosed(EventArgs e) { this._cacheValid[4] = true; try { base.RaiseClrEvent(ClosedKey, e); } finally { this._cacheValid[4] = false; } } private static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Popup popup = (Popup) d; bool flag = (popup._secHelper.IsWindowAlive() && (popup._asyncDestroy == null)) || (popup._asyncCreate != null); bool newValue = (bool) e.NewValue; if (newValue != flag) { if (newValue) { if (popup._cacheValid[4]) { throw new InvalidOperationException(SR.Get("PopupReopeningNotAllowed")); } popup.CancelAsyncDestroy(); popup.CancelAsyncCreate(); popup.CreateWindow(false); if (CloseOnUnloadedHandler == null) { CloseOnUnloadedHandler = new RoutedEventHandler(Popup.CloseOnUnloaded); } popup.Unloaded += CloseOnUnloadedHandler; } else { popup.CancelAsyncCreate(); if (popup._secHelper.IsWindowAlive() && (popup._asyncDestroy == null)) { popup.HideWindow(); if (CloseOnUnloadedHandler != null) { popup.Unloaded -= CloseOnUnloadedHandler; } } } } } private static void OnLostMouseCapture(object sender, MouseEventArgs e) { Popup popup = sender as Popup; if (!popup.StaysOpen) { PopupRoot reference = popup. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value; if (Mouse.Captured != reference) { if (e.OriginalSource == reference) { if ((Mouse.Captured == null) || !MenuBase.IsDescendant(reference, Mouse.Captured as DependencyObject)) { popup.IsOpen = false; } else { popup._cacheValid[1] = false; } } else if (MenuBase.IsDescendant(reference, e.OriginalSource as DependencyObject)) { if ((popup.IsOpen && (Mouse.Captured == null)) && (SafeNativeMethods.GetCapture() == IntPtr.Zero)) { popup.EstablishPopupCapture(); e.Handled = true; } } else { popup.IsOpen = false; } } } } private static void OnOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ((Popup) d).Reposition(); } protected virtual void OnOpened(EventArgs e) { base.RaiseClrEvent(OpenedKey, e); } private static void OnPlacementChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ((Popup) d).Reposition(); } private static void OnPlacementTargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Popup popup = (Popup) d; if (popup.IsOpen) { popup.UpdatePlacementTargetRegistration((UIElement) e.OldValue, (UIElement) e.NewValue); } else if (e.OldValue != null) { UnregisterPopupFromPlacementTarget(popup, (UIElement) e.OldValue); } } private void OnPreviewMouseButton(MouseButtonEventArgs e) { if (((this._cacheValid[1] && !this.StaysOpen) && ((this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value != null) && (e.OriginalSource == this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value))) && (this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.InputHitTest(e.GetPosition(this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value)) == null)) { this.IsOpen = false; } } protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) { this.OnPreviewMouseButton(e); base.OnPreviewMouseLeftButtonDown(e); } protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) { this.OnPreviewMouseButton(e); base.OnPreviewMouseLeftButtonUp(e); } protected override void OnPreviewMouseRightButtonDown(MouseButtonEventArgs e) { base.OnPreviewMouseRightButtonDown(e); this.OnPreviewMouseButton(e); } protected override void OnPreviewMouseRightButtonUp(MouseButtonEventArgs e) { base.OnPreviewMouseRightButtonUp(e); this.OnPreviewMouseButton(e); } private static void OnStaysOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Popup popup = (Popup) d; if (popup.IsOpen) { if ((bool) e.NewValue) { popup.ReleasePopupCapture(); } else { popup.EstablishPopupCapture(); } } } internal override void OnThemeChanged() { if (this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value != null) { TreeWalkHelper.InvalidateOnResourcesChange(this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value, null, ResourcesChangeInfo.ThemeChangeInfo); } } private void OnWindowResize(object sender, AutoResizedEventArgs e) { if (e.Size != this._positionInfo.ChildSize) { this._positionInfo.ChildSize = e.Size; this.Reposition(); } } private void OpenOnLoad(object sender, RoutedEventArgs e) { base.Dispatcher.BeginInvoke(DispatcherPriority.Input, delegate (object param) { base.CoerceValue(IsOpenProperty); return null; }, null); } private IntPtr PopupFilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { switch (msg) { case 0x1c: if (wParam == IntPtr.Zero) { base.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback(this.HandleDeactivateApp), null); } break; case 0x21: handled = true; return new IntPtr(3); } return IntPtr.Zero; } private static void RegisterPopupWithPlacementTarget(Popup popup, UIElement placementTarget) { " href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Collections.Generic.List<>">List list = > System.Windows.Controls.Primitives.Popup.RegisteredPopupsField;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/RegisteredPopupsField:System.Windows.UncommonField >">RegisteredPopupsField. System.Windows.UncommonField >.GetValue(DependencyObject);" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/System.Windows.UncommonField<>/GetValue(System.Windows.DependencyObject):">GetValue(placementTarget); if ( list // Local Variable">list == null) { list // Local Variable">list = new .List
();" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Collections.Generic.List<>">List (); > System.Windows.Controls.Primitives.Popup.RegisteredPopupsField;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/RegisteredPopupsField:System.Windows.UncommonField >">RegisteredPopupsField.>.SetValue(DependencyObject, List );" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/System.Windows.UncommonField<>/SetValue(System.Windows.DependencyObject,)">SetValue(placementTarget, list // Local Variable">list); } if (! list // Local Variable">list..Contains(Popup);" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Collections.Generic.List<>/Contains():Boolean">Contains(popup)) { list // Local Variable">list..Add(Popup);" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Collections.Generic.List<>/Add()">Add(popup); } } private void RegisterToOpenOnLoad() { base.Loaded += new RoutedEventHandler(this.OpenOnLoad); } private void ReleasePopupCapture() { if (this._cacheValid[1]) { if (Mouse.Captured == this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value) { Mouse.Capture(null); } this._cacheValid[1] = false; } } internal void Reposition() { DispatcherOperationCallback method = null; if (this.IsOpen && this._secHelper.IsWindowAlive()) { if (base.CheckAccess()) { this.UpdatePosition(); } else { if (method == null) { method = delegate (object param) { this.Reposition(); return null; }; } base.Dispatcher.BeginInvoke(DispatcherPriority.Normal, method, null); } } } internal Size RestrictSize(Size desiredSize) { Rect rect; Rect rect2; Size size; this.GetPopupRootLimits(out rect, out rect2, out size); desiredSize = (Size) this._secHelper.GetTransformToDevice().Transform((Point) desiredSize); desiredSize.Width = Math.Min(desiredSize.Width, rect2.Width); desiredSize.Width = Math.Min(desiredSize.Width, size.Width); double num = ((0.75 * rect2.Width) * rect2.Height) / desiredSize.Width; desiredSize.Height = Math.Min(desiredSize.Height, rect2.Height); desiredSize.Height = Math.Min(desiredSize.Height, num); desiredSize.Height = Math.Min(desiredSize.Height, size.Height); desiredSize = (Size) this._secHelper.GetTransformFromDevice().Transform((Point) desiredSize); return desiredSize; } private void SetHitTestable(bool hitTestable) { this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.IsHitTestVisible = hitTestable; if (this.IsTransparent) { this._secHelper.SetHitTestable(hitTestable); } } [SecurityCritical, SecurityTreatAsSafe] private void SetRootVisualToPopupRoot() { if ((this.PopupAnimation != PopupAnimation.None) && this.IsTransparent) { this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.Opacity = 0.0; } this._secHelper.SetWindowRootVisual(this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value); } private bool SetupAnimations(bool visible) { PopupAnimation popupAnimation = this.PopupAnimation; this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.StopAnimations(); if ((popupAnimation != PopupAnimation.None) && this.IsTransparent) { if (popupAnimation == PopupAnimation.Fade) { this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.SetupFadeAnimation(AnimationDelayTime, visible); return true; } if (visible) { this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.SetupTranslateAnimations(popupAnimation, AnimationDelayTime, this.AnimateFromRight, this.AnimateFromBottom); return true; } } return false; } private void ShowWindow() { if (this._secHelper.IsWindowAlive()) { this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.Opacity = 1.0; this.SetupAnimations(true); this.SetHitTestable(this.HitTestable || !this.IsTransparent); this.EstablishPopupCapture(); this._secHelper.ShowWindow(); } } private static void SwapPoints(ref Point p1, ref Point p2) { Point point = p1; p1 = p2; p2 = point; } void IAddChild.AddChild(object value) { UIElement element = value as UIElement; if ((element == null) && (value != null)) { throw new ArgumentException(SR.Get("UnexpectedParameterType", new object[] { value.GetType(), typeof(UIElement) }), "value"); } this.Child = element; } void IAddChild.AddText(string text) { TextBlock block = new TextBlock(); block.Text = text; this.Child = block; } private static GeneralTransform TransformToClient(Visual visual, Visual rootVisual) { GeneralTransformGroup group = new GeneralTransformGroup(); group.Children.Add(visual.TransformToAncestor(rootVisual)); group.Children.Add(new MatrixTransform(PointUtil.GetVisualTransform(rootVisual) * PopupSecurityHelper.GetTransformToDevice(rootVisual))); return group; } private static void UnregisterPopupFromPlacementTarget(Popup popup, UIElement placementTarget) { " href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Collections.Generic.List<>">List list = > System.Windows.Controls.Primitives.Popup.RegisteredPopupsField;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/RegisteredPopupsField:System.Windows.UncommonField >">RegisteredPopupsField. System.Windows.UncommonField >.GetValue(DependencyObject);" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/System.Windows.UncommonField<>/GetValue(System.Windows.DependencyObject):">GetValue(placementTarget); if ( list // Local Variable">list != null) { list // Local Variable">list..Remove(Popup);" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Collections.Generic.List<>/Remove():Boolean">Remove(popup); if ( list // Local Variable">list..Count { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Collections.Generic.List
/property:Count:Int32">Count == 0) { > System.Windows.Controls.Primitives.Popup.RegisteredPopupsField;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/RegisteredPopupsField:System.Windows.UncommonField >">RegisteredPopupsField.>.SetValue(DependencyObject, List );" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/System.Windows.UncommonField<>/SetValue(System.Windows.DependencyObject,)">SetValue(placementTarget, null); } } } private void UpdatePlacementTargetRegistration(UIElement oldValue, UIElement newValue) { if (oldValue != null) { UnregisterPopupFromPlacementTarget(this, oldValue); if ((newValue == null) && (VisualTreeHelper.GetParent(this) == null)) { TreeWalkHelper.InvalidateOnTreeChange(this, null, oldValue, false); } } if ((newValue != null) && (VisualTreeHelper.GetParent(this) == null)) { RegisterPopupWithPlacementTarget(this, newValue); TreeWalkHelper.InvalidateOnTreeChange(this, null, newValue, true); } } private void UpdatePosition() { if (this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value != null) { int numberOfCombinations; PlacementMode placement = this.Placement; Point[] placementTargetInterestPoints = this.GetPlacementTargetInterestPoints(placement); Point[] childInterestPoints = this.GetChildInterestPoints(placement); Rect bounds = this.GetBounds(placementTargetInterestPoints); Rect screenBounds = this.GetScreenBounds(bounds); Rect rect = this.GetBounds(childInterestPoints); double num = rect.Width * rect.Height; int num2 = -1; Vector offsetVector = new Vector((double) this._positionInfo.X, (double) this._positionInfo.Y); double num3 = -1.0; CustomPopupPlacement[] placementArray = null; if (placement == PlacementMode.Custom) { CustomPopupPlacementCallback customPopupPlacementCallback = this.CustomPopupPlacementCallback; if (customPopupPlacementCallback != null) { placementArray = customPopupPlacementCallback(rect.Size, bounds.Size, new Point(this.HorizontalOffset, this.VerticalOffset)); } numberOfCombinations = (placementArray == null) ? 0 : placementArray.Length; if (!this.IsOpen) { return; } } else { numberOfCombinations = GetNumberOfCombinations(placement); } for (int i = 0; i < numberOfCombinations; i++) { Vector vector2; PopupPrimaryAxis primaryAxis; bool flag = false; bool flag2 = false; if (placement == PlacementMode.Custom) { vector2 = ((Vector) placementTargetInterestPoints[0]) + ((Vector) placementArray[i].Point); primaryAxis = placementArray[i].PrimaryAxis; } else { PointCombination combination = this.GetPointCombination(placement, i, out primaryAxis); InterestPoint targetInterestPoint = combination.TargetInterestPoint; InterestPoint childInterestPoint = combination.ChildInterestPoint; vector2 = (Vector) (placementTargetInterestPoints[(int) targetInterestPoint] - childInterestPoints[(int) childInterestPoint]); flag = (childInterestPoint == InterestPoint.TopRight) || (childInterestPoint == InterestPoint.BottomRight); flag2 = (childInterestPoint == InterestPoint.BottomLeft) || (childInterestPoint == InterestPoint.BottomRight); } Rect rect4 = Rect.Offset(rect, vector2); Rect rect5 = Rect.Intersect(screenBounds, rect4); double num6 = (rect5 != Rect.Empty) ? (rect5.Width * rect5.Height) : 0.0; if ((num6 - num3) > 0.01) { num2 = i; offsetVector = vector2; num3 = num6; this.AnimateFromRight = flag; this.AnimateFromBottom = flag2; if (Math.Abs((double) (num6 - num)) < 0.01) { break; } } } if ((num2 >= 2) && ((placement == PlacementMode.Right) || (placement == PlacementMode.Left))) { this.DropOpposite = !this.DropOpposite; } rect = new Rect((Size) this._secHelper.GetTransformToDevice().Transform((Point) this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.RenderSize)); rect.Offset(offsetVector); Rect rect6 = Rect.Intersect(screenBounds, rect); if ((Math.Abs((double) (rect6.Width - rect.Width)) > 0.01) || (Math.Abs((double) (rect6.Height - rect.Height)) > 0.01)) { Point point3 = placementTargetInterestPoints[0]; Point point4 = placementTargetInterestPoints[1]; Vector vector3 = (Vector) (point4 - point3); vector3.Normalize(); if ((!this.IsTransparent || double.IsNaN(vector3.Y)) || (Math.Abs(vector3.Y) < 0.01)) { if (rect.Right > screenBounds.Right) { offsetVector.X = screenBounds.Right - rect.Width; } else if (rect.Left < screenBounds.Left) { offsetVector.X = screenBounds.Left; } } else if (this.IsTransparent && (Math.Abs(vector3.X) < 0.01)) { if (rect.Bottom > screenBounds.Bottom) { offsetVector.Y = screenBounds.Bottom - rect.Height; } else if (rect.Top < screenBounds.Top) { offsetVector.Y = screenBounds.Top; } } Point point5 = placementTargetInterestPoints[2]; Vector vector4 = (Vector) (point3 - point5); vector4.Normalize(); if ((!this.IsTransparent || double.IsNaN(vector4.X)) || (Math.Abs(vector4.X) < 0.01)) { if (rect.Bottom > screenBounds.Bottom) { offsetVector.Y = screenBounds.Bottom - rect.Height; } else if (rect.Top < screenBounds.Top) { offsetVector.Y = 0.0; } } else if (this.IsTransparent && (Math.Abs(vector4.Y) < 0.01)) { if (rect.Right > screenBounds.Right) { offsetVector.X = screenBounds.Right - rect.Width; } else if (rect.Left < screenBounds.Left) { offsetVector.X = 0.0; } } } int x = DoubleUtil.DoubleToInt(offsetVector.X); int y = DoubleUtil.DoubleToInt(offsetVector.Y); if ((x != this._positionInfo.X) || (y != this._positionInfo.Y)) { this._positionInfo.X = x; this._positionInfo.Y = y; this._secHelper.SetPopupPos(true, x, y, false, 0, 0); } } } private void UpdateTransform() { Matrix matrix = base.LayoutTransform.Value * base.RenderTransform.Value; DependencyObject parent = VisualTreeHelper.GetParent(this); Visual ancestor = (parent == null) ? null : GetRootVisual(this); if (ancestor != null) { matrix = (matrix * base.TransformToAncestor(ancestor).AffineTransform.Value) * PointUtil.GetVisualTransform(ancestor); } if (this.IsTransparent) { if ((parent != null) && (((FlowDirection) parent.GetValue(FrameworkElement.FlowDirectionProperty)) == FlowDirection.RightToLeft)) { matrix.Scale(-1.0, 1.0); } } else { Vector vector = matrix.Transform(new Vector(1.0, 0.0)); Vector vector2 = matrix.Transform(new Vector(0.0, 1.0)); matrix = new Matrix(); matrix.Scale(vector.Length, vector2.Length); } this. System.Windows.Controls.Primitives.Popup._popupRoot;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup/_popupRoot:MS.Internal.SecurityCriticalDataForSet ">_popupRoot..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataForSet /property:Value:">Value.Transform = new MatrixTransform(matrix); } // Properties public bool AllowsTransparency { get { return (bool) base.GetValue(AllowsTransparencyProperty); } set { base.SetValue(AllowsTransparencyProperty, BooleanBoxes.Box(value)); } } private bool AnimateFromBottom { get { return this._cacheValid[0x40]; } set { this._cacheValid[0x40] = value; } } private bool AnimateFromRight { get { return this._cacheValid[0x20]; } set { this._cacheValid[0x20] = value; } } [Bindable(true), CustomCategory("Content")] public UIElement Child { get { return (UIElement) base.GetValue(ChildProperty); } set { base.SetValue(ChildProperty, value); } } [Bindable(false), Category("Layout")] public CustomPopupPlacementCallback CustomPopupPlacementCallback { get { return (CustomPopupPlacementCallback) base.GetValue(CustomPopupPlacementCallbackProperty); } set { base.SetValue(CustomPopupPlacementCallbackProperty, value); } } internal bool DropOpposite { get { if (this._cacheValid[8]) { return this._cacheValid[0x10]; } DependencyObject reference = this; do { reference = VisualTreeHelper.GetParent(reference); PopupRoot root = reference as PopupRoot; if (root != null) { Popup parent = root.Parent as Popup; reference = parent; if ((parent != null) && parent._cacheValid[8]) { return parent._cacheValid[0x10]; } } } while (reference != null); return false; } set { this._cacheValid[0x10] = value; this._cacheValid[8] = true; } } internal override int EffectiveValuesInitialSize { get { return 0x13; } } public bool HasDropShadow { get { return (bool) base.GetValue(HasDropShadowProperty); } } internal bool HitTestable { get { return !this._cacheValid[0x80]; } set { this._cacheValid[0x80] = !value; } } [TypeConverter(typeof(LengthConverter)), Bindable(true), Category("Layout")] public double HorizontalOffset { get { return (double) base.GetValue(HorizontalOffsetProperty); } set { base.SetValue(HorizontalOffsetProperty, value); } } [Bindable(true), Category("Appearance")] public bool IsOpen { get { return (bool) base.GetValue(IsOpenProperty); } set { base.SetValue(IsOpenProperty, BooleanBoxes.Box(value)); } } private bool IsTransparent { get { return this._cacheValid[2]; } set { this._cacheValid[2] = value; } } protected internal override IEnumerator LogicalChildren { get { object child = this.Child; if (child == null) { return EmptyEnumerator.Instance; } return new PopupModelTreeEnumerator(this, child); } } [Category("Layout"), Bindable(true)] public PlacementMode Placement { get { return (PlacementMode) base.GetValue(PlacementProperty); } set { base.SetValue(PlacementProperty, value); } } [Category("Layout"), Bindable(true)] public Rect PlacementRectangle { get { return (Rect) base.GetValue(PlacementRectangleProperty); } set { base.SetValue(PlacementRectangleProperty, value); } } [Bindable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("Layout")] public UIElement PlacementTarget { get { return (UIElement) base.GetValue(PlacementTargetProperty); } set { base.SetValue(PlacementTargetProperty, value); } } [Category("Appearance"), Bindable(true)] public PopupAnimation PopupAnimation { get { return (PopupAnimation) base.GetValue(PopupAnimationProperty); } set { base.SetValue(PopupAnimationProperty, value); } } [Category("Behavior"), Bindable(true)] public bool StaysOpen { get { return (bool) base.GetValue(StaysOpenProperty); } set { base.SetValue(StaysOpenProperty, BooleanBoxes.Box(value)); } } [Category("Layout"), TypeConverter(typeof(LengthConverter)), Bindable(true)] public double VerticalOffset { get { return (double) base.GetValue(VerticalOffsetProperty); } set { base.SetValue(VerticalOffsetProperty, value); } } // Nested Types private enum CacheBits { AnimateFromBottom = 0x40, AnimateFromRight = 0x20, CaptureEngaged = 1, DropOpposite = 0x10, DropOppositeSet = 8, HitTestable = 0x80, IsTransparent = 2, OnClosedHandlerReopen = 4 } private enum InterestPoint { TopLeft, TopRight, BottomLeft, BottomRight, Center } [StructLayout(LayoutKind.Sequential)] private struct PointCombination { public Popup.InterestPoint TargetInterestPoint; public Popup.InterestPoint ChildInterestPoint; public PointCombination(Popup.InterestPoint targetInterestPoint, Popup.InterestPoint childInterestPoint) { this.TargetInterestPoint = targetInterestPoint; this.ChildInterestPoint = childInterestPoint; } } private class PopupModelTreeEnumerator : ModelTreeEnumerator { // Fields private Popup _popup; // Methods internal PopupModelTreeEnumerator(Popup popup, object child) : base(child) { this._popup = popup; } // Properties protected override bool IsUnchanged { get { return object.ReferenceEquals(base.Content, this._popup.Child); } } } private class PopupSecurityHelper { // Fields [SecurityCritical] private bool _isChildPopup; [SecurityCritical] private bool _isChildPopupInitialized; private " href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass<>" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass<>">SecurityCriticalDataClass " href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass ">_window ; private const string WebOCWindowClassName = "Shell Embedding"; // Methods internal PopupSecurityHelper() { } [SecurityCritical] internal void BuildWindow(int x, int y, Visual placementTarget, bool transparent, HwndSourceHook hook, AutoResizedEventHandler handler) { transparent = transparent && !this.IsChildPopup; Visual visual = placementTarget; if (this.IsChildPopup) { visual = FindMainTreeVisual(placementTarget); } HwndSource presentationSource = GetPresentationSource(visual) as HwndSource; IntPtr zero = IntPtr.Zero; if (presentationSource != null) { zero = GetHandle(presentationSource); } int num = 0; int num2 = 0x4000000; int num3 = 0x8000080; if (this.IsChildPopup) { num2 |= 0x40000000; } else { num2 |= -2147483648; num3 |= 8; } HwndSourceParameters parameters = new HwndSourceParameters(string.Empty); parameters.WindowClassStyle = num; parameters.WindowStyle = num2; parameters.ExtendedWindowStyle = num3; parameters.SetPosition(x, y); if (this.IsChildPopup) { if (zero != IntPtr.Zero) { parameters.ParentWindow = zero; } else { SecurityHelper.DemandUIWindowPermission(); } } else { parameters.UsesPerPixelOpacity = transparent; if ((zero != IntPtr.Zero) && ConnectedToForegroundWindow(zero)) { parameters.ParentWindow = zero; } } HwndSource source2 = new HwndSource(parameters); new UIPermission(UIPermissionWindow.AllWindows).Assert(); try { source2.AddHook(hook); } finally { CodeAccessPermission.RevertAssert(); } this. System.Windows.Controls.Primitives.Popup+PopupSecurityHelper._window;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass ">_window = new .SecurityCriticalDataClass (HwndSource);" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass<>" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass<>">SecurityCriticalDataClass (source2); source2.CompositionTarget.BackgroundColor = transparent ? Colors.Transparent : Colors.Black; source2.AutoResized += handler; } [SecurityCritical, SecurityTreatAsSafe] private NativeMethods.POINT ClientToScreen(HwndSource hwnd, Point clientPt) { bool isChildPopup = this.IsChildPopup; HwndSource presentationSource = null; if (isChildPopup) { presentationSource = HwndSource.CriticalFromHwnd(this.ParentHandle); } Point pointScreen = clientPt; if (!isChildPopup || (presentationSource != hwnd)) { pointScreen = PointUtil.ClientToScreen(clientPt, hwnd); } if (isChildPopup && (presentationSource != hwnd)) { pointScreen = PointUtil.ScreenToClient(pointScreen, presentationSource); } return new NativeMethods.POINT((int) pointScreen.X, (int) pointScreen.Y); } [SecurityCritical, SecurityTreatAsSafe] internal Point ClientToScreen(Visual rootVisual, Point clientPoint) { HwndSource presentationSource = GetPresentationSource(rootVisual) as HwndSource; if (presentationSource != null) { return PointUtil.ToPoint(this.ClientToScreen(presentationSource, clientPoint)); } return clientPoint; } [SecurityCritical] private static bool ConnectedToForegroundWindow(IntPtr window) { IntPtr foregroundWindow = UnsafeNativeMethods.GetForegroundWindow(); while (window != IntPtr.Zero) { if (window == foregroundWindow) { return true; } window = UnsafeNativeMethods.GetParent(new HandleRef(null, window)); } return false; } [SecurityCritical] internal void DestroyWindow(HwndSourceHook hook, AutoResizedEventHandler onAutoResizedEventHandler) { HwndSource source = this. System.Windows.Controls.Primitives.Popup+PopupSecurityHelper._window;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass " href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass ">_window..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:">Value; this. System.Windows.Controls.Primitives.Popup+PopupSecurityHelper._window;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass " href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass ">_window = null; if (!source.IsDisposed) { source.AutoResized -= onAutoResizedEventHandler; new UIPermission(UIPermissionWindow.AllWindows).Assert(); try { source.RemoveHook(hook); source.RootVisual = null; source.Dispose(); } finally { CodeAccessPermission.RevertAssert(); } } } private static Visual FindMainTreeVisual(Visual v) { DependencyObject obj2 = null; DependencyObject reference = v; while (reference != null) { obj2 = reference; PopupRoot root = reference as PopupRoot; if (root != null) { reference = root.Parent; Popup popup = reference as Popup; if (popup != null) { UIElement placementTarget = popup.PlacementTarget; if (placementTarget != null) { reference = placementTarget; } } } else { reference = VisualTreeHelper.GetParent(reference); } } return (obj2 as Visual); } [SecurityCritical] private static IntPtr GetHandle(HwndSource hwnd) { if (hwnd == null) { return IntPtr.Zero; } return hwnd.CriticalHandle; } [SecurityCritical] private IntPtr GetLastWebOCHwnd() { IntPtr window = UnsafeNativeMethods.GetWindow(new HandleRef(null, this.Handle), 1); StringBuilder lpClassName = new StringBuilder(260); while (window != IntPtr.Zero) { if (UnsafeNativeMethods.GetClassName(new HandleRef(null, window), lpClassName, 260) == 0) { throw new Win32Exception(); } if (string.Compare(lpClassName.ToString(), "Shell Embedding", StringComparison.OrdinalIgnoreCase) == 0) { return window; } window = UnsafeNativeMethods.GetWindow(new HandleRef(null, window), 3); } return window; } [SecurityTreatAsSafe, SecurityCritical] internal NativeMethods.POINT GetMouseCursorPos(Visual targetVisual) { if (Mouse.DirectlyOver != null) { HwndSource hwnd = null; if (targetVisual != null) { hwnd = GetPresentationSource(targetVisual) as HwndSource; } IInputElement relativeTo = targetVisual as IInputElement; if (relativeTo != null) { Point position = Mouse.GetPosition(relativeTo); if ((hwnd != null) && !hwnd.IsDisposed) { Visual rootVisual = hwnd.RootVisual; CompositionTarget compositionTarget = hwnd.CompositionTarget; if ((rootVisual != null) && (compositionTarget != null)) { GeneralTransform transform = targetVisual.TransformToAncestor(rootVisual); Matrix matrix = PointUtil.GetVisualTransform(rootVisual) * compositionTarget.TransformToDevice; transform.TryTransform(position, out position); position = matrix.Transform(position); return this.ClientToScreen(hwnd, position); } } } } NativeMethods.POINT pt = new NativeMethods.POINT(0, 0); UnsafeNativeMethods.TryGetCursorPos(pt); return pt; } [SecurityCritical] private static IntPtr GetParentHandle(HwndSource hwnd) { if (hwnd != null) { IntPtr handle = GetHandle(hwnd); if (handle != IntPtr.Zero) { return UnsafeNativeMethods.GetParent(new HandleRef(null, handle)); } } return IntPtr.Zero; } [SecurityTreatAsSafe, SecurityCritical] internal Rect GetParentWindowRect() { NativeMethods.RECT rect = new NativeMethods.RECT(0, 0, 0, 0); IntPtr parentHandle = this.ParentHandle; if (parentHandle != IntPtr.Zero) { SafeNativeMethods.GetClientRect(new HandleRef(null, parentHandle), ref rect); } return PointUtil.ToRect(rect); } [SecurityCritical] private static PresentationSource GetPresentationSource(Visual visual) { if (visual == null) { return null; } return PresentationSource.CriticalFromVisual(visual); } [SecurityCritical, SecurityTreatAsSafe] internal Matrix GetTransformFromDevice() { CompositionTarget compositionTarget = this. System.Windows.Controls.Primitives.Popup+PopupSecurityHelper._window;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass " href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass ">_window..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:">Value.CompositionTarget; if ((compositionTarget != null) && !compositionTarget.IsDisposed) { return compositionTarget.TransformFromDevice; } return Matrix.Identity; } [SecurityTreatAsSafe, SecurityCritical] internal Matrix GetTransformToDevice() { CompositionTarget compositionTarget = this. System.Windows.Controls.Primitives.Popup+PopupSecurityHelper._window;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass " href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass ">_window..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:">Value.CompositionTarget; if ((compositionTarget != null) && !compositionTarget.IsDisposed) { return compositionTarget.TransformToDevice; } return Matrix.Identity; } [SecurityCritical, SecurityTreatAsSafe] internal static Matrix GetTransformToDevice(Visual targetVisual) { HwndSource presentationSource = null; if (targetVisual != null) { presentationSource = GetPresentationSource(targetVisual) as HwndSource; } if (presentationSource != null) { CompositionTarget compositionTarget = presentationSource.CompositionTarget; if ((compositionTarget != null) && !compositionTarget.IsDisposed) { return compositionTarget.TransformToDevice; } } return Matrix.Identity; } [SecurityTreatAsSafe, SecurityCritical] internal void HideWindow() { UnsafeNativeMethods.ShowWindow(new HandleRef(null, this.Handle), 0); } [SecurityTreatAsSafe, SecurityCritical] internal static bool IsVisualPresentationSourceNull(Visual visual) { return (GetPresentationSource(visual) == null); } [SecurityCritical, SecurityTreatAsSafe] internal bool IsWindowAlive() { if (this. System.Windows.Controls.Primitives.Popup+PopupSecurityHelper._window;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass " href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass ">_window == null) { return false; } HwndSource source = this. System.Windows.Controls.Primitives.Popup+PopupSecurityHelper._window;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass " href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass ">_window..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:">Value; return ((source != null) && !source.IsDisposed); } [SecurityCritical, SecurityTreatAsSafe] internal void SetHitTestable(bool hitTestable) { if (!this.IsChildPopup) { SecurityHelper.DemandUnmanagedCode(); } IntPtr handle = this.Handle; int windowLong = UnsafeNativeMethods.GetWindowLong(new HandleRef(this, handle), -20); if (((windowLong & 0x20) == 0) != hitTestable) { int num; if (hitTestable) { num = windowLong & -33; } else { num = windowLong | 0x20; } UnsafeNativeMethods.CriticalSetWindowLong(new HandleRef(null, handle), -20, (IntPtr) num); } } [SecurityCritical, SecurityTreatAsSafe] internal void SetPopupPos(bool position, int x, int y, bool size, int width, int height) { int flags = 20; if (!position) { flags |= 2; } if (!size) { flags |= 1; } UnsafeNativeMethods.SetWindowPos(new HandleRef(null, this.Handle), new HandleRef(null, IntPtr.Zero), x, y, width, height, flags); } [SecurityCritical] internal void SetWindowRootVisual(Visual v) { this. System.Windows.Controls.Primitives.Popup+PopupSecurityHelper._window;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass " href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass ">_window..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:">Value.RootVisual = v; } [SecurityCritical, SecurityTreatAsSafe] internal void ShowWindow() { if (this.IsChildPopup) { IntPtr lastWebOCHwnd = this.GetLastWebOCHwnd(); UnsafeNativeMethods.SetWindowPos(new HandleRef(null, this.Handle), (lastWebOCHwnd == IntPtr.Zero) ? NativeMethods.HWND_TOP : new HandleRef(null, lastWebOCHwnd), 0, 0, 0, 0, 0x53); } else { UnsafeNativeMethods.ShowWindow(new HandleRef(null, this.Handle), 8); } } // Properties private IntPtr Handle { [SecurityCritical] get { return GetHandle(this. System.Windows.Controls.Primitives.Popup+PopupSecurityHelper._window;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass " href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass ">_window..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:">Value); } } internal bool IsChildPopup { [SecurityTreatAsSafe, SecurityCritical] get { if (!this._isChildPopupInitialized) { this._isChildPopup = BrowserInteropHelper.IsBrowserHosted || !SecurityHelper.CheckUnmanagedCodePermission(); this._isChildPopupInitialized = true; } return this._isChildPopup; } } private IntPtr ParentHandle { [SecurityCritical] get { return GetParentHandle(this. System.Windows.Controls.Primitives.Popup+PopupSecurityHelper._window;" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass " href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.Popup.PopupSecurityHelper/_window:MS.Internal.SecurityCriticalDataClass ">_window..Value { ... }" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:" href_cetemp="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WindowsBase:3.0.0.0:31bf3856ad364e35/MS.Internal.SecurityCriticalDataClass /property:Value:">Value); } } } private class PositionInfo { // Fields public Size ChildSize; public Rect MouseRect = Rect.Empty; public int X; public int Y; } }
Collapse Methods
Popup 类
WPF popup is always TOP_MOST
用Popup对象构建网页右键菜单
Displaying popup listview/gridview within a Listview/gridview?
用于订阅rss到狗狗(gougou.com)的书签按钮-A bookmarklet for popup post to gougou.com
CRect类(矩形类)
CRect类(矩形类)
小雨--边界类、控制类、实体类
小雨--边界类、控制类、实体类
小雨--边界类、控制类、实体类
素菜类
素菜类
complex类
Person类
技术类
词汇类
门窗类
Time类
vector类
门窗类
幻灯片类
望诊类
自然科学类
针炙类--->>>>>