Common-wpf.Utility
                              
                            
                                2024.1.4.1616
                            
                        
                    dotnet add package Common-wpf.Utility --version 2024.1.4.1616
NuGet\Install-Package Common-wpf.Utility -Version 2024.1.4.1616
        
        
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="Common-wpf.Utility" Version="2024.1.4.1616" />
        
        
For projects that support PackageReference, copy this XML node into the project file to reference the package.
                    
    
    <PackageVersion Include="Common-wpf.Utility" Version="2024.1.4.1616" />
<PackageReference Include="Common-wpf.Utility" />
        
        
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 Common-wpf.Utility --version 2024.1.4.1616
        
        
 The NuGet Team does not provide support for this client. Please contact its maintainers for support.
                    
    
    #r "nuget: Common-wpf.Utility, 2024.1.4.1616"
        
        
#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 Common-wpf.Utility@2024.1.4.1616
        
        
#: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=Common-wpf.Utility&version=2024.1.4.1616
#tool nuget:?package=Common-wpf.Utility&version=2024.1.4.1616
        
        
 The NuGet Team does not provide support for this client. Please contact its maintainers for support.
                    
    
    Common-wpf
A collection of useful libraries for wpf.
All utilities are available as NuGet packages:
Install-Package Common-wpf.Settings
Install-Package Common-wpf.Utility
Common.Settings
A settings system for wpf that allows easy access for both code behind and xaml, with auto-complete and two way bindings.
namespace Example.Settings; //namespace we need to import in xaml (xmlns:settings="clr-namespace:Example.Settings")
public class WindowTitle : Setting<string, WindowTitle>
{
    public override string? DefaultValue => "Example";
}
public class ExampleCollection : CollectionSetting<string, Collection>
{
    public override IEnumerable<string>? DefaultItems => new[] { "" };
}
public class ExampleDictionary : DictionarySetting<string, string, Dictionary>
{
    public override Dictionary<string, string>? DefaultItems => new() { { "testKey", "testValue" } };
}
public class ExampleFlags : FlagSetting<string, Flag>
{
    public override Dictionary<string, bool>? DefaultItems => null; //null is default, so no reason to override, but for example purposes
}
<Window
  ..
  xmlns:settings="clr-namespace:Example.Settings"
  xmlns:settingsUtility="common://settings"
  Width="800" Height="450" WindowStartupLocation="Manual"
  Title="{settings:WindowTitle Mode=OneWay}"
  Settings.SavePosition="True">
  ..
</Window>
public Window : System.Windows.Window
{
    private void Window_Loaded(..)
    {
        //Set some new values through code
        Settings.WindowTitle.Current.Value = "This is an example";
        Settings.ExampleCollection.Current.Add("test");
        Settings.ExampleDictionary.Current.Set("test", "value");
        Settings.ExampleFlags.Current.Set("test");
        Settings.ExampleFlags.Current.Unset("test");
        //We delay the actual write for a bit to ensure we don't spam write value to registry.
        //While delay duration can be modified using Common.Settings.SettingsUtility.DelayDuration property,
        //the following call ensures all pending writes are done at once.
        //This is by automatically called during App.Current.Exit event, by default.
        Common.Settings.SettingsUtility.SavePending(); 
        //List all settings and values
        foreach (var setting in Common.Settings.SettingsUtility.Enumerate())
            if (Common.Settings.SettingsUtility.GetJson(setting, out var json))
                Debug.WriteLine($"{setting.Name} ({setting.Name}):\n{json}\n");
    }
}
Common.Utility
Contains utility functions for wpf.
<Window ..
  xmlns:common="http://common"
  Common:IsVisibleInAltTab="False">
</Window>
public class Window : System.Windows.Window
{
    private void Window_Loaded(..)
    {
        //Center window on the screen that the window is currently on
        this.Center();
        this.CenterVertically();
        this.CenterHorizontally();
        //Restricts window from being moved offscreen (supports multiple monitors)
        this.MakeSureVisible();
    }
}
public class App : System.Windows.Application
{
    void Application_Startup(object sender, StartupEventArgs e)
    {
    
        //Makes sure app runs as single instance
        if (AppUtility.IsSecondaryInstance(HandleArguments))
        {
            Shutdown();
            return;
        }
        
        //Enable auto start, can be bound to using two-way binding
        //{Binding Source={x:Static common:AppUtility.AutoStart}, Path=IsEnabled, Mode=TwoWay}
        AppUtility.AutoStart.IsEnabled = true;
    }
    
    //Handle command line arguements here, which are passed from secondary instance
    void HandleArguments(AppArguments arguments)
    { }
    
}
| Product | Versions Compatible and additional computed target framework versions. | 
|---|---|
| .NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. net9.0-windows was computed. net10.0-windows was computed. | 
        
        Compatible target framework(s)
    
    
        
        Included target framework(s) (in package)
    
    Learn more about Target Frameworks and .NET Standard.
- 
                                                    net6.0-windows7.0- ShellUtility.Screens (>= 1.0.50)
- System.Drawing.Common (>= 6.0.0)
 
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 | 
|---|---|---|
| 2024.1.4.1616 | 310 | 1/4/2024 | 
| 2024.1.4.1457 | 170 | 1/4/2024 | 
| 2024.1.4.1256 | 169 | 1/4/2024 | 
| 2024.1.4.1245 | 172 | 1/4/2024 | 
| 2024.1.4.1112 | 199 | 1/4/2024 | 
| 2024.1.4.1108 | 181 | 1/4/2024 | 
| 2024.1.4.1106 | 204 | 1/4/2024 | 
| 2024.1.4.1104 | 177 | 1/4/2024 | 
| 2024.1.4.1100 | 172 | 1/4/2024 | 
| 2023.5.11.161712 | 294 | 5/11/2023 | 
| 1.0.38 | 523 | 9/29/2022 | 
| 1.0.37 | 542 | 9/15/2022 | 
| 1.0.36 | 499 | 9/12/2022 | 
| 1.0.35 | 512 | 9/9/2022 | 
| 1.0.34 | 521 | 8/10/2022 | 
| 1.0.33 | 514 | 8/5/2022 | 
| 1.0.32 | 537 | 8/2/2022 | 
| 1.0.31 | 204 | 8/1/2022 | 
| 1.0.30 | 212 | 8/1/2022 | 
| 1.0.29 | 225 | 8/1/2022 | 
| 1.0.28 | 217 | 8/1/2022 | 
| 1.0.25 | 221 | 7/24/2022 | 
| 1.0.24 | 215 | 7/21/2022 | 
| 1.0.23 | 207 | 7/21/2022 | 
| 1.0.22 | 226 | 6/12/2022 | 
| 1.0.21 | 554 | 9/7/2021 | 
| 1.0.20 | 446 | 9/6/2021 | 
| 1.0.19 | 446 | 9/3/2021 | 
| 1.0.18 | 464 | 9/3/2021 | 
| 1.0.17 | 463 | 6/29/2021 | 
| 1.0.16 | 606 | 6/26/2021 | 
| 1.0.15 | 476 | 6/24/2021 | 
| 1.0.14 | 487 | 6/22/2021 | 
| 1.0.13 | 490 | 6/22/2021 | 
| 1.0.12 | 488 | 6/14/2021 | 
| 1.0.11 | 502 | 6/13/2021 | 
| 1.0.10 | 489 | 5/15/2021 | 
| 1.0.9 | 439 | 5/14/2021 | 
| 1.0.8 | 451 | 3/31/2021 | 
| 1.0.7 | 469 | 3/31/2021 | 
| 1.0.6 | 480 | 3/31/2021 | 
| 1.0.5 | 561 | 1/21/2021 | 
| 1.0.4 | 462 | 10/26/2022 | 
| 1.0.3 | 507 | 1/19/2021 | 
| 1.0.2 | 494 | 1/18/2021 | 
| 1.0.0 | 526 | 1/21/2021 |