Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console prototype #86

Merged
merged 9 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion DicomGrep.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DicomGrep", "DicomGrep\Dico
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DicomGrepTests", "DicomGrepTests\DicomGrepTests.csproj", "{C26AA249-3A83-4B9A-9672-633AFE3081E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DicomGrepCore", "DicomGrepCore\DicomGrepCore.csproj", "{572F835B-6298-4075-A1E3-50675927CCF1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DicomGrepCore", "DicomGrepCore\DicomGrepCore.csproj", "{572F835B-6298-4075-A1E3-50675927CCF1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DicomGrepCli", "DicomGrepCli\DicomGrepCli.csproj", "{2404C580-7A56-4918-AB08-D9AF9E48ED15}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -27,6 +29,10 @@ Global
{572F835B-6298-4075-A1E3-50675927CCF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{572F835B-6298-4075-A1E3-50675927CCF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{572F835B-6298-4075-A1E3-50675927CCF1}.Release|Any CPU.Build.0 = Release|Any CPU
{2404C580-7A56-4918-AB08-D9AF9E48ED15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2404C580-7A56-4918-AB08-D9AF9E48ED15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2404C580-7A56-4918-AB08-D9AF9E48ED15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2404C580-7A56-4918-AB08-D9AF9E48ED15}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
43 changes: 42 additions & 1 deletion DicomGrep/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
using System;
using DicomGrep.Services.Interfaces;
using DicomGrep.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using DicomGrepCore.Services.Interfaces;
using DicomGrepCore.Services;

namespace DicomGrep
{
Expand All @@ -13,5 +18,41 @@ namespace DicomGrep
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
Services = ConfigureServices();

base.OnStartup(e);
}

/// <summary>
/// Configures the services for the application.
/// </summary>
private static IServiceProvider ConfigureServices()
{
var services = new ServiceCollection();
services.AddSingleton<IConfigurationService, ConfigurationService>();
services.AddSingleton<IDialogService, DialogService>();
services.AddSingleton<IDicomDictionaryLookupService, DicomDictionaryLookupService>();
services.AddSingleton<IExportService, ExportService>();
services.AddSingleton<IFileOperationService, FileOperationService>();
services.AddSingleton<IFolderPickupService, FolderPickupService>();
services.AddSingleton<ISopClassLookupService, SopClassLookupService>();
services.AddSingleton<ITagValueDetailService, TagValueDetailService>();
services.AddSingleton<ISearchService, SearchService>();
services.AddSingleton<IDictionaryService, DictionaryService>();

return services.BuildServiceProvider();
}

/// <summary>
/// Gets the <see cref="IServiceProvider"/> instance to resolve application services.
/// </summary>
public IServiceProvider Services { get; private set; }

/// <summary>
/// Gets the current <see cref="App"/> instance in use
/// </summary>
public new static App Current => (App)Application.Current;
}
}
20 changes: 1 addition & 19 deletions DicomGrep/DicomGrep.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
</PropertyGroup>

<ItemGroup>
<None Remove="DICOM Dictionary.sample.xml" />
<None Remove="DICOM Dictionary.xml" />
<None Remove="Private Dictionary.sample.xml" />
<None Remove="Private Dictionary.xml" />
<None Remove="Views\Images\logo_128.png" />
<None Remove="Views\Images\logo_16.png" />
<None Remove="Views\Images\logo_256.png" />
Expand All @@ -36,21 +32,6 @@
<None Remove="Views\Images\logo_96.png" />
</ItemGroup>

<ItemGroup>
<Content Include="DICOM Dictionary.sample.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="DICOM Dictionary.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Private Dictionary.sample.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Private Dictionary.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<None Include="..\README.md">
<Pack>True</Pack>
Expand All @@ -60,6 +41,7 @@

<ItemGroup>
<PackageReference Include="fo-dicom" Version="5.1.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
<PackageReference Include="NLog" Version="5.3.2" />
</ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions DicomGrep/Services/ConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
using System.Text.Json;
using DicomGrepCore.Entities;
using DicomGrepCore.Enums;
using DicomGrep.Services.Interfaces;

namespace DicomGrep.Services
{
/// <summary>
/// Configuration Service
/// </summary>
public class ConfigurationService
public class ConfigurationService : IConfigurationService
{
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private static Configuration CurrentConfiguration { get; set; }
Expand All @@ -38,7 +39,7 @@ public bool Save()
{
File.WriteAllText(CONFIG_FILE, JsonSerializer.Serialize(CurrentConfiguration, option));
}
catch(Exception ex)
catch (Exception ex)
{
logger.Error(ex, "Failed to save the configuration to file.");
return false;
Expand Down
5 changes: 3 additions & 2 deletions DicomGrep/Services/DialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
using System.Collections.Generic;
using System.Text;
using System.Windows;
using DicomGrep.Services.Interfaces;

namespace DicomGrep.Services
{
/// <summary>
/// Dialog Service. For the WPF MVVM pattern.
/// </summary>
public class DialogService
public class DialogService : IDialogService
{
public MessageBoxResult ShowMessageBox(string messageBoxText,
public MessageBoxResult ShowMessageBox(string messageBoxText,
string caption = "Message",
MessageBoxButton button = MessageBoxButton.OK,
MessageBoxImage icon = MessageBoxImage.None,
Expand Down
5 changes: 3 additions & 2 deletions DicomGrep/Services/DicomDictionaryLookupService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DicomGrep.ViewModels;
using DicomGrep.Services.Interfaces;
using DicomGrep.ViewModels;
using DicomGrep.Views;
using FellowOakDicom;
using System;
Expand All @@ -12,7 +13,7 @@ namespace DicomGrep.Services
/// <summary>
/// DICOM Dictionary lookup Service. In WPF to call View and VievModel.
/// </summary>
public class DicomDictionaryLookupService
public class DicomDictionaryLookupService : IDicomDictionaryLookupService
{
public bool SelectDicomDictionaryEntry(ref string dicomTagString)
{
Expand Down
5 changes: 3 additions & 2 deletions DicomGrep/Services/ExportService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DicomGrep.Models;
using DicomGrep.Services.Interfaces;
using DicomGrepCore.Entities;
using Microsoft.Win32;
using System;
Expand All @@ -13,7 +14,7 @@ namespace DicomGrep.Services
/// <summary>
/// Export the search result to file.
/// </summary>
public class ExportService
public class ExportService : IExportService
{
public void Export(List<ResultDicomFile> resultFiles, string exportTo = "")
{
Expand Down Expand Up @@ -47,7 +48,7 @@ public void Export(List<ResultDicomFile> resultFiles, string exportTo = "")

DialogService ds = new DialogService();
ds.ShowMessageBox($"Search result has been exported to:\n{exportTo}",
"Export",System.Windows.MessageBoxButton.OK,System.Windows.MessageBoxImage.Information);
"Export", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion DicomGrep/Services/FileOperationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
using System.IO;
using System.Text;
using System.Windows;
using DicomGrep.Services.Interfaces;

namespace DicomGrep.Services
{
/// <summary>
/// File system and Windows explorer related
/// </summary>
public class FileOperationService
public class FileOperationService : IFileOperationService
{
public bool OpenDirectory(string filePath)
{
Expand Down
3 changes: 2 additions & 1 deletion DicomGrep/Services/FolderPickupService.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using DicomGrep.Services.Interfaces;
using Microsoft.Win32;

namespace DicomGrep.Services
{
/// <summary>
/// Display a folder selector UI.
/// </summary>
public class FolderPickupService
public class FolderPickupService : IFolderPickupService
{
public bool SelectFolder(ref string folderPath)
{
Expand Down
12 changes: 12 additions & 0 deletions DicomGrep/Services/Interfaces/IConfigurationService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using DicomGrep.Models;

namespace DicomGrep.Services.Interfaces
{
public interface IConfigurationService
{
Configuration GetConfiguration();
bool Load();
bool Save();
void SetConfiguration(Configuration config);
}
}
11 changes: 11 additions & 0 deletions DicomGrep/Services/Interfaces/IDialogService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Windows;

namespace DicomGrep.Services.Interfaces
{
public interface IDialogService
{
MessageBoxResult ShowMessageBox(string messageBoxText, string caption = "Message", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.OK, MessageBoxOptions options = MessageBoxOptions.None);
void ShowView(Window view);
bool? ShowViewDialog(Window view);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace DicomGrep.Services.Interfaces
{
public interface IDicomDictionaryLookupService
{
bool SelectDicomDictionaryEntry(ref string dicomTagString);
}
}
10 changes: 10 additions & 0 deletions DicomGrep/Services/Interfaces/IExportService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using DicomGrepCore.Entities;
using System.Collections.Generic;

namespace DicomGrep.Services.Interfaces
{
public interface IExportService
{
void Export(List<ResultDicomFile> resultFiles, string exportTo = "");
}
}
10 changes: 10 additions & 0 deletions DicomGrep/Services/Interfaces/IFileOperationService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace DicomGrep.Services.Interfaces
{
public interface IFileOperationService
{
bool CopyFullNamePath(string filePath);
bool CopyName(string filePath);
bool OpenDirectory(string filePath);
bool OpenFile(string filePath);
}
}
7 changes: 7 additions & 0 deletions DicomGrep/Services/Interfaces/IFolderPickupService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace DicomGrep.Services.Interfaces
{
public interface IFolderPickupService
{
bool SelectFolder(ref string folderPath);
}
}
7 changes: 7 additions & 0 deletions DicomGrep/Services/Interfaces/ISopClassLookupService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace DicomGrep.Services.Interfaces
{
public interface ISopClassLookupService
{
bool SelectSopClass(ref string sopClassUidString);
}
}
9 changes: 9 additions & 0 deletions DicomGrep/Services/Interfaces/ITagValueDetailService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using DicomGrepCore.Entities;

namespace DicomGrep.Services.Interfaces
{
public interface ITagValueDetailService
{
void InspectTagValue(ResultDicomItem item);
}
}
5 changes: 3 additions & 2 deletions DicomGrep/Services/SopClassLookupService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DicomGrep.ViewModels;
using DicomGrep.Services.Interfaces;
using DicomGrep.ViewModels;
using DicomGrep.Views;
using FellowOakDicom;
using System;
Expand All @@ -12,7 +13,7 @@ namespace DicomGrep.Services
/// <summary>
/// SOP Class lookup Service. In WPF to call View and VievModel.
/// </summary>
public class SopClassLookupService
public class SopClassLookupService : ISopClassLookupService
{
public bool SelectSopClass(ref string sopClassUidString)
{
Expand Down
3 changes: 2 additions & 1 deletion DicomGrep/Services/TagValueDetailService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DicomGrep.Models;
using DicomGrep.Services.Interfaces;
using DicomGrep.ViewModels;
using DicomGrep.Views;
using DicomGrepCore.Entities;
Expand All @@ -14,7 +15,7 @@ namespace DicomGrep.Services
/// <summary>
/// DICOM tag value details lookup Service. In WPF to call View and VievModel.
/// </summary>
public class TagValueDetailService
public class TagValueDetailService : ITagValueDetailService
{
public void InspectTagValue(ResultDicomItem item)
{
Expand Down
Loading
Loading