private async Task RefreshSnapshots() { snapshotsPanel.Controls.Clear(); int i = 0; var paths = await GoProControl.GetMediaList(); int snapshotWidth = snapshotsPanel.Width - 20; int snapshotHeight = snapshotWidth * 120 / 160; paths.Reverse(); foreach (string path in paths) { PictureBox box = new PictureBox(); box.Image = await GoProControl.GetThumbnail(path); box.Location = new Point(0, i * (snapshotHeight + 5)); box.SizeMode = PictureBoxSizeMode.StretchImage; box.Size = new Size(snapshotWidth, snapshotHeight); snapshotsPanel.Controls.Add(box); Label label = new Label(); label.Text = path; label.Location = new Point(0, 0); label.Font = new Font("Consolas", 8); label.Size = new Size(snapshotWidth, 15); label.BackColor = Color.FromArgb(100, 0, 0, 0); label.ForeColor = Color.White; label.Parent = box; Button view = new Button(); view.Text = "View"; view.Location = new Point(snapshotWidth - 50, snapshotHeight - 20); view.Size = new Size(50, 20); view.Tag = dcimUrl + path; view.Click += thumbnailViewButton_Click; view.Parent = box; Button del = new Button(); del.Text = "Del"; del.Location = new Point(snapshotWidth - 50, 15); del.Size = new Size(50, 20); del.Tag = path; del.Click += thumbnailDelButton_Click; del.Parent = box; del.BackColor = Color.DarkRed; del.ForeColor = Color.White; i++; if (i >= 20) { break; } } snapshotsPanel.AutoScrollMinSize = new Size(0, 1200); snapshotsPanel.AutoScroll = true; }
public async Task capture() { await GoProControl.Trigger(); await GoProControl.WaitProcessingDone(); if (autoRefresh) { await RefreshSnapshots(); } }
private async void buttonStartStreaming_Click(object sender, EventArgs e) { if (buttonStartStreaming.Text.Equals("Start Streaming")) { buttonStartStreaming.Text = "Stop Streaming"; await GoProControl.StartStreaming(); } else { stopStreaming(); } }
public async Task downloadLatestPhoto(int frameId) { var paths = await GoProControl.GetMediaList(); string path = paths[paths.Count - 1]; string url = dcimUrl + path; String fileName = String.Format("{0}/{1:000}.png", snapshotsDir, frameId); Image image = await GoProControl.GetImage(url); var img = new Emgu.CV.Image <Emgu.CV.Structure.Bgr, byte>(new Bitmap(image)); double angle = checkBoxRotateCamera.Checked ? -90 : 0; var rimg = img.Rotate(angle, new Emgu.CV.Structure.Bgr(0, 0, 0), false); rimg.ROI = new Rectangle((rimg.Width - rimg.Height * targetWidth / targetHeight) / 2, 0, rimg.Height * targetWidth / targetHeight, rimg.Height); var cropped = rimg.Copy(); var resized = cropped.Resize(targetWidth, targetHeight, Emgu.CV.CvEnum.Inter.Linear); resized.Save(fileName); rimg.Dispose(); img.Dispose(); cropped.Dispose(); resized.Dispose(); }
private async void buttonSleep_Click(object sender, EventArgs e) { await GoProControl.Sleep(); }
public void stopStreaming() { buttonStartStreaming.Text = "Start Streaming"; GoProControl.StopStreaming(); }
private async void thumbnailDelButton_Click(object sender, EventArgs e) { await GoProControl.DeleteFile((string)((Button)sender).Tag); await RefreshSnapshots(); }