Esempio n. 1
0
        public Globals()
        {
            // Set default values and initialize objects
            // PAGE 0
            m_nTimerMax = 15;

            // PAGE 1
            m_MWLServer         = new DicomServer();
            m_MWLServer.AETitle = "LEAD_SERVER";
            m_MWLServer.Address = IPAddress.Parse("127.0.0.1");
            m_MWLServer.Port    = 104;

            m_strMWLClientAE = "LEAD_CLIENT";

            // PAGE 2
            m_nQueryType = 1;

            m_bCheckScheduledDate = false;
            m_bCheckModality      = false;
            m_ScheduledDate       = DateTime.Today;
            m_strModality         = m_ModalityTable[0].m_strValue;

            m_strAccessionNumber      = "";
            m_strPatientID            = "";
            m_strPatientName          = "";
            m_strRequestedProcedureID = "";

            // PAGE 3 & 4
            m_TreeResult      = new MyTreeView();
            m_TreeResult.Dock = DockStyle.Fill;

            // Build the icon image list
            m_IconImageList = new ImageList();
            m_IconImageList.Images.Add(
                new System.Drawing.Icon(typeof(Globals), "Resources.icoElement.ico"));
            m_IconImageList.Images.Add(
                new System.Drawing.Icon(typeof(Globals), "Resources.icoFolder.ico"));
            m_IconImageList.Images.Add(
                new System.Drawing.Icon(typeof(Globals), "Resources.icoMissing.ico"));
            m_IconImageList.Images.Add(
                new System.Drawing.Icon(typeof(Globals), "Resources.icoSequence.ico"));
            m_IconImageList.Images.Add(
                new System.Drawing.Icon(typeof(Globals), "Resources.icoWorklist.ico"));

            m_TreeResult.ImageList = m_IconImageList;

            // PAGE 5
            m_DS = new MyDicomDataSet();

            // Page 6
            m_StorageServer         = new DicomServer();
            m_StorageServer.AETitle = "LEAD_SERVER";
            m_StorageServer.Address = IPAddress.Parse("127.0.0.1");
            m_StorageServer.Port    = 104;
            m_strStorageClientAE    = "LEAD_CLIENT";
            m_bStoreOnServer        = true;
        }
Esempio n. 2
0
        /*
         * Parses through the data set, finds the mandatory type 1 elements, and adds them
         *   to the ListView.
         */
        public void Update(MyDicomDataSet ds, DicomClassType nClass)
        {
            try
            {
                if (ds == null)
                {
                    return;
                }

                MyListViewItem currentItem;
                string         strTag  = "";
                string         strDesc = "";

                DicomElement element;
                element = ds.GetFirstEmptyElementType1(nClass, ref strTag, ref strDesc);
                while (element != null)
                {
                    currentItem      = new MyListViewItem();
                    currentItem.Text = strTag;
                    currentItem.SubItems.Add(strDesc);
                    currentItem.SubItems.Add("");
                    currentItem.m_Element  = element;
                    currentItem.ImageIndex = (int)MyIconIndex.Missing;

                    MyTreeNode treeNode = m_TreeView.FindNodeByElement(element, null, null);
                    if (treeNode != null)
                    {
                        m_TreeView.FindNodeByElement(element, null, null).ImageIndex         = (int)MyIconIndex.Missing;
                        m_TreeView.FindNodeByElement(element, null, null).SelectedImageIndex = (int)MyIconIndex.Missing;
                        Items.Add(currentItem);
                    }

                    element = ds.GetNextEmptyElementType1(element, nClass, ref strTag, ref strDesc);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 3
0
        /*
         * Creates a new dataset based off of the MWL dataset
         */
        public CreateDatasetReturn CreateDataset()
        {
            CreateDatasetReturn nRet = CreateDatasetReturn.GeneralError;

            try
            {
                // Check for a selected node
                if (_globals.m_TreeResult.SelectedNode == null)
                {
                    return(CreateDatasetReturn.NoItemSelected);
                }

                // Make sure that the modality is supported
                nRet = CreateDatasetReturn.ModalityNotFound;
                string         strModality = Utils.GetStringValue(((MyTreeNode)_globals.m_TreeResult.SelectedNode).m_DS, DemoDicomTags.Modality, false);
                DicomClassType nClass      = DicomClassType.SCImageStorage; // use SCImageStorage if we cannot find the modality

                for (int i = 0; i < _globals.m_ModalityTable.Length; i++)
                {
                    if (strModality == _globals.m_ModalityTable[i].m_strValue)
                    {
                        // Modality was found, change return type to Success
                        nClass = _globals.m_ModalityTable[i].m_DicomClassType;
                        nRet   = CreateDatasetReturn.Success;
                        break;
                    }
                }

                // Initialize dataset
                MyDicomDataSet ds = new MyDicomDataSet();

                ds.Initialize(nClass, DicomDataSetInitializeFlags.ImplicitVR | DicomDataSetInitializeFlags.LittleEndian | DicomDataSetInitializeFlags.AddMandatoryElementsOnly | DicomDataSetInitializeFlags.AddMandatoryModulesOnly);



                ds.MapMWLtoDS(((MyTreeNode)_globals.m_TreeResult.SelectedNode).m_DS);
                ds.SetTagSpecificCharacterSet();
                ds.SetTagInstanceNumber(1);

                // Set Pixel Data
                DicomElement PixelDataElement = ds.FindFirstElement(null, DemoDicomTags.PixelData, true);
                if (PixelDataElement != null)
                {
                    ds.DeleteElement(PixelDataElement);
                    PixelDataElement = ds.InsertElement(null, false, DemoDicomTags.PixelData, DicomVRType.OB, false, 0);
                }

                // use RGB as default Photometric Interpretation
                DicomImagePhotometricInterpretationType nPhotometric = DicomImagePhotometricInterpretationType.Rgb;
                if (rasterImageViewer.Image != null)
                {
                    if (rasterImageViewer.Image.Order == Leadtools.RasterByteOrder.Gray)
                    {
                        nPhotometric = DicomImagePhotometricInterpretationType.Monochrome2;
                    }
                    else if (Convert.ToInt32(rasterImageViewer.Image.Order) <= 8)
                    {
                        nPhotometric = DicomImagePhotometricInterpretationType.PaletteColor;
                    }
                    else
                    {
                        nPhotometric = DicomImagePhotometricInterpretationType.Rgb;
                    }

                    ds.InsertImage(PixelDataElement, rasterImageViewer.Image, 0, DicomImageCompressionType.None,
                                   nPhotometric, 0, 0, DicomSetImageFlags.AutoSetVoiLut);
                }

                ds.DeleteEmptyElementsType3(nClass);
                ds.DeleteEmptyModulesOptional(nClass);

                if (nPhotometric != DicomImagePhotometricInterpretationType.PaletteColor)
                {
                    if (ds.IsEmptyModule(DicomModuleType.PaletteColorLookupTable))
                    {
                        ds.DeleteModule(DicomModuleType.PaletteColorLookupTable);
                    }
                }

                // Generate new series instance UID and SOP Instance UID
                ds.InsertUID(DemoDicomTags.SeriesInstanceUID);
                ds.InsertUID(DemoDicomTags.SOPInstanceUID);

                // If the MWL already had a study instance UID, we use that
                // If not, generate a new UID
                ds.GenerateStudyInstanceUID();

                _globals.m_nClass = nClass;
                _globals.m_DS     = ds;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            return(nRet);
        }