Ejemplo n.º 1
0
        private void InitView()
        {
            if (_isDesignTime == true)
            {
                return;
            }

            var panel = Content as Panel;

            _views = new List <IBaseView>();
            var _viewsDic = new Dictionary <int, IBaseView>();

            foreach (UIElement item in panel.Children)
            {
                if (item is IBaseView iBaseView)
                {
                    _views.Add(iBaseView);
                    var level = BaseComplexView.GetViewLevel(item);
                    if (_viewsDic.ContainsKey(level) == false)
                    {
                        _viewsDic.Add(level, iBaseView);
                    }
                    (item as UserControl).Loaded += Item_Loaded;
                }
            }

            if (_viewsDic.Count == 0)
            {
                return;
            }

            var viewList = new List <IBaseView>(_viewsDic.Count + 2);

            viewList.Add(_viewsDic[_viewsDic.Count - 1]);
            for (int i = 0; i < _viewsDic.Count; i++)
            {
                viewList.Add(_viewsDic[i]);
            }
            viewList.Add(_viewsDic[0]);

            for (int i = 1; i < viewList.Count - 1; i++)
            {
                var previousView = viewList[i - 1];
                var currentView  = viewList[i];
                var nextView     = viewList[i + 1];

                if (i < viewList.Count - 2)
                {
                    InitSelectedIndexChangedAction(currentView, nextView);
                }
                InitMoveFocusAction(currentView, nextView);
                InitAfterSave(previousView, currentView, nextView);
                InitAfterLoad(previousView, currentView, nextView);
            }
        }
Ejemplo n.º 2
0
        private void InitSelectedIndexChangedAction(IBaseView currentView, IBaseView nextView)
        {
            var filterProperty = BaseComplexView.GetFilterProperty(nextView as UIElement);
            var childViewModel = nextView.ViewModel;
            var headerFilter   = childViewModel.HeaderFilters.First(p => p.PropertyName == filterProperty);

            headerFilter.DisableChangedAction(p => { p.IsUsed = true; p.FilterValue = 0; });

            currentView.ViewModel.PropertyChanged += (sender, e) =>
            {
                OnSelectedIndexChanged(currentView, nextView, currentView.ViewModel.SelectedValue);
            };
        }
Ejemplo n.º 3
0
        protected virtual void OnSelectedIndexChanged(IBaseView currentView, IBaseView nextView, object selectedValue)
        {
            _logger.LogDebug("BaseComplexView OnSelectedIndexChanged {0}", currentView.GetType().Name);
            var viewModel      = currentView.ViewModel;
            var childViewModel = nextView.ViewModel;
            var filterProperty = BaseComplexView.GetFilterProperty(nextView as UIElement);
            var headerFilter   = childViewModel.HeaderFilters.First(p => p.PropertyName == filterProperty);

            childViewModel.ParentItem = viewModel.GetSelectedItem();
            if (selectedValue == null)
            {
                headerFilter.FilterValue = 0;
            }
            else
            {
                headerFilter.FilterValue = selectedValue;
            }
        }