using DevExpress.Data.Camera;
using DevExpress.XtraEditors.Camera;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DEV_相機控件使用
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//CameraDeviceInfo a4camInfo = CameraControl.GetDevices().Find(x => x.Name.Contains("Logitech"));
//cameraControl1.Start(CameraControl.GetDevice(a4camInfo));
//拖動控件的方式
string filePath = Path.Combine(@"D:\",
DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "--" +
DateTime.Now.Hour.ToString() + "-" + DateTime.Now.Minute.ToString() + "-" + DateTime.Now.Second.ToString() +
".jpg");
cameraControl1.TakeSnapshot().Save(filePath, ImageFormat.Jpeg);
}
private void button2_Click(object sender, EventArgs e)
{
//使用代碼調用控件的方式CameraControl.ShowSettingsButton
TakePictureDialog d = new TakePictureDialog();
if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Image i = d.Image;
i.Save("D:\\snapshot.bmp");
MessageBox.Show("OK");
}
}
}
}