예제 #1
0
        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)
                );
        }
예제 #2
0
        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();
                        }
                    }
                }
            });
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #6
0
 public void SelectedRecipientChanged(Recipient recipient)
 {
     if (recipient != null)
     {
         CurrentProperties.PopulateWith(recipient.Properties);
         OnPropertyChanged(nameof(CurrentProperties));
     }
 }
예제 #7
0
        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));
            }
        }
예제 #8
0
        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");
        }
예제 #9
0
        // 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();
        }
예제 #10
0
 protected override void LoadControlState(object savedState)
 {
     mCurrProps = new CurrentProperties();
     mCurrProps = (CurrentProperties)savedState;
 }