using Aurora.Api; using AuroraUIComponent.UserControls; using AuroraUIComponent.Util; using System; using System.Collections.Generic; using System.Linq; using System.Reactive.Linq; using System.Windows; using System.Windows.Controls; using VisionCommon; using VisionUI.Pattern; namespace VisionUI.Aligner { /// /// 얼라인 레시피 세팅 뷰 /// AlignRecipeSettingView.xaml BehindCode /// public partial class AlignRecipeSettingView : UserControl, IUpdateRecipe { private Logger _Logger; private AlignInfo _AlignInfo; private AlignRecipe _AlignRecipe; private List ParamContents = new List(); /// /// 생성자 /// /// 얼라인 정보 public AlignRecipeSettingView(AlignInfo alignInfo) { _Logger = new Logger($"AlignRecipeSettingView[{alignInfo.AlignName}]"); _AlignInfo = alignInfo; _AlignRecipe = VisionRecipeManager.GetAlignRecipe(_AlignInfo); ProcPatternSettingView = new ProcPatternSettingView(_AlignInfo.ToSubSysInfo(), _AlignRecipe.AlignId.ToString()); InitializeComponent(); CreateProcPatternSettingView(); // ContentView 전체 사용을 위한 Codes ParamContents = WpfUtil.GetLogicalChildCollection(this).ToList(); // ToggleValves foreach(var param in ParamContents) { param.SetFoldingChangedEventHandler(FoldingChangedNotifyEventHandler); } } private void FoldingChangedNotifyEventHandler(object sender, RoutedEventArgs e) { if (_foldingEventLock) { return; } else { IsAllOpen = ParamContents?.All(x => x.IsFolding == false) ?? false; } } /// /// Proc패턴 세팅 뷰 생성 /// public void CreateProcPatternSettingView() { } private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { bool isVisible = (bool)e.NewValue; if (isVisible == true) { RefreshVisionRecipes(); UpdateRecipeFromFile(); RefreshView(); } } public void RefreshVisionRecipes() { _AlignRecipe = VisionRecipeManager.GetAlignRecipe(_AlignInfo); (DataContext as AlignRecipeSettingViewModel).RefreshVisionRecipes(); } public void UpdateRecipeFromFile() { (DataContext as AlignRecipeSettingViewModel).UpdateRecipeFromFile(); UpdateRecipeFromUI_ProcPatternSetting(); } private void UpdateRecipeFromUI_ProcPatternSetting() { ProcPatternSettingView.UpdateRecipeFromUI(); } public void UpdateRecipeFromUI() { (DataContext as AlignRecipeSettingViewModel).UpdateRecipeFromUI(); UpdateRecipeFromUI_ProcPatternSetting(); } public void RefreshView() { // ContentView Folding => AllOpen foreach (var param in ParamContents) { param.ChangeFold(false); } IsAllOpen = ParamContents?.All(x => x.IsFolding == false) ?? false; } #region Folding Util Button public bool IsAllOpen { get { return (bool)GetValue(IsAllOpenProperty); } set { SetValue(IsAllOpenProperty, value); } } // Using a DependencyProperty as the backing store for IsAllOpen. This enables animation, styling, binding, etc... public static readonly DependencyProperty IsAllOpenProperty = DependencyProperty.Register("IsAllOpen", typeof(bool), typeof(AlignRecipeSettingView), new PropertyMetadata(false)); private ProcPatternSettingView _ProcPatternSettingView; public ProcPatternSettingView ProcPatternSettingView { get { return _ProcPatternSettingView; } set { _ProcPatternSettingView= value; } } private bool _foldingEventLock; // 1 개라도 Open 시 Foidng button private void BtnClick_Fold(object sender, RoutedEventArgs e) { _foldingEventLock = true; if (IsAllOpen) { foreach (var param in ParamContents) { param.ChangeFold(true); } } else { foreach (var param in ParamContents) { param.ChangeFold(false); } } IsAllOpen= !IsAllOpen; _foldingEventLock = false; } #endregion } }