![]() |
VOOZH | about |
dotnet add package DoenaSoft.AbstractionLayer.WinForms --version 2.0.6
NuGet\Install-Package DoenaSoft.AbstractionLayer.WinForms -Version 2.0.6
<PackageReference Include="DoenaSoft.AbstractionLayer.WinForms" Version="2.0.6" />
<PackageVersion Include="DoenaSoft.AbstractionLayer.WinForms" Version="2.0.6" />Directory.Packages.props
<PackageReference Include="DoenaSoft.AbstractionLayer.WinForms" />Project file
paket add DoenaSoft.AbstractionLayer.WinForms --version 2.0.6
#r "nuget: DoenaSoft.AbstractionLayer.WinForms, 2.0.6"
#:package DoenaSoft.AbstractionLayer.WinForms@2.0.6
#addin nuget:?package=DoenaSoft.AbstractionLayer.WinForms&version=2.0.6Install as a Cake Addin
#tool nuget:?package=DoenaSoft.AbstractionLayer.WinForms&version=2.0.6Install as a Cake Tool
WinForms abstractions that make Windows Forms components easier to mock and unit-test. This project targets multiple frameworks to support legacy .NET Framework and modern .NET desktop applications.
Package Id: DoenaSoft.AbstractionLayer.WinForms
Targets: net472, net8.0-windows, net10.0-windows
Usage:
Install the package from NuGet and program against the provided interfaces instead of concrete WinForms types to make code testable.
License: MIT
This package provides WinForms-specific implementations of the interfaces defined in DoenaSoft.AbstractionLayer.UI. The key interfaces include:
IUIServices - The primary entry point for UI operations. Provides methods to show message boxes and common file/folder dialogs:
ShowMessageBox - Display message boxes with configurable text, caption, buttons, and iconShowOpenFileDialog - Show open file dialogs for single or multiple file selectionShowSaveFileDialog - Show save file dialogsShowFolderBrowserDialog - Show folder browser dialogsIClipboardServices - Comprehensive clipboard operations:
ContainsText, ContainsAudio, ContainsFileDropList, ContainsImage, ContainsDataGetText, GetAudioStream, GetFileDropList, GetImage, GetData, GetDataObjectSetText, SetAudio (byte array or stream), SetFileDropList, SetImage, SetData, SetDataObjectClear - Remove all data from clipboardISynchronizer - Invoke work on the UI thread:
Invoke(Action) - Synchronously invoke an action on the UI threadInvoke<T>(Func<T>) - Synchronously invoke a function and return its resultBeginInvoke(Action) - Asynchronously invoke an action on the UI threadIDispatcherOperation - Represents a posted dispatcher operation:
Result - Gets the result after completionStatus - Gets the current status (Pending, Aborted, Completed, Executing)Task - Gets a Task that represents the operationFileDialogOptions - Base configuration for file dialogsOpenFileDialogOptions - Configuration for open file dialogs (includes multi-select)SaveFileDialogOptions - Configuration for save file dialogsFolderBrowserDialogOptions - Configuration for folder browser dialogsMessageButton - Message box button configuration (OK, YesNo, YesNoCancel)MessageIcon - Message box icon types (None, Information, Warning, Error, Question)Result - Dialog result values (OK, Cancel, Yes, No, etc.)DispatcherStatus - Dispatcher operation status (Pending, Aborted, Completed, Executing)This package provides concrete WinForms adapter implementations:
FormUIServices - Wraps System.Windows.Forms dialog types and implements IUIServicesFormClipboardServices - Wraps System.Windows.Forms.Clipboard and implements IClipboardServicesFormSynchronizer - Wraps Control.Invoke/BeginInvoke and implements ISynchronizerUsage from application code (example view model):
public class MyViewModel
{
private readonly DoenaSoft.AbstractionLayer.UIServices.IUIServices _ui;
private readonly DoenaSoft.AbstractionLayer.UIServices.IClipboardServices _clipboard;
public MyViewModel(
DoenaSoft.AbstractionLayer.UIServices.IUIServices ui,
DoenaSoft.AbstractionLayer.UIServices.IClipboardServices clipboard)
{
_ui = ui;
_clipboard = clipboard;
}
public void SaveCommand()
{
if (_ui.ShowMessageBox("Save changes?", "Confirm", MessageButton.YesNo, MessageIcon.Question) == Result.Yes)
{
// perform save
}
}
public void CopyToClipboard(string text)
{
if (_clipboard.SetText(text))
{
_ui.ShowMessageBox("Copied to clipboard", "Success", MessageButton.OK, MessageIcon.Information);
}
}
}
Simple fake for unit tests:
class FakeUIServices : DoenaSoft.AbstractionLayer.UIServices.IUIServices
{
public Result LastMessageBoxResult { get; set; } = Result.Yes;
public Result ShowMessageBox(string text, string caption, Buttons buttons, Icon icon)
{
return LastMessageBoxResult;
}
public bool ShowOpenFileDialog(OpenFileDialogOptions options, out string fileName)
{
fileName = "test.txt";
return true;
}
public bool ShowOpenFileDialog(OpenFileDialogOptions options, out string[] fileNames)
{
fileNames = new[] { "test.txt" };
return true;
}
public bool ShowSaveFileDialog(SaveFileDialogOptions options, out string fileName)
{
fileName = "out.txt";
return true;
}
public bool ShowFolderBrowserDialog(FolderBrowserDialogOptions options, out string folder)
{
folder = "C:\\Temp";
return true;
}
}
class FakeClipboardServices : DoenaSoft.AbstractionLayer.UIServices.IClipboardServices
{
public bool ContainsText => true;
public string ClipboardText { get; set; } = string.Empty;
public bool ContainsAudio() => false;
public bool ContainsFileDropList() => false;
public bool ContainsImage() => false;
public bool ContainsData(string format) => false;
public void Clear() => ClipboardText = string.Empty;
public string GetText() => ClipboardText;
public Stream GetAudioStream() => null;
public StringCollection GetFileDropList() => null;
public object GetImage() => null;
public object GetData(string format) => null;
public object GetDataObject() => null;
public bool SetText(string text)
{
ClipboardText = text;
return true;
}
public void SetAudio(byte[] audioBytes) { }
public void SetAudio(Stream audioStream) { }
public void SetFileDropList(StringCollection filePaths) { }
public void SetImage(object image) { }
public void SetData(string format, object data) { }
public void SetDataObject(object data, bool copy, int retryTimes, int retryDelay) { }
}
DoenaSoft.AbstractionLayer.UI version 2.0.1 or later, which contains the contract interfaces and data types.System.Windows.Forms types to implement the UI contracts.DoenaSoft.AbstractionLayer.WinForms provides concrete adapters and implementations for those interfaces (for example FormUIServices, FormClipboardServices) that wrap System.Windows.Forms components. In production you reference and use this package; in unit tests you should depend on the contracts (DoenaSoft.AbstractionLayer.UI) and supply test doubles for the interfaces.| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 net8.0-windows7.0 is compatible. net9.0-windows net9.0-windows was computed. net10.0-windows net10.0-windows was computed. net10.0-windows7.0 net10.0-windows7.0 is compatible. |
| .NET Framework | net472 net472 is compatible. net48 net48 was computed. net481 net481 was computed. |
Showing the top 1 NuGet packages that depend on DoenaSoft.AbstractionLayer.WinForms:
| Package | Downloads |
|---|---|
|
DoenaSoft.DVDProfiler.Xml
Strongly-typed .NET library for reading, writing, and manipulating DVD Profiler XML export files from Invelos. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.6 | 108 | 5/18/2026 |
| 2.0.5 | 123 | 4/12/2026 |
| 2.0.4 | 137 | 3/29/2026 |
| 1.1.9 | 275 | 7/27/2024 |
| 1.1.8 | 262 | 5/7/2024 |
| 1.1.7 | 346 | 12/5/2023 |
| 1.1.6 | 227 | 12/3/2023 |
| 1.1.5 | 254 | 12/3/2023 |
| 1.1.4 | 275 | 9/12/2023 |
| 1.1.3 | 304 | 8/28/2023 |
| 1.1.2 | 274 | 8/28/2023 |
| 1.1.1 | 260 | 8/28/2023 |
| 1.1.0 | 268 | 8/28/2023 |
| 1.0.0 | 274 | 8/28/2023 |