private void Sort(ImageComparerList.Item item) { IImageBox imageBox = ImageViewer.SelectedImageBox; IDisplaySet displaySet; if (imageBox == null || (displaySet = ImageViewer.SelectedImageBox.DisplaySet) == null) { return; } if (displaySet.PresentationImages.Count == 0) { return; } //try to keep the top-left image the same. IPresentationImage topLeftImage = imageBox.TopLeftPresentationImage; var command = new MemorableUndoableCommand(imageBox) { BeginState = imageBox.CreateMemento() }; displaySet.PresentationImages.Sort(item.Comparer); imageBox.TopLeftPresentationImage = topLeftImage; imageBox.Draw(); command.EndState = imageBox.CreateMemento(); if (!command.BeginState.Equals(command.EndState)) { var historyCommand = new DrawableUndoableCommand(imageBox) { Name = SR.CommandSortImages }; historyCommand.Enqueue(command); Context.Viewer.CommandHistory.AddCommand(historyCommand); } UpdateCheckState(); }
private bool GetSortMenuItemCheckState(ImageComparerList.Item item) { return(SelectedPresentationImage != null && SelectedPresentationImage.ParentDisplaySet != null && item.Comparer.Equals(SelectedPresentationImage.ParentDisplaySet.PresentationImages.SortComparer)); }
private static string GetActionKey(ImageComparerList.Item item) { return(item.IsReverse ? string.Format("{0} (Reverse)", item.Name) : item.Name); }