예제 #1
0
        private void btnAddMultipleNewAttribute_Click(object sender, RoutedEventArgs e)
        {
            if (_entityMetadata == null ||
                _entityMetadata.Attributes == null
                )
            {
                return;
            }

            var currentAttributes = new HashSet <string>(_listAttributeControls.OfType <IAttributeMetadataControl <AttributeMetadata> >().Select(c => c.AttributeMetadata.LogicalName), StringComparer.InvariantCultureIgnoreCase);

            var availableAttributes = _entityMetadata.Attributes.Where(a => string.IsNullOrEmpty(a.AttributeOf) && _attributeChecker(a) && !currentAttributes.Contains(a.LogicalName)).ToList();

            if (!availableAttributes.Any())
            {
                return;
            }

            var form = new WindowAttributeMultiSelect(_iWriteToOutput, _service, _entityMetadata.MetadataId.Value, availableAttributes, string.Empty);

            if (!form.ShowDialog().GetValueOrDefault())
            {
                return;
            }

            var selectedAttributes = form.GetAttributeMetadatas();

            if (!selectedAttributes.Any(a => string.IsNullOrEmpty(a.AttributeOf) && _attributeChecker(a)))
            {
                return;
            }

            foreach (var attributeMetadata in selectedAttributes.Where(a => string.IsNullOrEmpty(a.AttributeOf) && _attributeChecker(a)))
            {
                UserControl control = null;

                this.Dispatcher.Invoke(() =>
                {
                    control = _controlFactory.CreateControlForAttribute(this._iWriteToOutput, _service, this._entityMetadata, attributeMetadata, null, null, true, false);

                    if (control != null && control is IAttributeMetadataControl <AttributeMetadata> attributeControl)
                    {
                        attributeControl.RemoveControlClicked += AttributeControl_RemoveControlClicked;
                    }
                });

                if (control != null)
                {
                    _listAttributeControls.Add(control);
                }
            }

            FilterEntityAttributes(null);
        }
예제 #2
0
        private async void btnSelectAttributes_Click(object sender, RoutedEventArgs e)
        {
            if (!_entityName.IsValidEntityName())
            {
                return;
            }

            if (_entityMetadata == null)
            {
                ToggleControls(false, Properties.OutputStrings.GettingEntityMetadataFormat1, this._entityName);

                var repository = new EntityMetadataRepository(_service);

                _entityMetadata = await repository.GetEntityMetadataAsync(_entityName);

                ToggleControls(true, Properties.OutputStrings.GettingEntityMetadataCompletedFormat1, this._entityName);
            }

            if (_entityMetadata == null)
            {
                return;
            }

            ToggleControls(false, Properties.OutputStrings.UpdatingImageAttributesFormat1, this._entityName);

            var form = new WindowAttributeMultiSelect(_iWriteToOutput
                                                      , _service
                                                      , _entityMetadata.MetadataId.Value
                                                      , _entityMetadata.Attributes
                                                      , txtBAttributes.Text.Trim()
                                                      );

            if (form.ShowDialog().GetValueOrDefault())
            {
                txtBAttributes.Text    = form.GetAttributes();
                txtBAttributes.ToolTip = GetImageTooltip(txtBAttributes.Text);
            }

            ToggleControls(true, Properties.OutputStrings.UpdatingImageAttributesCompletedFormat1, this._entityName);
        }
        private async void btnSelectAttributes_Click(object sender, RoutedEventArgs e)
        {
            string entityName = cmBPrimaryEntity.SelectedItem?.ToString();

            if (!entityName.IsValidEntityName())
            {
                return;
            }

            ToggleControls(false, Properties.OutputStrings.GettingEntityMetadataFormat1, entityName);

            var repository = new EntityMetadataRepository(_service);

            var entityMetadata = await repository.GetEntityMetadataAsync(entityName);

            ToggleControls(true, Properties.OutputStrings.GettingEntityMetadataCompletedFormat1, entityName);

            if (entityMetadata == null)
            {
                return;
            }

            ToggleControls(false, Properties.OutputStrings.UpdatingStepFilteringAttributesFormat1, entityName);

            var form = new WindowAttributeMultiSelect(_iWriteToOutput
                                                      , _service
                                                      , entityMetadata.MetadataId.Value
                                                      , entityMetadata.Attributes
                                                      , txtBFilteringBAttributes.Text.Trim()
                                                      );

            if (form.ShowDialog().GetValueOrDefault())
            {
                txtBFilteringBAttributes.Text = form.GetAttributes();
            }

            ToggleControls(true, Properties.OutputStrings.UpdatingStepFilteringAttributesCompletedFormat1, entityName);
        }