Пример #1
0
        //
        // - Constructors -
        //
        /// <summary>
        /// Default constructor.
        /// </summary>
        public QREmulator()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.dvtkWebBrowserResults.ErrorWarningEnabledStateChangeEvent+=new DvtkWebBrowserNew.ErrorWarningEnabledStateChangeEventHandler(dvtkWebBrowserResults_ErrorWarningEnabledStateChangeEvent);

            if (!Directory.Exists(ConfigurationsDirectory))
            {
                Directory.CreateDirectory(ConfigurationsDirectory);
            }

            this.config = Config.Deserialize(Path.Combine(ConfigurationsDirectory, "Config.xml"));
            Config.ConfigFullFileName = Path.Combine(ConfigurationsDirectory, "Config.xml");

            //
            // Initialize browser control.
            //
            rootPath = Application.StartupPath;

            this.dvtkWebBrowserResults.XmlStyleSheetFullFileName = Path.Combine(rootPath, "DVT_RESULTS.xslt");

            dataDirectory = Path.Combine(rootPath, @"Data\QueryRetrieve\");

            //Update settings from the config XML
            if(config.DataDirectoryForEmulation != "")
                dataDirectory = config.DataDirectoryForEmulation;
            else
                config.DataDirectoryForEmulation = dataDirectory;

            checkBoxPRInfoModel.Checked = config.PatientRootInfoModelSupport;
            checkBoxSRInfoModel.Checked = config.StudyRootInfoModelSupport;
            checkBoxPSRInfoModel.Checked = config.PatientStudyRootInfoModelSupport;
            this.AE.Checked = this.config.IsCaseSensitiveAE;
            this.CS.Checked = this.config.IsCaseSensitiveCS;
            this.LO.Checked = this.config.IsCaseSensitiveLO;
            this.PN.Checked = this.config.IsCaseSensitivePN;
            this.SH.Checked = this.config.IsCaseSensitiveSH;
            if(config.TSILESupport)
                selectedTS.Add("1.2.840.10008.1.2");
            if(config.TSELESupport)
                selectedTS.Add("1.2.840.10008.1.2.1");
            if(config.TSEBESupport)
                selectedTS.Add("1.2.840.10008.1.2.2");

            //
            // Set the .Net thread name for debugging purposes.
            //
            System.Threading.Thread.CurrentThread.Name = "QR SCP Emulator";

            //
            // Stored files options.
            //
            this.fileGroups = new FileGroups("QR SCP Emulator");

            this.validationResultsFileGroup = new ValidationResultsFileGroup();
            this.validationResultsFileGroup.DefaultFolder = "Results";
            this.fileGroups.Add(validationResultsFileGroup);

            this.fileGroups.CreateDirectories();

            this.fileGroups.CheckIsConfigured("\"Stored Files\\Options...\" menu item");

            //
            // The dvtkThreadManager.
            //
            ThreadManager threadManager = new ThreadManager();

            //
            // Construct the source QR SCP.
            //
            this.sourceQRScp = new SCP();
            this.sourceQRScp.Initialize(threadManager);
            this.sourceQRScp.Options.LoadFromFile(Path.Combine(rootPath, "QR_SCP.ses"));
            this.sourceQRScp.Options.Identifier = "QR_SCP_Emulator";
            this.sourceQRScp.Options.AttachChildsToUserInterfaces = true;
            this.sourceQRScp.Options.StorageMode = Dvtk.Sessions.StorageMode.NoStorage;
            this.sourceQRScp.Options.LogThreadStartingAndStoppingInParent = false;
            this.sourceQRScp.Options.LogWaitingForCompletionChildThreads = false;
            this.sourceQRScp.Options.ResultsDirectory = validationResultsFileGroup.Directory;
            this.sourceQRScp.Options.DataDirectory = validationResultsFileGroup.Directory;
            this.socketTimeout.Value = this.sourceQRScp.Options.SocketTimeout;
            //
            //Initialize move destinations
            //
            aeRegistrationControl1.Initialize(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\DVtk\\QR SCP Emulator\\Configurations\\MoveDestinations.xml",
                sourceQRScp.Options);
            aeRegistrationControl1.OnShowEchoResults += new AERegistrationControl.ShowEchoResults(ShowMoveDestinationResults);

            //
            // Initialize the DicomThreadOptionsControls
            //
            this.dicomThreadOptionsUserControl.DicomThreadOptions = this.sourceQRScp.Options;
            this.dicomThreadOptionsUserControl.LocalAeTitleVisible = true;
            this.dicomThreadOptionsUserControl.LocalPortVisible = true;
            this.dicomThreadOptionsUserControl.LocalAETitleName = "Local AE title\n(QR SCP&& Store SCU)";
            this.dicomThreadOptionsUserControl.RemoteAeTitleLabel = "QR SCU AE Title:";
            this.dicomThreadOptionsUserControl.RemotePortLabel = "Move destination Port:";
            this.dicomThreadOptionsUserControl.RemoteIpAddressLabel = "Move destination IP Addr:";
            this.dicomThreadOptionsUserControl.RemoteAeTitleVisible = true;
            this.dicomThreadOptionsUserControl.RemoteIpAddressVisible = false;
            this.dicomThreadOptionsUserControl.RemotePortVisible = false;
            this.dicomThreadOptionsUserControl.OptionChangedEvent+= new DicomThreadOptionsUserControl.OptionChangedEventHandler(this.HandleOptionChanged);
            this.dicomThreadOptionsUserControl.UpdateUserControl();

            // Save the config so next time no attempt will be made to again try to load the same settings
            this.config.Serialize();

            //
            // Set the Backward/forward button handler.
            //
            this.dvtkWebBrowserResults.BackwardFormwardEnabledStateChangeEvent += new DvtkApplicationLayer.UserInterfaces.DvtkWebBrowserNew.BackwardFormwardEnabledStateChangeEventHandler(BackwardFormwardEnabledStateChangeEvent);
            UpdateButtons();

            this.threadsStateChangeEventHandler = new ThreadManager.ThreadsStateChangeEventHandler(this.HandleThreadsStateChangeEvent);

            // Load definition and DCM files
            dcmEditorQREmulator.DCMFileDataDirectory = validationResultsFileGroup.Directory;
            dcmEditorQREmulator.DefFile = sourceQRScp.Options.DvtkScriptSession.DefinitionManagement.DefinitionFileRootDirectory + "PatientRootQueryRetrieve-FIND.def";
            dcmEditorQREmulator.DCMFile = rootPath + @"\Data\QueryRetrieve\d1I00001.dcm";

            buttonBrowse.Visible = false;
            textBoxDataDir.Visible = false;

            dataDirectoryForTempFiles = validationResultsFileGroup.Directory;

            this.WindowState = FormWindowState.Maximized;
        }
Пример #2
0
        private void menuConfigLoad_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(ConfigurationsDirectory))
            {
                Directory.CreateDirectory(ConfigurationsDirectory);
            }

            OpenFileDialog theOpenFileDialog = new OpenFileDialog();

            theOpenFileDialog.Filter = "Config files (*.xml) |*.xml";
            theOpenFileDialog.Multiselect = false;
            theOpenFileDialog.Title = "Load a config file";

            if (theOpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                Config.ConfigFullFileName = theOpenFileDialog.FileName;
                this.config= Config.Deserialize(Config.ConfigFullFileName);

                selectedTS.Clear();
                if (config.TSILESupport)
                    selectedTS.Add("1.2.840.10008.1.2");
                if (config.TSELESupport)
                    selectedTS.Add("1.2.840.10008.1.2.1");
                if (config.TSEBESupport)
                    selectedTS.Add("1.2.840.10008.1.2.2");

                this.checkBoxPRInfoModel.Checked = this.config.PatientRootInfoModelSupport;
                this.checkBoxPSRInfoModel.Checked = this.config.PatientStudyRootInfoModelSupport;
                this.checkBoxSRInfoModel.Checked = this.config.StudyRootInfoModelSupport;
                this.textBoxDataDir.Text = this.config.DataDirectoryForEmulation;
                this.dicomThreadOptionsUserControl.LocalAeTitle = this.config.LocalAeTitle;
                this.dicomThreadOptionsUserControl.LocalPort = this.config.LocalPort;
                this.dicomThreadOptionsUserControl.RemoteAeTitle = this.config.RemoteAeTitle;
                this.dicomThreadOptionsUserControl.RemoteIpAddress = this.config.RemoteIpAddress;
                this.dicomThreadOptionsUserControl.RemotePort = this.config.RemotePort;
                this.AE.Checked = this.config.IsCaseSensitiveAE;
                this.CS.Checked = this.config.IsCaseSensitiveCS;
                this.LO.Checked = this.config.IsCaseSensitiveLO;
                this.PN.Checked = this.config.IsCaseSensitivePN;
                this.SH.Checked = this.config.IsCaseSensitiveSH;
            }
        }
Пример #3
0
        //
        // - Methods -
        //
        /// <summary>
        /// Deserialize an xml file to an Config instance.
        /// </summary>
        /// <returns>The deserialized Config instance.</returns>
        public static Config Deserialize(string configFile)
        {
            FileStream myFileStream = null;

            XmlSerializer mySerializer = new XmlSerializer(typeof(Config));

            Config config = null;

            try
            {
                // To read the file, creates a FileStream.
                myFileStream = new FileStream(configFile, FileMode.Open);

                // Calls the Deserialize method and casts to the object type.
                config = (Config)mySerializer.Deserialize(myFileStream);
            }
            catch
            {
                // If deserializing the config file fails, use the default settings.
                config = new Config();
            }
            finally
            {
                if (myFileStream != null)
                {
                    myFileStream.Close();
                }
            }

            return(config);
        }