Esempio n. 1
0
        /// <summary>
        /// Take a screenshot of a page and save it in images folder of solution directory.
        /// </summary>
        /// <param name="scrType">type of screenshot: which name to set to image</param>
        /// <param name="driver">IWebDriver</param>
        public static void TakeScreenshot(ScreenShotType scrType, IWebDriver driver)
        {
            ICapabilities capabilities = ((RemoteWebDriver)driver).Capabilities;

            CheckImageDirectory(imagePath);
            Screenshot scrFile = ((ITakesScreenshot)driver).GetScreenshot();

            switch (scrType)
            {
            case ScreenShotType.MainPage:
                scrFile.SaveAsFile(imagePath + capabilities.BrowserName + "WrongImageOnMainPage.jpg", ImageFormat.Jpeg);
                break;

            case ScreenShotType.CalcPage:
                scrFile.SaveAsFile(imagePath + capabilities.BrowserName + "ErrorOnCalculatorPage.jpg", ImageFormat.Jpeg);
                break;

            case ScreenShotType.InterpOfferPage:
                scrFile.SaveAsFile(imagePath + capabilities.BrowserName + "ErrorOnInterpretOfferPage.jpg", ImageFormat.Jpeg);
                break;

            case ScreenShotType.ContactInfo:
                scrFile.SaveAsFile(imagePath + capabilities.BrowserName + "ErrorWithContactInfo.jpg", ImageFormat.Jpeg);
                break;

            case ScreenShotType.LanguageChange:
                scrFile.SaveAsFile(imagePath + capabilities.BrowserName + "ErrorWithLanguageChange.jpg", ImageFormat.Jpeg);
                break;
            }
        }
        /// <summary>
        /// Effectue une capture d'écran
        /// </summary>
        /// <param name="type">Type de capture</param>
        /// <returns>Bitmap représentant la capture d'écran</returns>
        public static Bitmap Capture(ScreenShotType type)
        {
            Bitmap    bitmap = null;
            Rectangle rect;

            try {
                switch (type)
                {
                case ScreenShotType.PrimaryScreen:
                    rect = Screen.PrimaryScreen.Bounds;
                    break;

                default:
                case ScreenShotType.VirtualScreen:
                    rect = SystemInformation.VirtualScreen;
                    break;

                case ScreenShotType.WorkingArea:
                    rect = Screen.PrimaryScreen.WorkingArea;
                    break;
                }

                bitmap = capture(rect);
            }
            catch (Exception ex) {
                throw ex;
            }

            // retourne la capture
            return(bitmap);
        }
Esempio n. 3
0
        public static Image GetScreenShot(ScreenShotType type)
        {
            Size displaySize = new Size(
                Screen.PrimaryScreen.Bounds.Width,
                Screen.PrimaryScreen.Bounds.Height);

            return(GetScreenShot(type, new Point(0, 0), displaySize));
        }
        public string GetScreenShotName(ScreenShotType type)
        {
            switch (type)
            {
            case ScreenShotType.Regular:
                return(GetScreenShotName(type, settings.General_ScreenshotNameTemplate));

            case ScreenShotType.Pack:
                return(GetScreenShotName(type, settings.Packs_ScreenshotNameTemplate));

            default:
                throw new NotImplementedException("Unknown screenshot type" + type);
            }
        }
Esempio n. 5
0
        public static void ScreenShot(ScreenShotType screenShotType, Action <string> finsh, params object[] Params)
        {
            var        parent = InitPopupPrefab("Prefabs/ScreenShot/ScreenShotCamera");
            var        path   = "";
            GameObject go;

            switch (screenShotType)
            {
            case ScreenShotType.DrawCard:
                path = "Prefabs/ScreenShot/DrawViewScreenShot";
                go   = InitPopupPrefab(path);
                Popup(go, parent);
                go.GetComponent <DrawViewScreenShot>().SetData((DrawCardResultVo)Params[0]);
                break;

            case ScreenShotType.Clothes:
                path = "Prefabs/ScreenShot/FavorabilityMainViewScreenShot";
                go   = InitPopupPrefab(path);
                Popup(go, parent);
                go.GetComponent <FavorabilityMainViewScreenShot>().SetData((int)Params[0], (int)Params[1]);
                break;

            case ScreenShotType.MusicGame:
                path = "MusicRhythm/Prefabs/MusicRhythmResultShare";
                go   = InitPopupPrefab(path);
                go.AddScriptComponent <MusicRhythmResultShare>().SetData(Params[0] as MusicRhythmRunningInfo);
                Popup(go, parent);
                break;

            default:
                return;
            }

            ClientTimer.Instance.DelayCall(() =>
            {
                var _camera1 = parent.GetComponent <Camera>();
                var _rect1   = parent.transform.Find("Canvas").GetChild(0).GetComponent <RectTransform>().rect;
                var urlPath1 = CaptureCamera(_camera1, _rect1);
                finsh?.Invoke(urlPath1);

                parent.GetComponent <ScreenShotRender>().DestorySelf();
            }, 0.3f);

            //Camera _camera = parent.GetComponent<Camera>();
            //Rect _rect = parent.transform.Find("Canvas").GetChild(0).GetComponent<RectTransform>().rect;
            //string urlPath = ScreenShotUtil.CaptureCamera(_camera, _rect);

            // return urlPath;
        }
        public string GetScreenShotName(ScreenShotType type, string nameTemplate)
        {
            switch (type)
            {
            case ScreenShotType.Regular:
                nameTemplate = nameTemplate.Replace("{d", "{0");
                return(string.Format(nameTemplate, trackerFactory.GetDateTimeNow()));

            case ScreenShotType.Pack:
                nameTemplate = nameTemplate.Replace("{d", "{0").Replace("{n", "{1");
                return(string.Format(nameTemplate, trackerFactory.GetDateTimeNow(), trackerFactory.GetTracker().Packs.Count));

            default:
                throw new NotImplementedException("Unknown screenshot type" + type);
            }
        }
Esempio n. 7
0
        public static Image GetScreenShot(ScreenShotType type, Point location, Size size)
        {
            Image resultImage = null;

            if (type == ScreenShotType.Managed)
            {
                Bitmap   bmp = new Bitmap(size.Width, size.Height);
                Graphics g   = Graphics.FromImage(bmp);
                g.CopyFromScreen(location, new Point(0, 0), size);
                g.Dispose();

                resultImage = bmp;
            }
            else
            {
                throw new NotImplementedException();
            }

            return(resultImage);
        }
Esempio n. 8
0
 static ScreenShotUtility()
 {
     DefaultScreenShotType = ScreenShotType.Managed;
 }