154 lines
6.0 KiB
C#
154 lines
6.0 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using Aurora.Api;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using VisionCommon;
|
|
using System;
|
|
using VisionCommonUI.Resources;
|
|
using VisionCommonUI;
|
|
|
|
namespace VisionUI.Aligner {
|
|
/// <summary>
|
|
/// SubMenuAlignView.xaml에 대한 상호 작용 논리
|
|
/// </summary>
|
|
public partial class SubMenuAlignView : UserControl {
|
|
private static readonly Logger _Logger = new Logger("SubMenuAlignView");
|
|
private IDisposable _EventDisposable;
|
|
|
|
private bool _IsViewInitialized = false;
|
|
/// <summary>
|
|
/// 생성자
|
|
/// </summary>
|
|
public SubMenuAlignView() {
|
|
InitializeComponent();
|
|
InitializeView(); // 프로그램 시작 후, 얼라인 탭에 진입하지 않아도 공정 로그가 찍힐 수 있도록 하기 위함.
|
|
SetObservable();
|
|
}
|
|
|
|
private void SetObservable() {
|
|
if (_EventDisposable == null) {
|
|
var observable = VisionEventId.GetRecipeUpdateObservable();
|
|
_EventDisposable = observable.Subscribe(_ => ClearView());
|
|
}
|
|
}
|
|
|
|
private void ClearView() {
|
|
if (IsVisible) {
|
|
// Recipe가 변경된 Event가 들어왔는데 View가 보이는 상황이면, ProcPatternSettingView만 새로고침한다.
|
|
Application.Current.Dispatcher.BeginInvoke(
|
|
new System.Action(() => {
|
|
(((unitTabControl.SelectedContent as TabControl).SelectedContent as AlignSettingView).alignTabControl.SelectedContent as AlignRecipeSettingView).ClearView();
|
|
}));
|
|
return;
|
|
}
|
|
|
|
Application.Current.Dispatcher.BeginInvoke(
|
|
new System.Action(() => {
|
|
DisposableManager.ClearDisposable(eDpsGroupKey.SubMenu_Align);
|
|
unitTabControl.Items.Clear();
|
|
_IsViewInitialized = false;
|
|
}));
|
|
}
|
|
|
|
private void InitializeView() {
|
|
CreateUnitTabControl();
|
|
_IsViewInitialized = true;
|
|
}
|
|
|
|
#region Align Setting View
|
|
private AlignSettingView CreateAlignSettingView(SubSysInfo subSysInfo) {
|
|
var alignSettingView = new AlignSettingView(subSysInfo);
|
|
var alignSettingViewModel = new AlignSettingViewModel(subSysInfo);
|
|
alignSettingView.DataContext = alignSettingViewModel;
|
|
|
|
return alignSettingView;
|
|
}
|
|
#endregion
|
|
|
|
#region Proc Log View
|
|
private PatternDistanceLogView CreatePatternDistanceLogView(SubSysInfo subSysInfo) {
|
|
var patternDistanceLogView = new PatternDistanceLogView(subSysInfo);
|
|
var patternDistanceLogViewModel = new PatternDistanceLogViewModel(subSysInfo);
|
|
patternDistanceLogView.DataContext = patternDistanceLogViewModel;
|
|
|
|
return patternDistanceLogView;
|
|
}
|
|
#endregion
|
|
|
|
private void CreateUnitTabControl() {
|
|
var unitInfos = VisionRecipeManager.GetUnitInfos();
|
|
foreach (UnitInfo unitInfo in unitInfos) {
|
|
var unitTabItem = new TabItem() {
|
|
Header = unitInfo.UnitName,
|
|
Content = GetSubSystemTabControl(unitInfo)
|
|
};
|
|
unitTabItem.Style = FindResource("styleSubMenuRootTabItem") as Style;
|
|
unitTabControl.Items.Add(unitTabItem);
|
|
}
|
|
unitTabControl.SelectedIndex = 0;
|
|
|
|
if (unitInfos.Count == 0 || unitTabControl.Items.Count < unitInfos.Count) {
|
|
PrintRecipeError(typeof(UnitRecipe).Name, unitTabControl);
|
|
}
|
|
}
|
|
|
|
private TabControl GetSubSystemTabControl(UnitInfo unitInfo) {
|
|
try {
|
|
var subSystemTabControl = new TabControl();
|
|
subSystemTabControl.Style = FindResource("styleSubMenuRootTabControl") as Style;
|
|
subSystemTabControl.Margin = new System.Windows.Thickness(10, 0, 0, 0);
|
|
|
|
var subSysInfos = VisionRecipeManager.GetSubSysInfos(unitInfo.UnitId);
|
|
foreach (SubSysInfo subSysInfo in subSysInfos) {
|
|
if (VisionRecipeManager.GetSubSysType(subSysInfo) != eSubSysType.Align) {
|
|
continue;
|
|
}
|
|
|
|
var subSystemTabItem = new TabItem() {
|
|
Header = subSysInfo.SubSysName,
|
|
Content = CreateAlignSettingView(subSysInfo)
|
|
};
|
|
subSystemTabItem.Style = FindResource("styleSubMenuRootTabItem") as Style;
|
|
subSystemTabControl.Items.Add(subSystemTabItem);
|
|
}
|
|
subSystemTabControl.SelectedIndex = 0;
|
|
|
|
if (subSysInfos.Count == 0) {
|
|
PrintRecipeError(typeof(SubSysRecipe).Name, subSystemTabControl);
|
|
}
|
|
|
|
return subSystemTabControl;
|
|
}
|
|
catch (Exception e) {
|
|
_Logger.FuncE(e.Message);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private void PrintRecipeError(string recipeName, TabControl tabControl) {
|
|
var errMsg = string.Format(StrTokens.RecipeErrorMessage, recipeName);
|
|
var errTabItem = new TabItem() {
|
|
Header = "Undefined",
|
|
Content = new UCRecipeErrorTextBlock(errMsg) { Margin = new Thickness(15) }
|
|
};
|
|
errTabItem.Style = FindResource("styleSubMenuRootTabItem") as Style;
|
|
errTabItem.VerticalContentAlignment = VerticalAlignment.Center;
|
|
errTabItem.HorizontalContentAlignment = HorizontalAlignment.Center;
|
|
tabControl.Items.Add(errTabItem);
|
|
}
|
|
|
|
private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) {
|
|
bool isVisible = (bool)e.NewValue;
|
|
if (isVisible == true) {
|
|
if (!_IsViewInitialized) {
|
|
InitializeView();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|