Пример #1
0
		public SKDReportFilterViewModel(SKDReportFilter filter, FilterModel model)
		{
			var stopwatch = new Stopwatch();
			stopwatch.Start();
			Title = "Настройки отчета";
			_model = model;
			Filter = filter;
			Pages = new ObservableCollection<FilterContainerViewModel>();
			Pages.Add(new FilterMainPageViewModel(model, Filter, LoadFilter, UpdateFilter));
			model.Pages.ForEach(page => { if (page.IsActive) Pages.Add(page); });
			if (model.AllowSort)
				Pages.Add(new FilterSortPageViewModel(model.Columns));
			CommandPanel = model.CommandsViewModel;
			LoadFilter(Filter);
			stopwatch.Stop();
			Trace.WriteLine(string.Format("SKDReportFilterViewModel {0}", stopwatch.Elapsed));
		}
Пример #2
0
		public FilterMainPageViewModel(FilterModel model, SKDReportFilter filter, Action<SKDReportFilter> loadFilterAction, Action<SKDReportFilter> updateFilterAction)
		{
			_isLoaded = false;
			Title = "Настройки";
			_filter = filter;
			_loadFilterAction = loadFilterAction;
			_updateFilterAction = updateFilterAction;
			MainViewModel = model.MainViewModel;
			IsAdditionalExpanded = false;
			ExpandAdditionalCommand = new RelayCommand(() => IsAdditionalExpanded = !IsAdditionalExpanded);
			SaveFilterCommand = new RelayCommand(OnSaveFilter, CanSaveFilter);
			RemoveFilterCommand = new RelayCommand(OnRemoveFilter, CanRemoveFilter);
			_filterType = filter.GetType();
			Filters = new ObservableCollection<SKDReportFilter>(ClientSettings.ReportFilters.Filters.Where(f => f.GetType() == _filterType));
			Filters.Insert(0, (SKDReportFilter)Activator.CreateInstance(_filterType));
			SelectedFilter = Filters.FirstOrDefault(f => f.Name == filter.Name);
			if (SelectedFilter == null)
				SelectedFilter = Filters[0];
			_isLoaded = true;
		}