Пример #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;
            }
        }
Пример #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();
        }
Пример #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));
        }
Пример #4
0
        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);
            }
        }
Пример #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;
		}
Пример #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);
        }
Пример #7
0
		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;
			}
		}
Пример #8
0
        internal static void OnViewerOpened(IImageViewer viewer)
        {
            if (!_keyImageInformation.ContainsKey(viewer))
            {
                _keyImageInformation[viewer] = new KeyImageInformation();
            }

            ManageActivityMonitorConnection();
        }
Пример #9
0
		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));
		}
Пример #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;
		}
Пример #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);
        }
Пример #12
0
        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;
            }
        }
Пример #14
0
 public KeyImageClipboardComponent(KeyImageInformation keyImageInformation)
     : base(KeyImageClipboard.ToolbarSite, KeyImageClipboard.MenuSite, keyImageInformation.ClipboardItems, false)
 {
     _keyImageInformation = keyImageInformation;
 }
Пример #15
0
 public KeyImagePublisher(KeyImageInformation information)
 {
     _sourceInformation  = information;
     _keyObjectDocuments = new List <DicomFile>();
 }
Пример #16
0
		internal static void OnViewerOpened(IImageViewer viewer)
		{
			if (!_keyImageInformation.ContainsKey(viewer))
				_keyImageInformation[viewer] = new KeyImageInformation();

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