Bodoconsult.App.Windows 1.0.8

dotnet add package Bodoconsult.App.Windows --version 1.0.8
                    
NuGet\Install-Package Bodoconsult.App.Windows -Version 1.0.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bodoconsult.App.Windows" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bodoconsult.App.Windows" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Bodoconsult.App.Windows" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bodoconsult.App.Windows --version 1.0.8
                    
#r "nuget: Bodoconsult.App.Windows, 1.0.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bodoconsult.App.Windows@1.0.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bodoconsult.App.Windows&version=1.0.8
                    
Install as a Cake Addin
#tool nuget:?package=Bodoconsult.App.Windows&version=1.0.8
                    
Install as a Cake Tool

Bodoconsult.App.Windows

Overview

What does the library

Bodoconsult.App.Windows provides features related to Microsoft Windows operating system.

Current features are:

Logging to OS event log via EventLogLoggingProviderConfigurator

Sending TOAST messages via WindowsToastMessagingService

Using clipboard with Clipboard class

Using DataProtectionService to protect critical string data

Icon extraction as bitmap

Reading data from url files (get the included link address in file)

How to use the library

The source code contain a NUnit test classes, the following source code is extracted from. The samples below show the most helpful use cases for the library.

Logging to OS event log via EventLogLoggingProviderConfigurator

With EventLogLoggingProviderConfigurator you can enhance the logging system from Bodoconsult.App based on IAppLoggerProxy with logging to OS event log.


Sending TOAST messages via WindowsToastMessagingService

[Test]
public void SendSimpleToastMessage_NotifyRequestRecord_NotificationIsShown()
{
    // Arrange 
    var request = new NotifyRequestRecord
    {
        Text = "Das ist eine Message",
        Title = "Title"
    };

    var s = new WindowsToastMessagingService();

    // Act and assert
    Assert.DoesNotThrow(() =>
    {
        s.SendSimpleToastMessage(request);
    });
}

Using clipboard with Clipboard class

[Test]
public void TestSetText()
{
    // Arrange
    const string text = "CopyToClipboard";

    // Act
    Clipboard.SetText(text);

    var result = Clipboard.GetText();


    // Assert
    Assert.That(result, Is.EqualTo(text));
}

Using DataProtectionService to protect sensible string data

[SetUp]
public void Setup()
{
    _service = new DataProtectionService();
}

[Test]
public void ProtectUnprotect_CurrentUser_Successful()
{
    const string secret = "Test123!";

    _service.CurrentDataProtectionScope = DataProtectionScope.CurrentUser;

    //Encrypt the data.
    var encryptedSecret = _service.ProtectString(secret);
    Debug.Print($"The encrypted byte array is: {ArrayHelper.GetStringFromArray(encryptedSecret)}");

    // Decrypt the data and store in a byte array.
    var originalData = _service.UnprotectString(encryptedSecret);
    Debug.Print($"The original data is: {originalData}"); 

    Assert.That(originalData, Is.EqualTo(secret));
}

[Test]
public void ProtectUnprotect_LocalMachine_Successful()
{
    const string secret = "Test123!";

    _service.CurrentDataProtectionScope = DataProtectionScope.LocalMachine;

    //Encrypt the data.
    var encryptedSecret = _service.ProtectString(secret);
    Debug.Print($"The encrypted byte array is: {ArrayHelper.GetStringFromArray(encryptedSecret)}");

    // Decrypt the data and store in a byte array.
    var originalData = _service.UnprotectString(encryptedSecret);
    Debug.Print($"The original data is: {originalData}");

    Assert.That(originalData, Is.EqualTo(secret));
}
``` csharp

[Test]
public void TestRead()
{
    // Arrange
    var url = Path.Combine(TestHelper.TestDataPath, "Bodoconsult.url");

    var fri = new FileInfo(url);

    var urlFile = new FileSystemUrl(fri);

    // Act
    urlFile.Read();

    // Assert
    Assert.That(urlFile.Url, Is.EqualTo("http://www.bodoconsult.de/"));
    Assert.That(urlFile.Caption, Is.EqualTo("Bodoconsult"));
}

Using IconsAsFilesHelper to get GIF images from an app icon

[Test]
public void SaveIcons_OfficeDocuments_IconExtracted()
{
    var iconDocx = Path.Combine(TestHelper.OutputPath, "docx.gif");
    if (File.Exists(iconDocx))
    {
        File.Delete(iconDocx);
    }

    var iconXlsx = Path.Combine(TestHelper.OutputPath, "xlsx.gif");
    if (File.Exists(iconXlsx))
    {
        File.Delete(iconXlsx);
    }


    var icons = new IconsAsFilesHelper {IconPath = TestHelper.OutputPath};

    var path = Path.Combine(TestHelper.TestDataPath, "Test.docx");

    var fri = new FileInfo(path);
    icons.AddExtension(fri);


    path = Path.Combine(TestHelper.TestDataPath, "Test.xlsx");

    fri = new FileInfo(path);
    icons.AddExtension(fri);

    icons.SaveIcons();

    Assert.That(File.Exists(iconDocx));
    Assert.That(File.Exists(iconXlsx));
}

About us

Bodoconsult (http://www.bodoconsult.de) is a Munich based software development company from Germany.

Robert Leisner is senior software developer at Bodoconsult. See his profile on http://www.bodoconsult.de/Curriculum_vitae_Robert_Leisner.pdf.

Product Compatible and additional computed target framework versions.
.NET net9.0-windows10.0.17763 is compatible.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.8 96 1/11/2026
1.0.7 220 12/7/2025
1.0.6 187 7/27/2025
1.0.5 537 7/21/2025
1.0.0 138 4/26/2025

Added API docu and new packages