Ejemplo n.º 1
0
        private bool LoadAnnotationFile(string fileName, bool loadDefaultImage)
        {
            if (File.Exists(fileName))
            {
                try
                {
                    DicomDataSet dsPresentationState = new DicomDataSet();
                    dsPresentationState.Load(fileName, DicomDataSetLoadFlags.LoadAndClose);

                    AnnContainer annContainer = _dicomAnnotationsUtilities.FromDataSetToAnnContainer(dsPresentationState, null, _dsImage);
                    if (annContainer != null)
                    {
                        foreach (AnnObject annObject in annContainer.Children)
                        {
                            DrawLeadAnnotationObject(annObject);
                        }
                    }


                    _presentation = dsPresentationState.GetPresentationStateInformation();

                    DicomPresentationStateInformation PresState = dsPresentationState.GetPresentationStateInformation();
                    if (PresState != null)
                    {
                        _presentationStateDialog.Presentation.InstanceNumber          = PresState.InstanceNumber;
                        _presentationStateDialog.Presentation.PresentationCreator     = PresState.PresentationCreator;
                        _presentationStateDialog.Presentation.PresentationLabel       = PresState.PresentationLabel;
                        _presentationStateDialog.Presentation.PresentationDescription = PresState.PresentationDescription;
                        if (PresState.PresentationCreationDate.Year != 0)
                        {
                            _presentationStateDialog.Presentation.CreationDate = PresState.PresentationCreationDate.ToDateTime();
                        }
                        if (PresState.PresentationCreationTime.Hours != 0)
                        {
                            _presentationStateDialog.Presentation.CreationTime = PresState.PresentationCreationTime.ToDateTime();
                        }

                        _automation.SelectObjects(null);
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    Messager.ShowError(this, ex.Message);
                }
            }
            else
            {
                ClearAnnotations();

                //if not the default file, show a message
                if (!loadDefaultImage)
                {
                    Messager.ShowInformation(
                        this,
                        "No related Presentation State file (.pre) was found. A Grayscale Softcopy Presentation State object will be created for the loaded image."
                        );
                }
            }
            return(false);
        }