Example #1
0
 private void SourceSuspensionChanged(ScreenCapture sender, SourceSuspensionChangedEventArgs args)
 {
     Debug.WriteLine("SourceSuspensionChanged Event. Args: IsAudioSuspended:" +
                     args.IsAudioSuspended.ToString() +
                     " IsVideoSuspended:" +
                     args.IsVideoSuspended.ToString());
 }
        public static Capture PerformScreenCapture(TabControl.TabControl tab)
        {
            ScreenCapture sc = new ScreenCapture();
            string filename = DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss");
            string tempFile = System.IO.Path.Combine(CaptureManager.CaptureRoot, string.Format("{0}.png", filename));

            using(sc.CaptureControl(tab, tempFile, ImageFormatHandler.ImageFormatTypes.imgPNG));

            //System.Diagnostics.Process.Start(tempFile);
            return null;
        }
        internal static void PerformScreenCapture(TabControl.TabControl tab)
        {
            var activeTab = tab.SelectedItem as TerminalTabControlItem;
            string name = string.Empty;
            if (activeTab != null && activeTab.Favorite != null && !string.IsNullOrEmpty(activeTab.Favorite.Name))
            {
                name = activeTab.Favorite.Name + "-";
            }
            string filename = DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss");
            string tempFile = Path.Combine(CaptureRoot, string.Format("{0}{1}.png", name, filename));
            ScreenCapture sc = new ScreenCapture();
            Bitmap bmp = sc.CaptureControl(tab, tempFile, ImageFormatTypes.imgPNG);

            if (settings.EnableCaptureToClipboard)
                Clipboard.SetImage(bmp);
        }
Example #4
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            Mail mail = new Mail();
            string info = "";
            ArrayList al = new ArrayList();
            Log4Net.Logger.loggInfo("Sending support mail", Config.User, "");

            try
            {
                info = "\n\n\nMachinename: " + Environment.MachineName;
                info += "\nOS: " + Environment.OSVersion;
                info += "\nUser: "******"\nDoamin: " + Environment.UserDomainName;
                info += "\nConfigPath " + Config.ConfigPath;
                info += "\n\nStackTrace: " + Environment.StackTrace;

                ScreenCapture sc = new ScreenCapture();
                string imgWholeScreen = Path.GetTempPath() + "Screen_" + Path.ChangeExtension(Path.GetRandomFileName(), ".jpg");
                al.Add(imgWholeScreen);

                string imgPatient = Path.GetTempPath() + "Patient_" + Path.ChangeExtension(Path.GetRandomFileName(), ".jpg");
                al.Add(imgPatient);

                //string logPath = Path.GetTempPath() + "log_" + Path.ChangeExtension(Path.GetRandomFileName(), ".gcslogg");
                //File.Copy(Log4Net.Logger.getFileName(Config.User), logPath, true);
                //al.Add(logPath);

                //string confPath = Path.GetTempPath() + "config_" + Path.ChangeExtension(Path.GetRandomFileName(), ".gcslogg");
                //File.Copy(Config., confPath, true);
                //al.Add(confPath);

                sc.CaptureScreenToFile(imgWholeScreen, System.Drawing.Imaging.ImageFormat.Jpeg);
                sc.CaptureWindowToFile(mHandle, imgPatient, System.Drawing.Imaging.ImageFormat.Jpeg);

                mail.sendMail(Config.SMTP, 25, Config.SMTP_FromAddress, Config.SMTP_SupportAddress, "ErrorMessage from " + Config.User, rtMessage.Text + info, (string[])al.ToArray(typeof(string)), Config.SMTP_User, Config.SMTP_Password);

                this.Close();
            }
            catch (Exception ex)
            {
                Log4Net.Logger.loggError(ex, "Error while configuring mail to support", Config.User, "frmErrorReport.btnSend_Click");
            }
        }
Example #5
0
        /// <summary>
        /// Allows for adding a snapshot to the log event
        /// </summary>
        /// <param name="ImagePath">Path of the image</param>
        /// <returns>A formed HTML img tag with the supplied path</returns>
        public string AddScreenCapture(string ImagePath)
        {
            string screenCaptureHtml;

            if (IsPathRelative(ImagePath))
            {
                screenCaptureHtml = ImageHtml.GetSource(ImagePath).Replace("file:///", "");
            }
            else
            {
                screenCaptureHtml = ImageHtml.GetSource(ImagePath);
            }

            ScreenCapture img = new ScreenCapture();
            img.Source = screenCaptureHtml;
            img.TestName = test.Name;

            test.ScreenCapture.Add(img);

            return screenCaptureHtml;
        }
Example #6
0
        public UserView()
        {
            InitializeComponent();
            ColorOfScreen = new List<string>();
            _timer = new Timer(150);//1000 =1s
            _timer.Elapsed += _timer_Elapsed;
            _screenCapture = new ScreenCapture();
            _colorCalculate = new ColorCalculate(_screenCapture);

            _portNames = new List<string>();
            foreach (string srt in SerialPort.GetPortNames())
            {
                _portNames.Add(srt);
            }

            _resolution = System.Windows.SystemParameters.PrimaryScreenWidth.ToString() + " x " + System.Windows.SystemParameters.PrimaryScreenHeight.ToString();
            int index = 0;

                 _portCom = new PortCom("COM5", 115200);
                _portCom.OpenPort();

            _timer.Start();
        }
        private CaptureMethod?DetectCaptureMethod(IntPtr wnd, out ScreenshotResource img)
        {
            if (NativeMethods.IsIconic(wnd))
            {
                img = null;
                return(null);
            }

            if (ScreenCapture.IsFullScreen(wnd))
            {
                if (dontUseDirectX)
                {
                    Log.Warn("Auto-detect: full-screen and DirectX errors. Capturing will probably not work.");
                }
                else
                {
                    Log.Info("Auto-detect: window is full-screen, use DirectX");
                    try
                    {
                        img = CaptureDirectX(wnd);
                        if (img != null && img.Bitmap != null)
                        {
                            Log.Info("Auto-detect: Can use DirectX");
                            return(CaptureMethod.DirectX);
                        }
                        else
                        {
                            Log.Warn("Auto-detect: DirectX returned empty image");
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Warn("Auto-detect: DirectX throws errors, investigate: " + ex);
                    }
                }

                img = null;
                return(null);
            }

            if (!dontUseDirectX)
            {
                try
                {
                    img = CaptureDirectX(wnd);
                    if (img != null && img.Bitmap != null)
                    {
                        Log.Info("Auto-detect: Can use DirectX");
                        return(CaptureMethod.DirectX);
                    }
                }
                catch (Exception ex)
                {
                    Log.Warn("Auto-detect: DirectX throws errors, investigate: " + ex);
                }
            }

            try
            {
                img = CaptureWdm(wnd, true, false);
                if (img != null)
                {
                    if (!img.Bitmap.IsAllBlack())
                    {
                        Log.Info("Auto-detect: Can use Wdm");
                        return(CaptureMethod.Wdm);
                    }
                }
            }
            catch (Exception)
            {
            }

            //if (dontUseDirectX)
            //{
            //    Log.Info("Auto-detect: DirectX gave too much errors, skipping DirectX.");
            //}
            //else
            //{
            //    try
            //    {
            //        img = CaptureDirectX(wnd);
            //        if (img != null)
            //        {
            //            if (!img.Bitmap.IsAllBlack())
            //            {
            //                Log.Info("Auto-detect: Can use DirectX");
            //                return CaptureMethod.DirectX;
            //            }
            //        }
            //    }
            //    catch (Exception)
            //    {
            //    }
            //}

            try
            {
                img = this.CaptureWdm(wnd, false, true);
                if (img != null && img.Bitmap != null)
                {
                    if (!img.Bitmap.IsAllBlack())
                    {
                        Log.Info("Auto-detect: Can use BitBlt");
                        return(CaptureMethod.BitBlt);
                    }
                }
            }
            catch (Exception)
            {
            }

            img = null;
            return(null);
        }
Example #8
0
 public void CaptureImage()
 {
     ScreenCapture.CaptureScreenshot("screenshot.png");
     fd.DetectFaces(Application.persistentDataPath + "/screenshot.png");
 }
Example #9
0
    //IEnumerator 是所有非泛型列舉值的基底介面。
    public static IEnumerator Save(string fileName, Action successCallback, Action failCallbacks, string albumName = "MyScreenshots", bool callback = false)
    {
        bool photoSaved = false;

        string date = System.DateTime.Now.ToString("dd-MM-yy");

        ScreenShotNumber++;

        string screenshotFilename = fileName + "_" + date + "_" + ScreenShotNumber + ".png";

        Debug.Log("Save screenshot " + screenshotFilename);

#if UNITY_IOS
        Rect screenArea = new Rect(0, 0, Screen.width, Screen.height);
        Instance.StartCoroutine(Instance.IOSScreenshot(albumName, fileName, screenArea, Done => {
            if (Done == SaveStatus.SAVED)
            {
                successCallback();
            }
            else
            {
                failCallbacks();
            }
        }));
        yield return(new WaitForSeconds(.5f));
#elif UNITY_ANDROID
        if (Application.platform == RuntimePlatform.Android)
        {
            Debug.Log("Android platform detected");

            string androidPath = "/../../../../DCIM/" + albumName + "/" + screenshotFilename;
            string path        = Application.persistentDataPath + androidPath;
            string pathonly    = Path.GetDirectoryName(path);
            Directory.CreateDirectory(pathonly);
            ScreenCapture.CaptureScreenshot(androidPath);

            AndroidJavaClass obj = new AndroidJavaClass("com.ryanwebb.androidscreenshot.MainActivity");

            while (!photoSaved)
            {
                photoSaved = obj.CallStatic <bool>("scanMedia", path);

                yield return(new WaitForSeconds(.5f));
            }
        }
        else
        {
            ScreenCapture.CaptureScreenshot(screenshotFilename);
        }
#else
        while (!photoSaved)
        {
            yield return(new WaitForSeconds(.5f));

            Debug.Log("Screenshots only available in iOS/Android mode!");

            photoSaved = true;
        }
#endif
#if UNITY_IOS
#elif UNITY_ANDROID
        if (callback)
        {
            if (photoSaved)
            {
                successCallback();
            }
            else
            {
                failCallbacks();
            }
        }
#endif
    }
 internal void AddScreenCapture(Log log, ScreenCapture screenCapture)
 {
     StarterReporterList.ForEach(x => x.OnScreenCaptureAdded(log, screenCapture));
 }
Example #11
0
        //-------------------------------------------
        // PushStart
        //-------------------------------------------
        public static bool PushStart()
        {
            const int padding = 10;
            const int padding2 = 10;

            mFMEStarted = false;

            // プロセスが確保されていなければ、リターン
            if (mFMEprocess == null)
            {
                return false;
            }

            // プロセスが存在しても、終了していれば、リターン
            if (mFMEprocess.HasExited)
            {
                return false;
            }

            // ウインドウのサイズをあわせる
            FitWindowSize();

            RECT clientrect = new RECT();

            // クライアント領域のスクリーンをキャプチャする
            Bitmap bmp=null;

            bool bStartPushed = false;
            bool bStartComplete = false;
            using (ScreenCapture scr = new ScreenCapture())
            {
                int i;
                Point outPos = new Point();

                Point start_offs = new Point(417, 512);
                Point stop_offs = new Point(556, 512);
                Point ng_offs = new Point(489, 357);

                // スタートボタンを探して押す
                for (i = 0; i < 60; i++)
                {
                    // ウインドウをフォアグラウンドに
                    SetForegroundWindow(m_fme_hwnd);  // アクティブにする

                    // クライアント領域のサイズを取得
                    GetClientRect(m_fme_hwnd, ref clientrect);
                    POINT p1, p2;
                    p1.x = clientrect.left;
                    p1.y = clientrect.top;
                    p2.x = clientrect.right;
                    p2.y = clientrect.bottom;

                    //クライアント領域座標をスクリーン座標に変換
                    ClientToScreen(m_fme_hwnd, ref p1);
                    ClientToScreen(m_fme_hwnd, ref p2);

                    // クライアント領域のレクトアングルを設定
                    Rectangle iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                    bmp = scr.Capture(iRect);
                    if (ContainBitmap(mStartBmp, bmp, start_offs.X - padding2, start_offs.Y - padding, start_offs.X + padding2, start_offs.Y + padding, ref outPos, 5))
                    {
                        MouseClick(p1.x + outPos.X + 18, p1.y + outPos.Y + 14);
                        bStartPushed = true;
                        // 立ち上がるのを待つ
                        using (Bouyomi bm = new Bouyomi())
                        {
                            bm.Talk("スタートボタン、プッシュ");
                        }
                        break;
                    }

                    bmp.Dispose();
                    bmp = null;
                    FitWindowSize();
                    // 0.5[s] wait
                    System.Threading.Thread.Sleep(500);
                }

                // スタートボタンが押せなかった場合
                if (!bStartPushed)
                {
                    if (bmp != null)
                    {
                        bmp.Dispose();
                        bmp = null;
                    }
                    // 立ち上がるのを待つ
                    using (Bouyomi bm = new Bouyomi())
                    {
                        bm.Talk("スタートボタンを代わりに押してください");
                    }
                }

                // スタートできたかのチェック
                for (i = 0; i < 40; i++)
                {
                    // ウインドウをフォアグラウンドに
                    SetForegroundWindow(m_fme_hwnd);  // アクティブにする

                    GetClientRect(m_fme_hwnd, ref clientrect);
                    POINT p1, p2;
                    p1.x = clientrect.left;
                    p1.y = clientrect.top;
                    p2.x = clientrect.right;
                    p2.y = clientrect.bottom;

                    //クライアント領域座標をスクリーン座標に変換
                    ClientToScreen(m_fme_hwnd, ref p1);
                    ClientToScreen(m_fme_hwnd, ref p2);

                    Rectangle iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                    bmp = scr.Capture(iRect);

                    // Stop が押せるようになれば、とりあえず成功判定
                    if (ContainBitmap(mStopBmp, bmp, stop_offs.X - padding2, stop_offs.Y - padding, stop_offs.X + padding2, stop_offs.Y + padding, ref outPos, 5))
                    {
                        // 立ち上がるのを待つ
                        using (Bouyomi bm = new Bouyomi())
                        {
                            bm.Talk("ストップボタン、点灯確認");
                        }
                        bStartComplete = true;
                        mFMEStarted = true;
                        bmp.Dispose();
                        bmp = null;
                        break;
                    }

                    // NGダイアログが出てきたら、NG判定
                    if (ContainBitmap(mNgBmp, bmp, ng_offs.X - padding2, ng_offs.Y - padding, ng_offs.X + padding2, ng_offs.Y + padding, ref outPos, 5))
                    {
                        MouseClick(p1.x + outPos.X + 10, p1.y + outPos.Y + 10);
                        if (bmp != null)
                        {
                            bmp.Dispose();
                            bmp = null;
                        }

                        // NG ダイアログが消えるのを待つ
                        int j;
                        for (j = 0; j < 10; j++)
                        {
                            GetClientRect(m_fme_hwnd, ref clientrect);

                            p1.x = clientrect.left;
                            p1.y = clientrect.top;
                            p2.x = clientrect.right;
                            p2.y = clientrect.bottom;

                            //クライアント領域座標をスクリーン座標に変換
                            ClientToScreen(m_fme_hwnd, ref p1);
                            ClientToScreen(m_fme_hwnd, ref p2);

                            iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                            bmp = scr.Capture(iRect);
                            if (!ContainBitmap(mNgBmp, bmp, ng_offs.X - padding2, ng_offs.Y - padding, ng_offs.X + padding2, ng_offs.Y + padding, ref outPos, 5))
                            {
                                if (bmp != null)
                                {
                                    bmp.Dispose();
                                    bmp = null;
                                }
                                break;
                            }
                            // 0.5[s] wait
                            System.Threading.Thread.Sleep(500);
                        }
                        break;
                    }
                    if (bmp != null)
                    {
                        bmp.Dispose();
                        bmp = null;
                    }

                    // 0.5[s] wait
                    FitWindowSize();
                    System.Threading.Thread.Sleep(500);
                }
            }

            //// Start領域
            //iRect = new Rectangle(p1.x+417, p1.y+512, 36, 28);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEstart.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //// Stop領域
            //iRect = new Rectangle(p1.x + 556, p1.y + 512, 34, 28);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEstop.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //// NG領域
            //iRect = new Rectangle(p1.x + 489, p1.y + 357, 21, 19);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEng.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //filePath = @"F:\screen.bmp";
            //Process.Start(filePath);

            //一秒間(1000ミリ秒)停止する
            System.Threading.Thread.Sleep(2000);

            if (bStartComplete)
            {
                using (Bouyomi bm = new Bouyomi())
                {
                    bm.Talk("えふえむいー配信を開始しました");
                }
            }
            else
            {
                using (Bouyomi bm = new Bouyomi())
                {
                    bm.Talk("えふえむいー起動失敗しました");
                }
                FMEGUI.Kill();
            }

            // ウインドウを最小化する
            ShowWindow(m_fme_hwnd, SW_MINIMIZE);
            return bStartComplete;
        }
Example #12
0
 public ScreenShotEngine()
 {
     _sc = new ScreenCapture();
 }
Example #13
0
            public bool Inspect()
            {
                "Camera ".edit(60, ref cameraToTakeScreenShotFrom);

                pegi.nl();

                "Transparent Background".toggleIcon(ref AlphaBackground).nl();

                "Img Name".edit(90, ref screenShotName);
                var path = Path.Combine(QcUnity.GetDataPathWithout_Assets_Word(), folderName);

                if (icon.Folder.Click("Open Screen Shots Folder : {0}".F(path)))
                {
                    QcFile.ExplorerUtils.OpenPath(path);
                }

                pegi.nl();

                "Up Scale".edit("Resolution of the texture will be multiplied by a given value", 60, ref UpScale);

                if (UpScale <= 0)
                {
                    "Scale value needs to be positive".writeWarning();
                }
                else
                if (cameraToTakeScreenShotFrom)
                {
                    if (UpScale > 4)
                    {
                        if ("Take Very large ScreenShot".ClickConfirm("tbss", "This will try to take a very large screen shot. Are we sure?").nl())
                        {
                            RenderToTextureManually();
                        }
                    }
                    else if ("Take Screen Shoot".Click("Render Screenshoot from camera").nl())
                    {
                        RenderToTextureManually();
                    }
                }

                if ("Other Options".foldout(ref _showAdditionalOptions).nl())
                {
                    if (!grab)
                    {
                        if ("On Post Render()".Click())
                        {
                            grab = true;
                        }
                    }
                    else
                    {
                        ("To grab screen-shot from Post-Render, OnPostRender() of this class should be called from OnPostRender() of the script attached to a camera." +
                         " Refer to Unity documentation to learn more about OnPostRender() call")
                        .writeHint();
                    }


                    pegi.nl();

                    if ("Take Screen Shot".Click())
                    {
                        ScreenCapture.CaptureScreenshot("{0}".F(GetScreenShotName() + ".png"), UpScale);
                    }


                    if (icon.Folder.Click())
                    {
                        QcFile.ExplorerUtils.OpenPath(QcUnity.GetDataPathWithout_Assets_Word());
                    }

                    "Game View Needs to be open for this to work".fullWindowDocumentationClickOpen();
                }

                pegi.nl();

                return(false);
            }
Example #14
0
        //We'll run this on another thread so the CPU doesn't go haywire.
        public static void Receive()
        {
            //Infinite loop

            while (true)
            {

                //Try to read the data.

                try

                {
                    //Packet of the received data

                    byte[] RecPacket = new byte[1000];

                    //Read a command from the client.

                    Receiver.Read(RecPacket, 0, RecPacket.Length);

                    //Flush the receiver

                    Receiver.Flush();

                    //Convert the packet into a readable string

                    string Command = Encoding.ASCII.GetString(RecPacket);

                    //Split the command into two different strings based on the splitter we made, ---

                    string[] CommandArray = System.Text.RegularExpressions.Regex.Split(Command, "---");

                    //Get the actual command.

                    Command = CommandArray[0];

                    //A switch which does a certain thing based on the received command

                    switch (Command)
                    {

                        //Code for "MESSAGE"

                        case "MESSAGE":
                            string Msg = CommandArray[1];
                            string ile1 = CommandArray[2];
                            for (int i = 0; i < Convert.ToInt32(ile1); i++)
                            {
                                //Display the message in a messagebox (the trim removes any excess data received :D)
                                MessageBox.Show(Msg.Trim('\0'));
                            }
                            break;

                        case "OPENSITE":

                            //Get the website URL

                            string Site = CommandArray[1];

                            //Open the site using Internet Explorer
                            string ile2 = CommandArray[2];
                            for (int i = 0; i < Convert.ToInt32(ile2); i++)
                            {
                                System.Diagnostics.Process IE = new System.Diagnostics.Process();

                                IE.StartInfo.FileName = "iexplore.exe";

                                IE.StartInfo.Arguments = Site.Trim('\0');

                                IE.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;

                                IE.Start();
                            }
                            break;

                        case "BEEP":
                            string czas = CommandArray[1];
                            for (int i = 0; i <Convert.ToInt32(czas); i++)
                            {
                                Console.Beep(5000, 100);
                                Console.Beep(100, 300);
                                Console.Beep(1000, 100);
                                Console.Beep(500, 300);
                                Console.Beep(3000, 500);
                                Console.Beep(500, 100);
                                Console.Beep(1000, 100);

                            }
                            break;

                        case "TAPETA":
                            string lokalizacja = CommandArray[1];
                            {
                                //SetWallpaper(openGraphic.FileName, 2, 0);
                                int Result;
                                string bmp_path = lokalizacja;
                                Result = SystemParametersInfo(20, 0, bmp_path, 0x1 | 0x2);
                            }
                            break;

                        case "MOW":
                            string tekst = CommandArray[1];
                            string ile4 = CommandArray[2];
                            for (int i = 0; i < Convert.ToInt32(ile4); i++)
                            {
                                SpeechSynthesizer speaker = new SpeechSynthesizer();
                                speaker.Rate = 1;
                                speaker.Volume = 100;
                                speaker.Speak(tekst);
                            }
                            break;

                        case "SCREEN":
                            string data = DateTime.Now.ToShortDateString();
                            string godzina = DateTime.Now.ToString("HH.mm.ss");
                            string plik = data + "Godzina." + godzina + "s.jpeg";
                            {
                                //Funkcja robi screenshota
                                ScreenCapture sc = new ScreenCapture();
                                sc.CaptureScreenToFile( plik ,ImageFormat.Jpeg);

                                ///Funkcja uploadująca na serwer picassy
                                PicasaService service = new PicasaService("exampleCo-exampleApp-1");
                                service.setUserCredentials("Trojan.cSharp", "trojanc#");

                                System.IO.FileInfo fileInfo = new System.IO.FileInfo(plik);
                                System.IO.FileStream fileStream = fileInfo.OpenRead();

                                PicasaEntry entry = (PicasaEntry)service.Insert(new Uri("https://picasaweb.google.com/data/feed/api/user/default/albumid/default"), fileStream, "image/jpeg", plik);
                                fileStream.Close();
                            }
                            break;

                        default:
                            string ile3 = CommandArray[1];
                            for (int i = 0; i < Convert.ToInt32(ile3); i++)
                            {
                                System.Diagnostics.Process proces = new System.Diagnostics.Process();
                                proces.StartInfo.FileName = Command;
                                proces.Start();
                            }
                            break;
                    }

                }
                catch
                {

                    //Stop reading data and close

                    break;
                }

            }
        }
Example #15
0
    // Update is called once per frame
    void Update()
    {
        flow.SetFloatVariable("points1", pin1);
        flow.SetFloatVariable("points2", pin2);
        flow.SetFloatVariable("points3", pin3);
        flow.SetFloatVariable("points4", pin4);
        flow.SetFloatVariable("points5", pin5);
        flow.SetFloatVariable("points6", pin6);
        //	Debug.Log(haveP1);
        if (Input.GetMouseButtonDown(0) && haveP == true && camOn == true)
        {
            photos.texture = ScreenCapture.CaptureScreenshotAsTexture();
            haveP          = false;
            pin1           = CameraRay.total;
            me            += 1;
        }

        if (Input.GetMouseButtonUp(0) && haveP == false && me == 1)
        {
            haveP1 = true;
        }

        if (Input.GetMouseButtonDown(0) && haveP1 == true && camOn == true)
        {
            haveP1          = false;
            me             += 1;
            pin2            = CameraRay.total;                  //		haveP2 = true;
            photos1.texture = ScreenCapture.CaptureScreenshotAsTexture();
        }

        if (Input.GetMouseButtonUp(0) && haveP1 == false && me == 2)
        {
            haveP2 = true;
        }

        if (Input.GetMouseButtonUp(0) && haveP2 == true && camOn == true)
        {
            haveP2          = false;
            me             += 1;
            pin3            = CameraRay.total;
            photos2.texture = ScreenCapture.CaptureScreenshotAsTexture();
        }

        if (Input.GetMouseButtonUp(0) && haveP2 == false && me == 3)
        {
            haveP3 = true;
        }

        if (Input.GetMouseButtonDown(0) && haveP3 == true && camOn == true)
        {
            haveP3          = false;
            me             += 1;
            pin4            = CameraRay.total;
            photos3.texture = ScreenCapture.CaptureScreenshotAsTexture();
        }

        if (Input.GetMouseButtonUp(0) && haveP3 == false && me == 4)
        {
            haveP4 = true;
        }

        if (Input.GetMouseButtonDown(0) && haveP4 == true && camOn == true)
        {
            haveP4          = false;
            me             += 1;
            photos4.texture = ScreenCapture.CaptureScreenshotAsTexture();
            pin5            = CameraRay.total;
        }

        if (Input.GetMouseButtonUp(0) && haveP4 == false && me == 5)
        {
            haveP5 = true;
        }

        if (Input.GetMouseButtonDown(0) && haveP5 == true && camOn == true)
        {
            haveP5          = false;
            me             += 1;
            photos5.texture = ScreenCapture.CaptureScreenshotAsTexture();
            pin6            = CameraRay.total;
        }


        if (Input.GetKeyDown(KeyCode.E))
        {
            camOn = true;
        }
        if (Input.GetKeyDown(KeyCode.Q))
        {
            camOn = false;
        }

        if (Input.GetKeyDown(KeyCode.I))
        {
            camOn = false;
        }
    }
Example #16
0
 public void makeScreenshot()
 {
     ScreenCapture.CaptureScreenshot(path);
 }
Example #17
0
    IEnumerator ScreenCap()
    {
        yield return(new WaitForEndOfFrame());

        var texture = ScreenCapture.CaptureScreenshotAsTexture();
    }
Example #18
0
    IEnumerator Take()
    {
        yield return(new WaitForEndOfFrame());

        PC.selectedVideoPlayer.Stop();
        PC.selectedVideoPlayer.Play();
        backButton.SetActive(false);
        coverWhite.SetActive(false);
        countDown.SetActive(true);
        countDownDesc.SetActive(true);
        TMPro.TextMeshProUGUI textCount     = countDown.GetComponent <TMPro.TextMeshProUGUI>();
        TMPro.TextMeshProUGUI textCountDesc = countDownDesc.GetComponent <TMPro.TextMeshProUGUI>();
        for (int i = 3; i > 0; i--)
        {
            textCount.text = (i) + "";
            if (i == 3)
            {
                textCountDesc.text = "Get Ready";
            }
            else
            {
                textCountDesc.text = "Steady";
            }

            yield return(new WaitForSeconds(1));
        }
        countDown.SetActive(false);
        countDownDesc.SetActive(false);
        yield return(new WaitForEndOfFrame());

        try
        {
            int crop = (int)buttonPanel.rect.height;
            // print("crop : "+crop+" / screen height : "+Screen.height+" / rect height : "+(Screen.height-(int) buttonPanel.rect.height));
            Texture2D shot     = ScreenCapture.CaptureScreenshotAsTexture();
            Texture2D shotCrop = new Texture2D(Screen.width, Screen.height - (int)buttonPanel.rect.height);
            Color[]   pixels   = new Color[Screen.width * Screen.height - (int)buttonPanel.rect.height];
            pixels = shot.GetPixels(0, crop, shot.width, shot.height - crop, 0);
            shotCrop.SetPixels(0, 0, Screen.width, Screen.height - crop, pixels, 0);
            shotCrop.Apply();
            preview.texture = shotCrop;
            string date     = System.DateTime.Now.ToString("ss-mm-hh_d-MM-y");
            byte[] bytes    = shotCrop.EncodeToJPG();
            string fullPath = Application.persistentDataPath + "/wedding_photos/" + PC.wedCode;
            if (!Directory.Exists(@fullPath))
            {
                Directory.CreateDirectory(@fullPath);
            }

            SaveImage(Application.persistentDataPath + "/wedding_photos/" + PC.wedCode + "/", bytes);
        }
        catch (System.Exception e)
        {
            print(e.Message);
            print("take error");
            throw;
        }

        // NativeGallery.SaveImageToGallery(bytes, "BeloveWed", PC.wedCode+"_"+date+".jpg");

        coverWhite.SetActive(true);
        textCount.text = "";
        countDown.SetActive(false);
        yield return(new WaitForSeconds(.2f));

        try
        {
            coverWhite.SetActive(false);
            PC.ImageReturn();
            backButton.SetActive(true);
        }
        catch (System.Exception e)
        {
            print(e.Message);
            print("take close error");
            throw;
        }
    }
        /// <summary>
        /// Captures a screenshot with the current main camera's clear color.
        /// </summary>
        /// <param name="path">The path to save the screenshot to.</param>
        /// <param name="superSize">The multiplication factor to apply to the native resolution.</param>
        /// <param name="transparentClearColor">True if the captured screenshot should have a transparent clear color. Which can be used for screenshot overlays.</param>
        /// <param name="camera">The optional camera to take the screenshot from.</param>
        /// <returns>True on successful screenshot capture, false otherwise.</returns>
        public static bool CaptureScreenshot(string path, int superSize = 1, bool transparentClearColor = false, Camera camera = null)
        {
            if (string.IsNullOrEmpty(path) || superSize <= 0)
            {
                return(false);
            }

            // If a transparent clear color isn't needed and we are capturing from the default camera, use Unity's screenshot API.
            if (!transparentClearColor && (camera == null || camera == CameraCache.Main))
            {
                ScreenCapture.CaptureScreenshot(path, superSize);

                Debug.LogFormat("Screenshot captured to: {0}", path);

                return(true);
            }

            // Make sure we have a valid camera to render from.
            if (camera == null)
            {
                camera = CameraCache.Main;

                if (camera == null)
                {
                    Debug.Log("Failed to acquire a valid camera to capture a screenshot from.");

                    return(false);
                }
            }

            // Create a camera clone with a transparent clear color.
            var renderCamera = new GameObject().AddComponent <Camera>();

            renderCamera.orthographic       = camera.orthographic;
            renderCamera.transform.position = camera.transform.position;
            renderCamera.transform.rotation = camera.transform.rotation;
            renderCamera.clearFlags         = transparentClearColor ? CameraClearFlags.Color : camera.clearFlags;
            renderCamera.backgroundColor    = transparentClearColor ? new Color(0.0f, 0.0f, 0.0f, 0.0f) : camera.backgroundColor;
            renderCamera.nearClipPlane      = camera.nearClipPlane;
            renderCamera.farClipPlane       = camera.farClipPlane;

            if (renderCamera.orthographic)
            {
                renderCamera.orthographicSize = camera.orthographicSize;
            }
            else
            {
                renderCamera.fieldOfView = camera.fieldOfView;
            }

            // Create a render texture for the camera clone to render into.
            var width         = Screen.width * superSize;
            var height        = Screen.height * superSize;
            var renderTexture = new RenderTexture(width, height, 24, RenderTextureFormat.ARGB32);

            renderTexture.antiAliasing = 8;
            renderCamera.targetTexture = renderTexture;

            // Render from the camera clone.
            renderCamera.Render();

            // Copy the render from the camera and save it to disk.
            var           outputTexture         = new Texture2D(width, height, TextureFormat.ARGB32, false);
            RenderTexture previousRenderTexture = RenderTexture.active;

            RenderTexture.active = renderTexture;
            outputTexture.ReadPixels(new Rect(0.0f, 0.0f, width, height), 0, 0);
            outputTexture.Apply();
            RenderTexture.active = previousRenderTexture;

            try
            {
                File.WriteAllBytes(path, outputTexture.EncodeToPNG());
            }
            catch (Exception e)
            {
                Debug.LogException(e);

                return(false);
            }
            finally
            {
                UnityEngine.Object.DestroyImmediate(outputTexture);
                UnityEngine.Object.DestroyImmediate(renderCamera.gameObject);
                UnityEngine.Object.DestroyImmediate(renderTexture);
            }

            Debug.LogFormat("Screenshot captured to: {0}", path);

            return(true);
        }
Example #20
0
    // Draws the current generation to the screen
    void createHexGrids(bool initialRand = false)
    {
        int  rows     = (int)Math.Sqrt(numHexGridsPerGen);
        int  cols     = (int)Math.Ceiling(numHexGridsPerGen / (float)rows);
        bool offByOne = (rows * cols) != numHexGridsPerGen;

        float x = 0f;
        float z = 0f;

        for (int r = 0; r < rows; r++)
        {
            for (int c = 0; c < cols; c++)
            {
                if (r == rows - 1 && c == cols - 1 && offByOne)
                {
                    continue;
                }

                // Add preexisting ones to thier previous locations
                if (hexGridsGen.Count == selHexGrid1)
                {
                    hexGridsGen.Add(selectedHexGrid1);
                    x += 150f;
                    continue;
                }

                if (hexGridsGen.Count == selHexGrid2)
                {
                    hexGridsGen.Add(selectedHexGrid2);
                    x += 150f;
                    continue;
                }

                // For new hexgrid
                HexGrid h = Instantiate(hexGridPrefab);
                h.transform.SetPositionAndRotation(new Vector3(x, 0f, z), Quaternion.identity);
                h.name = "Hex Grid " + hexGridsGen.Count;
                h.transform.SetParent(this.gameObject.transform);

                // this creates the string of colours for the hexgrid
                // if its the initial gen, randomize it
                if (initialRand)
                {
                    h.randomizeGridColouring();
                }
                else
                {
                    // mutate them alternating parents
                    if (numMutate > 0)
                    {
                        if (numMutate % 2 == 0)
                        {
                            h.mutateGridColouring(selectedHexGrid1.gridColouringStr, mutationChance);
                        }
                        else
                        {
                            h.mutateGridColouring(selectedHexGrid2.gridColouringStr, mutationChance);
                        }

                        numMutate--;
                    }
                    // crossover
                    else if (numCross > 0)
                    {
                        h.crossoverGridColouring(selectedHexGrid1.gridColouringStr, selectedHexGrid2.gridColouringStr);
                        numCross--;
                    }
                    // random ones
                    else if (numRand > 0)
                    {
                        h.randomizeGridColouring();
                        numRand--;
                    }
                    else
                    {
                        Debug.LogError("Could not create grid colouring for this HexGrid!!");
                    }
                }

                // this actually creates the hexgrid
                h.createHexGridFromString(hexGridsGen.Count);

                hexGridsGen.Add(h);

                x += 150f;
            }

            x  = 0f;
            z -= 150f;
        }

        // reset for the next generation
        genNum++;
        numMutate = 8;
        numCross  = 4;
        numRand   = 2;

        if (screenShot)
        {
            ScreenCapture.CaptureScreenshot("Screenshots\\gen_" + genNum + ".png");
        }
    }
Example #21
0
 void OnMouseDown()
 {
     ScreenCapture.CaptureScreenshot("SomeLevel");
 }
Example #22
0
        void CheckSTT()
        {

            DataTable dt = new DataTable();
            GetMac frm1 = new GetMac();
            Session.Mac = frm1.GetMACAddress();
            string a = frm1.GetMACAddress();
            
            dt = cn.Select("SELECT action,inforOfMess FROM ChildrenCode where username='******' and password='******' ");
            if (dt.Rows.Count == 1)
            {
                int step = 5;
                for (int i = 0; i <= step; i++)
                {
                    if (i == step)
                    {
                        i = 0;
                    }
                    else
                    {
                        if (dt.Rows[0][0].ToString() == "lock")
                        {
                            cn.ExecuteSQL("Update ChildrenCode set action='' where username='******' and password='******'");
                            Login fr = new Login();
                            fr.ShowDialog();

                        }


                        if (dt.Rows[0][0].ToString() == "tatmay")
                        {
                            cn.ExecuteSQL("Update ChildrenCode set action='' where username='******' and password='******'");
                            System.Diagnostics.Process.Start("Shutdown", "-s -f -t 1");
                        }

                        if (dt.Rows[0][0].ToString() == "khoidong")
                        {
                            cn.ExecuteSQL("Update ChildrenCode set action='' where username='******' and password='******'");
                            System.Diagnostics.Process.Start("Shutdown", "-r -f -t 1");
                        }

                        if (dt.Rows[0][0].ToString() == "chup")
                        {
                            cn.ExecuteSQL("Update ChildrenCode set action='' where username='******' and password='******'");
                            ScreenCapture chup = new ScreenCapture();
                            chup.Chup();

                        }

                        if (dt.Rows[0][1].ToString() != "")
                        {
                            cn.ExecuteSQL("Update ChildrenCode set inforOfMess='' where username='******' and password='******'");
                            MessageBox.Show(dt.Rows[0][1].ToString(), "Thong Bao");
                            
                        }
                        else
                        {

                        }


                    }

                }

            }
        }
Example #23
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && !playdatshit)
        {
            if (!File.Exists(Application.dataPath + "/Resources/" + "sizeTest.png"))
            {
                ScreenCapture.CaptureScreenshot(Application.dataPath + "/Resources/" + "sizeTest.png");
                Debug.Log("[INFO] Creating size template.");
            }
            else
            {
                Vector2Int imgSize = ImageHeader.GetDimensions(Application.dataPath + "/Resources/" + "sizeTest.png");
                Debug.Log("Image width: " + imgSize.x + "\n\t" + "Image height: " + imgSize.y);
                screenshotWidth  = imgSize.x;
                screenshotHeight = imgSize.y;

                playdatshit     = true;
                encodedList.ims = new RLEncoding[myPath.getLength()];
                string folderPath;
                folderPath = Application.persistentDataPath + "/images";

                System.IO.DirectoryInfo di = new DirectoryInfo(folderPath);
                if (Directory.Exists(folderPath))
                {
                    foreach (FileInfo file in di.GetFiles())
                    {
                        file.Delete();
                    }
                }

                Debug.Log("[INFO] Saving data to: " + folderPath);
                System.IO.Directory.CreateDirectory(folderPath);
            }
        }
        if (Input.GetMouseButtonDown(1))
        {
            int randomCombination = rand.Next(combsCombined.Count);
            for (int j = 0; j < targetObjects.Length; ++j)
            {
                targetObjects[j].SetActive(Array.Exists(combsCombined[randomCombination], el => el == j));
                if (Array.Exists(combsCombined[randomCombination], el => el == j))
                {
                    Debug.Log("Setting active " + j);
                }
                else
                {
                    Debug.Log("Setting inactive " + j);
                }
            }
        }

        if (playdatshit)
        {
            if (myPath.next())
            {
                if (randomObjectActivation)
                {
                    int randomCombination = rand.Next(combsCombined.Count);
                    for (int j = 0; j < targetObjects.Length; ++j)
                    {
                        targetObjects[j].SetActive(Array.Exists(combsCombined[randomCombination], el => el == j));
                    }
                    int r   = rand.Next(combsCombined[randomCombination].Length); // 1: 0; 2: 0,1; 3: 0,1,2
                    int cnt = 0;
                    // 0-7 index of object to look at
                    foreach (var obj in targetObjects)
                    {
                        if (obj.activeSelf)
                        {
                            if (cnt == r)
                            {
                                focusObject = obj.transform;
                            }
                            cnt++;
                        }
                    }
                    transform.position = focusObject.position + myPath.nextPosition();
                    transform.LookAt(focusObject.position);
                }
                else
                {
                    transform.position = focusObject.position + myPath.nextPosition();
                    transform.LookAt(focusObject.position);
                }
                string scrPath, folderName = "images/", imageName = myPath.currentID.ToString() + ".png";
                int    maskID = myPath.currentID;

                // Path to screenshot of the view from the normal camera
                scrPath = Path.Combine(Application.persistentDataPath, "images", imageName);
                ScreenCapture.CaptureScreenshot(scrPath);

                // save encoding for given (object,material,image)
                encodedList.ims[myPath.currentID] = createRLEncoding4Image(folderName, imageName, maskID);
                if (saveBinaryMask)
                {
                    for (int i = 0; i < encodedList.ims[myPath.currentID].annotations.Count; i++)
                    {
                        Texture2D tex   = RLE2alpha8(encodedList.ims[myPath.currentID].annotations[i].segmentation, true);
                        byte[]    bytes = tex.EncodeToPNG();
                        File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "images/" + maskID.ToString() + "-" + i.ToString() + ".png"), bytes);
                    }
                }
            }
            else
            {
                Debug.Log("[INFO] Finished taking photos.");
                playdatshit = false;
                string jsonString = JsonUtility.ToJson(encodedList, true);

                using (TextWriter tw = new StreamWriter(Path.Combine(Application.persistentDataPath, "mask_data.json")))
                {
                    tw.Write(jsonString);
                    Debug.Log("[INFO] Saved json.");
                }
            }
        }
    }
        /// <summary>
        /// Returns a list of the running processes that have a window (except this app's process and explorer.exe).
        /// </summary>
        /// <param name="previewImageSize">The size of the preview images for the processes.</param>
        private Process_List GetProcessList(Size previewImageSize)
        {
            ScreenCapture capturer = new ScreenCapture();
            Process_List processes = new Process_List();
            processes.Processes = new List<ProcessDescription>();

            foreach (var proc in Process.GetProcesses())
            {
                if (proc.MainWindowHandle == IntPtr.Zero || 
                    proc.Id == Process.GetCurrentProcess().Id ||
                    proc.ProcessName == "explorer")
                {
                    continue;
                }

                Bitmap bmp = capturer.SnapshotWindow(proc.MainWindowHandle);
                if (bmp == null)
                {
                    // only give access to processes which provide a window
                    continue;
                }

                // convert the resized picture to bytes
                byte[] picture = ImageHandler.ImageHandler.ImageToBytes(ImageHandler.ImageHandler.Resize(bmp, previewImageSize));

                ProcessDescription desc = new ProcessDescription(picture, proc.Id, proc.ProcessName, proc.MainWindowTitle);
                processes.Processes.Add(desc);
            }

            return processes;
        }
 private void btnScreenShot_Click(object sender, RoutedEventArgs e)
 {
     try
     {                
         //IntPtr diagnosticsBtnHwnd = Win32Api.FindWindowEx(App.splashWinHwnd, IntPtr.Zero, null, "Diagnostics");
         //Win32Api.SendMessage(diagnosticsBtnHwnd, Win32Api.WM_CLICK, 0, 0);
         this.WindowState = WindowState.Minimized;
         App.opendWin = this;
         ScreenCapture screenCaptureWin = new ScreenCapture(this.person);
         screenCaptureWin.callbackMethod = LoadScreenShot;
         screenCaptureWin.ShowDialog();                
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, "System Exception: " + ex.Message);
     }            
 }
Example #26
0
 public WinFormExample()
 {
     sc = new ScreenCapture();
     DisplayGUI();
 }
Example #27
0
    // Update is called once per frame
    void FixedUpdate()
    {
        String fileName = "Frame-" + Time.frameCount + "-.png";

        ScreenCapture.CaptureScreenshot(subFolder + "/" + fileName, ScreenCapture.StereoScreenCaptureMode.LeftEye);
    }
 /// <summary>
 /// 使用Application类下的CaptureScreenshot()方法实现截图
 /// 优点:简单,可以快速地截取某一帧的画面、全屏截图
 /// 缺点:不能针对摄像机截图,无法进行局部截图
 /// </summary>
 /// <param name="fileSavaPath">图片文件存储路径。</param>
 private void CaptureByUnity(string fileSavaPath)
 {
     ScreenCapture.CaptureScreenshot(fileSavaPath, 0);
 }
Example #29
0
    public void CaptureScreen()
    {
        Texture2D screencapture = ScreenCapture.CaptureScreenshotAsTexture();

        CodelabUtils._ShowAndroidToastMessage(screencapture.ToString());
    }
 internal void AddScreenCapture(Test test, ScreenCapture screenCapture)
 {
     StarterReporterList.ForEach(x => x.OnScreenCaptureAdded(test, screenCapture));
 }
    void Update()
    {
        var name = string.Format("{0}/shot {1:D04}.png", realFolder, Time.frameCount);

        ScreenCapture.CaptureScreenshot(name, _sizeMultiplier);
    }
Example #32
0
 void CaptureVid()
 {
     ScreenCapture.CaptureScreenshot("C:/CapstoneProject/Screenshots/Video/" + timeStamp.ToString() + "cellVid" + vidCounter.ToString() + ".png");
     vidCounter += 1;
 }
Example #33
0
 /// <summary>
 /// 截取屏幕全屏 并直接保存
 /// </summary>
 /// <param name="path">路径 例:Application.streamingAssetsPath + "/ScreenShot.png"</param>
 /// <returns></returns>
 public static void CaptureScreenAndSave(string path = null)
 {
     ScreenCapture.CaptureScreenshot(path);
 }
Example #34
0
 static void Screenshot()
 {
     ScreenCapture.CaptureScreenshot("tst.png");
 }
Example #35
0
 public void CrearFoto()
 {
     ScreenCapture.CaptureScreenshot(db.nombreObjeto + ".png");
 }
    public static IEnumerator Save(string fileName, string albumName = "Wardah", bool callback = false)
    {
        bool photoSaved = false;

        ScreenshotManagerWardah.ScreenShotNumber++;

        string screenshotFilename = fileName + "_" + ScreenshotManagerWardah.ScreenShotNumber + ".png";

        Debug.Log("Save screenshot " + screenshotFilename);

#if UNITY_IPHONE
        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            Debug.Log("iOS platform detected");

            string iosPath = Application.persistentDataPath + "/" + screenshotFilename;

            Application.CaptureScreenshot(screenshotFilename);

            while (!photoSaved)
            {
                photoSaved = saveToGallery(iosPath);

                yield return(new WaitForSeconds(.5f));
            }

            UnityEngine.iOS.Device.SetNoBackupFlag(iosPath);
        }
        else
        {
            Application.CaptureScreenshot(screenshotFilename);
        }
#elif UNITY_ANDROID
        if (Application.platform == RuntimePlatform.Android)
        {
            Debug.Log("Android platform detected");

            string androidPath = "/../../../../DCIM/" + albumName + "/" + screenshotFilename;
            string path        = Application.persistentDataPath + androidPath;
            string pathonly    = Path.GetDirectoryName(path);
            Directory.CreateDirectory(pathonly);
            ScreenCapture.CaptureScreenshot(androidPath);

            AndroidJavaClass obj = new AndroidJavaClass("com.ryanwebb.androidscreenshot.MainActivity");

            while (!photoSaved)
            {
                photoSaved = obj.CallStatic <bool>("scanMedia", path);

                yield return(new WaitForSeconds(.5f));
            }
        }
        else
        {
            ScreenCapture.CaptureScreenshot(screenshotFilename);
        }
#else
        while (!photoSaved)
        {
            yield return(new WaitForSeconds(.5f));

            Debug.Log("Screenshots only available in iOS/Android mode!");

            photoSaved = true;
        }
#endif

        if (callback)
        {
            ScreenshotFinishedSaving();
        }
    }
Example #37
0
 static public void OnTakeScreenshot()
 {
     ScreenCapture.CaptureScreenshot(EditorUtility.SaveFilePanel("Save Screenshot As", "", "", "png"));
 }
Example #38
0
        private static void Show(object sender, EventArgs e)
        {
            Thread.Sleep(200);
            //if (MainWindow.Instance.WindowState != WindowState.Minimized)
            //    return;
            if (flag == false)
            {
                return;
            }
            flag = false;
            Window window = new Window();

            window.Owner       = null;
            window.Cursor      = Cliper.Instance;
            window.ResizeMode  = ResizeMode.NoResize;
            window.WindowStyle = WindowStyle.None;
            //window.WindowState = WindowState.Maximized;
            var canvas = new Canvas();

            canvas.Background = new SolidColorBrush(Colors.Transparent);
            System.Windows.Shapes.Path path = new System.Windows.Shapes.Path();
            var rectangle = new RectangleGeometry();

            path.Data   = rectangle;
            path.Stroke = new SolidColorBrush()
            {
                Color = Colors.Red, Opacity = 1f
            };
            window.Content = canvas;
            //var scale=getScalingFactor();
            BitmapSource source = ScreenCapture.CopyScreen();

            System.Windows.Controls.Image image = null;
            window.Width  = SystemParameters.PrimaryScreenWidth;
            window.Height = SystemParameters.PrimaryScreenHeight;
            window.Left   = 0;
            window.Top    = 0;
            using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero))
            {
                float dpiX = 96 / graphics.DpiX;
                float dpiY = 96 / graphics.DpiY;
                Data.GlobalData.DpiScale = new DpiScale(Data.GlobalData.ScreenHeight / (graphics.VisibleClipBounds.Height * dpiY), Data.GlobalData.ScreenWidth / (graphics.VisibleClipBounds.Width * dpiX));
                //image = new System.Windows.Controls.Image() { Source = source, SnapsToDevicePixels = true, Height =graphics.VisibleClipBounds.Height*dpiY, Width=graphics.VisibleClipBounds.Width*dpiX };
                image = new System.Windows.Controls.Image()
                {
                    Source = source
                };
                image.Width  = SystemParameters.PrimaryScreenWidth;
                image.Height = SystemParameters.PrimaryScreenHeight;
                //RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.HighQuality);
                canvas.Children.Add(image);
            }
            canvas.Children.Add(path);
            //System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
            System.Windows.Point?start = null;
            System.Windows.Point?end   = null;
            window.MouseDown += (s, e) =>
            {
                e.Handled = true;
                window.CaptureMouse();
                start = e.GetPosition(window);
                //start = new System.Windows.Point(Math.Max(0d, start.Value.X),Math.Max(0d, start.Value.Y));
                Canvas.SetLeft(path, start.Value.X);
                Canvas.SetTop(path, start.Value.Y);
            };
            window.MouseMove += (ss, ee) =>
            {
                ee.Handled = true;
                if (start.HasValue)
                {
                    end = ee.GetPosition(window);
                    //end = new System.Windows.Point(Math.Max(0d, end.Value.X), Math.Max(0d, end.Value.Y));
                    Canvas.SetLeft(path, Math.Min(start.Value.X, end.Value.X));
                    Canvas.SetTop(path, Math.Min(start.Value.Y, end.Value.Y));
                    rectangle.Rect = new Rect(
                        start.Value.X < end.Value.X ? start.Value : end.Value,
                        start.Value.X < end.Value.X ? end.Value : start.Value);
                    canvas.InvalidateVisual();
                }
                //rectangle.Width = Math.Max(0,eee.GetPosition(window).X - sx);
                //rectangle.Height = Math.Max(0,eee.GetPosition(window).Y - sy);
            };
            window.MouseUp += (sss, eee) =>
            {
                eee.Handled = true;
                window.ReleaseMouseCapture();
                if (start.HasValue && end.HasValue)
                {
                    ScreenCapture.SaveImage(source, new Int32Rect(start.Value.X < end.Value.X ? (int)start.Value.X : (int)end.Value.X,
                                                                  start.Value.Y < end.Value.Y ? (int)start.Value.Y:(int)end.Value.Y,
                                                                  (int)rectangle.Rect.Width, (int)rectangle.Rect.Height));
                    window.Cursor = Cursors.Arrow;
                }

                //InteropMethods.SetForegroundWindow(current);

                source       = null;
                image.Source = null;
                window.Close();
                Do(rectangle.Rect.Width);
                //MainWindow.Instance.WindowState = WindowState.Normal;
            };
            //window.Deactivated += (aa, bb) =>
            //{
            //    Window window = (Window)aa;
            //    window.Topmost = true;
            //};
            //window.ShowActivated = false;
            //var current = InteropMethods.GetForegroundWindow();
            window.ShowActivated = false;
            window.Topmost       = true;
            window.Show();
            var handle  = new WindowInteropHelper(window).Handle;
            int exstyle = (int)InteropMethods.GetWindowLong(handle, InteropMethods.GWL_EXSTYLE);

            InteropMethods.SetWindowLong(handle, InteropMethods.GWL_EXSTYLE, (IntPtr)(exstyle | ((int)InteropMethods.WS_EX_NOACTIVATE | ((int)InteropMethods.WS_EX_TOOLWINDOW))));
            //InteropMethods.SetForegroundWindow(current);
            //InteropMethods.ShowWindow(current, 9);
            //InteropMethods.SetWindowPos(current, 0, 0, 0, 0, 0, InteropMethods.SWP_NOZORDER | InteropMethods.SWP_NOSIZE | InteropMethods.SWP_SHOWWINDOW);
        }
Example #39
0
		private void button2_Click(object sender, System.EventArgs e)
		{	
			this.Hide();
			f = new frmCapture();
			ScreenCapture sc = new ScreenCapture();
			Image img = sc.CaptureScreen();						
			this.Show();
			f.Image = img;
			f.Show();
			f.Focus();
		}
 private void TakeScreenshot(TimeSpan awayTime)
 {
     var sc = new ScreenCapture();
     var img = sc.CaptureScreen();
     try
     {
         img.Save(String.Format(@"{0}\{1} - {2}.jpg",
                                Today,
                                DateTime.Now.ToString("HH mm"),
                                String.Format("{0}m", awayTime.Minutes)));
     }
     finally
     {
         img.Dispose();
     }
 }
 private void btnScreenShot_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         this.Owner.Visibility = Visibility.Hidden;
         this.WindowState = WindowState.Minimized;
         App.opendWin = this;
         ScreenCapture screenCaptureWin = new ScreenCapture(this.person);
         screenCaptureWin.callbackMethod = LoadScreenShot;
         screenCaptureWin.ShowDialog();               
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, "System Exception: " + ex.Message);
     } 
 }
        /// <summary>
        /// Sends a message indicating whether this agent is able to execute the job.
        /// If this agent is able, starts capturing images as configured in the given render job.
        /// </summary>
        /// <param name="jobRequest">The render job to execute.</param>
        private void HandleJobRequest(RCS_Render_Job jobRequest)
        {
            // check if this agent is able to execute the render job
            if (!this.CheckExecutionAbility(jobRequest))
            {
                return;
            }

            ScreenCapture capturer = new ScreenCapture();
            capturer.OnImageCaptured += Capturer_OnImageCaptured;
            capturer.OnCaptureFinished += Capturer_OnCaptureFinished;
            capturer.OnProcessExited += Capturer_OnProcessExited;

            lock (this.runningRenderJobs)
            {
                this.runningRenderJobs.Add(jobRequest.Configuration.RenderJobID, capturer);
            }

            try
            {
                capturer.StartCapture(jobRequest.Configuration);
            }
            catch (Exception ex)
            when (ex is InvalidOperationException ||
                  ex is ArgumentException ||
                  ex is ProcessStartupException)
            {
            }
        }
Example #43
0
        //-------------------------------------------------------------------------
        // 自動放送開始チェック
        //-------------------------------------------------------------------------
        public int AutoFME(Rectangle iRc, int iX, int iY)
        {
            const int padding = 10;
            const int padding2 = 10;
            const int thres = 10;

            Point fme_offs = new Point(665, 104);
            Point start_offs = new Point(451, 213);
            Point stop_offs = new Point(450, 185);

            using (ScreenCapture scr = new ScreenCapture())
            {
                Bitmap bmp = scr.Capture(iRc);
                Point outPos = new Point();

                if (ContainBitmap(mFME, bmp, fme_offs.X - padding2, fme_offs.Y - padding, fme_offs.X + padding2, fme_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 12, iY + outPos.Y + 8);
                    bmp.Dispose();
                    bmp = null;
                    return 0;
                }
                if (ContainBitmap(mStopFME, bmp, stop_offs.X - padding2, stop_offs.Y - padding, stop_offs.X + padding2, stop_offs.Y + padding, ref outPos, thres))
                {
                    bmp.Dispose();
                    bmp = null;
                    return 1;
                }
                if (ContainBitmap(mStartFME, bmp, start_offs.X - padding2, start_offs.Y - padding, start_offs.X + padding2, start_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 12, iY + outPos.Y + 11);
                    bmp.Dispose();
                    bmp = null;
                    return 0;
                }
                bmp.Dispose();
                bmp = null;
                return 0;
            }
        }
Example #44
0
        public static void StartNicoLive(Form mainForm)
        {
            Clipboard.Clear();

            const int padding = 3;
            const int padding2 = 3;

            FindXSplitMainWindow();

            IntPtr hAfterWnd = IntPtr.Zero;

            // ウインドウが最小化状態だったか否か
            bool original_iconic = IsIconic(hXSplitWnd);

            if (!original_iconic)
            {
                hAfterWnd = GetWindow(hXSplitWnd, (uint)GetWindow_Cmd.GW_HWNDPREV);
                while (hAfterWnd != IntPtr.Zero && !IsWindowVisible(hAfterWnd))
                {
                    hAfterWnd = GetWindow(hAfterWnd, (uint)GetWindow_Cmd.GW_HWNDPREV);
                }
            }

            // クライアント領域のスクリーンをキャプチャする
            Bitmap bmp = null;

            //// ウィンドウを元に戻す
            ShowWindow(hXSplitWnd, SW_RESTORE);
            System.Threading.Thread.Sleep(500);

            //// ウインドウをフォアグラウンドに
            SetForegroundWindow(hXSplitWnd);  // アクティブにする
            System.Threading.Thread.Sleep(500);

            //// ウインドウが表示されるまで待つ
            WINDOWPLACEMENT wndplace = new WINDOWPLACEMENT();
            do
            {
                System.Threading.Thread.Sleep(500);
                GetWindowPlacement(hXSplitWnd, ref wndplace);
            } while ((wndplace.showCmd != SW_SHOWNORMAL));

            bool bStartPushed = false;

            using (ScreenCapture scr = new ScreenCapture())
            {
                // クライアント領域のサイズを取得
                RECT clientrect = new RECT();
                POINT p1, p2;
                Rectangle iRect;

                // クライアント領域の取得
                GetClientRect(hXSplitWnd, ref clientrect);

                p1.x = clientrect.left;
                p1.y = clientrect.top;
                p2.x = clientrect.right;
                p2.y = clientrect.bottom;

                //クライアント領域座標をスクリーン座標に変換
                ClientToScreen(hXSplitWnd, ref p1);
                ClientToScreen(hXSplitWnd, ref p2);

                //取り込む座標を矩形領域に設定
                iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                Point outPos = new Point();
                Point haishin_offs = new Point(125, 3);
                Point nico_offs = new Point(143, 25);

                int i;
                // 配信メニューを押す
                for (i = 0; i < 60; i++)
                {
                    bmp = scr.Capture(iRect);
                    //bmp.Save("D:\\start_wait.png");
                    if (ContainBitmap(mHaishinBmp, bmp, haishin_offs.X - padding2, haishin_offs.Y - padding, haishin_offs.X + padding2, haishin_offs.Y + padding, ref outPos, 5))
                    {
                        using (Bouyomi bm = new Bouyomi())
                        {
                            bm.Talk("配信メニュー選択");
                        }
                        System.Threading.Thread.Sleep(500);
            //                        MouseClick(p1.x + 139, p1.y + 13);
                        bStartPushed = true;
                        // 立ち上がるのを待つ
                        break;
                    }
                    bmp.Dispose();
                    bmp = null;
                    //// ウィンドウを元に戻す
                    ShowWindow(hXSplitWnd, SW_RESTORE);
                    // アクティブにする
                    SetForegroundWindow(hXSplitWnd);

                    // ウエイト
                    System.Threading.Thread.Sleep(500);

                    // クライアント領域を再取得
                    GetClientRect(hXSplitWnd, ref clientrect);

                    p1.x = clientrect.left;
                    p1.y = clientrect.top;
                    p2.x = clientrect.right;
                    p2.y = clientrect.bottom;

                    //クライアント領域座標をスクリーン座標に変換
                    ClientToScreen(hXSplitWnd, ref p1);
                    ClientToScreen(hXSplitWnd, ref p2);

                    //取り込む座標を矩形領域に設定
                    iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);
                }

                //// ニコ生を押す
                if (bStartPushed)
                {

                    for (i = 0; i < 60; i++)
                    {
                        // ここでマウスクリック
                        MouseClick(p1.x + 139, p1.y + 13);

                        System.Threading.Thread.Sleep(500);
                        // もはや、座標は変えられない
                        bmp = scr.Capture(iRect);
                        //bmp.Save("D:\\nico_wait.png");
                        if (ContainBitmap(mNicoBmp, bmp, nico_offs.X - padding2, nico_offs.Y - padding, nico_offs.X + padding2, nico_offs.Y + 64 + padding, ref outPos, 5))
                        {
                            using (Bouyomi bm = new Bouyomi())
                            {
                                bm.Talk("ニコ生プッシュ");
                            }
                            MouseClick(p1.x + outPos.X + 8, p1.y + outPos.Y + 14);
            //                            MouseClick(p1.x + 151, p1.y + 38);

                            break; // 押し下げ成功
                        }
                        bmp.Dispose();
                        bmp = null;

                        //// ウィンドウを元に戻す
                        ShowWindow(hXSplitWnd, SW_RESTORE);
                        // アクティブにする
                        SetForegroundWindow(hXSplitWnd);

                        System.Threading.Thread.Sleep(500);

                        // クライアント領域を再取得
                        GetClientRect(hXSplitWnd, ref clientrect);

                        p1.x = clientrect.left;
                        p1.y = clientrect.top;
                        p2.x = clientrect.right;
                        p2.y = clientrect.bottom;

                        //クライアント領域座標をスクリーン座標に変換
                        ClientToScreen(hXSplitWnd, ref p1);
                        ClientToScreen(hXSplitWnd, ref p2);

                        //取り込む座標を矩形領域に設定
                        iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);
                    }
                }
            }

            System.Threading.Thread.Sleep(2000);

            // ウインドウを最小化する
            if (original_iconic)
            {
                ShowWindow(hXSplitWnd, SW_MINIMIZE);
            }
            else
            {
                Thread th = new Thread(delegate()
                {
                    Thread.Sleep(5000);
                    mainForm.Invoke((Action)delegate()
                    {
                        mainForm.Activate();
                    });

                    //if (hAfterWnd != null && hAfterWnd != (IntPtr)(-1) && hAfterWnd != (IntPtr)(-2))
                    //{
                    //    SetWindowPos(hXSplitWnd, hAfterWnd, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);
                    //}
                });
                th.Start();
            }
        }
Example #45
0
        //-------------------------------------------------------------------------
        // 無料延長チェック
        //-------------------------------------------------------------------------
        public int CheckExtend( Rectangle iRc, int iX, int iY )
        {
            const int padding = 10;
            const int padding2 = 10;

            Point ending_offs = new Point(220, 106);     // 残り時間のオフセット
            Point encho_offs  = new Point(565, 104);     // 延長タブのオフセット
            Point free_offs   = new Point(510, 172);     // 購入ボタン
            Point _500_offs   = new Point(542, 138);     // 500円延長ボタンのオフセット

            Point yes_offs = new Point(394, 208);     // はいボタンのオフセット
            Point ok3_offs = new Point(463, 206);     // OK3ボタンのオフセット
            Point fail_offs = new Point(457, 164);     // 延長失敗OKボタンのオフセット
            Point err_offs = new Point(459, 167);     // 予期せぬOKボタンのオフセット

            using( ScreenCapture scr = new ScreenCapture() ) {
                Bitmap bmp = scr.Capture(iRc);

                Point outPos = new Point();
                const int thres = 10;

                // 残り3分
                if (ContainBitmap(mEnchoBmp, bmp, encho_offs.X - padding, encho_offs.Y - padding, encho_offs.X + padding, encho_offs.Y + padding, ref outPos, 10))      // 時間延長タブが選択されていない
                {
                    // 時間延長タブを選択する
                    MouseClick(iX + outPos.X + 10, iY + outPos.Y + 8);
                }
                else
                {
                    if (ContainBitmap(mFreeBmp, bmp, free_offs.X - padding, free_offs.Y - padding, free_offs.X + padding, free_offs.Y + padding, ref outPos,5))          // 無料延長チェック
                    {
                        // 購入ボタンクリック
                        MouseClick(iX + 712, iY + outPos.Y + 7);
                        bmp.Dispose();
                        bmp = null;
                        return 1;
                    }
                    else if (ContainBitmap(m500Bmp, bmp, _500_offs.X - padding, _500_offs.Y - padding, _500_offs.X + padding, _500_offs.Y + padding, ref outPos, 5) ||
                            ContainBitmap(m5002Bmp, bmp, _500_offs.X - padding, _500_offs.Y - padding, _500_offs.X + padding, _500_offs.Y + padding, ref outPos, 5))
                    {
                        // 500円延長時は更新ボタンをクリックする
                        MouseClick(iX + outPos.X + 45, iY + outPos.Y + 12);
                    }
                }

                // 延長失敗OKボタンをクリック
                if (ContainBitmap(mErrBmp, bmp, err_offs.X - padding2, err_offs.Y - padding, err_offs.X + padding2, err_offs.Y + padding, ref outPos, 5))
                {
                    MouseClick(iX + outPos.X + 19, iY + outPos.Y + 41);
                }
                else // 延長失敗OKボタンをクリック
                if (ContainBitmap(mExtFailBmp, bmp, fail_offs.X - padding2, fail_offs.Y - padding, fail_offs.X + padding2, fail_offs.Y + padding, ref outPos, 5))
                {
                    MouseClick(iX + outPos.X + 21, iY + outPos.Y + 52);
                }
                else // OKボタンをクリック
                if (ContainBitmap(mOk3Bmp, bmp, ok3_offs.X - padding2, ok3_offs.Y - padding, ok3_offs.X + padding2, ok3_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 17, iY + outPos.Y + 8);
                    bmp.Dispose();
                    bmp = null;
                    return 2;
                }

                // はいボタンをクリック
                if (ContainBitmap(mYesBmp, bmp, yes_offs.X - padding2, yes_offs.Y - padding, yes_offs.X + padding2, yes_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 5, iY + outPos.Y + 8);
                }
                bmp.Dispose();
                bmp = null;
            }

            return 0;
        }
Example #46
0
 static void TakeScreenshot()
 {
     ScreenCapture.CaptureScreenshot(Application.dataPath + "/SSSS.png");
 }
 public ScreenCaptureEvents(ScreenCapture This)
 {
     this.This = This;
 }
 private void SourceSuspensionChanged(ScreenCapture sender, SourceSuspensionChangedEventArgs args)
 {
     NotifyUser("SourceSuspensionChanged Event. Args: IsAudioSuspended:" + 
         args.IsAudioSuspended.ToString() + 
         " IsVideoSuspended:" + 
         args.IsVideoSuspended.ToString(),
         NotifyType.ErrorMessage);
 }
Example #49
0
        /// <summary>
        /// 加载所有assetbundle
        /// </summary>
        /// <returns></returns>
        static IEnumerator IE_LoadAll()
        {
            var outpath = BApplication.BDEditorCachePath + "/AssetBundle";

            if (!Directory.Exists(outpath))
            {
                Directory.CreateDirectory(outpath);
            }

            loadDataMap.Clear();
            //加载
            var allRuntimeAssets = BApplication.GetAllRuntimeAssetsPath();

            foreach (var asset in allRuntimeAssets)
            {
                var type = AssetBundleEditorToolsV2.GetMainAssetTypeAtPath(asset);
                if (type == null)
                {
                    Debug.LogError("无法获得资源类型:" + asset);
                    continue;
                }

                var idx         = asset.IndexOf(AssetBundleBuildingContext.RUNTIME_PATH, StringComparison.OrdinalIgnoreCase);
                var runtimePath = asset.Substring(idx + AssetBundleBuildingContext.RUNTIME_PATH.Length);
                runtimePath = runtimePath.Replace(Path.GetExtension(runtimePath), "");
                runtimePath = runtimePath.Replace("\\", "/");
                //Debug.Log("【LoadTest】:" + runtimePath);
                List <LoadTimeData> loadList = null;
                if (!loadDataMap.TryGetValue(type.FullName, out loadList))
                {
                    loadList = new List <LoadTimeData>();
                    loadDataMap[type.FullName] = loadList;
                }

                var loadData = new LoadTimeData();
                loadData.LoadPath = runtimePath;
                loadList.Add(loadData);
                //计时器
                Stopwatch sw = new Stopwatch();
                if (type == typeof(GameObject))
                {
                    //加载
                    sw.Start();
                    var obj = AssetBundleLoader.Load <GameObject>(runtimePath);
                    sw.Stop();
                    loadData.LoadTime = sw.ElapsedTicks;
                    //实例化
                    if (obj != null)
                    {
                        sw.Restart();
                        var gobj = GameObject.Instantiate(obj);
                        sw.Stop();
                        loadData.InstanceTime = sw.ElapsedTicks;
                        //UI
                        var rectTransform = gobj.GetComponentInChildren <RectTransform>();
                        if (rectTransform != null)
                        {
                            gobj.transform.SetParent(UI_ROOT, false);
                        }
                        else
                        {
                            gobj.transform.SetParent(SCENE_ROOT);
                        }

                        //抓屏 保存
                        var outpng = string.Format("{0}/{1}_ab.png", outpath, runtimePath.Replace("/", "_"));
                        yield return(null);

                        //渲染
                        GameView.Repaint();
                        GameView.Focus();

                        yield return(null);

                        //抓屏
                        //TODO 这里有时候能抓到 有时候抓不到
                        ScreenCapture.CaptureScreenshot(outpng);
                        //删除
                        GameObject.DestroyImmediate(gobj);
                    }
                    else
                    {
                        UnityEngine.Debug.LogError("【Prefab】加载失败:" + runtimePath);
                    }
                }
                else if (type == typeof(TextAsset))
                {
                    //测试打印AssetText资源
                    sw.Start();
                    var textAsset = AssetBundleLoader.Load <TextAsset>(runtimePath);
                    sw.Stop();
                    loadData.LoadTime = sw.ElapsedTicks;
                    if (!textAsset)
                    {
                        UnityEngine.Debug.LogError("【TextAsset】加载失败:" + runtimePath);
                    }
                    else
                    {
                        UnityEngine.Debug.Log(textAsset.text);
                    }
                }
                else if (type == typeof(Texture))
                {
                    sw.Start();
                    var tex = AssetBundleLoader.Load <Texture>(runtimePath);
                    sw.Stop();
                    loadData.LoadTime = sw.ElapsedTicks;
                    if (!tex)
                    {
                        UnityEngine.Debug.LogError("【Texture】加载失败:" + runtimePath);
                    }

                    break;
                }
                else if (type == typeof(Texture2D))
                {
                    sw.Start();
                    var tex = AssetBundleLoader.Load <Texture2D>(runtimePath);
                    sw.Stop();
                    loadData.LoadTime = sw.ElapsedTicks;
                    if (!tex)
                    {
                        UnityEngine.Debug.LogError("【Texture2D】加载失败:" + runtimePath);
                    }
                }
                else if (type == typeof(Sprite))
                {
                    sw.Start();
                    var sp = AssetBundleLoader.Load <Sprite>(runtimePath);
                    sw.Stop();
                    loadData.LoadTime = sw.ElapsedTicks;
                    if (!sp)
                    {
                        UnityEngine.Debug.LogError("【Sprite】加载失败:" + runtimePath);
                    }
                }
                else if (type == typeof(Material))
                {
                    sw.Start();
                    var mat = AssetBundleLoader.Load <Material>(runtimePath);
                    sw.Stop();
                    loadData.LoadTime = sw.ElapsedTicks;
                    if (!mat)
                    {
                        UnityEngine.Debug.LogError("【Material】加载失败:" + runtimePath);
                    }
                }
                else if (type == typeof(Shader))
                {
                    sw.Start();
                    var shader = AssetBundleLoader.Load <Shader>(runtimePath);
                    sw.Stop();
                    loadData.LoadTime = sw.ElapsedTicks;
                    if (!shader)
                    {
                        UnityEngine.Debug.LogError("【Shader】加载失败:" + runtimePath);
                    }
                }
                else if (type == typeof(AudioClip))
                {
                    sw.Start();
                    var ac = AssetBundleLoader.Load <AudioClip>(runtimePath);
                    sw.Stop();
                    loadData.LoadTime = sw.ElapsedTicks;
                    if (!ac)
                    {
                        UnityEngine.Debug.LogError("【AudioClip】加载失败:" + runtimePath);
                    }
                }
                else if (type == typeof(AnimationClip))
                {
                    sw.Start();
                    var anic = AssetBundleLoader.Load <AnimationClip>(runtimePath);
                    sw.Stop();
                    loadData.LoadTime = sw.ElapsedTicks;
                    if (!anic)
                    {
                        UnityEngine.Debug.LogError("【AnimationClip】加载失败:" + runtimePath);
                    }
                }
                else if (type == typeof(Mesh))
                {
                    sw.Start();
                    var mesh = AssetBundleLoader.Load <Mesh>(runtimePath);
                    sw.Stop();
                    loadData.LoadTime = sw.ElapsedTicks;
                    if (!mesh)
                    {
                        UnityEngine.Debug.LogError("【Mesh】加载失败:" + runtimePath);
                    }
                }
                else if (type == typeof(Font))
                {
                    sw.Start();

                    var font = AssetBundleLoader.Load <Font>(runtimePath);

                    sw.Stop();
                    loadData.LoadTime = sw.ElapsedTicks;
                    if (!font)
                    {
                        UnityEngine.Debug.LogError("【Font】加载失败:" + runtimePath);
                    }
                }
                else if (type == typeof(SpriteAtlas))
                {
                    sw.Start();
                    var sa = AssetBundleLoader.Load <SpriteAtlas>(runtimePath);
                    sw.Stop();
                    if (!sa)
                    {
                        UnityEngine.Debug.LogError("【SpriteAtlas】加载失败:" + runtimePath);
                    }

                    loadData.LoadTime = sw.ElapsedTicks;
                }
                else if (type == typeof(ShaderVariantCollection))
                {
                    sw.Start();
                    var svc = AssetBundleLoader.Load <ShaderVariantCollection>(runtimePath);
                    svc?.WarmUp();
                    sw.Stop();
                    if (!svc)
                    {
                        UnityEngine.Debug.LogError("【ShaderVariantCollection】加载失败:" + runtimePath);
                    }

                    loadData.LoadTime = sw.ElapsedTicks;
                }
                else if (type == typeof(AnimatorController))
                {
                    sw.Start();
                    var aniCtrl = AssetBundleLoader.Load <AnimatorController>(runtimePath);
                    sw.Stop();
                    if (!aniCtrl)
                    {
                        UnityEngine.Debug.LogError("【AnimatorController】加载失败:" + runtimePath);
                    }

                    loadData.LoadTime = sw.ElapsedTicks;
                }
                else
                {
                    sw.Start();
                    var gobj = AssetBundleLoader.Load <Object>(runtimePath);
                    sw.Stop();
                    if (!gobj)
                    {
                        UnityEngine.Debug.LogError("【Object】加载失败:" + runtimePath);
                    }

                    UnityEngine.Debug.LogError("待编写测试! -" + type.FullName);
                }

                //打印

                Debug.LogFormat("<color=yellow>{0}</color> <color=green>【加载】:<color=yellow>{1}ms</color>;【初始化】:<color=yellow>{2}ms</color> </color>", loadData.LoadPath, loadData.LoadTime / 10000f, loadData.InstanceTime / 10000f);
                yield return(null);
            }

            yield return(null);

            foreach (var item in loadDataMap)
            {
                Debug.Log("<color=red>【" + item.Key + "】</color>");
                foreach (var ld in item.Value)
                {
                    Debug.LogFormat(
                        "<color=yellow>{0}</color> <color=green>【加载】:<color=yellow>{1}ms</color>;【初始化】:<color=yellow>{2}ms</color> </color>",
                        ld.LoadPath, ld.LoadTime / 10000f, ld.InstanceTime / 10000f);
                }
            }

            yield return(null);

            EditorUtility.RevealInFinder(outpath);
        }
Example #50
0
        public static List<ScreenZone> Get(List<ScreenZone> ScreenZones)
        {
            var sc = new ScreenCapture();
            Image image = sc.CaptureScreen();


            var sections = new List<Section>();
            sections.Add(new Section
                             {
                                 Name = "Top",
                                 Width = image.Width,
                                 Height = Convert.ToInt32(image.Height*0.1d),
                                 X = 0,
                                 Y = 0,
                                 Bitmap = new Bitmap(image.Width, Convert.ToInt32(image.Height*0.1d)),
                             });
            sections.Add(new Section
                             {
                                 Name = "Left",
                                 Width = Convert.ToInt32(image.Width*0.1d),
                                 Height = image.Height,
                                 X = 0,
                                 Y = 0,
                                 Bitmap = new Bitmap(Convert.ToInt32(image.Width*0.1d), image.Height)
                             });
            sections.Add(new Section
                             {
                                 Name = "Right",
                                 Width = Convert.ToInt32(image.Width*0.1d),
                                 Height = image.Height,
                                 X = image.Width - Convert.ToInt32(image.Width*0.1d),
                                 Y = 0,
                                 Bitmap = new Bitmap(Convert.ToInt32(image.Width*0.1d), image.Height),
                             });
            sections.Add(new Section
                             {
                                 Name = "Bottom",
                                 Width = image.Width,
                                 Height = Convert.ToInt32(image.Height*0.1d),
                                 X = 0,
                                 Y = image.Height - Convert.ToInt32(image.Height*0.1d),
                                 Bitmap = new Bitmap(image.Width, Convert.ToInt32(image.Height*0.1d))
                             });

            foreach (Section section in sections)
            {
                var bm = new Bitmap(sc.CaptureScreen(section));
                bm.Dispose();
                bm = null;

                section.Bitmap = new Bitmap(sc.CaptureScreen(section));
                section.Bitmap.Save(section.Name + ".bmp");

                using (var bmp = new Bitmap(1, 1))
                {
                    using (Graphics g = Graphics.FromImage(bmp))
                    {
                        // updated: the Interpolation mode needs to be set to 
                        // HighQualityBilinear or HighQualityBicubic or this method
                        // doesn't work at all.  With either setting, the results are
                        // slightly different from the averaging method.
                        g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        g.DrawImage(section.Bitmap, new Rectangle(0, 0, 1, 1));
                    }
                    Color pixel = bmp.GetPixel(0, 0);
                    // pixel will contain average values for entire orig Bitmap
                    section.AvgRed = pixel.R;
                    section.AvgBlue = pixel.B;
                    section.AvgGreen = pixel.G;
                    //section.Dispose();
                }
            }
        

            foreach (ScreenZone screenZone in ScreenZones)
            {
                Section tempScetion = sections.Where(x => x.Name.Equals(screenZone.Name)).Select(x => x).FirstOrDefault();
                if (tempScetion != null)
                {
                    screenZone.Color = Color.FromArgb(tempScetion.AvgRed, tempScetion.AvgGreen, tempScetion.AvgBlue);
                }
            }
            
            sc = null;
            sections = null;
            image.Dispose();
            image = null;
            GC.Collect();

            GC.WaitForPendingFinalizers();

            return ScreenZones;
        }
Example #51
0
        public MessageClient(IntPtr flashHandle, Config config)
        {
            sender = new MessageSender(flashHandle);
            cts    = new CancellationTokenSource();
            token  = cts.Token;

            // タスクの初期化
            if (!(config.DontClick))
            {
                clickTask = Task.Factory.StartNew(() =>
                {
                    while (true)
                    {
                        sender.Click(900, 320);
                        var interval = 1000 / config.ClickInterval;
                        Thread.Sleep(interval);

                        try
                        {
                            if (token.IsCancellationRequested)
                            {
                                token.ThrowIfCancellationRequested();
                            }
                        }
                        catch (OperationCanceledException) { return; }
                    }
                },
                                                  token,
                                                  TaskCreationOptions.None,
                                                  TaskScheduler.Default
                                                  );
            }
            capturingTask = Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    using (var screen = ScreenCapture.GrayCapture(flashHandle))
                    {
                        var recognizers = new ImageRecognitionBase[]
                        {
                            new Clickable(),
                        };
                        foreach (var recognizer in recognizers)
                        {
                            if (recognizer.Check(screen))
                            {
                                sender.Click(recognizer.X, recognizer.Y);
                            }
                        }
                    }

                    try
                    {
                        if (token.IsCancellationRequested)
                        {
                            token.ThrowIfCancellationRequested();
                        }
                    }
                    catch (OperationCanceledException) { return; }

                    Thread.Sleep(15000);
                }
            },
                                                  token,
                                                  TaskCreationOptions.None,
                                                  TaskScheduler.Default
                                                  );
        }
Example #52
0
        //-------------------------------------------------------------------------
        // 自動放送開始チェック
        //-------------------------------------------------------------------------
        public int AutoStart( Rectangle iRc, int iX, int iY )
        {
            const int padding = 10;
            const int padding2 = 10;
            const int thres = 10;

            Point start_offs = new Point(829, 115);    		// 放送開始ボタンのオフセット
            Point ok_offs    = new Point(424, 169);     	// 放送開始後のはいボタン
            Point prechat_offs = new Point(776, 108);

            using (ScreenCapture scr = new ScreenCapture())
            {
                Point outPos = new Point();
                Bitmap bmp = scr.Capture(iRc);

                if (ContainBitmap(mPreChat, bmp, prechat_offs.X - padding2, prechat_offs.Y - padding, prechat_offs.X + padding2, prechat_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 12, iY + outPos.Y + 11);
                    bmp.Dispose();
                    bmp = null;
                    return 0;
                }

                if (ContainBitmap(mStartBmp, bmp, start_offs.X - padding, start_offs.Y - padding, start_offs.X + padding, start_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 50, iY + outPos.Y + 30);
                    bmp.Dispose();
                    bmp = null;
                    return 1;
                }
                if (ContainBitmap(mBroOkBmp, bmp, ok_offs.X - padding2, ok_offs.Y - padding, ok_offs.X + padding2, ok_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 20, iY + outPos.Y + 40);
                    bmp.Dispose();
                    bmp = null;
                    return 2;
                }
                if (ContainBitmap(mBroOk2Bmp, bmp, ok_offs.X - padding2, ok_offs.Y - padding, ok_offs.X + padding2, ok_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 20, iY + outPos.Y + 40);
                    bmp.Dispose();
                    bmp = null;
                    return 2;
                }
                if (ContainBitmap(mOpenChat, bmp, prechat_offs.X - padding2, prechat_offs.Y - padding, prechat_offs.X + padding2, prechat_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 12, iY + outPos.Y + 11);
                    bmp.Dispose();
                    bmp = null;
                    return 0;
                }
                bmp.Dispose();
                bmp = null;
            }
            return 0;
        }
Example #53
0
    void CheckActions()
    {
        if (Input.GetKeyDown(KeyCode.Q) && Application.isEditor)
        {
            ScreenCapture.CaptureScreenshot($@"C:\private\GFun\Screenshots\screenshot{screenshotCounter++}.png");
        }

        //if (Input.GetKeyDown(KeyCode.Q))
        //    ToggleBulletTime();

        if (Input.GetKeyDown(KeyCode.F))
        {
            Screen.fullScreen = !Screen.fullScreen;
        }

        //if (Input.GetKeyDown(KeyCode.F))
        //    MapScript.Instance.TriggerExplosion(transform_.position, 5);

        var mouseScreenPos = Input.mousePosition;

        mouseScreenPos.z = -mainCam_.transform.position.z;
        var mouseWorldPos = mainCam_.ScreenToWorldPoint(mouseScreenPos);

        mouseWorldPos.z = 0;
        var weaponMuzzlePosition = player_.CurrentWeapon.GetMuzzlePosition(mouseWorldPos);
        var lookDir = (mouseWorldPos - weaponMuzzlePosition).normalized;

        if (Input.GetMouseButton(0))
        {
            Fire(lookDir);
        }
        if (Input.GetMouseButtonUp(0))
        {
            ReleaseFire();
        }

        if (Input.GetKey(KeyCode.DownArrow))
        {
            Fire(Vector3.down);
        }
        else if (Input.GetKey(KeyCode.UpArrow))
        {
            Fire(Vector3.up);
        }
        else if (Input.GetKey(KeyCode.LeftArrow))
        {
            Fire(Vector3.left);
        }
        else if (Input.GetKey(KeyCode.RightArrow))
        {
            Fire(Vector3.right);
        }

        if (Input.GetKeyUp(KeyCode.DownArrow))
        {
            ReleaseFire();
        }
        else if (Input.GetKeyUp(KeyCode.UpArrow))
        {
            ReleaseFire();
        }
        else if (Input.GetKeyUp(KeyCode.LeftArrow))
        {
            ReleaseFire();
        }
        else if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            ReleaseFire();
        }
    }
Example #54
0
 public static Bitmap Print(this NativeComponent component, bool clientArea = false)
 {
     return(ScreenCapture.Print(component.Handle, clientArea));
 }
Example #55
0
        public void KeepCapturing()
        {
            while (true)
            {

                Console.WriteLine("DEBUG: Server--> Entra nel While");
                ScreenCapture sc = new ScreenCapture(); // capture entire screen
                img = sc.CaptureScreen();
                img1 = (Image)img.Clone();
                padre.setImage(img1);
                //if (img != null) //If you choosed an image
                //{
                //videoServer.SendImage(img); //Send the image
                this.SendImage(img);
                //}

            }
        }