当前位置: 首页>>代码示例>>C#>>正文


C# DvtkData.ToString方法代码示例

本文整理汇总了C#中DvtkData.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# DvtkData.ToString方法的具体用法?C# DvtkData.ToString怎么用?C# DvtkData.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DvtkData的用法示例。


在下文中一共展示了DvtkData.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Compare

        /// <summary>
        /// Compare the DICOM files in the two directories based on there being corresponding
        /// files in each directory with the same attribute value for the matching Tag.
        /// </summary>
        /// <param name="directory1">Full directory name of first directory.</param>
        /// <param name="directory2">Full directory name of second directory.</param>
        /// <param name="matchingTag">DICOM Tag value to match in a file in each directory.</param>
        /// <returns>Total number of differences between compared files.</returns>
        public int Compare(String directory1, String directory2, DvtkData.Dimse.Tag matchingTag)
        {
            int totalDifferences = 0;

            StreamWriter htmlOutput = null;

            try
            {
                // create the output file writer if necessary
                if (_htmlOutputFilename != String.Empty)
                {
                     htmlOutput = new StreamWriter(_htmlOutputFilename);
                }

                // compare all files in directory 1 with corresponding files in directory 2
                // - the files compared is based on them having the same attribute value for the
                // Tag given.
                DirectoryInfo directoryInfo = new DirectoryInfo(directory1);
                FileInfo[] fileInfo = directoryInfo.GetFiles();
                for (int i = 0; i < fileInfo.Length; i++)
                {
                    DataSet dataset1 = new DataSet();
                    String filename1 = fileInfo[i].FullName;
                    dataset1.DvtkDataDataSet = Dvtk.DvtkDataHelper.ReadDataSetFromFile(filename1);

                    // get the attribute value for the matching tag from this dataset
                    String valueToMatch = GetAttributeValueFromDataset(dataset1, matchingTag);
                    if (valueToMatch != String.Empty)
                    {
                        // try to find a dataset (file) containing the same value in directory 2
                        String filename2 = String.Empty;
                        DataSet dataset2 = GetMatchingDatasetFromStoreDataDirectory(directory2, matchingTag, valueToMatch, out filename2);

                        // if a dataset is returned that contains the matching attribute value go on to compare all the attributes
                        // in both datasets with eachother
                        if (dataset2 != null)
                        {
                            // get a new compare instance and set the comparison flags
                            StaticDicomCompare staticDicomCompare = new StaticDicomCompare();
                            FlagsDicomAttribute flags = FlagsDicomAttribute.Compare_values | FlagsDicomAttribute.Compare_present | FlagsDicomAttribute.Include_sequence_items;
                            if (_compareVr == false)
                            {
                                staticDicomCompare.DisplayAttributeVR = false;
                            }
                            else
                            {
                                flags |= FlagsDicomAttribute.Compare_VR;
                            }
                            staticDicomCompare.DisplayGroupLength = _displayGroupLength;

                            dataset1.UnVrDefinitionLookUpWhenReading = _unVrDefinitionLookUpWhenReading;
                            dataset2.UnVrDefinitionLookUpWhenReading = _unVrDefinitionLookUpWhenReading;

                            AttributeCollections datasets = new AttributeCollections();
                            datasets.Add(dataset1);
                            datasets.Add(dataset2);

                            StringCollection datasetDescriptions = new StringCollection();
                            datasetDescriptions.Add(filename1);
                            datasetDescriptions.Add(filename2);

                            String title = String.Format("Comparison Results with matching using Tag with {0}", matchingTag.ToString());
                            DvtkHighLevelInterface.Common.Compare.CompareResults datasetCompareResults = staticDicomCompare.CompareAttributeSets(title, datasets, datasetDescriptions, flags);
                            if (htmlOutput != null)
                            {
                                if (_includeDetailedResults == true)
                                {
                                    htmlOutput.WriteLine(datasetCompareResults.Table.ConvertToHtml());
                                }
                                else
                                {
                                    htmlOutput.WriteLine("<br />");
                                    String message = String.Format("Compared {0} with {1} - number of differences: {2}", filename1, filename2, datasetCompareResults.DifferencesCount);
                                    htmlOutput.WriteLine(message);
                                    htmlOutput.WriteLine("<br />");
                                }
                            }

                            // update the total differences counter
                            totalDifferences += datasetCompareResults.DifferencesCount;
                        }
                    }
                }
            }
            catch (System.Exception)
            {
            }
            if (htmlOutput != null)
            {
                htmlOutput.Flush();
                htmlOutput.Close();
            }
//.........这里部分代码省略.........
开发者ID:ewcasas,项目名称:DVTK,代码行数:101,代码来源:StoreDataDirectory.cs


注:本文中的DvtkData.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。