89 lines
4.1 KiB
C#
89 lines
4.1 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using System.Collections.Generic;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
namespace VisionCommon {
|
|
/// <summary>
|
|
/// 다른 디스플레이에서 동일 카메라 라이브 동작시, 버튼 UI Sync를 맞추기 위함.
|
|
/// </summary>
|
|
public class CamLiveBtnManager {
|
|
private static Dictionary<eDisplayType, Dictionary<FovInfo, LiveBtns>> _DicLiveBtns =
|
|
new Dictionary<eDisplayType, Dictionary<FovInfo, LiveBtns>>();
|
|
|
|
public static void SetLiveBtnsForVisibility(eDisplayType displayType, FovInfo fovInfo, Button btnLiveStart, Button btnLiveStop) {
|
|
if (!_DicLiveBtns.ContainsKey(displayType)) {
|
|
_DicLiveBtns.Add(displayType, new Dictionary<FovInfo, LiveBtns>());
|
|
}
|
|
_DicLiveBtns[displayType][fovInfo] = new LiveBtns(btnLiveStart, btnLiveStop);
|
|
}
|
|
|
|
public static void SetVisibilityAsLiveStart(eDisplayType displayType, FovInfo fovInfo) {
|
|
Application.Current.Dispatcher.BeginInvoke(
|
|
new System.Action(() => {
|
|
var camRecipe = VisionRecipeManager.GetCamRecipe(fovInfo);
|
|
|
|
// 같은 CamId를 사용하는 디스플레이의 라이브 버튼 모두 끄기
|
|
foreach (Dictionary<FovInfo, LiveBtns> dicLiveBtns in _DicLiveBtns.Values) {
|
|
foreach (FovInfo curFovInfo in dicLiveBtns.Keys) {
|
|
var curCamRecipe = VisionRecipeManager.GetCamRecipe(curFovInfo);
|
|
if (curCamRecipe == null) {
|
|
continue;
|
|
}
|
|
|
|
if (camRecipe.CamId == curCamRecipe.CamId) {
|
|
LiveBtns liveBtns = dicLiveBtns[curFovInfo];
|
|
liveBtns.BtnLiveStart.Visibility = Visibility.Visible;
|
|
liveBtns.BtnLiveStop.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 내 Fov를 사용하는 디스플레이만 라이브 버튼 켜기
|
|
if (_DicLiveBtns.ContainsKey(displayType)) {
|
|
if (_DicLiveBtns[displayType].ContainsKey(fovInfo)) {
|
|
LiveBtns liveBtns = _DicLiveBtns[displayType][fovInfo];
|
|
liveBtns.BtnLiveStart.Visibility = Visibility.Collapsed;
|
|
liveBtns.BtnLiveStop.Visibility = Visibility.Visible;
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
public static void SetVisibilityAsLiveStop(FovInfo fovInfo) {
|
|
Application.Current.Dispatcher.BeginInvoke(
|
|
new System.Action(() => {
|
|
var camRecipe = VisionRecipeManager.GetCamRecipe(fovInfo);
|
|
|
|
// 같은 CamId를 사용하는 디스플레이의 라이브 버튼 모두 끄기
|
|
foreach (Dictionary<FovInfo, LiveBtns> dicLiveBtns in _DicLiveBtns.Values) {
|
|
foreach (FovInfo key in dicLiveBtns.Keys) {
|
|
var curCamRecipe = VisionRecipeManager.GetCamRecipe(key);
|
|
if (curCamRecipe == null) {
|
|
continue;
|
|
}
|
|
|
|
if (camRecipe.CamId == curCamRecipe.CamId) {
|
|
LiveBtns liveBtns = dicLiveBtns[key];
|
|
liveBtns.BtnLiveStart.Visibility = Visibility.Visible;
|
|
liveBtns.BtnLiveStop.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
}
|
|
|
|
public class LiveBtns {
|
|
public Button BtnLiveStart { get; set; }
|
|
public Button BtnLiveStop { get; set; }
|
|
|
|
public LiveBtns(Button btnLiveStart, Button btnLiveStop) {
|
|
BtnLiveStart = btnLiveStart;
|
|
BtnLiveStop = btnLiveStop;
|
|
}
|
|
}
|
|
} |