private void MainForm_Load(object sender, System.EventArgs e) { // Initialize the viewer object. DicomEngine.Startup(); _viewer = new MyAutomationImageViewer(); _viewer.BackColor = SystemColors.Control; _viewer.KeyDown += new KeyEventHandler(_viewer_KeyDown); _viewer.Dock = DockStyle.Fill; this._splitContainer.Panel2.Controls.Add(_viewer); _automationInteractiveMode = new AutomationInteractiveMode(); _automationInteractiveMode.IdleCursor = Cursors.Arrow; _automationInteractiveMode.WorkingCursor = Cursors.Cross; _viewer.InteractiveModes.BeginUpdate(); _viewer.InteractiveModes.Add(_automationInteractiveMode); _viewer.InteractiveModes.EndUpdate(); _dsImage = new DicomDataSet(); if (_dsImage == null) { Messager.ShowError(this, "Can't create dicom object. Quitting app."); Application.Exit(); return; } BringToFront(); InitAutomationManager(); _presentation = new DicomPresentationStateInformation(); _presentation.InstanceNumber = 1; _presentation.PresentationLabel = "LABEL"; _presentationStateDialog = new PresentationStateAttributesDialog(); _dicomAnnotationsUtilities = new DicomAnnotationsUtilities(); Application.ApplicationExit += new EventHandler(Application_ApplicationExit); LoadImage(true); }
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); }