add:展台

This commit is contained in:
2026-02-19 18:18:47 +08:00
parent 9ef764ffa1
commit 432cc3825e
3 changed files with 61 additions and 21 deletions
+28 -5
View File
@@ -46,6 +46,7 @@ namespace Ink_Canvas
VideoPresenterSidebar.Visibility = Visibility.Visible;
EnsureCameraService();
if (BtnCapturePhoto != null) BtnCapturePhoto.IsEnabled = false;
RefreshVideoPresenterDeviceList();
if (CheckBoxEnablePhotoCorrection != null)
@@ -86,16 +87,25 @@ namespace Ink_Canvas
try
{
Bitmap copy;
Bitmap serviceCopy;
try
{
serviceCopy = (Bitmap)frame.Clone();
}
catch
{
// 可能在下一帧到来时被 CameraService 释放,直接忽略这一帧
return;
}
lock (_videoPresenterFrameLock)
{
_lastFrame?.Dispose();
_lastFrame = (Bitmap)frame.Clone();
copy = (Bitmap)_lastFrame.Clone();
_lastFrame = (Bitmap)serviceCopy.Clone();
}
var preview = ConvertBitmapToBitmapImage(copy);
copy.Dispose();
var preview = ConvertBitmapToBitmapImage(serviceCopy);
serviceCopy.Dispose();
if (preview == null) return;
Dispatcher.BeginInvoke(new Action(() =>
@@ -154,6 +164,19 @@ namespace Ink_Canvas
rb.Checked += (s, e) => StartVideoPresenterPreview(idx);
CameraDevicesStackPanel.Children.Add(rb);
}
// 自动启动第一个摄像头
if (_cameraService.AvailableCameras.Count > 0)
{
if (CameraDevicesStackPanel.Children.Count > 0 && CameraDevicesStackPanel.Children[0] is RadioButton first)
{
first.IsChecked = true;
}
else
{
StartVideoPresenterPreview(0);
}
}
}
private void StartVideoPresenterPreview(int cameraIndex)