private void CreateDICOMDIR_Click(object sender, EventArgs e) { try { CreateDICOMDIR.Enabled = false; // Load the Media session string sessionFileName = Application.StartupPath + "\\Media.ses"; Dvtk.Sessions.MediaSession mediaSession = Dvtk.Sessions.MediaSession.LoadFromFile(sessionFileName); mediaSession.ResultsRootDirectory = outputDirectory; mediaSession.StorageMode = Dvtk.Sessions.StorageMode.NoStorage; // Move all DCM files to directory "DICOM" in result root directory. DirectoryInfo theDirectoryInfo = new DirectoryInfo(outputDirectory + "\\DICOM"); // Create "DICOM" directory if it doesn't exist if (!theDirectoryInfo.Exists) { theDirectoryInfo.Create(); } else { // Remove existing DCM files from "DICOM" directory FileInfo[] files = theDirectoryInfo.GetFiles(); foreach (FileInfo file in files) { file.Delete(); } } int i = 0; string[] dcmFiles = new string[allDCMFilesTemp.Count]; foreach (string dcmFile in allDCMFilesTemp) { FileInfo theFileInfo = new FileInfo(dcmFile); string destFileName = theDirectoryInfo.FullName + "\\" + theFileInfo.Name; theFileInfo.CopyTo(destFileName, true); dcmFiles.SetValue(destFileName, i); i++; } if (mediaSession.GenerateDICOMDIR(dcmFiles)) { string msg = string.Format("DICOMDIR created successfully in directory:{0}", outputDirectory); MessageBox.Show(msg, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception exp) { string msg = "Exception in DICOMDIR generation:" + exp.Message + "\n"; MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Initialize the media session. /// </summary> private void InitializeMediaSession() { try { // Report Progress. ReportProgress(0, "Load definition files..."); this.mediaSession = new Dvtk.Sessions.MediaSession(); string definitionFilesPath = Path.Combine(Environment.GetEnvironmentVariable("COMMONPROGRAMFILES"), @"DVTk\Definition Files\DICOM"); string[] definitionFilePaths = Directory.GetFiles(definitionFilesPath); foreach (string definitionFilePath in definitionFilePaths) { this.mediaSession.DefinitionManagement.LoadDefinitionFile(definitionFilePath); } } catch (Exception exception) { this.mediaSession = null; MessageBox.Show("An exception occured while loading the definition files: " + exception.Message); } }
private void ComboBoxSessionType_SelectedIndexChanged(object sender, System.EventArgs e) { if ((this.ComboBoxSessionType.SelectedItem.ToString() == "Script") && !(this.selected_session is Dvtk.Sessions.ScriptSession)) { // We only want to replace the selected session when the user // has changed the session type. Dvtk.Sessions.ScriptSession session; session = new Dvtk.Sessions.ScriptSession(); session.SessionFileName = this.selected_session.SessionFileName; session.SessionTitle = this.TextBoxSessionTitle.Text; session.SessionId = Convert.ToUInt16 (this.NumericSessonID.Value); session.TestedBy = this.TextBoxTestedBy.Text; session.Date = this.DateTested.Value; if (this.TextBoxResultsRoot.Text == "") session.ResultsRootDirectory = "."; else session.ResultsRootDirectory = this.TextBoxResultsRoot.Text; if (this.TextBoxScriptRoot.Text == "") session.DicomScriptRootDirectory = "."; else session.DicomScriptRootDirectory = this.TextBoxScriptRoot.Text; session.DvtSystemSettings.AeTitle = this.TextBoxDVTAETitle.Text; session.DvtSystemSettings.Port = (ushort)this.NumericDVTListenPort.Value; session.DvtSystemSettings.SocketTimeout = (ushort)this.NumericDVTTimeOut.Value; session.DvtSystemSettings.MaximumLengthReceived = (uint)this.NumericDVTMaxPDU.Value; session.SutSystemSettings.AeTitle = this.TextBoxSUTAETitle.Text; session.SutSystemSettings.Port = (ushort)this.NumericSUTListenPort.Value; session.SutSystemSettings.HostName = this.TextBoxSUTTCPIPAddress.Text; session.SutSystemSettings.MaximumLengthReceived = (uint)this.NumericSUTMaxPDU.Value; session.SecuritySettings.SecureSocketsEnabled = this.CheckBoxSecureConnection.Checked; if (this.CheckBoxSecureConnection.Checked) { session.SecuritySettings.CacheTlsSessions = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.CacheTlsSessions; session.SecuritySettings.CertificateFileName = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.CertificateFileName; session.SecuritySettings.CheckRemoteCertificate = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.CheckRemoteCertificate; session.SecuritySettings.CipherFlags = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.CipherFlags; session.SecuritySettings.CredentialsFileName = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.CredentialsFileName; session.SecuritySettings.TlsCacheTimeout = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.TlsCacheTimeout; session.SecuritySettings.TlsPassword = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.TlsPassword; session.SecuritySettings.TlsVersionFlags = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.TlsVersionFlags; } // Copy the definition settings (SOP Classes, AE title/version and definition dirs) session.DefinitionManagement.ApplicationEntityName = this.selected_session.DefinitionManagement.ApplicationEntityName; session.DefinitionManagement.ApplicationEntityVersion = this.selected_session.DefinitionManagement.ApplicationEntityVersion; session.DefinitionManagement.DefinitionFileDirectoryList.Clear (); foreach (string def_dir in this.selected_session.DefinitionManagement.DefinitionFileDirectoryList) session.DefinitionManagement.DefinitionFileDirectoryList.Add (def_dir); session.DefinitionManagement.DefinitionFileRootDirectory = this.selected_session.DefinitionManagement.DefinitionFileRootDirectory; foreach (string def_file in this.selected_session.DefinitionManagement.LoadedDefinitionFileNames) session.DefinitionManagement.LoadDefinitionFile (def_file); this.selected_session.DefinitionManagement.UnLoadDefinitionFiles (); //this.project.ReplaceSession (this.selected_session, session, this._activity_handler); foreach (TreeNode node in this.SessionBrowser.Nodes) { // Clear the tree node representing the old session. if (node.Text == session.SessionFileName) node.Nodes.Clear (); } this.selected_session = session; this.UpdateSessionProperties (); ////////this.project.SetSessionChanged (session.SessionFileName, true); this.ResizeSessionPropertiesView (); } if ((this.ComboBoxSessionType.SelectedItem.ToString() == "Media") && !(this.selected_session is Dvtk.Sessions.MediaSession)) { // We only want to replace the selected session when the user // has changed the session type. Dvtk.Sessions.MediaSession session; session = new Dvtk.Sessions.MediaSession (); session.SessionFileName = this.selected_session.SessionFileName; session.SessionTitle = this.TextBoxSessionTitle.Text; session.SessionId = Convert.ToUInt16 (this.NumericSessonID.Value); session.TestedBy = this.TextBoxTestedBy.Text; session.Date = this.DateTested.Value; if (this.TextBoxResultsRoot.Text == "") session.ResultsRootDirectory = "."; else session.ResultsRootDirectory = this.TextBoxResultsRoot.Text; // Copy the definition settings (SOP Classes, AE title/version and definition dirs) session.DefinitionManagement.ApplicationEntityName = this.selected_session.DefinitionManagement.ApplicationEntityName; session.DefinitionManagement.ApplicationEntityVersion = this.selected_session.DefinitionManagement.ApplicationEntityVersion; session.DefinitionManagement.DefinitionFileDirectoryList.Clear (); foreach (string def_dir in this.selected_session.DefinitionManagement.DefinitionFileDirectoryList) session.DefinitionManagement.DefinitionFileDirectoryList.Add (def_dir); session.DefinitionManagement.DefinitionFileRootDirectory = this.selected_session.DefinitionManagement.DefinitionFileRootDirectory; foreach (string def_file in this.selected_session.DefinitionManagement.LoadedDefinitionFileNames) session.DefinitionManagement.LoadDefinitionFile (def_file); this.selected_session.DefinitionManagement.UnLoadDefinitionFiles (); //this.project.ReplaceSession (this.selected_session, session, this._activity_handler); foreach (TreeNode node in this.SessionBrowser.Nodes) { // Clear the tree node representing the old session. if (node.Text == session.SessionFileName) node.Nodes.Clear (); } this.selected_session = session; this.UpdateSessionProperties (); //////this.project.SetSessionChanged (session.SessionFileName, true); this.ResizeSessionPropertiesView (); } if ((this.ComboBoxSessionType.SelectedItem.ToString() == "Emulator") && !(this.selected_session is Dvtk.Sessions.EmulatorSession)) { // We only want to replace the selected session when the user // has changed the session type. Dvtk.Sessions.EmulatorSession session; session = new Dvtk.Sessions.EmulatorSession (); session.SessionFileName = this.selected_session.SessionFileName; session.SessionTitle = this.TextBoxSessionTitle.Text; session.SessionId = Convert.ToUInt16 (this.NumericSessonID.Value); session.TestedBy = this.TextBoxTestedBy.Text; session.Date = this.DateTested.Value; if (this.TextBoxResultsRoot.Text == "") session.ResultsRootDirectory = "."; else session.ResultsRootDirectory = this.TextBoxResultsRoot.Text; session.DvtSystemSettings.AeTitle = this.TextBoxDVTAETitle.Text; session.DvtSystemSettings.Port = (ushort)this.NumericDVTListenPort.Value; session.DvtSystemSettings.SocketTimeout = (ushort)this.NumericDVTTimeOut.Value; session.DvtSystemSettings.MaximumLengthReceived = (uint)this.NumericDVTMaxPDU.Value; session.SutSystemSettings.AeTitle = this.TextBoxSUTAETitle.Text; session.SutSystemSettings.Port = (ushort)this.NumericSUTListenPort.Value; session.SutSystemSettings.HostName = this.TextBoxSUTTCPIPAddress.Text; session.SutSystemSettings.MaximumLengthReceived = (uint)this.NumericSUTMaxPDU.Value; session.SecuritySettings.SecureSocketsEnabled = this.CheckBoxSecureConnection.Checked; if (this.CheckBoxSecureConnection.Checked) { session.SecuritySettings.CacheTlsSessions = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.CacheTlsSessions; session.SecuritySettings.CertificateFileName = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.CertificateFileName; session.SecuritySettings.CheckRemoteCertificate = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.CheckRemoteCertificate; session.SecuritySettings.CipherFlags = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.CipherFlags; session.SecuritySettings.CredentialsFileName = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.CredentialsFileName; session.SecuritySettings.TlsCacheTimeout = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.TlsCacheTimeout; session.SecuritySettings.TlsPassword = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.TlsPassword; session.SecuritySettings.TlsVersionFlags = ((Dvtk.Sessions.ISecure)this.selected_session).SecuritySettings.TlsVersionFlags; } // Copy the definition settings (SOP Classes, AE title/version and definition dirs) session.DefinitionManagement.ApplicationEntityName = this.selected_session.DefinitionManagement.ApplicationEntityName; session.DefinitionManagement.ApplicationEntityVersion = this.selected_session.DefinitionManagement.ApplicationEntityVersion; session.DefinitionManagement.DefinitionFileDirectoryList.Clear (); foreach (string def_dir in this.selected_session.DefinitionManagement.DefinitionFileDirectoryList) session.DefinitionManagement.DefinitionFileDirectoryList.Add (def_dir); session.DefinitionManagement.DefinitionFileRootDirectory = this.selected_session.DefinitionManagement.DefinitionFileRootDirectory; foreach (string def_file in this.selected_session.DefinitionManagement.LoadedDefinitionFileNames) session.DefinitionManagement.LoadDefinitionFile (def_file); this.selected_session.DefinitionManagement.UnLoadDefinitionFiles (); //this.project.ReplaceSession (this.selected_session, session, this._activity_handler); foreach (TreeNode node in this.SessionBrowser.Nodes) { // Clear the tree node representing the old session. if (node.Text == session.SessionFileName) node.Nodes.Clear (); } this.selected_session = session; this.UpdateSessionProperties (); //////this.project.SetSessionChanged (session.SessionFileName, true); this.ResizeSessionPropertiesView (); } // Update the session tree browser this.UpdateSessionTreeView (); // Update the mainform controls (menu, toolbar, title) ((MainForm)this.ParentForm).UpdateUIControls (); }