/// <summary> /// Called to create a clipboard item representing a display set. /// </summary> /// <param name="displaySet"></param> /// <param name="selectionStrategy"></param> /// <returns></returns> public virtual ClipboardItem CreateDisplaySetItem(IDisplaySet displaySet, IImageSelectionStrategy selectionStrategy = null) { if (displaySet.PresentationImages.Count == 0) { throw new ArgumentException("DisplaySet must have at least one image."); } var presentationImage = displaySet.ImageBox != null && displaySet.ImageBox.SelectedTile != null && displaySet.ImageBox.SelectedTile.PresentationImage != null ? displaySet.ImageBox.SelectedTile.PresentationImage : displaySet.PresentationImages[displaySet.PresentationImages.Count / 2]; var clientRectangle = presentationImage.ClientRectangle; if (clientRectangle.IsEmpty) { clientRectangle = new Rectangle(new Point(), presentationImage.SceneSize); } if (selectionStrategy == null) { if (displaySet.PresentationImages.Count == 1) { // Add as a single image. return(CreatePresentationImageItem(displaySet.PresentationImages[0])); } else { return(CreateDisplaySetItem(displaySet.Clone(), clientRectangle)); } } else { List <IPresentationImage> images = new List <IPresentationImage>(selectionStrategy.GetImages(displaySet)); if (images.Count == 1) { // Add as a single image. return(CreatePresentationImageItem(images[0])); } else { string name = String.Format("{0} - {1}", selectionStrategy.Description, displaySet.Name); displaySet = new DisplaySet(name, displaySet.Uid) { Description = displaySet.Description, Number = displaySet.Number }; images.ForEach(image => displaySet.PresentationImages.Add(image.Clone())); return(CreateDisplaySetItem(displaySet, clientRectangle)); } } }
public static IClipboardItem CreateDisplaySetItem(IDisplaySet displaySet, IImageSelectionStrategy selectionStrategy) { if (displaySet.ImageBox == null || displaySet.ImageBox.SelectedTile == null || displaySet.ImageBox.SelectedTile.PresentationImage == null) { throw new ArgumentException("DisplaySet must have a selected image."); } Rectangle clientRectangle = displaySet.ImageBox.SelectedTile.PresentationImage.ClientRectangle; if (selectionStrategy == null) { if (displaySet.PresentationImages.Count == 1) { // Add as a single image. return(CreatePresentationImageItem(displaySet.PresentationImages[0])); } else { return(CreateDisplaySetItem(displaySet.Clone(), clientRectangle)); } } else { List <IPresentationImage> images = new List <IPresentationImage>(selectionStrategy.GetImages(displaySet)); if (images.Count == 1) { // Add as a single image. return(CreatePresentationImageItem(images[0])); } else { string name = String.Format("{0} - {1}", selectionStrategy.Description, displaySet.Name); displaySet = new DisplaySet(name, displaySet.Uid) { Description = displaySet.Description, Number = displaySet.Number }; images.ForEach(delegate(IPresentationImage image) { displaySet.PresentationImages.Add(image.Clone()); }); return(CreateDisplaySetItem(displaySet, clientRectangle)); } } }
/// <summary> /// Called to create a clipboard item representing a display set. /// </summary> /// <param name="displaySet"></param> /// <param name="selectionStrategy"></param> /// <returns></returns> public virtual ClipboardItem CreateDisplaySetItem(IDisplaySet displaySet, IImageSelectionStrategy selectionStrategy = null) { if (displaySet.PresentationImages.Count == 0) throw new ArgumentException("DisplaySet must have at least one image."); var presentationImage = displaySet.ImageBox != null && displaySet.ImageBox.SelectedTile != null && displaySet.ImageBox.SelectedTile.PresentationImage != null ? displaySet.ImageBox.SelectedTile.PresentationImage : displaySet.PresentationImages[displaySet.PresentationImages.Count/2]; var clientRectangle = presentationImage.ClientRectangle; if (clientRectangle.IsEmpty) clientRectangle = new Rectangle(new Point(), presentationImage.SceneSize); if (selectionStrategy == null) { if (displaySet.PresentationImages.Count == 1) { // Add as a single image. return CreatePresentationImageItem(displaySet.PresentationImages[0]); } else { return CreateDisplaySetItem(displaySet.Clone(), clientRectangle); } } else { List<IPresentationImage> images = new List<IPresentationImage>(selectionStrategy.GetImages(displaySet)); if (images.Count == 1) { // Add as a single image. return CreatePresentationImageItem(images[0]); } else { string name = String.Format("{0} - {1}", selectionStrategy.Description, displaySet.Name); displaySet = new DisplaySet(name, displaySet.Uid) {Description = displaySet.Description, Number = displaySet.Number}; images.ForEach(image => displaySet.PresentationImages.Add(image.Clone())); return CreateDisplaySetItem(displaySet, clientRectangle); } } }