99 lines
3.0 KiB
C#
99 lines
3.0 KiB
C#
using Aurora;
|
|
using Aurora.Api;
|
|
using VisionCommon;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System;
|
|
using VisionCommonUI;
|
|
|
|
namespace VisionUI.Pattern {
|
|
/// <summary>
|
|
/// 패턴 등록 뷰
|
|
/// PatternRegistrationView.xaml behind code
|
|
/// </summary>
|
|
public partial class PatternRegistrationView : UserControl, IUpdateRecipe, IDisposable {
|
|
private Logger _Logger = new Logger("PatternRegistrationView");
|
|
|
|
private UserControl _CameraView;
|
|
private FovInfo _FovInfo;
|
|
/// <summary>
|
|
/// 생성자
|
|
/// </summary>
|
|
/// <param name="fovInfo">Fov 정보</param>
|
|
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);
|
|
if (VisionSettingManager.VisionSetting.UseCamPattern) {
|
|
patterrnListView.DataContext = IpViewManager.CreateCamPatternListViewModel(_FovInfo, _CameraView);
|
|
}
|
|
else {
|
|
patterrnListView.DataContext = IpViewManager.CreateFovPatternListViewModel(_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
|
|
}
|
|
}
|