Ejemplo n.º 1
0
        private void ButtonSelectImage_Click(object sender, RoutedEventArgs e)
        {
            ///////// Select image with a open file dialog
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "All DICOM Files(*.dcm)|*.dcm";
            ofd.Title            = "Select Dicom Image";
            ofd.InitialDirectory = @"D:\PhantomAcceptance\115_Phantom\E2398\4_49_50_8\1.2.276.0.45.44.2.41.3.160600737534.20160926.154948001";

            //System.Windows.MessageBox.Show(short.MaxValue.ToString());

            if (ofd.ShowDialog() == true)
            {
                ImageInfo.inputPath   = Directory.GetParent(ofd.FileName).ToString();
                ImageInfo.fileNames   = Directory.GetFiles(ImageInfo.inputPath, "*.dcm", SearchOption.TopDirectoryOnly);
                ImageInfo.ImageNumber = ImageInfo.fileNames.Length;
                if (ImageInfo.ImageNumber < 1)
                {
                    MessageBox.Show("No DICOM file found, please check folder path.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    // Upon path selected, display an image, and get image info: pixel size, dimension, etc.

                    ImageInfo.IsImageFound = true;
                    DisplayControl.ReadDicomData(ImageInfo.fileNames[ImageInfo.ImageNumber * 7 / 8]);

                    MeasurementResults.SetAllNotMeasured();
                    DataGridMeasurementResult.ItemsSource = null;
                    DataGridMeasurementResult.ItemsSource = MeasurementResults.Result;
                    DetectionResults.SetAllNull();
                    DataGridDetectionResult.ItemsSource = null;
                    DataGridDetectionResult.ItemsSource = DetectionResults.Result;
                    ImageInfo.resetParameter();

                    // Calculate displaycenteroncanvas and display ratio before calling displayimage
                    DisplayControl.DisplayCenterOnCanvas.X = Canvas.ActualWidth / 2;
                    DisplayControl.DisplayCenterOnCanvas.Y = Canvas.ActualHeight / 2;
                    DisplayControl.DisplayRatio            = Math.Min(Canvas.ActualHeight / ImageInfo.Height, Canvas.ActualWidth / ImageInfo.Width);
                    DisplayImage();

                    ButtonImageManipulation.IsChecked = false;
                }
            }
        }