ClientToScreen() public static method

public static ClientToScreen ( FrameworkElement element, Point point ) : IntPoint
element System.Windows.FrameworkElement
point Point
return IntPoint
示例#1
0
        public static IntRect ClientToScreen(FrameworkElement element, Rect rect)
        {
            IntPoint topLeft     = NativeMethods.ClientToScreen(element, new Point(rect.X, rect.Y));
            IntPoint bottomRight = NativeMethods.ClientToScreen(element, new Point(rect.X + rect.Width, rect.Y + rect.Height));

            return(new IntRect(topLeft.X, topLeft.Y, bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y));
        }
示例#2
0
        protected override void OnLostMouseCapture(MouseEventArgs e)
        {
            base.OnLostMouseCapture(e);

            if (this.bounds.Width < 3 || this.bounds.Height < 3)
            {
                CloseService();

                return;
            }

            Cursor = Cursors.Arrow;

            IntRect startRect = NativeMethods.ClientToScreen(this, this.bounds);

            screenshot = new ScreenShot(startRect);

            startRect.Width  -= 1;
            startRect.Height -= 1;

            IntRect screenBounds = ScreenCoordinates.Collapse(startRect, screenshot);
            Rect    bounds       = NativeMethods.ScreenToClient(this, screenBounds);

            if (!bounds.IsEmpty)
            {
                AnimateBounds(bounds);
            }

            isInDrawMode        = false;
            Dimensions.CanClose = true;
        }
示例#3
0
        private void CaptureIt()
        {
            IntRect bounds = NativeMethods.ClientToScreen(this, Bounds);

            ScreenShot screenshot = new ScreenShot(bounds);

            Clipboard.SetImage(screenshot.Image);

            CloseService();
        }
示例#4
0
        public static IntPoint ClientToScreen(FrameworkElement element, Point point)
        {
            PresentationSource source = PresentationSource.FromVisual(element);

            point = element.TransformToAncestor(source.RootVisual).Transform(point);

            Point offset = source.CompositionTarget.TransformToDevice.Transform(new Point(point.X, point.Y));

            Win32Point winPt = new Win32Point((int)offset.X, (int)offset.Y);

            NativeMethods.ClientToScreen(((HwndSource)source).Handle, ref winPt);

            return(new IntPoint(winPt.x, winPt.y));
        }
示例#5
0
        protected override void  OnLostMouseCapture(MouseEventArgs e)
        {
            base.OnLostMouseCapture(e);

            if (this.bounds.Width == 0 || this.bounds.Height == 0)
            {
                this.CloseService();

                return;
            }

            this.IsGrayed = false;
            this.Cursor   = Cursors.Arrow;

            IntRect startRect = NativeMethods.ClientToScreen(this, this.bounds);

            startRect.Width  -= 1;
            startRect.Height -= 1;
            IntRect screenBounds = ScreenCoordinates.Collapse(startRect, this.screenshot);


            if (!screenBounds.IsEmpty)
            {
                this.AnimateBounds(screenBounds);
            }

            this.BoundsRect.Visibility = Visibility.Visible;
            this.Dimensions.CanClose   = true;

            //BitmapFrame frame = BitmapFrame.Create(this.screenshot.Image);
            //PngBitmapEncoder encoder = new PngBitmapEncoder();
            //encoder.Frames.Add(frame);

            //using (FileStream fs = new FileStream(@"C:\tmp\ss.png", FileMode.Create, FileAccess.Write)) {
            //    encoder.Save(fs);
            //};
        }