示例#1
0
        private IntPtr GetWin32InfoFromUIElement(System.Windows.UIElement uiElement, out System.Drawing.Rectangle rect)
        {
            // Convert UIElement to Rectangle
            System.Windows.Media.Matrix       matrix;
            System.Windows.PresentationSource presentationSource = System.Windows.PresentationSource.FromVisual(uiElement);
            if (presentationSource == null)
            {
                throw new InvalidOperationException("The specified UiElement is not connected to a rendering Visual Tree.");
            }
            try
            {
                System.Windows.Media.GeneralTransform generalTransform = uiElement.TransformToAncestor(presentationSource.RootVisual);
                System.Windows.Media.Transform        transform        = generalTransform as System.Windows.Media.Transform;
                if (transform == null)
                {
                    throw new ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change");
                }
                matrix = transform.Value;
            }
            catch (InvalidOperationException)
            {
                throw new InvalidOperationException("The specified UiElement is not connected to a rendering Visual Tree.");
            }
            System.Windows.Rect rect1 = new System.Windows.Rect(new System.Windows.Point(), uiElement.RenderSize);
            rect1.Transform(matrix);
            System.Windows.Point point1 = rect1.TopLeft;
            point1 = presentationSource.CompositionTarget.TransformToDevice.Transform(point1);
            Point  point2 = new Point((int)point1.X, (int)point1.Y);
            IntPtr hwnd   = ((System.Windows.Interop.HwndSource)presentationSource).Handle; // PresentaionSource.RootVisual ?

            User32.ClientToScreen(hwnd, ref point2);
            rect = new System.Drawing.Rectangle(point2, new System.Drawing.Size(
                                                    Convert.ToInt32(Microsoft.Test.Display.Monitor.ConvertLogicalToScreen(Microsoft.Test.Display.Dimension.Width, uiElement.RenderSize.Width)),
                                                    Convert.ToInt32(Microsoft.Test.Display.Monitor.ConvertLogicalToScreen(Microsoft.Test.Display.Dimension.Height, uiElement.RenderSize.Height))));

            return(hwnd);
        }
 public void PushMenuMode(System.Windows.PresentationSource menuSite)
 {
 }
 protected void SetActiveSource(System.Windows.PresentationSource activeSource)
 {
 }
 protected System.Windows.Point GetClientPosition(System.Windows.PresentationSource presentationSource)
 {
     return(default(System.Windows.Point));
 }
示例#5
0
 public KeyEventArgs(KeyboardDevice keyboard, System.Windows.PresentationSource inputSource, int timestamp, Key key) : base(default(KeyboardDevice), default(int))
 {
 }