private void AddBlockExecute()
        {
            var blockViewModel = new SmartViewBlockViewModel(this);

            blockViewModel.Rules.Add(new SmartViewRuleViewModel(blockViewModel));

            this.blocks.Add(blockViewModel);
        }
Example #2
0
        private void RemoveRuleExecute()
        {
            SmartViewBlockViewModel block = this.parent;

            block.Rules.Remove(this);
            if (block.Rules.Count == 0)
            {
                block.Parent.Blocks.Remove(block);
            }
        }
        public CreateSmartViewViewModel(IWorkbook workbook, INavigationService navigationService, IMessageBoxService messageBoxService, ITrackingManager trackingManager)
            : base(workbook, navigationService, messageBoxService, trackingManager)
        {
            var block = new SmartViewBlockViewModel(this);
            var rule  = new SmartViewRuleViewModel(block);

            block.Rules.Add(rule);

            this.Blocks.Add(block);
        }
Example #4
0
        public SmartViewRuleViewModel(SmartViewBlockViewModel parent)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }

            this.parent = parent;

            this.fields  = new ObservableCollection <SmartViewField>(EnumHelper.GetAllValues <SmartViewField>());
            this.filters = new ObservableCollection <SmartViewFilter>();

            this.removeRuleCommand = new RelayCommand(this.RemoveRuleExecute);

            this.UpdateEditMode();
        }
        protected async void LoadStringAsync(string content)
        {
            Exception exception = null;

            try
            {
                var handler = SmartViewHandler.FromString(content);
                foreach (var block in handler.Blocks)
                {
                    var blockViewModel = new SmartViewBlockViewModel(this);

                    foreach (var rule in block.Rules)
                    {
                        var ruleViewModel = new SmartViewRuleViewModel(blockViewModel)
                        {
                            SelectedField  = rule.Field,
                            SelectedFilter = rule.Filter,
                            Value          = this.CreateValueViewModel(rule.Filter, rule.Field, rule.Value)
                        };

                        blockViewModel.Rules.Add(ruleViewModel);
                    }
                    if (block.Match == SmartViewMatchType.All)
                    {
                        blockViewModel.MatchAnd = true;
                    }
                    else
                    {
                        blockViewModel.MatchOr = true;
                    }

                    this.blocks.Add(blockViewModel);
                }
                this.matchType = handler.Match;
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            if (exception != null)
            {
                await this.messageBoxService.ShowAsync(StringResources.Message_Warning, string.Format(StringResources.SmartView_MessageCannotLoadFormat, exception));
            }
        }