基本信息
源码名称:C# 年会抽奖(图片+姓名)摄像头拍照示例源码
源码大小:61.73M
文件格式:.zip
开发语言:C#
更新时间:2017-12-14
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
基于DEVEXPRESS
基于DEVEXPRESS
using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.IO; namespace ncpcjdev { public partial class FormBegin : DevExpress.XtraEditors.XtraForm { List<String> names = new List<String>(); int i; int namescount; string needdel; public Image CameraImage { get; set; } public FormBegin() { InitializeComponent(); this.LookAndFeel.SkinName = "Money Twins"; this.LookAndFeel.UseDefaultLookAndFeel = false; } private void btncapture_Click(object sender, EventArgs e) { if (this.cameraControl1.TakeSnapshot() != null) { this.CameraImage = this.cameraControl1.TakeSnapshot(); this.pictureBox1.Image = this.CameraImage; txtsavestate.Visible = false; btnsave.Focus(); } else { MessageBox.Show("请先连接摄像头!"); } } private void FormBegin_FormClosed(object sender, FormClosedEventArgs e) { this.cameraControl1.Dispose(); Application.Exit(); } private void btnsave_Click(object sender, EventArgs e) { Image img = this.pictureBox1.Image; if (img == null) { MessageBox.Show("请选择图片"); return; } Bitmap curBitmap = new Bitmap(img); if (curBitmap == null) { return; } try { string filrname = DateTime.Now.ToString("hhmmss") ".jpg"; img.Save(@"customer\" filrname); img.Dispose(); txtsavestate.Visible = true; this.pictureBox1.Image = null; btncapture.Focus(); } catch { } } private void FormBegin_Load(object sender, EventArgs e) { if (this.Height > 900) this.picBox.Size = new Size(960, 540); else this.picBox.Size = new Size(640, 360); timer.Enabled = false; timer.Tick = Timer_Tick; picBox.Visible = false; this.BackgroundImageLayout = ImageLayout.Zoom; this.picBox.Location = new Point((this.Width - picBox.Width) / 2, this.Height / 5); picBox.SizeMode = PictureBoxSizeMode.StretchImage; this.txttitle.Location = new Point(100, 60); this.txttitle.Size = new Size(this.Width - 200, 80); this.txttitle.BackColor = Color.Transparent; tabPage3.BackgroundImageLayout = ImageLayout.Stretch; tabPage3.BackgroundImage = Image.FromFile(@"bj.jpg"); } private void Timer_Tick(object sender, EventArgs e) { Random rand = new Random(); i = rand.Next(namescount); picBox.Image = Image.FromFile(names[i]); if (needdel != "") DeleteFile(); } private void btnstart_Click(object sender, EventArgs e) { if (!picBox.Visible) { picBox.Visible = true; string path = @"customer"; names = new List<String>(Directory.GetFiles(path)); namescount = names.Count; btncapture.Focus(); needdel = ""; } if (timer.Enabled) { timer.Enabled = false; txttitle.Text = "恭 喜 中 奖"; string filename = names[i].Replace("customer\\", ""); CopyFile(filename); needdel = names[i]; names.RemoveAt(i); namescount = names.Count; } else { if (namescount <= 1) { MessageBox.Show("已经是最后一张照片!"); return; } txttitle.Text = ""; timer.Enabled = true; } } private void CopyFile(string filename) { string sourceFile = @"customer\" filename; string destinationFile = @"jiang\" filename; if (File.Exists(sourceFile)) { File.Copy(sourceFile, destinationFile, true); } } private void DeleteFile() { string fileToBeDeleted = needdel; if (File.Exists(fileToBeDeleted)) { try { File.Delete(fileToBeDeleted); needdel = ""; } catch { } } } } }