90 lines
3.0 KiB
C#
90 lines
3.0 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using Aurora.Api;
|
|
using System;
|
|
using System.Windows;
|
|
using System.ComponentModel;
|
|
using System.Windows.Threading;
|
|
using VisionCommon;
|
|
using System.Windows.Controls;
|
|
using System.Collections.Generic;
|
|
|
|
namespace VisionUI.Camera {
|
|
/// <summary>
|
|
/// CameraViewWindow.xaml BehindCode
|
|
/// </summary>
|
|
public partial class CameraViewWindow : Window {
|
|
private static Logger _Logger = new Logger("CameraViewWindow");
|
|
private FovInfo _FovInfo;
|
|
private FovRecipe _FovRecipe;
|
|
private eDisplayType _displayType = eDisplayType.Main_1;
|
|
|
|
private List<UserControl> _CamViewList;
|
|
|
|
private delegate void HideWindow();
|
|
/// <summary>
|
|
/// 생성자
|
|
/// </summary>
|
|
/// <param name="fovInfo">Fov 정보</param>
|
|
/// <param name="displayType">디스플레이 타입</param>
|
|
public CameraViewWindow(FovInfo fovInfo, eDisplayType displayType) {
|
|
_FovInfo = fovInfo;
|
|
_FovRecipe = VisionRecipeManager.GetFovRecipe(_FovInfo);
|
|
_displayType = displayType;
|
|
|
|
InitializeComponent();
|
|
CreateView();
|
|
}
|
|
|
|
private void CreateView() {
|
|
try {
|
|
var cameraView = CameraViewManager.Instance.GetCameraView(_displayType, _FovInfo);
|
|
_CamViewList = MainCameraViewManager.Instance.GetMainCameraView(_displayType).DisconnectMainCamera(cameraView);
|
|
|
|
foreach (var camView in _CamViewList) {
|
|
(camView as ICameraView).MenuShowCamWindow.Visibility = Visibility.Collapsed;
|
|
gridCameraView.Children.Add(camView);
|
|
}
|
|
}
|
|
catch (Exception e) {
|
|
_Logger.FuncE(e.Message);
|
|
}
|
|
}
|
|
|
|
private void RestoreMainCameraView() {
|
|
gridCameraView.Children.Clear();
|
|
MainCameraViewManager.Instance.GetMainCameraView(_displayType).RestoreMainCamera(_CamViewList);
|
|
}
|
|
|
|
protected override void OnClosing(CancelEventArgs e) {
|
|
CamViewWindowUtil.SetFovCamViewWindowActivated(_FovInfo, _displayType, false);
|
|
RestoreMainCameraView();
|
|
e.Cancel = true;
|
|
Dispatcher.BeginInvoke(DispatcherPriority.Normal, new HideWindow(_HideWindow));
|
|
}
|
|
|
|
private void _HideWindow() {
|
|
this.Hide();
|
|
}
|
|
|
|
private void Window_StateChanged(object sender, EventArgs e) {
|
|
var window = sender as Window;
|
|
if (window.WindowState == WindowState.Minimized) {
|
|
window.Close();
|
|
}
|
|
}
|
|
|
|
private void Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) {
|
|
bool isVisible = (bool)e.NewValue;
|
|
if (isVisible == true) {
|
|
UpdateVisionRecipes();
|
|
}
|
|
}
|
|
|
|
private void UpdateVisionRecipes() {
|
|
_FovRecipe = VisionRecipeManager.GetFovRecipe(_FovInfo);
|
|
}
|
|
}
|
|
} |