private void UpdateCurrentMessage(MessageView mv) { CurrentMessage = mv; if (mv != null) { CurrentProperties.PopulateWith(mv.Properties); } else { CurrentProperties.Clear(); } OnPropertyChanged( nameof(CurrentMessage), nameof(CurrentProperties), nameof(IsMessagePresent), nameof(CanExportProperties), nameof(CanPopMessage), nameof(IsAttachmentPresent), nameof(IsFileAttachmentPresent), nameof(IsFileAttachmentSelected), nameof(IsEmailAttachmentPresent), nameof(IsEmailAttachmentSelected) ); }
public void Check() { TModel entity = mapper.Map <TModel>(CurrentProperties.ToDictionary(p => p.Name, p => p.Value)); conditions.ForEach(condition => { DoCheck(CurrentPropertiesDictionary[condition.Field]); void DoCheck(IValidatable currentValidatable) { HashSet <IValidationRule> existingRules = currentValidatable.Validations.ToHashSet(); if (CanValidate(entity, condition.Evaluator)) { if (!existingRules.Contains(condition.Validator)) { currentValidatable.Validations.Add(condition.Validator); currentValidatable.Validate(); } } else { if (existingRules.Contains(condition.Validator)) { currentValidatable.Validations.Remove(condition.Validator); currentValidatable.Validate(); } } } }); }
public void Check(ClearIf <TModel> condition) { DoCheck(CurrentPropertiesDictionary[condition.Field]); void DoCheck(IFormField currentField) { if ( ShouldClear ( mapper.Map <TModel>(CurrentProperties.ToDictionary(p => p.Name, p => p.Value)), condition.Evaluator ) ) { currentField.Clear(); } } bool ShouldClear(TModel entity, Expression <Func <TModel, bool> > evaluator) => new List <TModel> { entity } .AsQueryable().All(evaluator); }
public void Check(ReloadIf <TModel> condition) { DoCheck(CurrentPropertiesDictionary[condition.Field]); void DoCheck(IFormField currentField) { if (currentField is IHasItemsSource hasItemsSource) { TModel entity = mapper.Map <TModel>(CurrentProperties.ToDictionary(p => p.Name, p => p.Value)); if ( ShouldReload ( entity, condition.Evaluator ) ) { hasItemsSource.Reload(entity, typeof(TModel)); } } } bool ShouldReload(TModel entity, Expression <Func <TModel, bool> > evaluator) => new List <TModel> { entity } .AsQueryable().All(evaluator); }
public void Check(ValidateIf <TModel> condition) { DoCheck(CurrentPropertiesDictionary[condition.Field]); void DoCheck(IValidatable currentValidatable) { HashSet <IValidationRule> existingRules = currentValidatable.Validations.ToHashSet(); TModel entity = mapper.Map <TModel>(CurrentProperties.ToDictionary(p => p.Name, p => p.Value)); if (CanValidate(entity, condition.Evaluator)) { if (!existingRules.Contains(condition.Validator)) { currentValidatable.Validations.Add(condition.Validator); currentValidatable.Validate(); } } else { if (existingRules.Contains(condition.Validator)) { currentValidatable.Validations.Remove(condition.Validator); currentValidatable.Validate(); } } } bool CanValidate(TModel entity, Expression <Func <TModel, bool> > evaluator) => new List <TModel> { entity } .AsQueryable().All(evaluator); }
public void SelectedRecipientChanged(Recipient recipient) { if (recipient != null) { CurrentProperties.PopulateWith(recipient.Properties); OnPropertyChanged(nameof(CurrentProperties)); } }
public void SelectedAttachmentsChanged(IEnumerable <Attachment> selection) { IsFileAttachmentSelected = selection.FirstOrDefault(a => a.IsFile) != null; IsEmailAttachmentSelected = selection.FirstOrDefault(a => a.IsEmail) != null; var firstAttachment = selection.FirstOrDefault(a => (a.IsFile || a.IsEmail)); if (firstAttachment != null) { CurrentProperties.PopulateWith(firstAttachment.Properties); OnPropertyChanged(nameof(CurrentProperties)); } }
private void UpdateCurrentMessage(Message m) { CurrentMessage = m; if (m != null) { CurrentProperties.PopulateWith(m.Properties); } else { CurrentProperties.Clear(); } OnPropertyChanged("CurrentMessage"); OnPropertyChanged("CurrentProperties"); OnPropertyChanged("IsMessagePresent"); OnPropertyChanged("CanExportProperties"); OnPropertyChanged("CanPopMessage"); OnPropertyChanged("IsAttachmentPresent"); OnPropertyChanged("IsFileAttachmentPresent"); OnPropertyChanged("IsFileAttachmentSelected"); OnPropertyChanged("IsEmailAttachmentPresent"); OnPropertyChanged("IsEmailAttachmentSelected"); }
// NOTE: make sure to call this method when making an instance of this window. public void PropertiesInit() { ObjectManager objectManager = MainWindowViewModel.viewModel.objectManager; if (objectManager.SelectionObject.Selection != null && objectManager.SelectionObject.Selection.Count > 0) { foreach (KeyValuePair <string, GameObjectProperty> propertyPair in objectManager.SelectionObject.Selection[0].Properties) { CurrentProperties.Add(propertyPair.Key, new GameObjectProperty(propertyPair.Value.RealName, propertyPair.Value.propertyType) { DefaultValue = propertyPair.Value.DefaultValue, CurrentValue = propertyPair.Value.CurrentValue }); } // Add components of selected object to dropdown list foreach (ComponentInfo component in objectManager.SelectionObject.Selection[0].Components) { CurrentComponents.Add(component.Copy()); } } UpdateProperties(); }
protected override void LoadControlState(object savedState) { mCurrProps = new CurrentProperties(); mCurrProps = (CurrentProperties)savedState; }