/* * Copyright (c) 2025 LG Electronics Inc. * SPDX-License-Identifier: LicenseRef-LGE-Proprietary */ using Aurora; using Aurora.Api; using VisionCommon; using System.Windows; using System.Windows.Controls; using System; using VisionCommonUI; namespace VisionUI.Pattern { /// /// 패턴 등록 뷰 /// PatternRegistrationView.xaml behind code /// public partial class PatternRegistrationView : UserControl, IUpdateRecipe, IDisposable { private Logger _Logger = new Logger("PatternRegistrationView"); private UserControl _CameraView; private FovInfo _FovInfo; /// /// 생성자 /// /// Fov 정보 public PatternRegistrationView(FovInfo fovInfo) { _FovInfo = fovInfo; InitializeComponent(); } private void Init() { CreateCameraView(); CreatePatternListView(); } private void CreateCameraView() { _CameraView = IpViewManager.CreateCameraView(_FovInfo, eDisplayType.Pattern); gridCameraView.Children.Add(_CameraView); } private void CreatePatternListView() { var patterrnListView = new PatternListView(_FovInfo); patterrnListView.DataContext = IpViewManager.CreatePatternListViewModel(_FovInfo, _CameraView); gridPatternListView.Children.Add(patterrnListView); } private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { bool isVisible = (bool)e.NewValue; if (isVisible == true) { RefreshVisionRecipes(); Init(); } else { Dispose(); } } public void RefreshVisionRecipes() { _FovInfo = VisionRecipeManager.GetFovInfo(_FovInfo); } public void UpdateRecipeFromFile() { throw new NotImplementedException(); } public void UpdateRecipeFromUI() { throw new NotImplementedException(); } #region Dispose public void Dispose() { RemoveCameraView(); RemovePatternListView(); } private void RemoveCameraView() { foreach (var child in gridCameraView.Children) { if (child is UserControl view) { IpViewManager.DisposeCameraView(view); } } gridCameraView.Children.Clear(); } private void RemovePatternListView() { foreach (var child in gridPatternListView.Children) { if (child is PatternListView patternListView) { patternListView = null; } } gridPatternListView.Children.Clear(); } #endregion } }