private void TerminateRecord() { if (this.currentState == RecordState.Run || this.currentState == RecordState.Pause) { recorder.Stop(); this.currentState = RecordState.Stop; // 设置按钮状态 btnPause.Enabled = false; btnStop.Enabled = false; btnStart.Enabled = true; btnPlay.Enabled = true; // 拖盘图标通知一声 notifyIcon.BalloonTipText = "腾光录屏:录制已经完成"; notifyIcon.ShowBalloonTip(1000); } }
private bool BeginRecord() { recorder = new Recordor(new WMVEncoder()); // 假如已经选择文件保存路径 if (saveFile.FilePath != string.Empty) { try { // 假如当前不处于运行状态 if (currentState != RecordState.Run) { // 假如压缩方式已经选定 if (cbProfiles.Text != string.Empty) { // 初始录制区域 此处设为全屏,本例子不进行局部录制的处理 ScreenArea area; area.X = int.Parse(tbOriPointX.Text); // 左上角坐标X值 area.Y = int.Parse(tbOriPointY.Text); // 左上角坐标Y值 area.Weight = int.Parse(tbAreaWidth.Text); // 宽度 area.Height = int.Parse(tbAreaHeight.Text); // 高度 // 初始媒体信息 MediaInfo mediaInfo = new MediaInfo(); mediaInfo.SavePath = saveFile.FilePath; mediaInfo.ProfileName = cbProfiles.Text; if (rbBoth.Checked) { mediaInfo.AudioVedio = AudioVedioType.Both; } if (rbOnlyAudio.Checked) { mediaInfo.AudioVedio = AudioVedioType.AudioOnly; } if (rbOnlyVideo.Checked) { mediaInfo.AudioVedio = AudioVedioType.VedioOnly; } try { recorder.Start(mediaInfo, area); // 将当前状态设为录制中。 this.currentState = RecordState.Run; // 设置按钮状态 btnStart.Enabled = false; btnPause.Enabled = true; btnStop.Enabled = true; btnPlay.Enabled = false; } catch (Exception ce) { this.currentState = RecordState.Stop; MessageBox.Show(ce.Message); recorder.Stop(); return(false); } } else { MessageBox.Show("请选择压缩方式"); return(false); } } else { MessageBox.Show("正在录制中"); return(false); } } catch { return(false); } } else { MessageBox.Show("请指定保存的位置"); return(false); } // 启动一个线程 管理拖盘图标的状态 闪动 if (iconRunState == null) { iconRunState = new Thread(IconRunStateThread); // 设置为后台线程,保证,程序退出时,即使出错了,也会退出。 iconRunState.IsBackground = true; iconRunState.Start(); } else { iconRunState.Resume(); } return(true); }