/// <summary> /// Loads the filters. /// </summary> /// <param name="field">The field.</param> private void LoadFilters(ProcessViewFieldEdit field) { IsProcessSelected = false; var processEdit = field.GetParent<ProcessEdit>(); var checklistField = processEdit.GetAllFields().FirstOrDefault(f => f.SystemName == field.FieldSystemName); if (checklistField != null && checklistField.FieldType != null && checklistField.FieldType.ColumnType == ColumnTypes.Checklist) { var settingsStep = (ChecklistSettingsStepEdit)checklistField.StepList.FirstOrDefault(s => s is ChecklistSettingsStepEdit); if (settingsStep != null) LoadProcessInfo(settingsStep); } }
private static void Static(WeakEventListener<DataCollectionChecklistFieldCustomConfigViewModel, ProcessViewFieldEdit, PropertyChangedEventArgs> listener, ProcessViewFieldEdit source) { source.PropertyChanged -= listener.OnEvent; }
/// <summary> /// Initializes a new instance of the <see cref="ProcessViewFieldViewModel"/> class. /// </summary> /// <param name="model">The model.</param> /// <param name="parentViewModel">The parent view model.</param> public ProcessViewFieldViewModel(ProcessViewFieldEdit model, ProcessViewSectionViewModel parentViewModel) { Parent = parentViewModel; SetModel(model); }
/// <summary> /// Initializes the specified process view field. /// </summary> /// <param name="processViewField">The process view field.</param> /// <param name="templateField">The template field.</param> /// <exception cref="System.ArgumentOutOfRangeException">@Configurator cannot be null.</exception> public void Init(ProcessViewFieldEdit processViewField, IProcessViewFieldTemplate templateField) { _processViewField = processViewField; _configurator = templateField.CustomConfigurator as DataCollectProcessViewChecklistFieldConfigurator; if (_configurator == null) { throw new ArgumentOutOfRangeException(@"Configurator cannot be null."); } LoadFilters(processViewField); var weakListener = new WeakEventListener<DataCollectionChecklistFieldCustomConfigViewModel, ProcessViewFieldEdit, PropertyChangedEventArgs>(this, _processViewField); _processViewField.PropertyChanged += weakListener.OnEvent; weakListener.OnEventAction += OnFieldPropertyChanged; weakListener.OnDetachAction += Static; }
/// <summary> /// Sets the model. /// </summary> /// <param name="model">The model.</param> private void SetModel(ProcessViewFieldEdit model) { Model = model; var processViewSection = Parent.With(vm => vm.Model); var processView = Parent.With(vm => vm.Parent).With(vm => vm.Model); var processViewManager = Parent.With(vm => vm.Parent).With(vm => vm.Parent).With(vm => vm.ProcessViewManager); if (Model == null || processViewSection == null || processView == null || processViewManager == null) return; var sectionTemplate = processViewManager.GetTemplateForType(processView.ViewType).Sections.FirstOrDefault (s => s.Guid == processViewSection.TemplateSectionGuid); if (sectionTemplate == null) return; var fieldTemplate = sectionTemplate.Fields.FirstOrDefault(f => f.Guid == Model.TemplateFieldGuid); if (fieldTemplate == null) return; FieldTypeFilters = fieldTemplate.FieldTypeFilters; var process = Parent.With(vm => vm.Parent).With(vm => vm.Parent).With(vm => vm.Model); if (process != null) { var childChangedWeakListener = new WeakEventListener<ProcessViewFieldViewModel, ProcessEdit, ChildChangedEventArgs>(this, process); process.ChildChanged += childChangedWeakListener.OnEvent; childChangedWeakListener.OnEventAction += OnModelChildChanged; childChangedWeakListener.OnDetachAction += Static; } }