private void UpdateAnnotations() { var selectedAnnotations = new HashSet <string>(SelectedAnnotationNames); var annotationTargets = SelectedHandlers.Aggregate(AnnotationDef.AnnotationTargetSet.EMPTY, (value, handler) => value.Union(handler.AnnotationTargets)); var newAnnotations = Document.Settings.DataSettings.AnnotationDefs.Where( annotationDef => annotationDef.AnnotationTargets.Intersect(annotationTargets).Any()) .Select(annotationDef => annotationDef.Name).OrderBy(name => name).ToArray(); if (newAnnotations.SequenceEqual(listBoxAnnotations.Items.OfType <string>())) { return; } listBoxAnnotations.Items.Clear(); listBoxAnnotations.Items.AddRange(newAnnotations); for (int i = 0; i < listBoxAnnotations.Items.Count; i++) { if (selectedAnnotations.Contains(newAnnotations[i])) { listBoxAnnotations.SelectedIndices.Add(i); } else { listBoxAnnotations.SelectedIndices.Remove(i); } } }
private void UpdateProperties() { var selectedProperties = ImmutableList.ValueOf(SelectedProperties); var newProperties = SelectedHandlers .SelectMany(handler => handler.Properties.Select(pd => pd.PropertyDescriptor.Name)).Distinct() .OrderBy(name => name).ToArray(); if (newProperties.SequenceEqual(listBoxProperties.Items.OfType <string>())) { return; } listBoxProperties.Items.Clear(); listBoxProperties.Items.AddRange(newProperties); for (int i = 0; i < listBoxProperties.Items.Count; i++) { if (selectedProperties.Contains(newProperties[i])) { listBoxProperties.SelectedIndices.Add(i); } else { listBoxProperties.SelectedIndices.Remove(i); } } }
public ExportAnnotationSettings GetExportAnnotationSettings() { return(ExportAnnotationSettings.EMPTY .ChangeElementTypes(SelectedHandlers.Select(handler => handler.Name)) .ChangeAnnotationNames(SelectedAnnotationNames) .ChangePropertyNames(SelectedProperties) .ChangeRemoveBlankRows(cbxRemoveBlankRows.Checked)); }