using Aurora; using Aurora.Api; using VisionCommon; using System.Windows.Controls; using System; using System.Windows; namespace VisionUI.Pattern { /// /// 바코드 로그 서브 메뉴 뷰 /// SubMenuBcrLogView.xaml behindCode /// public partial class SubMenuBcrLogView : UserControl { private static readonly Logger _Logger = new Logger("SubMenuBcrLogView"); private IDisposable _EventDisposable; private bool _IsViewInitialized = false; /// /// 생성자 /// public SubMenuBcrLogView() { InitializeComponent(); InitializeView(); // 공정 중 로그 뷰 보장을 위해 미리 생성 SetObservable(); } private void SetObservable() { if (_EventDisposable == null) { var observable = VisionEventId.GetRecipeUpdateObservable(); _EventDisposable = observable.Subscribe(_ => ClearView()); } } private void ClearView() { if (IsVisible) { return; } Application.Current.Dispatcher.BeginInvoke( new System.Action(() => { //subMenuInspTabControl.Items.Clear(); _IsViewInitialized = false; })); } private void InitializeView() { //CreateBcrLogView_Base(); //CreateBcrLogView_Flex(); _IsViewInitialized = true; } //private void CreateBcrLogView_Base() { // var vsRps_Base = VisionRecipeManager.GetVisionRecipes(eSubSysName.DpBaseCarrierPickupAlign); // var bcrLogView_Base = new BcrLogView(vsRps_Base); // var bcrLogViewModel_Base = new BcrLogViewModel(vsRps_Base); // bcrLogView_Base.DataContext = bcrLogViewModel_Base; // gridBcrLogView_Base.Children.Add(bcrLogView_Base); // BcrLogViewManager.Instance.SetBcrLogViewModel(vsRps_Base.SubSysName, bcrLogViewModel_Base); //} //private void CreateBcrLogView_Flex() { // var vsRps_Flex = VisionRecipeManager.GetVisionRecipes(eSubSysName.WpFlexCarrierPickupAlign); // var bcrLogView_Flex = new BcrLogView(vsRps_Flex); // var bcrLogViewModel_Flex = new BcrLogViewModel(vsRps_Flex); // bcrLogView_Flex.DataContext = bcrLogViewModel_Flex; // gridBcrLogView_Flex.Children.Add(bcrLogView_Flex); // BcrLogViewManager.Instance.SetBcrLogViewModel(vsRps_Flex.SubSysName, bcrLogViewModel_Flex); //} private void UserControl_IsVisibleChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e) { bool isVisible = (bool)e.NewValue; if (isVisible == true) { if (!_IsViewInitialized) { InitializeView(); } } } } }