本文整理汇总了C#中DicomFile.Write方法的典型用法代码示例。如果您正苦于以下问题:C# DicomFile.Write方法的具体用法?C# DicomFile.Write怎么用?C# DicomFile.Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DicomFile
的用法示例。
在下文中一共展示了DicomFile.Write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buttonSave_Click
private void buttonSave_Click(object sender, System.EventArgs e)
{
if(DCMFile == "")
{
richTextBoxLog.AppendText("There is no Media file to save, please select Media file.\n");
return;
}
try
{
SaveFileDialog saveAsDlg = new SaveFileDialog();
saveAsDlg.Filter = "DCM files (*.dcm)|*.dcm|All files (*.*)|*.*";
FileInfo dcmFileInfo = new FileInfo(DCMFile);
saveAsDlg.InitialDirectory = dcmFileInfo.DirectoryName;
saveAsDlg.FileName = dcmFileInfo.Name;
saveAsDlg.Title = "Save Media file...";
if (saveAsDlg.ShowDialog () == DialogResult.OK)
{
richTextBoxLog.AppendText("Saving the modified Media file.\n");
_NewDCMFileName = saveAsDlg.FileName.Trim();
if(DCMFile != _NewDCMFileName)
_IsSavedInNewDCMFile = true;
string theLogText;
if (!_IsDICOMDIR)
{
DicomFile dcmFile = new DicomFile();
// Add FMI as it is to Media file
dcmFile.FileMetaInformation = _FileMetaInfo;
dcmFile.FileMetaInformation.TransferSyntax = _TransferSyntax;
// Add modified dataset to Media file
dcmFile.DataSet = _DCMdataset;
//Set attribute group length
if (_IsAttributeGroupLengthDefined)
dcmFile.AddGroupLength = true;
dcmFile.Write(_NewDCMFileName);
}
else
{
//DicomDir dicomdir = new DicomDir();
//// Add FMI as it is to Media file
//dicomdir.FileMetaInformation = _FileMetaInfo;
//dicomdir.FileMetaInformation.TransferSyntax = _TransferSyntax;
//// Add modified dataset to Media file
//dicomdir.DataSet = _DCMdataset;
//dicomdir.Write(_NewDCMFileName);
}
theLogText = string.Format("Media file {0} saved successfully.\n\n", _NewDCMFileName);
richTextBoxLog.AppendText(theLogText);
richTextBoxLog.ScrollToCaret();
richTextBoxLog.Focus();
//Cleanup the FMI & Dataset
IsDCMFileModified = false;
_IsAttributeGroupLengthDefined = false;
_DCMdataset = null;
_FileMetaInfo = null;
if(_IsSavedInNewDCMFile)
{
FileInfo newDcmFileInfo = new FileInfo(_NewDCMFileName);
_IsNewDCMFileLoaded = true;
this.dirListBox.Path = newDcmFileInfo.DirectoryName;
this.fileListBox.Path = this.dirListBox.Path;
this.fileListBox.SelectedItem = newDcmFileInfo.Name;
this.dirListBox.Refresh();
this.fileListBox.Refresh();
//Load the new Media file
LoadDCMFile(_NewDCMFileName);
}
else
{
_IsNewDCMFileLoaded = false;
this.dirListBox.Path = dcmFileInfo.DirectoryName;
this.fileListBox.Path = this.dirListBox.Path;
this.fileListBox.SelectedItem = dcmFileInfo.Name;
//Load the new Media file
LoadDCMFile(DCMFile);
}
UpdateTitleBarText();
}
}
catch(Exception exception)
{
//.........这里部分代码省略.........
示例2: buttonSave_Click
private void buttonSave_Click(object sender, System.EventArgs e)
{
if(_DCMFileName == "")
{
richTextBoxLog.AppendText("There is no DCM File to save, please select DCM file.\n");
return;
}
richTextBoxLog.AppendText("Saving the modified DCM file.\n");
try
{
SaveFileDialog saveAsDlg = new SaveFileDialog();
saveAsDlg.Filter = "DCM files (*.dcm)|*.dcm|All files (*.*)|*.*";
FileInfo dcmFileInfo = new FileInfo(_DCMFileName);
saveAsDlg.InitialDirectory = dcmFileInfo.DirectoryName;
saveAsDlg.FileName = dcmFileInfo.Name;
saveAsDlg.Title = "Save DCM File...";
if (saveAsDlg.ShowDialog () == DialogResult.OK)
{
_NewDCMFileName = saveAsDlg.FileName.Trim();
if(_DCMFileName != _NewDCMFileName)
_IsSavedInNewDCMFile = true;
_DCMFileName = saveAsDlg.FileName;
DicomFile dcmFile = new DicomFile();
// Add FMI as it is to DCM file
dcmFile.FileMetaInformation = _FileMetaInfo;
// Add modified dataset to DCM file
dcmFile.DataSet = _DCMdataset;
string theLogText;
dcmFile.Write(_NewDCMFileName);
theLogText = string.Format("DCM file {0} saved successfully.\n\n", _NewDCMFileName);
richTextBoxLog.AppendText(theLogText);
richTextBoxLog.ScrollToCaret();
_IsDCMFileChanged = false;
_DCMdataset = null;
_FileMetaInfo = null;
if(_IsSavedInNewDCMFile)
{
FileInfo newDcmFileInfo = new FileInfo(_NewDCMFileName);
_IsNewDCMFileLoaded = true;
this.dirListBox.Path = newDcmFileInfo.DirectoryName;
this.fileListBox.Path = this.dirListBox.Path;
this.fileListBox.SelectedItem = newDcmFileInfo.Name;
this.dirListBox.Refresh();
this.fileListBox.Refresh();
//Load the new DCM file
LoadDCMFile(_NewDCMFileName);
}
else
{
_IsNewDCMFileLoaded = false;
this.dirListBox.Path = dcmFileInfo.DirectoryName;
this.fileListBox.Path = this.dirListBox.Path;
this.fileListBox.SelectedItem = dcmFileInfo.Name;
//Load the new DCM file
LoadDCMFile(_DCMFileName);
}
}
}
catch(Exception exception)
{
string theErrorText;
theErrorText = string.Format("DCM file {0} could not be saved:\n{1}\n\n", _NewDCMFileName, exception.Message);
richTextBoxLog.AppendText(theErrorText);
richTextBoxLog.ScrollToCaret();
_IsDCMFileChanged = false;
}
}
示例3: Ticket740_2_1
public void Ticket740_2_1()
{
Byte[] value1 = new Byte[2] { 0, 1};
Byte[] value2 = new Byte[8] { 0, 1, 2, 3, 4, 5, 6, 7 };
DicomFile dicomFile1 = new DicomFile();
DicomFile dicomFile2 = new DicomFile();
dicomFile1.DataSet.Set(Tag.PIXEL_DATA, VR.OB, value1);
dicomFile2.DataSet.Set(Tag.PIXEL_DATA, VR.OW, value2);
String dicomFile1FullPath = Path.Combine(Paths.DataDirectoryFullPath, "Ticket740_2_1_1.DCM");
String dicomFile2FullPath = Path.Combine(Paths.DataDirectoryFullPath, "Ticket740_2_1_2.DCM");
dicomFile1.Write(dicomFile1FullPath);
dicomFile2.Write(dicomFile2FullPath);
FileInfo fileInfo1 = new FileInfo(dicomFile1FullPath);
FileInfo fileInfo2 = new FileInfo(dicomFile2FullPath);
Assert.That(fileInfo1.Length + 6, Is.EqualTo(fileInfo2.Length));
}
示例4: buttonReqWL_Click
private void buttonReqWL_Click(object sender, System.EventArgs e)
{
///Moved to ClearInformation
//buttonStorageCommit.Enabled = false;
////buttonTS.Enabled = false;
//buttonMPPSMsg.Enabled = false;
//toolBarButtonLog.Enabled = true;
//toolBarButtonStop.Enabled = true;
////buttonReqWL.Enabled = false;
//buttonStoreImage.Enabled = false;
//labelMPPSMsg.Text = "";
//labelStoreCommit.Text = "";
//labelEchoRIS.Text = "";
//labelPingRIS.Text = "";
//labelReqWLM.Text = "";
this.Invoke(new CleanUp(ClearInformation), new string[] { "Req MWL" });
bool isSendOk = false;
//If result tab is present, remove it
if(tabControlEmulator.Controls.Contains(tabPageResults))
{
tabControlEmulator.Controls.Remove(tabPageResults);
}
try
{
if (!checkRISConfig())
return;
if (!isCreated)
{
CreateIntegrationProfile();
isCreated = true;
}
if (!isInitialized)
{
//Apply updated settings
if (!UpdateConfig())
return;
wrapper.Initialize();
isInitialized = true;
isTerminated = false;
}
string wlmRqDcmFile = dcmEditorWLM.DCMFile;
string scheduledProcStepStartDate = System.DateTime.Now.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
if(wlmRqDcmFile != "")
isSendOk = wrapper.GetWorklist(wlmRqDcmFile, scheduledProcStepStartDate);
//isRISConnected = true;
if (isSendOk)
{
if (wrapper.ModalityActor.ModalityWorklistItems.Count > 0)
{
labelReqWLM.Text = string.Format("Received {0} worklist items successfully.", wrapper.ModalityActor.ModalityWorklistItems.Count);
toolBarButtonResults.Enabled = true;
foreach (DicomQueryItem mwlItem in wrapper.ModalityActor.ModalityWorklistItems)
{
DicomFile dcmFile = new DicomFile();
// Save dataset to DCM file
dcmFile.DataSet = mwlItem.DicomMessage.DataSet;
string mwlRspFileName = string.Format("wlmRsp{0:0000}", mwlItem.Id);
// create the sub mwlrsp directory
string subMwlRspDirectory = System.DateTime.Now.ToString("yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture);
string fullPath = wlmRspDataDirectory + subMwlRspDirectory;
DirectoryInfo directoryInfo = Directory.CreateDirectory(fullPath);
dcmFile.Write(fullPath + "\\" + mwlRspFileName);
}
}
else
{
labelReqWLM.Text = "No worklist item received.";
labelRIS.Text = "Only Dummy patient can be selected.";
}
}
else
{
labelReqWLM.Text = "Fail to send C-FIND-RQ message to RIS.";
labelRIS.Text = "Is RIS on the network? Only Dummy patient can be selected.";
buttonReqWL.Enabled = true;
SystemSounds.Beep.Play();
}
// Select patient
selectPatient();
}
catch(Exception except)
{
string msg = string.Format("Error: No worklist items received from {0} due to {1}.",textBoxRISAETitle.Text, except.Message);
labelReqWLM.Text = msg;
buttonStorageCommit.Enabled = false;
//buttonTS.Enabled = false;
buttonStoreImage.Enabled = false;
//.........这里部分代码省略.........
示例5: RetrievingFilesFromDirectory
private void RetrievingFilesFromDirectory()
{
try
{
String indexFileName = initialDirectory + @"/index1.htm";
StringBuilder indexContent = new StringBuilder();
indexContent.Append("<center><font size='5' color='#0000ff'>");
if(utility.AnonymizationType)
{
indexContent.Append("Anonymized DCM files (Basic)</font></center>");
}
else
{
indexContent.Append("Anonymized DCM files (Complete)</font></center>");
}
indexContent.Append("<left><font color='black' size = '4'><br></br> Input Directory: " + inputDirectory);
indexContent.Append("</font>");
indexContent.Append("</left>");
indexContent.Append("<br></br>");
indexContent.Append("<font size='3'>");
HLI.DataSet srcDataset = null;
DicomFile dcmFile = null;
allDCMFilesTemp = new ArrayList();
FileInfo mediaInputFileInfo = null;
string mediaFileDir = inputDirectory;
DirectoryInfo theDirectoryInfo = new DirectoryInfo(mediaFileDir);
allDCMFilesTemp = utility.GetFilesRecursively(theDirectoryInfo);
foreach ( string fileName in allDCMFilesTemp)
{
mediaInputFileInfo = new FileInfo(fileName);
counter++;
dcmFile = new DicomFile();
dcmFile.Read(fileName, mainThread);
// Get the Data set from the selected DCM file
srcDataset = dcmFile.DataSet;
indexContent.Append("<li><a href='" + mediaInputFileInfo.Name + "_" + counter.ToString() +".html'>" + fileName.Substring(inputDirectory.Length) + "</a></li>");
HLI.DataSet annonymizedDataset = srcDataset.Clone();
utility.PatientAttributes(annonymizedDataset);
for ( int number = 0; number < annonymizedDataset.Count; number++)
{
HLI.Attribute attribute = annonymizedDataset[number];
if (attribute.VR == VR.SQ)
{
utility.SequenceAttribute_recursive(attribute);
}
else
{
utility.CacheAndRepairIdentifyingAttribute(attribute);
utility.UpdateAnonymizedAttributes(attribute);
}
}
//Save annonymized data to selected directory
string savedFileName = "";
if(mediaInputFileInfo.Extension != "")
{
string srcFileNameWithoutExtn = mediaInputFileInfo.Name.Substring(0,(mediaInputFileInfo.Name.Length-4));
savedFileName = outputDirectory + "\\" + srcFileNameWithoutExtn + "_an";
}
else
savedFileName = outputDirectory + "\\" + mediaInputFileInfo.Name + "_an";
dcmFile.DataSet = annonymizedDataset;
dcmFile.Write(savedFileName);
datasets = new AttributeCollections();
datasets.Add(srcDataset);
datasets.Add(annonymizedDataset);
//Cleanup temp file
utility.cleanup();
resultFileName = mediaInputFileInfo.Name;
CreateTableWithoutNav();
}
StreamWriter writer = new StreamWriter(indexFileName);
indexContent.Append("</font>");
indexContent.Append("<left><font color='black' size = '4'><br></br> Output Directory: " + outputDirectory);
indexContent.Append("</font>");
indexContent.Append("</left>");
writer.Write(indexContent.ToString());
writer.Close();
dvtkWebBrowser.Navigate(indexFileName);
}
catch ( Exception e)
{
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
//.........这里部分代码省略.........
示例6: AnonymizeDCMFile
private void AnonymizeDCMFile()
{
try
{
utility.AnonymizationType = anonymizationMode;
CreateDICOMDIR.Enabled = true;
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Multiselect = false;
fileDialog.ReadOnlyChecked = true;
fileDialog.Title = "Select DCM File";
fileDialog.Filter = "DCM files (*.dcm) |*.dcm|All files (*.*)|*.*";
// Show the file dialog.
// If the user pressed the OK button...
if (fileDialog.ShowDialog() == DialogResult.OK)
{
DicomFile dcmFile = new DicomFile();
dcmFile.Read(fileDialog.FileName, mainThread);
// Get the Data set from the selected DCM file
HLI.DataSet srcDataset = dcmFile.DataSet;
SaveFileDialog saveDialog = new SaveFileDialog();
FileInfo saveFileInfo = null;
saveDialog.Filter = "DCM files (*.dcm) |*.dcm|All files (*.*)|*.*";
if (saveDialog.ShowDialog() == DialogResult.OK)
{
HLI.DataSet annonymizedDataset = srcDataset.Clone();
utility.PatientAttributes(annonymizedDataset);
for ( int number = 0; number < annonymizedDataset.Count; number++)
{
HLI.Attribute attribute = annonymizedDataset[number];
if (attribute.VR == VR.SQ)
{
utility.SequenceAttribute_recursive(attribute);
}
else
{
utility.CacheAndRepairIdentifyingAttribute(attribute);
utility.UpdateAnonymizedAttributes(attribute);
}
}
datasets = new AttributeCollections();
datasets.Add(srcDataset);
datasets.Add(annonymizedDataset);
//Save annonymized data to selected file
saveFileInfo = new FileInfo(saveDialog.FileName);
dcmFile.DataSet = annonymizedDataset;
dcmFile.Write(saveFileInfo.FullName);
//Cleanup temp file
utility.cleanup();
}
else
{
return;
}
string htmlFileName = initialDirectory + "\\" + saveFileInfo.Name + ".html";
XmlTextWriter writer = new XmlTextWriter(htmlFileName, System.Text.Encoding.UTF8);
writer.WriteStartElement("b");
writer.WriteRaw(@"<b><font size='3' color='#ff0000'>DCM File Anonymization Started...</font></b>");
writer.WriteEndElement();
writer.Close();
resultFileName = htmlFileName;
System.Threading.Thread t = new System.Threading.Thread(new ThreadStart(CreateTable));
dvtkWebBrowser.Navigate(htmlFileName);
t.Start();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}