private void SaveFilter()
        {
            if (EntityDataFilter == null)
            {
                return;
            }

            //EntityDataFilter.EnglishLabelField = TextBoxEnglishLabelField.Text;

            EntityDataFilter.Attributes       = Fields.Where(field => field.IsSelected).Select(field => field.Name).ToArray();
            EntityDataFilter.AttributeRenames = Fields.Where(field => !string.IsNullOrWhiteSpace(field.Rename))
                                                .ToDictionary(field => field.Name, field => field.Rename);
            EntityDataFilter.AttributeLanguages = Fields.Where(field => !string.IsNullOrWhiteSpace(field.Language))
                                                  .ToDictionary(field => field.Name, field => field.Language);
            EntityDataFilter.ReadOnly  = Fields.Where(field => field.IsReadOnly).Select(field => field.Name).ToArray();
            EntityDataFilter.ClearFlag = Fields.Where(field => field.IsClearFlag).Select(field => field.Name).ToArray();

            EntityDataFilter.OneToN =
                Relations1N.Where(relation => relation.IsSelected).Select(relation => relation.Name).ToArray();
            EntityDataFilter.OneToNRenames = Relations1N.Where(relation => !string.IsNullOrWhiteSpace(relation.Rename))
                                             .ToDictionary(relation => relation.Name, relation => relation.Rename);
            EntityDataFilter.OneToNReadOnly = Relations1N.ToDictionary(relation => relation.Name, relation => relation.IsReadOnly);

            EntityDataFilter.NToOne =
                RelationsN1.Where(relation => relation.IsSelected).Select(relation => relation.Name).ToArray();
            EntityDataFilter.NToOneRenames = RelationsN1.Where(relation => !string.IsNullOrWhiteSpace(relation.Rename))
                                             .ToDictionary(relation => relation.Name, relation => relation.Rename);
            EntityDataFilter.NToOneFlatten  = RelationsN1.ToDictionary(relation => relation.Name, relation => relation.IsFlatten);
            EntityDataFilter.NToOneReadOnly = RelationsN1.ToDictionary(relation => relation.Name, relation => relation.IsReadOnly);

            EntityDataFilter.NToN =
                RelationsNN.Where(relation => relation.IsSelected).Select(relation => relation.Name).ToArray();
            EntityDataFilter.NToNRenames = RelationsNN.Where(relation => !string.IsNullOrWhiteSpace(relation.Rename))
                                           .ToDictionary(relation => relation.Name, relation => relation.Rename);
            EntityDataFilter.NToNReadOnly = RelationsNN.ToDictionary(relation => relation.Name, relation => relation.IsReadOnly);

            var toSelect = Relations1N.Where(relation => relation.IsSelected).Select(relation => relation.ToEntity)
                           .Union(RelationsN1.Where(relation => relation.IsSelected).Select(relation => relation.ToEntity)
                                  .Union(RelationsNN.Where(relation => relation.IsSelected)
                                         .SelectMany(relation => new[] { relation.ToEntity, relation.IntersectEntity })))
                           .Distinct();

            foreach (var entityRow in Entities.Where(entity => toSelect.Contains(entity.Name) && !entity.IsSelected))
            {
                entityRow.IsSelected = true;
            }
        }
        private void ButtonClearNames_Click(object sender, RoutedEventArgs e)
        {
            foreach (var field in Fields.Where(field => !string.IsNullOrEmpty(field.Rename)))
            {
                field.Rename = "";
            }

            foreach (var relation in Relations1N.Where(relation => !string.IsNullOrEmpty(relation.Rename)))
            {
                relation.Rename = "";
            }

            foreach (var relation in RelationsN1.Where(relation => !string.IsNullOrEmpty(relation.Rename)))
            {
                relation.Rename = "";
            }

            foreach (var relation in RelationsNN.Where(relation => !string.IsNullOrEmpty(relation.Rename)))
            {
                relation.Rename = "";
            }
        }