/// <summary> /// 录制工作流程 /// 1. 绑定快捷键 Alt+R /// 2. 打开录制窗口后,显示选项工具条 /// 3. 设置好选项后,点击【开始】以开始录制 /// 4. 点击后隐藏工具条,再次按下快捷键停止录制,并显示保存位置选择对话框 /// 5. 选择保存文件后,合成GIF文件,关闭录制窗口 /// </summary> public static void Record() { if (Busy) { if (recordForm != null) { // 关闭窗口,此时会停止录制 recordForm.Close(); } return; } Busy = true; try { recordForm = new ScreenRecordForm(); recordForm.FormClosed += RecordForm_FormClosed; recordForm.ShowDialog(); } finally { Busy = false; if (recordForm != null) { recordForm.Close(); recordForm.Dispose(); } } }
/// <summary> /// 录制工作流程 /// 1. 绑定快捷键 Alt+R /// 2. 打开录制窗口后,显示选项工具条 /// 3. 设置好选项后,点击【开始】以开始录制 /// 4. 点击后隐藏工具条,再次按下快捷键停止录制,并显示保存位置选择对话框 /// 5. 选择保存文件后,合成GIF文件,关闭录制窗口 /// </summary> public static void Record() { if (Busy) { // 关闭窗口,此时会停止录制 recordForm?.Close(); return; } Busy = true; try { ToggleColorWindows(false); recordForm = new ScreenRecordForm(); recordForm.FormClosing += (sender, e) => { ToggleColorWindows(true); }; // 根据配置判断是否使用全屏 // 光标所在屏幕 var bounds = Util.GetScreenBounds(); recordForm.Left = bounds.X + bounds.Width / 2 - recordForm.Width / 2; recordForm.Top = bounds.Y + bounds.Height / 2 - recordForm.Height / 2; recordForm.FormClosed += RecordForm_FormClosed; recordForm.ShowDialog(); } finally { Busy = false; if (recordForm != null) { recordForm.Close(); recordForm.Dispose(); } } }