예제 #1
0
        void onStudyClicked(ListViewItem sender)
        {
            // find series ...............................
            var studyQueryOut       = sender.Content as StudyQueryOut;
            DicomCFindRequest cfind = new DicomCFindRequest(DicomQueryRetrieveLevel.Series);

            PropertyInfo[] properties = typeof(SeriesQueryOut).GetProperties();
            foreach (var property in properties)
            {
                string   tag    = typeof(DicomTag).GetField(property.Name).GetValue(null).ToString();
                DicomTag theTag = (DicomTag.Parse(tag));
                if (theTag == DicomTag.StudyInstanceUID)
                {
                    cfind.Dataset.Add(DicomTag.StudyInstanceUID, studyQueryOut.StudyInstanceUID);
                }
                else
                {
                    cfind.Dataset.Add(theTag, "");
                }
            }
            cfind.OnResponseReceived = (request, response) =>
            {
                if (response.HasDataset)
                {
                    seriesResponses.Add(new SeriesQueryOut(response));
                }
                else
                {
                    Console.WriteLine("got " + seriesResponses.Count + " series");
                }
            };

            var client = new DicomClient();

            client.AddRequest(cfind);

            mainWindow.frame.Navigate(mainWindow.downloadPage);
            mainWindow.downloadPage.dataGrid.Items.Clear();
            seriesResponses = new List <SeriesQueryOut>();

            try
            {
                Console.WriteLine(Environment.NewLine + "#############################################################" + Environment.NewLine + Environment.NewLine
                                  + "Querying server " + configuration.ip + ":" + configuration.port +
                                  " for SERIES in study no. " + studyQueryOut.StudyInstanceUID);
                client.Send(configuration.ip, configuration.port, false, configuration.thisNodeAET, configuration.AET);
            }
            catch (Exception ec)
            {
                Console.WriteLine("Impossible to connect to server");
            }
            // arrange results in table
            foreach (SeriesQueryOut seriesResponse in seriesResponses)
            {
                Console.WriteLine("Added series to table" + Environment.NewLine +
                                  "-------------------------------------------------------------------" + Environment.NewLine);
                SetupGUI.addElementToSeriesTable(mainWindow.downloadPage, seriesResponse);
            }
        }
예제 #2
0
        // init
        public Program(MainWindow mainWindow)
        {
            // init listener
            Process[] listeners = Process.GetProcessesByName("Listener");
            if (listeners.Length == 0)
            {
                //MessageBox.Show("No listener available");
                //Environment.Exit(0);
                Process.Start("Listener");
            }
            else
            {
                foreach (var listener in listeners)
                {
                    listener.Kill();
                }
                Process.Start("Listener");
            }

            // setup GUI and GUI events
            SetupGUI.setupStudyTable(mainWindow);
            SetupGUI.setupSeriesTable(mainWindow.downloadPage);
            mainWindow.queryPage.localSearch.Click    += onLocalSearchButtonClicked;
            mainWindow.queryPage.Search.Click         += onSearchButtonClicked;
            mainWindow.downloadPage.series_ClickEvent += onSeriesClicked;
            mainWindow.downloadPage.thumb_ClickEvent  += onThumbClicked;

            // watch changes in configuration
            configuration = new CurrentConfiguration();
            FileSystemWatcher watcher = new FileSystemWatcher();

            watcher.Path                = Path.GetDirectoryName("./");
            watcher.Filter              = Path.GetFileName("ServerConfig.txt");
            watcher.Changed            += new FileSystemEventHandler(onConfigurationChanged);
            watcher.EnableRaisingEvents = true;

            this.mainWindow = mainWindow;
            mainWindow.frame.Navigate(mainWindow.queryPage);
        }
예제 #3
0
        public void onThumbClicked(int seriesNumber)
        {
            var seriesResponse = seriesResponses[seriesNumber];

            try
            {
                BitmapImage img            = new BitmapImage();
                string      SOPInstanceUID = getImagesInSeries(seriesResponse);
                if (SOPInstanceUID != "")
                {
                    Console.WriteLine("Downloading from server " + configuration.ip + ":" + configuration.port +
                                      " sample image no. " + SOPInstanceUID + Environment.NewLine);
                    img = downloadSampleImage(seriesResponse, SOPInstanceUID);

                    SetupGUI.addImage(mainWindow.downloadPage, seriesNumber, img);
                    Console.WriteLine("Done.");
                }
            }
            catch (Exception ec)
            {
                Console.WriteLine(ec.StackTrace);
            }
        }