Example #1
0
        public static void Show(IDesktopWindow desktopWindow, ShelfDisplayHint displayHint)
        {
            if (!PermissionsHelper.IsInRole(AuthorityTokens.KeyImages))
            {
                throw new PolicyException(SR.ExceptionViewKeyImagePermissionDenied);
            }

            desktopWindow = desktopWindow ?? Application.ActiveDesktopWindow;

            IShelf shelf = GetClipboardShelf(desktopWindow);

            if (shelf != null)
            {
                shelf.Activate();
            }
            else
            {
                Workspace           activeWorkspace = desktopWindow.ActiveWorkspace;
                KeyImageInformation info            = GetKeyImageInformation(activeWorkspace) ?? new KeyImageInformation();
                ClipboardComponent  component       = new KeyImageClipboardComponent(info);
                shelf         = ApplicationComponent.LaunchAsShelf(desktopWindow, component, SR.TitleKeyImages, displayHint);
                shelf.Closed += OnClipboardShelfClosed;

                _clipboardShelves[desktopWindow] = shelf;
            }
        }
Example #2
0
        internal static void OnViewerClosed(IImageViewer viewer)
        {
            KeyImageInformation info = GetKeyImageInformation(viewer);

            _keyImageInformation.Remove(viewer);

            if (info != null)
            {
                using (info)
                {
                    try
                    {
                        var publisher = new KeyImagePublisher(info);
                        publisher.Publish();
                    }
                    catch (Exception e)
                    {
                        //Should never happen because KeyImagePublisher.Publish doesn't throw exceptions.
                        ExceptionHandler.Report(e, Application.ActiveDesktopWindow);
                    }
                }
            }

            ManageActivityMonitorConnection();
        }
Example #3
0
        public static void Add(IPresentationImage image)
        {
            Platform.CheckForNullReference(image, "image");
            Platform.CheckForNullReference(image.ImageViewer, "image.ImageViewer");

            if (!PermissionsHelper.IsInRole(AuthorityTokens.KeyImages))
            {
                throw new PolicyException(SR.ExceptionCreateKeyImagePermissionDenied);
            }

            KeyImageInformation info = GetKeyImageInformation(image.ImageViewer);

            if (info == null)
            {
                throw new ArgumentException("The specified image's viewer is not valid.", "image");
            }

            IImageSopProvider sopProvider = image as IImageSopProvider;

            if (sopProvider == null)
            {
                throw new ArgumentException("The image must be an IImageSopProvider.", "image");
            }

            info.ClipboardItems.Add(ClipboardComponent.CreatePresentationImageItem(image));
        }
        private static IEnumerable <IClipboardItem> CreateClipboardItems(StudyTree studyTree, Sop keyObjectSelectionDocument)
        {
            Platform.CheckTrue(keyObjectSelectionDocument.SopClassUid == SopClass.KeyObjectSelectionDocumentStorageUid, "SOP Class must be Key Object Selection Document Storage");

            var dummyContext = new KeyImageInformation();             // just need an instance of creating items
            var factory      = new PresentationImageFactory(studyTree);

            foreach (var image in factory.CreateImages(keyObjectSelectionDocument))
            {
                var presentationStateInstanceUid = string.Empty;

                // set the deserialize interactive flag on the presentation state
                var dicomPresentationImage = image as IDicomPresentationImage;
                if (dicomPresentationImage != null)
                {
                    var presentationState = dicomPresentationImage.PresentationState as DicomSoftcopyPresentationState;
                    if (presentationState != null)
                    {
                        presentationState.DeserializeOptions |= DicomSoftcopyPresentationStateDeserializeOptions.InteractiveAnnotations;
                        presentationStateInstanceUid          = presentationState.PresentationSopInstanceUid;
                    }
                }

                var item = dummyContext.CreateKeyImageItem(image, true);
                item.AssignSourceInfo(Guid.NewGuid(), keyObjectSelectionDocument.SopInstanceUid, presentationStateInstanceUid);
                yield return(item);
            }
        }
Example #5
0
		public static bool UpdateKeyImage(this IPresentationImage image, KeyImageInformation context)
		{
			if (context != null)
			{
				var presentationStateUid = GetPresentationStateSopInstanceUid(image);

				var clipboardItems = context.Items;
				var result = clipboardItems.Select((k, i) => new
				                                             	{
				                                             		k.Item,
				                                             		IsSerialized = k.IsSerialized(),
				                                             		Index = i,
				                                             		MetaData = k.ExtensionData.GetOrCreate<KeyImageItemMetaData>()
				                                             	})
					.FirstOrDefault(c => c.IsSerialized && c.MetaData.PrSopInstanceUid == presentationStateUid);
				if (result != null)
				{
					var keyImageItem = context.CreateKeyImageItem(image);

					var metadata = ((IClipboardItem) keyImageItem).ExtensionData.GetOrCreate<KeyImageItemMetaData>();
					metadata.Changes = true;
					metadata.Guid = result.MetaData.Guid;
					metadata.KoSopInstanceUid = result.MetaData.KoSopInstanceUid;
					metadata.PrSopInstanceUid = result.MetaData.PrSopInstanceUid;
					metadata.OriginalItem = result.MetaData.OriginalItem ?? clipboardItems[result.Index];

					clipboardItems[result.Index] = keyImageItem;
					return true;
				}
			}
			return false;
		}
Example #6
0
        public static bool UpdateKeyImage(this IPresentationImage image, KeyImageInformation context)
        {
            if (context != null)
            {
                var presentationStateUid = GetPresentationStateSopInstanceUid(image);

                var clipboardItems = context.Items;
                var result         = clipboardItems.Select((k, i) => new
                {
                    k.Item,
                    IsSerialized = k.IsSerialized(),
                    Index        = i,
                    MetaData     = k.ExtensionData.GetOrCreate <KeyImageItemMetaData>()
                })
                                     .FirstOrDefault(c => c.IsSerialized && c.MetaData.PrSopInstanceUid == presentationStateUid);
                if (result != null)
                {
                    var keyImageItem = context.CreateKeyImageItem(image);

                    var metadata = ((IClipboardItem)keyImageItem).ExtensionData.GetOrCreate <KeyImageItemMetaData>();
                    metadata.Changes          = true;
                    metadata.Guid             = result.MetaData.Guid;
                    metadata.KoSopInstanceUid = result.MetaData.KoSopInstanceUid;
                    metadata.PrSopInstanceUid = result.MetaData.PrSopInstanceUid;
                    metadata.OriginalItem     = result.MetaData.OriginalItem ?? clipboardItems[result.Index];

                    clipboardItems[result.Index] = keyImageItem;
                    return(true);
                }
            }
            return(false);
        }
		private static IEnumerable<IClipboardItem> CreateClipboardItems(StudyTree studyTree, Sop keyObjectSelectionDocument)
		{
			Platform.CheckTrue(keyObjectSelectionDocument.SopClassUid == SopClass.KeyObjectSelectionDocumentStorageUid, "SOP Class must be Key Object Selection Document Storage");

			var dummyContext = new KeyImageInformation(); // just need an instance of creating items
			var factory = new PresentationImageFactory(studyTree);
			foreach (var image in factory.CreateImages(keyObjectSelectionDocument))
			{
				var presentationStateInstanceUid = string.Empty;

				// set the deserialize interactive flag on the presentation state
				var dicomPresentationImage = image as IDicomPresentationImage;
				if (dicomPresentationImage != null)
				{
					var presentationState = dicomPresentationImage.PresentationState as DicomSoftcopyPresentationState;
					if (presentationState != null)
					{
						presentationState.DeserializeOptions |= DicomSoftcopyPresentationStateDeserializeOptions.InteractiveAnnotations;
						presentationStateInstanceUid = presentationState.PresentationSopInstanceUid;
					}
				}

				var item = dummyContext.CreateKeyImageItem(image, true);
				item.AssignSourceInfo(Guid.NewGuid(), keyObjectSelectionDocument.SopInstanceUid, presentationStateInstanceUid);
				yield return item;
			}
		}
Example #8
0
        internal static void OnViewerOpened(IImageViewer viewer)
        {
            if (!_keyImageInformation.ContainsKey(viewer))
            {
                _keyImageInformation[viewer] = new KeyImageInformation();
            }

            ManageActivityMonitorConnection();
        }
		public KeyImageClipboard(StudyTree studyTree)
		{
			_studyTree = studyTree;

			_currentContext = new KeyImageInformation();
			_availableContexts = new ObservableList<KeyImageInformation> {_currentContext};
			_availableContexts.AddRange(_studyTree.Studies
			                            	.SelectMany(s => s.Series)
			                            	.SelectMany(s => s.Sops)
			                            	.Where(s => s.SopClassUid == SopClass.KeyObjectSelectionDocumentStorageUid)
			                            	.Select(s => new KeyImageInformation(studyTree, s))
			                            	.OrderByDescending(s => s.ContentDateTime)
			                            	.ThenBy(s => s.SeriesNumber));
		}
Example #10
0
		public static bool RevertKeyImage(this IClipboardItem item, KeyImageInformation context)
		{
			var guid = GetGuid(item);
			if (context != null && IsSerialized(item))
			{
				var clipboardItems = context.Items;
				var result = clipboardItems.Where(k => IsSerialized(k) && GetGuid(k) == guid).Select((k, i) => new {k.Item, Index = i, MetaData = k.ExtensionData.GetOrCreate<KeyImageItemMetaData>()}).FirstOrDefault();
				if (result != null)
				{
					clipboardItems[result.Index] = result.MetaData.OriginalItem;
					return true;
				}
			}
			return false;
		}
Example #11
0
        public static bool RevertKeyImage(this IClipboardItem item, KeyImageInformation context)
        {
            var guid = GetGuid(item);

            if (context != null && IsSerialized(item))
            {
                var clipboardItems = context.Items;
                var result         = clipboardItems.Where(k => IsSerialized(k) && GetGuid(k) == guid).Select((k, i) => new { k.Item, Index = i, MetaData = k.ExtensionData.GetOrCreate <KeyImageItemMetaData>() }).FirstOrDefault();
                if (result != null)
                {
                    clipboardItems[result.Index] = result.MetaData.OriginalItem;
                    return(true);
                }
            }
            return(false);
        }
        public KeyImageClipboard(StudyTree studyTree)
        {
            _studyTree = studyTree;

            _currentContext    = new KeyImageInformation();
            _availableContexts = new List <KeyImageInformation> {
                _currentContext
            };
            _availableContexts.AddRange(_studyTree.Studies
                                        .SelectMany(s => s.Series)
                                        .SelectMany(s => s.Sops)
                                        .Where(s => s.SopClassUid == SopClass.KeyObjectSelectionDocumentStorageUid)
                                        .Select(s => new KeyImageInformation(studyTree, s))
                                        .OrderByDescending(s => s.ContentDateTime)
                                        .ThenBy(s => s.SeriesNumber));
        }
        internal static void Launch(IDesktopWindow desktopWindow)
        {
            KeyImageInformation info = KeyImageClipboard.GetKeyImageInformation(desktopWindow);

            if (info == null)
            {
                throw new ArgumentException("There is no valid key image data available for the given window.", "desktopWindow");
            }

            KeyImageInformationEditorComponent component = new KeyImageInformationEditorComponent();

            component.Description       = info.Description;
            component.DocumentTitle     = info.DocumentTitle;
            component.SeriesDescription = info.SeriesDescription;

            ApplicationComponentExitCode exitCode = LaunchAsDialog(desktopWindow, component, SR.TitleEditKeyImageInformation);

            if (exitCode == ApplicationComponentExitCode.Accepted)
            {
                info.Description       = component.Description;
                info.DocumentTitle     = component.DocumentTitle;
                info.SeriesDescription = component.SeriesDescription;
            }
        }
 public KeyImageClipboardComponent(KeyImageInformation keyImageInformation)
     : base(KeyImageClipboard.ToolbarSite, KeyImageClipboard.MenuSite, keyImageInformation.ClipboardItems, false)
 {
     _keyImageInformation = keyImageInformation;
 }
Example #15
0
 public KeyImagePublisher(KeyImageInformation information)
 {
     _sourceInformation  = information;
     _keyObjectDocuments = new List <DicomFile>();
 }
Example #16
0
		internal static void OnViewerOpened(IImageViewer viewer)
		{
			if (!_keyImageInformation.ContainsKey(viewer))
				_keyImageInformation[viewer] = new KeyImageInformation();

			ManageActivityMonitorConnection();
		}
Example #17
0
		public KeyImageClipboardComponent(KeyImageInformation keyImageInformation)
			: base(KeyImageClipboard.ToolbarSite, KeyImageClipboard.MenuSite, keyImageInformation.ClipboardItems, false)
		{
			_keyImageInformation = keyImageInformation;
		}