Skip to content

Commit

Permalink
Merge pull request #2 from ChrisPulman/AddConverters
Browse files Browse the repository at this point in the history
Add Converters
  • Loading branch information
ChrisPulman committed Jan 10, 2024
2 parents f0e33da + 8f4d176 commit 9fffd5e
Show file tree
Hide file tree
Showing 74 changed files with 4,281 additions and 0 deletions.
537 changes: 537 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions .github/workflows/BuildDeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# ------------------------------------------------------------------------------
# <auto-generated>
#
# This code was generated.
#
# - To turn off auto-generation set:
#
# [GitHubActions (AutoGenerate = false)]
#
# - To trigger manual generation invoke:
#
# nuke --generate-configuration GitHubActions_BuildDeploy --host GitHubActions
#
# </auto-generated>
# ------------------------------------------------------------------------------

name: BuildDeploy

on:
push:
branches:
- main

jobs:
windows-latest:
name: windows-latest
runs-on: windows-latest
environment:
name: release
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: NBGV
id: nbgv
uses: dotnet/nbgv@master
with:
setAllVars: true
- run: echo 'SemVer2=${{ steps.nbgv.outputs.SemVer2 }}'

- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
- name: 'Run: Compile, Deploy'
run: ./build.cmd Compile Deploy
env:
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
- name: 'Publish: output'
uses: actions/upload-artifact@v3
with:
name: output
path: output

- name: Changelog
uses: glennawatson/ChangeLog@v1
id: changelog

- name: Create Release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.nbgv.outputs.SemVer2 }}
release_name: ${{ steps.nbgv.outputs.SemVer2 }}
body: |
${{ steps.changelog.outputs.commitLog }}
41 changes: 41 additions & 0 deletions .github/workflows/BuildOnly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ------------------------------------------------------------------------------
# <auto-generated>
#
# This code was generated.
#
# - To turn off auto-generation set:
#
# [GitHubActions (AutoGenerate = false)]
#
# - To trigger manual generation invoke:
#
# nuke --generate-configuration GitHubActions_BuildOnly --host GitHubActions
#
# </auto-generated>
# ------------------------------------------------------------------------------

name: BuildOnly

on:
push:
branches-ignore:
- main

jobs:
windows-latest:
name: windows-latest
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
- name: 'Run: Compile'
run: ./build.cmd Compile
4 changes: 4 additions & 0 deletions .nuke/parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "./build.schema.json",
"Solution": "src/XamlConverters.sln"
}
62 changes: 62 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Authors>Chris Pulman</Authors>
<Description>A collection of XAML Converters</Description>
<Copyright>Copyright © https://github.com/ChrisPulman $([System.DateTime]::Now.ToString(yyyy))</Copyright>
<IsTestProject>$(MSBuildProjectName.Contains('Tests'))</IsTestProject>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>preview</LangVersion>
<Configuration>$(TargetFramework)</Configuration>
<Company>ChrisPulman</Company>
<NoWarn>CS1591;IDE0190;IDE1006</NoWarn>
<Nullable>enable</Nullable>
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Configurations>Debug;Release</Configurations>
<PackageReleaseNotes>Compatability with Net 6/7/8 and netstandard2.0</PackageReleaseNotes>
<PackageTags>XAML;converters;net;netstandard</PackageTags>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>

<PackageProjectUrl>https://github.com/ChrisPulman/XamlConverters</PackageProjectUrl>
<RepositoryUrl>https://github.com/ChrisPulman/XamlConverters</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<!--https://devblogs.microsoft.com/dotnet/producing-packages-with-source-link/-->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<DebugType>embedded</DebugType>
<IncludeSymbols>true</IncludeSymbols>

<!-- Include PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' != 'true'">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)images\logo.png" Pack="true" PackagePath="\"/>
<None Include="$(MSBuildThisFileDirectory)LICENSE" Pack="true" PackagePath="LICENSE" />
<None Include="$(MSBuildThisFileDirectory)README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<!--<Compile Update="**\*.cs" DependentUpon="I%(Filename).cs" />-->
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="all" />
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.556" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" Version="4.8.0" PrivateAssets="All" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
</ItemGroup>
</Project>
Binary file added Images/logo.ico
Binary file not shown.
Binary file added Images/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,70 @@
# XamlConverters
Converters for WPF

![Nuget](https://img.shields.io/nuget/v/CP.Xaml.Converters) ![Nuget](https://img.shields.io/nuget/dt/CP.Xaml.Converters)

Converters available are:

- ArithmeticConverter
- BackgroundColorToBwForegroundConverter
- BoolNegationConverter
- BoolToOpacityConverter
- BoolToStringTickCrossConverter
- BoolToVisibilityConverter
- BoolToVisibilityConverterNegate
- CollectionSizeToBoolConverter
- CollectionSizeToVisibilityConverter
- ColorToBrushConverter
- DoubleToCurrencyStringConverter
- EnumConverter
- HexStringToColorConverter
- HexStringToSolidColorBrushConverter
- IntToThicknessConverter
- IntToVisibilityConverter
- InverseValueToBoolConverter
- InvertSignConverter
- InvertValueConverter
- InvertVisibilityConverter
- IsGreaterThanOrEqualToConverter
- LineStrokeLevelConverter
- ToLowerConverter
- MathConverter
- MultiConverter
- MultiplierConverter
- NullToBoolConverter
- NullToVisibilityConverter
- ToUpperConverter
- ValueCompareVisibilityConverter
- ValueGreaterThanXToBoolConverter
- ValueGtXConverter
- ValueLessThanXToBoolConverter
- ValueNotNullToBoolConverter
- ValueNotNullToVisibilityConverter
- ValueToBrushConverter
- VisibilityFromNumberConverter
- VisibilityFromNumberEqualsConverter
- ZeroToVisibilityConverter

## Usage


Add the namespace to your App.xaml file:

```xaml
xmlns:converters="https://github.com/ChrisPulman/XamlConverters"
```

Then add the ConvertersDictionary to your resources in App.xaml:

```xaml
<Application.Resources>
<converters:ConvertersDictionary />
</Application.Resources>
```

This will make all of the converters available to your application.
Then use it by selecting a `Converter={StaticResource #CONVERTER#}}` such as:

```xaml
<TextBlock Text="{Binding MyProperty, Converter={StaticResource ToUpperConverter}}" />
```
18 changes: 18 additions & 0 deletions Version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.0",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/heads/main$"
],
"nugetPackageVersion": {
"semVer": 2,
"precision": "build"
},
"cloudBuild": {
"setVersionVariables": true,
"buildNumber": {
"enabled": false
}
}
}
7 changes: 7 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:; set -eo pipefail
:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
:; ${SCRIPT_DIR}/build.sh "$@"
:; exit $?

@ECHO OFF
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %*
74 changes: 74 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[CmdletBinding()]
Param(
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$BuildArguments
)

Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"

Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent

###########################################################################
# CONFIGURATION
###########################################################################

$BuildProjectFile = "$PSScriptRoot\build\_build.csproj"
$TempDirectory = "$PSScriptRoot\\.nuke\temp"

$DotNetGlobalFile = "$PSScriptRoot\\global.json"
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
$DotNetChannel = "STS"

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:DOTNET_MULTILEVEL_LOOKUP = 0

###########################################################################
# EXECUTION
###########################################################################

function ExecSafe([scriptblock] $cmd) {
& $cmd
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}

# If dotnet CLI is installed globally and it matches requested version, use for execution
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
$(dotnet --version) -and $LASTEXITCODE -eq 0) {
$env:DOTNET_EXE = (Get-Command "dotnet").Path
}
else {
# Download install script
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)

# If global.json exists, load expected version
if (Test-Path $DotNetGlobalFile) {
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
$DotNetVersion = $DotNetGlobal.sdk.version
}
}

# Install by channel or version
$DotNetDirectory = "$TempDirectory\dotnet-win"
if (!(Test-Path variable:DotNetVersion)) {
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
} else {
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
}
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
}

Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"

if (Test-Path env:NUKE_ENTERPRISE_TOKEN) {
& $env:DOTNET_EXE nuget remove source "nuke-enterprise" > $null
& $env:DOTNET_EXE nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password $env:NUKE_ENTERPRISE_TOKEN > $null
}

ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }

0 comments on commit 9fffd5e

Please sign in to comment.