private FilteredGroup <IImageSet> GetRootGroup(FilteredGroup <IImageSet> group) { if (group.HasItems) { return(group); } int validChildGroups = 0; foreach (FilteredGroup <IImageSet> child in group.ChildGroups) { if (child.GetAllItems().Count > 0) { ++validChildGroups; } } //if this group has more than one child group with items anywhere in it's tree, then it's first. if (validChildGroups > 1) { return(group); } foreach (FilteredGroup <IImageSet> child in group.ChildGroups) { FilteredGroup <IImageSet> rootGroup = GetRootGroup(child); if (rootGroup != null) { return(rootGroup); } } return(null); }
private IEnumerable <FilteredGroup <IImageSet> > TraverseImageSetGroups(FilteredGroup <IImageSet> group, string rootPath) { List <IImageSet> allItems = group.GetAllItems(); if (allItems.Count != 0) { if (_currentPathElements.Count == 0) { _currentPathElements.Add(rootPath); } else { _currentPathElements.Add(group.Label.Replace("/", "-")); } yield return(group); } foreach (FilteredGroup <IImageSet> child in group.ChildGroups) { foreach (FilteredGroup <IImageSet> nonEmptyChild in TraverseImageSetGroups(child, rootPath)) { yield return(nonEmptyChild); } } if (allItems.Count != 0) { _currentPathElements.RemoveAt(_currentPathElements.Count - 1); } }
private void TraceGroup(FilteredGroup <IImageSet> group, string currentGroupPath) { foreach (IImageSet imageSet in group.Items) { string imageSetPath = String.Format("{0}/{1}", currentGroupPath, imageSet.Name); Trace.WriteLine(imageSetPath); } foreach (FilteredGroup <IImageSet> childGroup in group.ChildGroups) { string name = childGroup.Label; string groupPath = String.Format("{0}/{1}", currentGroupPath, name); TraceGroup(childGroup, groupPath); } }
private ImageSetTreeGroupItem FindGroupItem(FilteredGroup <IImageSet> filteredGroup) { ImageSetTreeGroupItem groupItem = CollectionUtils.SelectFirst(_tree.Items, delegate(IImageSetTreeItem treeItem) { if (treeItem is ImageSetTreeGroupItem) { return(((ImageSetTreeGroupItem)treeItem)._group == filteredGroup); } else { return(false); } }) as ImageSetTreeGroupItem; return(groupItem); }
internal ImageSetTreeGroupItem(FilteredGroup <IImageSet> group, IComparer <IImageSet> imageSetComparer, ITreeItemBinding binding) { _group = group; _imageSetComparer = imageSetComparer; _tree = new Tree <IImageSetTreeItem>(binding); _group.ItemAdded += OnItemAdded; _group.ItemRemoved += OnItemRemoved; _group.ChildGroups.ItemAdded += OnChildGroupAdded; _group.ChildGroups.ItemRemoved += OnChildGroupRemoved; _group.ChildGroups.ItemChanging += OnChildGroupChanging; _group.ChildGroups.ItemChanged += OnChildGroupChanged; Initialize(); IsExpanded = false; }
private ImageSetTreeGroupItem(FilteredGroup <IImageSet> group, ImageSetTreeGroupItem parent, ITreeItemBinding binding) : this(group, parent._imageSetComparer, binding) { _parent = parent; }
/// <summary> /// Gets an array of <see cref="IAction"/> objects that allow selection of specific display /// sets for display in the currently selected image box. /// </summary> /// <returns></returns> private IActionSet GetDisplaySetActions() { #if TRACEGROUPS TraceGroups(); #endif const string rootPath = _contextMenuSite; _currentPathElements = new List <string>(); List <IAction> actions = new List <IAction>(); FilteredGroup <IImageSet> rootGroup = GetRootGroup(_imageSetGroups.Root); if (rootGroup != null) { var actionPlaceholder = ActionPlaceholder.GetPlaceholderAction(_contextMenuSite, base.Actions, _placeHolderActionId); ActionFactoryContext context = new ActionFactoryContext { DesktopWindow = Context.DesktopWindow, ImageViewer = Context.Viewer, Namespace = GetType().FullName, ActionPlaceholder = actionPlaceholder }; bool showImageSetNames = base.ImageViewer.LogicalWorkspace.ImageSets.Count > 1; int loadingPriorsNumber = 0; foreach (FilteredGroup <IImageSet> group in TraverseImageSetGroups(rootGroup, rootPath)) { string basePath = StringUtilities.Combine(_currentPathElements, "/"); //not incredibly efficient, but there really aren't that many items. List <IImageSet> orderedItems = new List <IImageSet>(group.Items); orderedItems.Sort(_comparer); foreach (IImageSet imageSet in orderedItems) { string imageSetPath; if (showImageSetNames) { imageSetPath = String.Format("{0}/{1}", basePath, imageSet.Name.Replace("/", "-")); } else { imageSetPath = basePath; } context.Initialize(imageSet, imageSetPath); foreach (IActionFactory factory in _actionFactories) { actions.AddRange(factory.CreateActions(context)); } if (actions.Count == 0 || !context.ExcludeDefaultActions) { actions.AddRange(_defaultActionFactory.CreateActions(context)); } } if (group.Items.Count > 0 && base.ImageViewer.PriorStudyLoader.IsActive) { actions.Add(CreateLoadingPriorsAction(actionPlaceholder, basePath, ++loadingPriorsNumber)); } } } return(new ActionSet(actions)); }
private ImageSetTreeGroupItem FindGroupItem(FilteredGroup<IImageSet> filteredGroup) { ImageSetTreeGroupItem groupItem = CollectionUtils.SelectFirst(_tree.Items, delegate(IImageSetTreeItem treeItem) { if (treeItem is ImageSetTreeGroupItem) return ((ImageSetTreeGroupItem)treeItem)._group == filteredGroup; else return false; }) as ImageSetTreeGroupItem; return groupItem; }
internal ImageSetTreeGroupItem(FilteredGroup<IImageSet> group, IComparer<IImageSet> imageSetComparer, ITreeItemBinding binding) { _group = group; _imageSetComparer = imageSetComparer; _tree = new Tree<IImageSetTreeItem>(binding); _group.ItemAdded += OnItemAdded; _group.ItemRemoved += OnItemRemoved; _group.ChildGroups.ItemAdded += OnChildGroupAdded; _group.ChildGroups.ItemRemoved += OnChildGroupRemoved; _group.ChildGroups.ItemChanging += OnChildGroupChanging; _group.ChildGroups.ItemChanged += OnChildGroupChanged; Initialize(); IsExpanded = false; }
private ImageSetTreeGroupItem(FilteredGroup<IImageSet> group, ImageSetTreeGroupItem parent, ITreeItemBinding binding) : this(group, parent._imageSetComparer, binding) { _parent = parent; }
private void TraceGroup(FilteredGroup<IImageSet> group, string currentGroupPath) { foreach (IImageSet imageSet in group.Items) { string imageSetPath = String.Format("{0}/{1}", currentGroupPath, imageSet.Name); Trace.WriteLine(imageSetPath); } foreach (FilteredGroup<IImageSet> childGroup in group.ChildGroups) { string name = childGroup.Label; string groupPath = String.Format("{0}/{1}", currentGroupPath, name); TraceGroup(childGroup, groupPath); } }
private FilteredGroup<IImageSet> GetRootGroup(FilteredGroup<IImageSet> group) { if (group.HasItems) return group; int validChildGroups = 0; foreach (FilteredGroup<IImageSet> child in group.ChildGroups) { if (child.GetAllItems().Count > 0) ++validChildGroups; } //if this group has more than one child group with items anywhere in it's tree, then it's first. if (validChildGroups > 1) return group; foreach (FilteredGroup<IImageSet> child in group.ChildGroups) { FilteredGroup<IImageSet> rootGroup = GetRootGroup(child); if (rootGroup != null) return rootGroup; } return null; }
private IEnumerable<FilteredGroup<IImageSet>> TraverseImageSetGroups(FilteredGroup<IImageSet> group, string rootPath) { List<IImageSet> allItems = group.GetAllItems(); if (allItems.Count != 0) { if (_currentPathElements.Count == 0) _currentPathElements.Add(rootPath); else _currentPathElements.Add(group.Label.Replace("/", "-")); yield return group; } foreach (FilteredGroup<IImageSet> child in group.ChildGroups) { foreach (FilteredGroup<IImageSet> nonEmptyChild in TraverseImageSetGroups(child, rootPath)) yield return nonEmptyChild; } if (allItems.Count != 0) _currentPathElements.RemoveAt(_currentPathElements.Count - 1); }