private void OnSaveSnapshot() { string filename = "snapshot"; int i = 0; while (File.Exists(Path.Combine(CSettings.sFolderProfiles, filename + i + ".png"))) { i++; } _Snapshot.Save(Path.Combine(CSettings.sFolderProfiles, filename + i + ".png"), System.Drawing.Imaging.ImageFormat.Png); CProfiles.LoadAvatars(); LoadAvatars(); _Snapshot = null; CWebcam.Stop(); CDraw.RemoveTexture(ref _WebcamTexture); for (int j = 0; j < CProfiles.Avatars.Length; j++) { if (CProfiles.Avatars[j].FileName == (filename + i + ".png")) { CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, j); break; } } Buttons[htButtons(ButtonSaveSnapshot)].Visible = false; Buttons[htButtons(ButtonDiscardSnapshot)].Visible = false; Buttons[htButtons(ButtonTakeSnapshot)].Visible = false; Buttons[htButtons(ButtonWebcam)].Visible = true; }
private void _OnTakeSnapshot() { if (!CWebcam.IsDeviceAvailable()) { CDraw.RemoveTexture(ref _WebcamTexture); _Snapshot = null; _Buttons[_ButtonSaveSnapshot].Visible = false; _Buttons[_ButtonDiscardSnapshot].Visible = false; _Buttons[_ButtonTakeSnapshot].Visible = false; _Buttons[_ButtonWebcam].Visible = false; _SelectElement(_Buttons[_ButtonSave]); } else { CWebcam.Stop(); //Do this first to get consistent frame and bitmap _Snapshot = CWebcam.GetBitmap(); if (CWebcam.GetFrame(ref _WebcamTexture)) { _Statics[_StaticAvatar].Texture = _WebcamTexture; } _Buttons[_ButtonSaveSnapshot].Visible = true; _Buttons[_ButtonDiscardSnapshot].Visible = true; _Buttons[_ButtonTakeSnapshot].Visible = false; _Buttons[_ButtonWebcam].Visible = false; _SelectElement(_Buttons[_ButtonSaveSnapshot]); } }
private void OnDiscardSnapshot() { CWebcam.Stop(); CDraw.RemoveTexture(ref _WebcamTexture); _Snapshot = null; Buttons[htButtons(ButtonSaveSnapshot)].Visible = false; Buttons[htButtons(ButtonDiscardSnapshot)].Visible = false; Buttons[htButtons(ButtonTakeSnapshot)].Visible = false; Buttons[htButtons(ButtonWebcam)].Visible = true; }
public override void OnClose() { base.OnClose(); CWebcam.Stop(); }