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); }
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)); } }