Esempio n. 1
0
        public CaptureStrategy GetStrategy(CaptureType captureType, MainForm mainForm)
        {
            CaptureStrategy strategy = null;

            switch (captureType)
            {
                case CaptureType.Screen:
                    strategy = new CaptureScreen(mainForm);
                    break;
                case CaptureType.ActiveWindow:
                    strategy = new CaptureActiveWindow(mainForm);
                    break;
                case CaptureType.ActiveMonitor:
                    strategy = new CaptureActiveMonitor(mainForm);
                    break;
                case CaptureType.Rectangle:
                case CaptureType.RectangleWindow:
                case CaptureType.Polygon:
                case CaptureType.Freehand:
                    strategy = new CaptureRegion(mainForm);
                    break;
                case CaptureType.CustomRegion:
                    strategy = new CaptureCustomRegion(mainForm);
                    break;
                case CaptureType.LastRegion:
                    strategy = new CaptureLastRegion(mainForm);
                    break;
            }
            return strategy;
        }
Esempio n. 2
0
        /// <summary>
        ///   Draws the click animation into a Graphics object.
        /// </summary>
        ///
        public void Draw(Graphics graphics)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            if (currentRadius <= Threshold)
            {
                return;
            }

            if (!CaptureRegion.Contains(currentLocation))
            {
                return;
            }

            relativeLocation.X = currentLocation.X - CaptureRegion.X;
            relativeLocation.Y = currentLocation.Y - CaptureRegion.Y;

            drawCircle(graphics);

            if (!pressed)
            {
                currentRadius -= StepSize;

                if (currentRadius <= 0)
                {
                    currentRadius = 0;
                }
            }
        }
Esempio n. 3
0
    private void Receive_CreateCaptureRegion(string[] splitData)
    {
        // Capture Region initialization structure : CreateCaptureRegion|CaptureRegionId|playerId|arrayOfNodeEntityIds{0,1,2...}

        Debug.Log(string.Join("|", splitData));

        // Get data bits
        int captureRegionId = int.Parse(splitData[1]);
        int playerId        = int.Parse(splitData[2]);

        int[] nodeEntityIds = Array.ConvertAll(splitData[3].Split('$'), s => int.Parse(s));

        List <Vector2> vertices2D = new List <Vector2>();

        foreach (int nodeEntityId in nodeEntityIds)
        {
            vertices2D.Add(entities[nodeEntityId].transform.position);
        }

        CaptureRegion newCaptureRegion = GameObject.Instantiate(prefab_CaptureRegion, Vector3.zero, Quaternion.identity).GetComponent <CaptureRegion>();

        newCaptureRegion.regionRenderer.material = players[playerId].captureRegionMaterial;
        captureRegions.Add(captureRegionId, newCaptureRegion);

        // Use the triangulator to get indices for creating triangles
        Triangulator tr = new Triangulator(vertices2D.ToArray());

        int[] indices = tr.Triangulate();

        // Create the Vector3 vertices							// TODO: can we remove this step?
        Vector3[] vertices = new Vector3[vertices2D.Count];
        for (int i = 0; i < vertices.Length; i++)
        {
            vertices[i] = new Vector3(vertices2D[i].x, vertices2D[i].y, 0);
        }

        // Create the mesh
        Mesh newMesh = new Mesh();

        newMesh.vertices  = vertices;
        newMesh.triangles = indices;
        newMesh.RecalculateNormals();
        newMesh.RecalculateBounds();

        // Apply the new mesh to the new CaptureRegion
        newCaptureRegion.meshFilter.mesh = newMesh;
    }
Esempio n. 4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var c = new CaptureRegion(RegionCaptureType.Default);

            var taskSettings = TaskSettings.GetDefaultTaskSettings();

            taskSettings.GeneralSettings.PlaySoundAfterCapture           = false;
            taskSettings.GeneralSettings.PlaySoundAfterUpload            = false;
            taskSettings.GeneralSettings.PopUpNotification               = PopUpNotificationType.None;
            taskSettings.AdvancedSettings.RegionCaptureDisableAnnotation = true;

            c.Capture(taskSettings, true);
            var imageInfo = c.GetLastCapture();

            if (imageInfo != null && imageInfo.Image != null)
            {
                Msg.Text = $"捕获目标,W:{imageInfo.Image.Width},H:{imageInfo.Image.Height}";
            }
            else
            {
                Msg.Text = "放弃捕获";
            }
        }
Esempio n. 5
0
        public void RegionCaptureTypeShouldBeDefault()
        {
            var target = new CaptureRegion();

            Assert.AreEqual(target.RegionCaptureType, RegionCaptureType.Default);
        }