示例#1
0
        /// <summary>
        /// 截图游戏并保存
        /// </summary>
        public static void ScreenShot()
        {
            if (!Directory.Exists("screenshot"))
            {
                Directory.CreateDirectory("screenshot");
            }

            string path = @"screenshot\" + LogsHelper.GetServerName() + "_" + LogsHelper.GetFilePlayerName() + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff") + "." + DataUtil.Config.sysConfig.capFormat.ToString().ToLower();

            System.Windows.Point p = new System.Windows.Point();
            var screenPoint        = main.WinFormHost.PointToScreen(p);
            int x      = (int)screenPoint.X;
            int y      = (int)screenPoint.Y;
            int width  = Convert.ToInt32(main.WinFormHost.Width);
            int height = Convert.ToInt32(main.WinFormHost.Height);

            var image = ScreenHelper.CaptureScreen(x, y, width, height);

            var format = Path.GetExtension(path) == ".jpg"
                ? ImageFormat.Jpeg
                : ImageFormat.Png;

            image.Save(path, format);
            AddLog("截圖已經保存到文件" + path);
        }
示例#2
0
        public static ScreenHelper GetScreenFrom(Window window)
        {
            WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window);
            Screen       screen    = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle);
            ScreenHelper wpfScreen = new ScreenHelper(screen);

            return(wpfScreen);
        }
示例#3
0
        public static ScreenHelper GetScreenFrom(System.Windows.Point point)
        {
            int x = (int)Math.Round(point.X);
            int y = (int)Math.Round(point.Y);

            System.Drawing.Point drawingPoint = new System.Drawing.Point(x, y);
            Screen       screen    = System.Windows.Forms.Screen.FromPoint(drawingPoint);
            ScreenHelper wpfScreen = new ScreenHelper(screen);

            return(wpfScreen);
        }