-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
it works, but still have tiny issues
- Loading branch information
1 parent
7ee4e05
commit d537d1f
Showing
9 changed files
with
176 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using DicomGrep.ViewModels; | ||
using DicomGrep.Views; | ||
using FellowOakDicom; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DicomGrep.Services | ||
{ | ||
public class DicomDictionaryLookupService | ||
{ | ||
public bool SelectDicomDictionaryEntry(ref string dicomTagString) | ||
{ | ||
DicomDictionaryLookupView window = new DicomDictionaryLookupView(); | ||
DicomDictionaryLookupViewModel vm = window.DataContext as DicomDictionaryLookupViewModel; | ||
if (!string.IsNullOrWhiteSpace(dicomTagString)) | ||
{ | ||
//build pass | ||
//vm.SelectedEntry = DicomTag.Parse(dicomTagString); | ||
} | ||
if (window.ShowDialog() == true) | ||
{ | ||
dicomTagString = vm.SelectedEntry?.ToString(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using FellowOakDicom; | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DicomGrep.ViewModels | ||
{ | ||
public class DicomDictionaryLookupViewModel : ViewModelBase | ||
{ | ||
public ObservableCollection<DicomDictionaryEntry> DicomDictionaryEntries { get; private set; } | ||
|
||
private DicomDictionaryEntry _selectedEntry; | ||
public DicomDictionaryEntry SelectedEntry | ||
{ | ||
get { return _selectedEntry; } | ||
set { SetProperty(ref _selectedEntry, value); } | ||
} | ||
|
||
public DicomDictionaryLookupViewModel() : base() | ||
{ | ||
if (DicomDictionaryEntries == null || DicomDictionaryEntries.Count == 0) | ||
{ | ||
DicomDictionaryEntries = new ObservableCollection<DicomDictionaryEntry>( | ||
GetAllDicomTagDefs().OrderBy(entry=>entry.Tag.Group).ThenBy(entry=>entry.Tag.Element) | ||
.Concat(GetAllPrivateTagDefs()).OrderBy(entry=>entry.Tag.PrivateCreator).ThenBy(entry => entry.Tag.Group).ThenBy(entry => entry.Tag.Element) | ||
); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Get all public DICOM tag definitions. Private tags are not included. | ||
/// </summary> | ||
/// <returns></returns> | ||
private IEnumerable<DicomDictionaryEntry> GetAllDicomTagDefs() | ||
{ | ||
return DicomDictionary.Default; | ||
} | ||
|
||
/// <summary> | ||
/// Get all private DICOM tag definitions. | ||
/// </summary> | ||
/// <returns></returns> | ||
private IEnumerable<DicomDictionaryEntry> GetAllPrivateTagDefs() | ||
{ | ||
ConcurrentDictionary<string, DicomDictionary> _private = typeof(DicomDictionary) | ||
.GetField("_private", BindingFlags.NonPublic | BindingFlags.Instance)? | ||
.GetValue(DicomDictionary.Default) | ||
as ConcurrentDictionary<string, DicomDictionary>; | ||
|
||
// each vendor (private tag creator) can own multiple entries (tags) | ||
IEnumerable<DicomDictionary> vendorsDictionary = _private.Select(item => item.Value); | ||
foreach (var dictionary in vendorsDictionary) | ||
{ | ||
foreach( var entry in dictionary) | ||
{ | ||
yield return entry; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using FellowOakDicom; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
|
||
namespace DicomGrep.Views | ||
{ | ||
[ValueConversion(typeof(DicomTag), typeof(string))] | ||
public class TagValueConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is DicomTag dicomTag) | ||
{ | ||
string para = "X"; | ||
if (parameter is string _p && !string.IsNullOrWhiteSpace(_p)) | ||
{ | ||
para = (string)parameter; | ||
} | ||
|
||
if (para == "C") | ||
{ | ||
if (dicomTag.PrivateCreator == null) | ||
{ | ||
return $"({dicomTag.Group:x4},{dicomTag.Element:x4})"; | ||
} | ||
return $"({dicomTag.Group:x4},xx{dicomTag.Element & 0xFF:x2})"; | ||
} | ||
else | ||
{ | ||
return dicomTag.ToString(para, null); | ||
} | ||
} | ||
else | ||
{ | ||
return value; | ||
} | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |