├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ └── bug_report.md
├── dependabot.yml
├── release-drafter.yml
└── workflows
│ ├── compile.yml
│ ├── publish.yml
│ └── release-drafter.yaml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── docs
├── BLoc-and-FELoc.md
├── FAQ.md
├── Features.md
├── GapText.md
├── Installation-and-dependencies.md
├── Keys.md
├── LocProxy-&-EnumComboBox.md
├── Localization-providers.md
├── Localization.md
├── Localize.md
├── Logo.png
├── MarkupExtension-basics.md
├── Multiple-assemblies-and-dictionaries.md
├── Our-first-localized-text.md
├── Preparing-the-XAML-code.md
├── README.md
├── Resource-files.md
├── SAPLogo.gif
├── Structure.png
├── Supported-platforms.md
└── ValueConverters.md
├── src
├── Deprecated
│ ├── Engine
│ │ ├── GapTextControl.cs
│ │ ├── LocBinding.cs
│ │ └── LocProxy.cs
│ ├── Extensions
│ │ └── Compatibility.cs
│ └── Providers
│ │ ├── CSVEmbeddedLocalizationProvider.cs
│ │ ├── CSVLocalizationProvider.cs
│ │ └── CSVLocalizationProviderBase.cs
├── Engine
│ ├── EnumComboBox.cs
│ ├── EnumRun.cs
│ ├── FallbackBehavior.cs
│ ├── IDictionaryEventListener.cs
│ ├── ListenerList.cs
│ ├── LocalizeDictionary.cs
│ ├── MissingKeyEventArgs.cs
│ ├── ObjectDependencyManager.cs
│ ├── ParentNotifiers.cs
│ ├── SafeTargetInfo.cs
│ └── WeakReference.cs
├── Extensions
│ ├── BLoc.cs
│ ├── FELoc.cs
│ └── LocExtension.cs
├── Providers
│ ├── FQAssemblyDictionaryKey.cs
│ ├── FullyQualifiedResourceKeyBase.cs
│ ├── IInheritingLocalizationProvider.cs
│ ├── ILocalizationProvider.cs
│ ├── InheritingResxLocalizationProvider.cs
│ ├── ParentChangedNotifierHelper.cs
│ ├── ProviderEventArgs.cs
│ ├── ResxLocalizationProvider.cs
│ └── ResxLocalizationProviderBase.cs
├── Themes
│ └── Generic.xaml
├── TypeConverters
│ ├── BitmapSourceTypeConverter.cs
│ ├── DefaultConverter.cs
│ ├── RegisterMissingTypeConverters.cs
│ └── ThicknessConverter.cs
├── ValueConverters
│ ├── PrependTypeConverter.cs
│ ├── StringFormatConverter.cs
│ ├── ToLowerConverter.cs
│ ├── ToUpperConverter.cs
│ ├── TranslateConverter.cs
│ └── TypeValueConverterBase.cs
├── WPFLocalizeExtension.csproj
├── WPFLocalizeExtension.sln
├── XmlnsPrefix.cs
├── packages.lock.json
└── public.snk
└── tests
├── AssemblyTest
├── App.xaml
├── App.xaml.cs
├── AssemblyTest.csproj
├── CaseConverter.cs
├── CountryRes.Designer.cs
├── CountryRes.de.resx
├── CountryRes.resx
├── Example.csv
├── Example.de.csv
├── Item.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── MyViewModel.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resource.With.Dot.Designer.cs
├── Resource.With.Dot.de.resx
├── Resource.With.Dot.en.resx
├── Resource.With.Dot.resx
├── Resources
│ ├── Austria.png
│ ├── France.png
│ ├── Germany.png
│ ├── Test.bmp
│ ├── Test1.bmp
│ ├── Test11.bmp
│ ├── Test12.bmp
│ └── United_Kingdom.png
├── StringFormatProxy.cs
├── Strings.Designer.cs
├── Strings.de.resx
├── Strings.resx
├── Strings2.Designer.cs
├── Strings2.de.resx
├── Strings2.resx
├── TestDataClass.cs
├── TestEnum.cs
└── ViewModelBase.cs
├── AssemblyTestResourceLib
├── AssemblyTest.csproj
├── AssemblyTestResourceLib.csproj
├── Properties
│ └── AssemblyInfo.cs
├── Resources
│ ├── Test.bmp
│ ├── Test1.bmp
│ ├── Test11.bmp
│ └── Test12.bmp
├── Strings.Designer.cs
├── Strings.de.resx
├── Strings.resx
├── Strings2.Designer.cs
├── Strings2.de.resx
└── Strings2.resx
├── FluentLexTest
├── Application.xaml
├── Application.xaml.cs
├── Fluent.Sample.Foundation.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.de.resx
│ └── Resources.resx
├── Window.xaml
├── Window.xaml.cs
└── app.config
├── GapTextWpfTest
├── App.config
├── App.xaml
├── App.xaml.cs
├── Converters
│ └── ObjectTypeEqualsConverter.cs
├── GapTextWpfTest.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
└── packages.config
├── HelloWorldWPF.sln
├── HelloWorldWPF
├── App.xaml
├── App.xaml.cs
├── HelloWorldWPF.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ └── AssemblyInfo.cs
├── Ressourcen.Designer.cs
├── Ressourcen.ar.resx
├── Ressourcen.de.resx
├── Ressourcen.en.resx
├── Ressourcen.he.resx
├── Ressourcen.resx
└── TestVM.cs
├── LeakSample.sln
├── LeakSample
├── App.config
├── App.xaml
├── App.xaml.cs
├── LeakSample.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── MainWindowViewModel.cs
├── Properties
│ ├── Annotations.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── Resources
│ ├── Localization.Designer.cs
│ └── Localization.resx
├── LocalizationTest.sln
├── LocalizationTest
├── App.config
├── App.xaml
├── App.xaml.cs
├── Loader.xaml
├── Loader.xaml.cs
├── LocalizationTest.csproj
├── Popup.xaml
├── Popup.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── TestResource.Designer.cs
├── TestResource.en-GB.resx
├── TestResource.pl-PL.resx
└── TestResource.resx
├── MemoryTest.sln
├── MemoryTest
├── App.xaml
├── App.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── MemoryTest.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.de.resx
│ ├── Resources.en.resx
│ └── Resources.resx
├── TestWindow.xaml
├── TestWindow.xaml.cs
├── TestWindowUnlocalized.xaml
└── TestWindowUnlocalized.xaml.cs
├── ProviderExample
├── CSVLocalizationProvider.cs
├── ProviderExample.csproj
└── TestProvider.cs
├── ResourceAssembly
├── Properties
│ └── AssemblyInfo.cs
├── ResTexts.Designer.cs
├── ResTexts.resx
└── ResourceAssembly.csproj
├── SatelliteAssemblyTest.sln
├── SatelliteAssemblyTest
├── App.xaml
├── App.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ └── AssemblyInfo.cs
├── SatelliteAssemblyTest.csproj
├── TestRes.Designer.cs
├── TestRes.de.resx
├── TestRes.es.resx
├── TestRes.fr.resx
├── TestRes.resx
└── packages.config
├── Tests.sln
├── ThreadPerformance.sln
├── ThreadPerformance
├── App.config
├── App.xaml
├── App.xaml.cs
├── MainView.xaml
├── MainView.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Resources
│ ├── MainView.Designer.cs
│ ├── MainView.de.resx
│ └── MainView.resx
├── ThreadPerformance.csproj
└── packages.config
├── VbWpfApplication.sln
├── VbWpfApplication
├── Application.xaml
├── Application.xaml.vb
├── MainWindow.xaml
├── MainWindow.xaml.vb
├── My Project
│ ├── AssemblyInfo.vb
│ ├── MyExtensions
│ │ └── MyWpfExtension.vb
│ ├── Resources.Designer.vb
│ ├── Resources.resx
│ ├── Settings.Designer.vb
│ └── Settings.settings
├── Strings.Designer.vb
├── Strings.en-GB.Designer.vb
├── Strings.en-GB.resx
├── Strings.resx
├── Strings.sv-SE.Designer.vb
├── Strings.sv-SE.resx
├── VbWpfApplication.vbproj
└── packages.config
├── WPFLocalizeExtension.UnitTests
├── ValueConvertersTests
│ ├── LocExtensionTests.cs
│ └── StringFormatConverterTests.cs
└── WPFLocalizeExtension.UnitTests.csproj
└── XamlLocalizationTest.sln
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [konne, seriousm]
4 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Code snipet, or better a small code example that shows the issue
15 |
16 | **Expected behavior**
17 | A clear and concise description of what you expected to happen.
18 |
19 | **Screenshots**
20 | If applicable, add screenshots to help explain your problem.
21 |
22 | **Enviroment (please complete the following information):**
23 | - OS: [e.g. iOS]
24 | - .NET Framework: [e.g. NET452, netcore30]
25 |
26 | **Additional context**
27 | Add any other context about the problem here.
28 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: nuget
4 | directory: "/src"
5 | schedule:
6 | interval: daily
7 | time: "08:00"
8 | timezone: Europe/Berlin
9 | target-branch: development
10 |
11 | - package-ecosystem: "github-actions"
12 | directory: "/"
13 | schedule:
14 | # Check for updates to GitHub Actions every weekday
15 | interval: "daily"
16 |
--------------------------------------------------------------------------------
/.github/release-drafter.yml:
--------------------------------------------------------------------------------
1 | categories:
2 | - title: 'Features'
3 | labels:
4 | - 'feature'
5 | - 'enhancement'
6 | - title: 'Bug Fixes'
7 | labels:
8 | - 'fix'
9 | - 'bugfix'
10 | - 'bug'
11 | - title: 'Maintenance'
12 | labels:
13 | - 'chore'
14 | - 'dependencies'
15 | change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
16 | template: |
17 | ## Changes
18 |
19 | $CHANGES
20 |
--------------------------------------------------------------------------------
/.github/workflows/compile.yml:
--------------------------------------------------------------------------------
1 | name: .NET
2 |
3 | on:
4 | push:
5 | branches: [ master, development ]
6 | paths-ignore:
7 | - '*.md'
8 | - 'docs/**'
9 |
10 | pull_request:
11 | branches: [ master, development ]
12 | paths-ignore:
13 | - '*.md'
14 | - 'docs/**'
15 |
16 | workflow_dispatch:
17 | branches: [ master, development ]
18 | paths-ignore:
19 | - '*.md'
20 | - 'docs/**'
21 |
22 | jobs:
23 | build:
24 | runs-on: windows-latest
25 |
26 | steps:
27 | - name: checkout
28 | uses: actions/checkout@v4
29 | with:
30 | fetch-depth: 0
31 |
32 | - name: Fetch all history for all tags and branches
33 | run: |
34 | git fetch --prune
35 |
36 | - name: Setup MSBuild.exe
37 | uses: microsoft/setup-msbuild@v2
38 |
39 | - name: Cache Nuget
40 | uses: actions/cache@v4.0.2
41 | with:
42 | path: ~/.nuget/packages
43 | key: ${{ runner.os }}-nugetv1-${{ hashFiles('**/packages.lock.json') }}
44 | restore-keys: |
45 | ${{ runner.os }}-nugetv1-
46 |
47 | - name: Build
48 | working-directory: src
49 | run: |
50 | dotnet restore --disable-parallel
51 | # dotnet build --disable-parallel --configuration Release
52 | # can't use pure dotnet build because gitversion issues
53 | msbuild ${{ github.event.repository.name }}.csproj -verbosity:minimal /p:Configuration=Release /property:DisableGitVersionTask=true
54 |
55 | # add check for PR against master from development -> build preRelease to nuget
56 | # if merged into master -> build Release -> nuget
57 | # if: github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/tags/') && contains(github.ref,'-alpha'))
58 | #/property:NugetAPIKey=${{ secrets.NugetAPIKey }}
59 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish
2 |
3 | on:
4 | release:
5 | types: [ published ]
6 |
7 | jobs:
8 | build:
9 | runs-on: windows-latest
10 |
11 | steps:
12 | - name: checkout
13 | uses: actions/checkout@v4
14 |
15 | - name: Setup MSBuild.exe
16 | uses: microsoft/setup-msbuild@v2
17 |
18 | - name: Write Fullkey.snk
19 | uses: RollyPeres/base64-to-path@v1
20 | with:
21 | filePath: ${{ github.workspace }}/src/fullkey.snk
22 | encodedString: ${{ secrets.SIGNKEY }}
23 |
24 | - name: Create msbuild params
25 | run: |
26 | echo "::set-output name=params::${{ github.event.repository.name }}.csproj -verbosity:minimal /p:Configuration=Release /property:DisableGitVersionTask=true /property:GitVersion_NuGetVersion=${{ github.event.release.tag_name }} /property:Version=${{ github.event.release.tag_name }}"
27 | id: msbuild
28 |
29 | - name: add nuget API Key for releases
30 | if: "!github.event.release.prerelease"
31 | run: |
32 | echo "::set-output name=params::/property:NugetAPIKey=${{ secrets.NugetAPIKey }}"
33 | id: apikey
34 |
35 | - name: Restore
36 | working-directory: src
37 | run: |
38 | dotnet restore --disable-parallel
39 |
40 | - name: Restore & Build & (Publish)
41 | working-directory: src
42 | run: |
43 | msbuild ${{ steps.msbuild.outputs.params }} ${{ steps.apikey.outputs.params }}
44 | rm -R .\obj\Release
45 | msbuild ${{ steps.msbuild.outputs.params }} ${{ steps.apikey.outputs.params }} /property:UnSigned=true
46 |
47 | - name: Upload Release Assets
48 | uses: softprops/action-gh-release@v2
49 | with:
50 | files: src/bin/Release/*.nupkg
51 |
--------------------------------------------------------------------------------
/.github/workflows/release-drafter.yaml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 | paths:
7 | - 'src/**'
8 | - '.github/workflows/release-drafter.yml'
9 |
10 | jobs:
11 | release:
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | - name: checkout
16 | uses: actions/checkout@v4
17 | with:
18 | fetch-depth: 0
19 |
20 | - name: Fetch all history for all tags and branches
21 | run: |
22 | git fetch --prune
23 |
24 | - name: Install GitVersion
25 | uses: gittools/actions/gitversion/setup@v3.0.0
26 | with:
27 | versionSpec: '5.6.x'
28 |
29 | - name: Use GitVersion
30 | id: gitversion
31 | uses: gittools/actions/gitversion/execute@v3.0.0
32 |
33 | - name: create release
34 | id: create_release
35 | uses: release-drafter/release-drafter@v6
36 | with:
37 | tag: '${{ steps.gitversion.outputs.semVer }}'
38 | name: 'Release ${{ steps.gitversion.outputs.semVer }}'
39 | env:
40 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #ignore thumbnails created by windows
2 | Thumbs.db
3 | #Ignore files build by Visual Studio
4 | *.obj
5 | *.exe
6 | *.pdb
7 | *.user
8 | *.aps
9 | *.pch
10 | *.vspscc
11 | *_i.c
12 | *_p.c
13 | *.ncb
14 | *.suo
15 | *.tlb
16 | *.tlh
17 | *.bak
18 | *.cache
19 | *.ilk
20 | *.log
21 | [Bb]in
22 | [Dd]ebug*/
23 | *.lib
24 | *.sbr
25 | obj/
26 | [Rr]elease*/
27 | _ReSharper*/
28 | [Tt]est[Rr]esult*
29 | Sandbox
30 | *Sandbox*
31 | *.ncrunchsolution
32 | *.xap
33 | ClientBin/*
34 | *.zip
35 | *.pfx
36 | Example.xlsx
37 | packages/
38 | .vs/
39 | *.nupkg
40 |
41 | # Jetbrain Rider Cache
42 | .idea/
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Thanks for reporting an issue!
2 |
3 | Please keep in mind that this project is not actively developed and that @MrCircuit and I (@SeriousM) don't work full-time on it.
4 |
5 | If you have a clue how to resolve the issue please try to resolve it yourself and send us a Pull Request including unit tests.
6 |
7 | Open-Source means not only the "free" availability of source code, it also means that the users are free to contribute to it to make it better.
8 |
9 | Thank you for your help and understanding.
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Microsoft Public License (Ms-PL)
2 |
3 | This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
4 |
5 | 1. Definitions
6 |
7 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
8 |
9 | A "contribution" is the original software, or any additions or changes to the software.
10 |
11 | A "contributor" is any person that distributes its contribution under this license.
12 |
13 | "Licensed patents" are a contributor's patent claims that read directly on its contribution.
14 |
15 | 2. Grant of Rights
16 |
17 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
18 |
19 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
20 |
21 | 3. Conditions and Limitations
22 |
23 | (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
24 |
25 | (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
26 |
27 | (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
28 |
29 | (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
30 |
31 | (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
32 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WPFLocalizeExtension
2 | [](https://www.codefactor.io/repository/github/xamlmarkupextensions/WPFLocalizeExtension/overview/master)
3 | [](https://www.nuget.org/packages/WpfLocalizeExtension)
4 | 
5 | [](https://gitter.im/SeriousM/WPFLocalizationExtension?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
6 |
7 | #### ...is a really the easiest way to localize any type of DependencyProperties or native Properties on DependencyObjects since 2008!
8 |
9 | ## Supported Frameworks
10 |
11 | * .Net Framework 4.0+
12 | * .Net CORE 3.0+
13 |
14 | ## Installation
15 |
16 | [NuGet Package](https://nuget.org/packages/WpfLocalizeExtension/)
17 |
18 | ```net
19 | dotnet add package WPFLocalizationExtension
20 | ```
21 |
22 | ## Getting started
23 |
24 | Coming soon
25 |
26 | ## Documentation & Tutorial:
27 | [Documentation / Wiki](docs/README.md)
28 |
29 | ## Localization Tools:
30 | [ResXManager (Visual Studio Plugin and StandAlone)](http://visualstudiogallery.msdn.microsoft.com/3b64e04c-e8de-4b97-8358-06c73a97cc68)
31 | [Zeta Resource Editor (Freeware)](http://www.zeta-resource-editor.com/index.html)
32 |
33 | -----
34 |
35 | ## Products that use this Solution:
36 |
37 |  SAP Crystal Reports, Version for Visual Studio .NET
38 |
39 | ## License:
40 | [MS-PL](https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE)
41 |
--------------------------------------------------------------------------------
/docs/BLoc-and-FELoc.md:
--------------------------------------------------------------------------------
1 | # BLoc
2 |
3 | This Extensions is a
4 |
5 | # FELoc
--------------------------------------------------------------------------------
/docs/GapText.md:
--------------------------------------------------------------------------------
1 | # Gap Text
2 |
3 | Use a multibinding with the [StringFormatConverter](ValueConverters.md).
4 | The first **parameter** is the StringFormat
5 | All others are parameter.
6 | ```XML
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | ```
16 |
17 | integrate [SmartFormat](https://github.com/axuno/SmartFormat/wiki) so that we have even a possibility to have real i18n with pluralization,...
--------------------------------------------------------------------------------
/docs/Installation-and-dependencies.md:
--------------------------------------------------------------------------------
1 | ### Installation
2 |
3 | The library itself can be obtained by two ways:
4 |
5 | * If you just want to use it without the need of compiling it, use the NuGet package manager of your VisualStudio or download it directly from our [NuGet package](https://www.nuget.org/packages/WpfLocalizeExtension).
6 | * If you are interested in the project details, feel free to get your own copy of the source code from GitHub.
7 |
8 | By using NuGet you just have to choose the projects where you want to use the extension - the rest is done automatically by NuGet as usual.
9 |
10 | ### Dependencies
11 |
12 | Starting with version 1.0.3, the project depends on the project [XAML Markup Extensions](https://github.com/XAMLMarkupExtensions/XAMLMarkupExtensions). NuGet will automatically ask you to download this package along with the LocalizationExtension.
13 |
--------------------------------------------------------------------------------
/docs/Keys.md:
--------------------------------------------------------------------------------
1 | Keys are entered either directly after the extension name or using the Key property of the LocExtension class. Both will yield the same result (here with the key named Test):
2 | ```xaml
3 |
4 |
5 | ```
6 | ### Automatic key retrieval
7 | If the control already got or can get a value for its _Name_ or _x:Name_ property, the key may be neglected, provided, that a key exists that matches one of the following criteria (checked in exactly this order):
8 |
9 | * _ControlName_PropertyName_
10 | * _ControlName_
11 |
12 | Using our button example we could imagine the following scenario:
13 | ```xaml
14 |
15 | ```
16 | As no key was provided, the extension will first try to resolve a resource key named _MyButton_Content_. If this fails, it will then look for a resource key named _MyButton_. If this fails too, no value will be provided.
17 |
18 | The separation character (default is underscore) can be individually set up for each control using the _LocalizeDictionary.Separation_ property.
19 |
--------------------------------------------------------------------------------
/docs/LocProxy-&-EnumComboBox.md:
--------------------------------------------------------------------------------
1 | Beginning with v2.1.3 the extension also features an Enum value localization technique. To achieve this one has to employ the new **LocProxy** class. Just pass the particular enum value to the **Source** property and check the right setting of the **PrependType** flag. If this is used, you may also specify a **Separator** that will be used between the type suffix and the value itself leading to key entries like this "MyEnum_MyValue" using underscore as the separator. This allows us to create unique localization keys for different enum types and their values. To get the localized value, just bind your text element to the **Result** property of the **LocProxy**:
2 | ```xaml
3 |
4 |
5 | ```
6 | In general, this proxy class triggers the _ToString_ function of the object that is bound to the **Source** property. It is therefore also applicable to all other kinds of objects where you need value localization.
7 |
8 | To enhance this feature, also an **EnumComboBox** class was introduced with v2.1.3. Just feed your enum type to the **Type** property of this class and it does the rest for you, provided, that you correctly style the entries, e.g. using the XAML code snippet from above. You may also hide particular enum values using the **BrowsableAttribute**. A complete example is included in the _AssemblyTest_ example located in the source code of the library.
--------------------------------------------------------------------------------
/docs/Localization-providers.md:
--------------------------------------------------------------------------------
1 | The project was restructured to separate the target identification and value conversion in the markup extension from the logic that actually provides the value by introducing the ILocalizationProvider interface. This enables us to plug in other provider services without touching the base, the LocExtension.
2 |
3 | 
4 |
5 | ### Changing the provider
6 | The provider can be changed using the **LocalizeDictionary.Provider** attached property at any node in the XAML document. Depending on the provider, a static singleton reference (e.g. resx provider) or an instance (e.g. csv provider) must be assigned to this property.
7 |
8 | The default provider is set to the ResxLocalizationProvider. If you need another application wide default provider, just overwrite the static backed-up attached property **LocalizeDictionary.DefaultProvider**.
9 |
10 | ### Provider features
11 | Besides its localized look up functionality, providers can give you a list of available cultures. This observable collection can be read out or bound - whatever you need or prefer. The list is additionally observed by the LocalizeDictionary instance providing a merged bindable list of all available cultures.
12 |
13 | Furthermore, providers fire events, when critical values in the provider changed (triggering an update of the LocExtension) or when an error occured.
14 |
15 | ### Implementing custom providers
16 | To implement your own provider, create a class that implements the ILocalizationProvider interface. There is no restriction concerning its base class.
17 | ```c#
18 | public interface ILocalizationProvider
19 | {
20 | ///
21 | /// Get the localized object.
22 | ///
23 | /// The key to the value.
24 | /// The target .
25 | /// The culture to use.
26 | /// The value corresponding to the key and culture.
27 | object GetLocalizedObject(string key, DependencyObject target, CultureInfo culture);
28 |
29 | ///
30 | /// An observable list of available cultures.
31 | ///
32 | ObservableCollection AvailableCultures { get; }
33 |
34 | ///
35 | /// An event when the provider changed.
36 | ///
37 | event ProviderChangedEventHandler ProviderChanged;
38 |
39 | ///
40 | /// An event when an error occurred.
41 | ///
42 | event ProviderErrorEventHandler ProviderError;
43 | }
44 | ```
45 | You can then assign your own provider to the properties of LocalizeDictionary.
--------------------------------------------------------------------------------
/docs/Localization.md:
--------------------------------------------------------------------------------
1 | Localization is the task to adapt values such as strings, colors or the text flow direction to the specific language and culture of the user. To fulfill this task, two major prerequisites are needed:
2 |
3 | * The designer has to decide **where** to apply a localized value. This means he needs a tool to mark the spot and to refer to a certain key in the translation dictionary. Note: Not all values have to be localized (e.g. usually the width of a control is calculated from the content size in an auto-layout application).
4 | * The designer and/or a translation agency has to fill out a cross-table containing all the keys mentioned above and values for each culture that should be supported by the application.
5 |
6 | This project offers the tool to easily define which value has to be localized to the developer - already in design time. It even tries to find the right key if none is given thus speeding up localized XAML coding while still providing a good code readability.
7 |
--------------------------------------------------------------------------------
/docs/Logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/docs/Logo.png
--------------------------------------------------------------------------------
/docs/MarkupExtension-basics.md:
--------------------------------------------------------------------------------
1 | The project is based on the MarkupExtension class of the .NET framework. All classes that derive from this class are asked by the framework to deliver a value to the target object and property.
2 |
3 | The LocalizationExtension uses this feature in order to provide the culture-specific values to localized properties. The general syntax of markup extensions that is applied to a particular _Property_ of a certain _Element_ is as follows:
4 | ```xaml
5 |
6 | ```
7 | The _ExtensionName_ has to be replaced by the class name of the extension without its ending "Extension". Usually, the XAML editor will propose the possible extensions to you. After the name, several properties of the extension itself can be initialized. It is obvious that this mechanism gives us the possibility to easily mark the localized property and give necessary information to look up its resource key.
8 |
--------------------------------------------------------------------------------
/docs/Multiple-assemblies-and-dictionaries.md:
--------------------------------------------------------------------------------
1 | In the previous sections we presumed that a default assembly and dictionary indicating the location of the resource file is set up in the XAML document root. There may be situations, where more than one assembly and/or dictionary is used for a single XAML code file. This scenario is fully supported by the LocExtension and **ResxLocalizationProvider**.
2 |
3 | ### Switching assemblies and dictionaries
4 | You may change the values of **ResxLocalizationProvider.DefaultAssembly** and **ResxLocalizationProvider.DefaultDictionary** on arbitrary locations throughout the VisualTree of your XAML code - where and as often you need it. The various LocExtension instances will automatically resolve the corresponding values. This implies, that you may also change both values dynamically during runtime. Refer to the test application AssemblyTest in the source code of the library.
5 |
6 | ### Directly provided assembly and/or dictionary
7 | You may also define the assembly or dictionary that will be used at each instance of LocExtension by using their properties _Assembly_ or _Dict_ respectively. Alternatively, you may use the constructor syntax already described for the keys. The following three buttons will have the same text:
8 | ```xaml
9 |
10 | // If you need different Assembly or Dic you should use the attached properties of ResxLocalizationProvider
11 |
12 |
13 | ```
14 | ### Assembly name differing from the default namespace
15 | This scenario is supported by the ResxLocalizationProvider. In case you have several resource files in a single assembly with the same name but in different namespaces, you have to provide a qualified name of your dictionary.
16 |
--------------------------------------------------------------------------------
/docs/Our-first-localized-text.md:
--------------------------------------------------------------------------------
1 | With the window or control control properly prepared in the previous section, we can now create our first localized text. Create a key named Test in your resource file(s) and give some distinct values to it (e.g. "Hello World" for culture "en" and "Hallo Welt" for culture "de").
2 | Now, create a button with our extension set to the Content property:
3 | ```xaml
4 |
5 | ```
6 | Note, that Test was our key in the resource file. That's it - you're done!
7 |
8 | ### Target types
9 | The LocExtension automatically retrieves the type of the target property and tries to find a _TypeConverter_ for this type. By additionally supplying a converter for _Bitmap_ (from resource files) to _BitmapSource_ (WPF) all normal cases should be covered. If you encounter an unsupported conversion, feel free to write a working converter code and make a pull request to our GIT repository. You may also provide a custom IValueConverter (Converter) along with a converter parameter in the LocExtension.
10 | Enum types are supported in general and do not need any specific converter.
11 |
--------------------------------------------------------------------------------
/docs/Preparing-the-XAML-code.md:
--------------------------------------------------------------------------------
1 | You have to initialize the localization engine in order to get values at design-time and to set up default dictionaries and assemblies (refer to [Multiple assemblies and dictionaries](Multiple-assemblies-and-dictionaries.md)).
2 |
3 | First of all, create a _xmlns_ reference to "http://wpflocalizeextension.codeplex.com". The next step is to set the design time culture as well as default assembly and dictionary where the resource is located:
4 | ```xaml
5 |
9 |
10 |
11 | ```
12 | The value of DesignCulture can be changed dynamically during design time and will have an immediate effect on all localized properties. This gives you the possibility to check the correct localization directly in the WPF designer. This example configures the resx provider. For a full explanation on this provider, refer to [Localization providers](Localization-providers.md).
13 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 | * [Localization](Localization.md)
3 | * [MarkupExtension basics](MarkupExtension-basics.md)
4 | * [Supported platforms](Supported-platforms.md)
5 | * [**Change log**](https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/releases)
6 |
7 | ### Usage
8 | * [Installation and dependencies](Installation-and-dependencies.md)
9 | * [Resource files](Resource-files.md)
10 | * [Preparing the XAML code](Preparing-the-XAML-code.md)
11 | * [Localize XAML](Localize.md)
12 | * [Keys](Keys.md)
13 | * [Multiple assemblies and dictionaries](Multiple-assemblies-and-dictionaries.md)
14 | * [Localization providers](Localization-providers.md)
15 | * DEPRECATED [LocProxy & EnumComboBox](LocProxy-&-EnumComboBox.md)
16 |
17 | ### [Common mistakes & FAQ](FAQ.md)
--------------------------------------------------------------------------------
/docs/Resource-files.md:
--------------------------------------------------------------------------------
1 | ### General instructions
2 |
3 | As explained in the section [Supported platforms](Supported-platform.md), the LocalizationExtension supports **resx** files for the storage of localized values. Create such a resource file with a suitable name and check its access modifier, if needed (refer to [Common mistakes - Access modifier for resource assemblies](FAQ.md#access-modifier-for-resource-assemblies)). Now, create further resource files for each culture your application will support and give them the same name as the first one - just add the general or specific culture code (e.g. "en-US", "de", "de-AT", ...) before the ".resx" ending yielding: _Name.CultureCode_.resx. Don't forget the dot before the culture code.
4 |
5 | Now, populate the resource files with your key/value pairs. Be sure to have the same name of a particular key for all cultures. You may use the automatic key retrieval mechanism (refer to [Keys](Keys.md)).
6 |
7 | ### Pay attention to:
8 | * The correct naming scheme of culture-specific resource files
9 | * The _Custom Tool_ property of the main resource file (ResXFileCodeGenerator), the others leave this field empty
10 | * The _Build_ Action property of all resource files (Embedded Resource)
11 | * The access modifier, if needed
12 | * Consistent key naming
13 | * **Rebuild** the project where the resource is located after adding new keys and values in order to see it in design time.
14 |
15 | ### How to get a treeview of culture-specific resources
16 | 1. Unload the project
17 | 1. Edit the corresponding **csproj** file
18 | 1. Locate the tags of the resources and rewrite them using the _DependentUpon_ syntax:
19 | ```xml
20 |
21 | Designer
22 | Strings.resx
23 |
24 |
25 | ResXFileCodeGenerator
26 | Strings.Designer.cs
27 |
28 | ```
--------------------------------------------------------------------------------
/docs/SAPLogo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/docs/SAPLogo.gif
--------------------------------------------------------------------------------
/docs/Structure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/docs/Structure.png
--------------------------------------------------------------------------------
/docs/Supported-platforms.md:
--------------------------------------------------------------------------------
1 | The LocalizationExtension is designed for and tested under the following frameworks:
2 |
3 | * WPF with .NET 4.0+
4 |
5 | The project comes along with the ability to plugin any custom localization provider that implements the _ILocalizationProvider_ interface. The support of resx of previous versions was transferred to such a provider that also serves as the default provider (can be changed, see [Localization providers](Localization-providers.md)). The resx files can be distributed over several assemblies in the project. As an example, another custom provider for CSV files was implemented.
6 |
--------------------------------------------------------------------------------
/docs/ValueConverters.md:
--------------------------------------------------------------------------------
1 | # Value Converters
2 |
3 | The library delivers some very usefull ValueConverts. All Valueconverters can be used with the standard syntax and the definition as resource, but the also implement a MarkupExtension declaration so that you can write as an example for the TranslateConverter:
4 |
5 | ```xaml
6 |
7 | ```
8 |
9 | ## TranslateConverter
10 |
11 | This converters allows to make the translation process as a converter. The input of the converter is the key for the lookup and the result the translated result.
12 |
13 | ## PrependTypeConverter
14 |
15 | This converter is especially for translation of enums. If you bind to an enum, only the
16 | the Enum Value is used as key for the resource lookup. A commonn approach in the resx
17 | file is to write like:
18 | MyEnum_Value1 -> Translation for Value1
19 | MyEnum_Value2 -> Translation for Value2
20 |
21 | For a more elegant use this converter automatically prepend the Type of the parameter
22 | to the key.
23 |
24 | ## StringFormatConverter
25 |
26 | This converter solves the issue that Binding unfortunately don't support changing of the StringFormat after the firts usage of the Binding.
27 | The StringFormatConverter expects as the first value the StringFormat and all further Values are given the StringFormat as paramter.
28 | If [smartFormat](https://github.com/axuno/SmartFormat) is available it will be automatically used for the StringFormat for extended possibilities especially pluralisation.
29 |
30 | ## ToLower & ToUpperConverter
31 |
32 | This converter just make an ToLower or ToUpper to the value. If you used the deprecated LocTextUpperExtension & LocTextLowerExtension this
33 | this is the Converter to have the same effect.
--------------------------------------------------------------------------------
/src/Deprecated/Engine/LocBinding.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Uwe Mayer
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.Deprecated.Engine
10 | {
11 | #region Usings
12 | using System;
13 | using System.Windows;
14 | using System.Windows.Data;
15 | using WPFLocalizeExtension.Extensions;
16 | #endregion
17 |
18 | ///
19 | /// A binding proxy class that accepts bindings and forwards them to the LocExtension.
20 | /// Based on: http://www.codeproject.com/Articles/71348/Binding-on-a-Property-which-is-not-a-DependencyPro
21 | ///
22 | [Obsolete("LocBinding is deprecated and will be removed in version 4.0, because lex:Loc supports now direct Binding, see documentation", false)]
23 | public class LocBinding : FrameworkElement
24 | {
25 | #region Source DP
26 | ///
27 | /// We don't know what will be the Source/target type so we keep 'object'.
28 | ///
29 | public static readonly DependencyProperty SourceProperty =
30 | DependencyProperty.Register("Source", typeof(object), typeof(LocBinding),
31 | new FrameworkPropertyMetadata(OnPropertyChanged)
32 | {
33 | BindsTwoWayByDefault = true,
34 | DefaultUpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
35 | });
36 |
37 | ///
38 | /// The source.
39 | ///
40 | public object Source
41 | {
42 | get => GetValue(SourceProperty);
43 | set => SetValue(SourceProperty, value);
44 | }
45 | #endregion
46 |
47 | #region Target LocExtension
48 | private LocExtension _target;
49 | ///
50 | /// The target extension.
51 | ///
52 | public LocExtension Target
53 | {
54 | get => _target;
55 | set
56 | {
57 | _target = value;
58 | if (_target != null && Source != null)
59 | _target.Key = Source.ToString();
60 | }
61 | }
62 | #endregion
63 |
64 | #region OnPropertyChanged
65 | private static void OnPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
66 | {
67 | if (obj is LocBinding locBinding && args.Property == SourceProperty)
68 | {
69 | if (!ReferenceEquals(locBinding.Source, locBinding._target) && locBinding._target != null && locBinding.Source != null)
70 | locBinding._target.Key = locBinding.Source.ToString();
71 | }
72 | }
73 | #endregion
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/Engine/FallbackBehavior.cs:
--------------------------------------------------------------------------------
1 | namespace WPFLocalizeExtension.Engine
2 | {
3 | ///
4 | /// Behavior when key is not found at the localization provider.
5 | ///
6 | public enum FallbackBehavior
7 | {
8 | ///
9 | /// Display "Key: {key}" string.
10 | ///
11 | Default,
12 |
13 | ///
14 | /// Display key string itself.
15 | ///
16 | Key,
17 |
18 | ///
19 | /// Display an empty string.
20 | ///
21 | EmptyString
22 | }
23 | }
--------------------------------------------------------------------------------
/src/Engine/IDictionaryEventListener.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Uwe Mayer
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.Engine
10 | {
11 | #region Usings
12 | using System;
13 | using System.Windows;
14 | #endregion
15 |
16 | ///
17 | /// Interface for listeners on dictionary events of the class.
18 | ///
19 | public interface IDictionaryEventListener
20 | {
21 | ///
22 | /// This method is called when the resource somehow changed.
23 | ///
24 | /// The sender.
25 | /// The event arguments.
26 | void ResourceChanged(DependencyObject sender, DictionaryEventArgs e);
27 | }
28 |
29 | ///
30 | /// An enumeration of dictionary event types.
31 | ///
32 | public enum DictionaryEventType
33 | {
34 | ///
35 | /// The separation changed.
36 | ///
37 | SeparationChanged,
38 | ///
39 | /// The provider changed.
40 | ///
41 | ProviderChanged,
42 | ///
43 | /// A provider reports an update.
44 | ///
45 | ProviderUpdated,
46 | ///
47 | /// The culture changed.
48 | ///
49 | CultureChanged,
50 | ///
51 | /// A certain value changed.
52 | ///
53 | ValueChanged,
54 | }
55 |
56 | ///
57 | /// Event argument for dictionary events.
58 | ///
59 | public class DictionaryEventArgs : EventArgs
60 | {
61 | ///
62 | /// The type of the event.
63 | ///
64 | public DictionaryEventType Type { get; }
65 |
66 | ///
67 | /// A corresponding tag.
68 | ///
69 | public object Tag { get; }
70 |
71 | ///
72 | /// The constructor.
73 | ///
74 | /// The type of the event.
75 | /// The corresponding tag.
76 | public DictionaryEventArgs(DictionaryEventType type, object tag)
77 | {
78 | Type = type;
79 | Tag = tag;
80 | }
81 |
82 | ///
83 | /// Returns the type and tag as a string.
84 | ///
85 | /// The type and tag as a string.
86 | public override string ToString()
87 | {
88 | return Type + ": " + Tag;
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/Engine/MissingKeyEventArgs.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Uwe Mayer
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.Engine
10 | {
11 | #region Usings
12 | using System;
13 | #endregion
14 |
15 | ///
16 | /// Event arguments for a missing key event.
17 | ///
18 | public class MissingKeyEventArgs : EventArgs
19 | {
20 | ///
21 | /// The key that is missing or has no data.
22 | ///
23 | public string Key { get; }
24 |
25 | ///
26 | /// A flag indicating that a reload should be performed.
27 | ///
28 | public bool Reload { get; set; }
29 |
30 | ///
31 | /// A custom returnmessage for the missing key
32 | ///
33 | public string MissingKeyResult { get; set; }
34 |
35 | ///
36 | /// Creates a new instance of .
37 | ///
38 | /// The missing key.
39 | public MissingKeyEventArgs(string key)
40 | {
41 | Key = key;
42 | Reload = false;
43 | MissingKeyResult = null;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Engine/ParentNotifiers.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Bernhard Millauer
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.Engine
10 | {
11 | #region Usings
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Windows;
16 | using XAMLMarkupExtensions.Base;
17 | #endregion
18 |
19 | ///
20 | /// A memory safe dictionary storage for instances.
21 | ///
22 | public class ParentNotifiers
23 | {
24 | readonly Dictionary, ParentChangedNotifier> _inner =
25 | new Dictionary, ParentChangedNotifier>();
26 |
27 | ///
28 | /// Check, if it contains the key.
29 | ///
30 | /// The target object.
31 | /// True, if the key exists.
32 | public bool ContainsKey(DependencyObject target)
33 | {
34 | return _inner.Keys.Any(x => x.TryGetTarget(out var item) && ReferenceEquals(item, target));
35 | }
36 |
37 | ///
38 | /// Removes the entry.
39 | ///
40 | /// The target object.
41 | public void Remove(DependencyObject target)
42 | {
43 | if (_inner.Count == 0)
44 | return;
45 |
46 | var deadItems = new List, ParentChangedNotifier>>();
47 |
48 | foreach (var item in _inner)
49 | {
50 | // If we can't get target (== target is dead) or this is the item which we have to remove - add it to the collection for removing.
51 | if (!item.Key.TryGetTarget(out var itemTarget) || ReferenceEquals(itemTarget, target))
52 | {
53 | deadItems.Add(item);
54 | }
55 | }
56 |
57 | foreach (var deadItem in deadItems)
58 | {
59 | deadItem.Value?.Dispose();
60 | _inner.Remove(deadItem.Key);
61 | }
62 | }
63 |
64 | ///
65 | /// Adds the key-value-pair.
66 | ///
67 | /// The target key object.
68 | /// The notifier.
69 | public void Add(DependencyObject target, ParentChangedNotifier parentChangedNotifier)
70 | {
71 | _inner.Add(new WeakReference(target), parentChangedNotifier);
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/src/Engine/SafeTargetInfo.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Uwe Mayer
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.Engine
10 | {
11 | #region Usings
12 | using System;
13 | using XAMLMarkupExtensions.Base;
14 | #endregion
15 |
16 | ///
17 | /// An extension to the class with WeakReference instead of direct object linking.
18 | ///
19 | public class SafeTargetInfo : TargetInfo
20 | {
21 | ///
22 | /// Gets the target object reference.
23 | ///
24 | public WeakReference TargetObjectReference { get; }
25 |
26 | ///
27 | /// Creates a new TargetInfo instance.
28 | ///
29 | /// The target object.
30 | /// The target property.
31 | /// The target property type.
32 | /// The target property index.
33 | public SafeTargetInfo(object targetObject, object targetProperty, Type targetPropertyType, int targetPropertyIndex)
34 | : base(null, targetProperty, targetPropertyType, targetPropertyIndex)
35 | {
36 | TargetObjectReference = new WeakReference(targetObject);
37 | }
38 |
39 | ///
40 | /// Creates a new based on a template.
41 | ///
42 | /// The target information.
43 | /// A new instance with safe references.
44 | public static SafeTargetInfo FromTargetInfo(TargetInfo targetInfo)
45 | {
46 | return new SafeTargetInfo(targetInfo.TargetObject, targetInfo.TargetProperty, targetInfo.TargetPropertyType, targetInfo.TargetPropertyIndex);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Engine/WeakReference.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Bernhard Millauer
7 | #endregion
8 |
9 | #if NET35 || NET40
10 | namespace WPFLocalizeExtension.Engine
11 | {
12 | #region Usings
13 | using System;
14 | using System.Runtime.Serialization;
15 | #endregion
16 |
17 | ///
18 | /// This class implements an wrapper for .NET35, because this is starting from NET45 of .
19 | ///
20 | /// The reference type.
21 | public class WeakReference : WeakReference
22 | {
23 | ///
24 | /// Creates a new instance.
25 | ///
26 | /// The target.
27 | public WeakReference(T target) : base(target)
28 | {
29 | }
30 |
31 | ///
32 | /// Creates a new instance.
33 | ///
34 | /// The target.
35 | /// The track resurrection flag.
36 | public WeakReference(T target, bool trackResurrection)
37 | : base(target, trackResurrection)
38 | {
39 | }
40 |
41 | ///
42 | /// Creates a new instance.
43 | ///
44 | /// The serialization info.
45 | /// The streaming context.
46 | protected WeakReference(SerializationInfo info, StreamingContext context)
47 | : base(info, context)
48 | {
49 | }
50 |
51 | ///
52 | /// Tries to retrieve the target object that is referenced by the current WeakReference<T> object.
53 | ///
54 | /// The target.
55 | /// true if the target was retrieved; otherwise, false.
56 | public bool TryGetTarget(out T target)
57 | {
58 | var baseTarget = base.Target;
59 | if (baseTarget != null)
60 | {
61 | target = (T)baseTarget;
62 | return true;
63 | }
64 | target = default;
65 | return false;
66 | }
67 |
68 | // /
69 | // / Gets or sets the target.
70 | // /
71 | //public new T Target
72 | //{
73 | // get
74 | // {
75 | // var baseTarget = base.Target;
76 | // if (IsAlive && baseTarget != null)
77 | // {
78 | // return (T)base.Target;
79 | // }
80 | // return default(T);
81 | // }
82 | // set { base.Target = value; }
83 | //}
84 | }
85 | }
86 | #endif
87 |
--------------------------------------------------------------------------------
/src/Providers/FQAssemblyDictionaryKey.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Justin Pihony
7 | // Uwe Mayer
8 | #endregion
9 |
10 | namespace WPFLocalizeExtension.Providers
11 | {
12 | #region Usings
13 | using System.Linq;
14 | #endregion
15 |
16 | ///
17 | /// A class that bundles the key, assembly and dictionary information.
18 | ///
19 | public class FQAssemblyDictionaryKey : FullyQualifiedResourceKeyBase
20 | {
21 | private readonly string _key;
22 | ///
23 | /// The key.
24 | ///
25 | public string Key => _key;
26 |
27 | private readonly string _assembly;
28 | ///
29 | /// The assembly of the dictionary.
30 | ///
31 | public string Assembly => _assembly;
32 |
33 | private readonly string _dictionary;
34 | ///
35 | /// The resource dictionary.
36 | ///
37 | public string Dictionary => _dictionary;
38 |
39 | ///
40 | /// Creates a new instance of .
41 | ///
42 | /// The key.
43 | /// The assembly of the dictionary.
44 | /// The resource dictionary.
45 | public FQAssemblyDictionaryKey(string key, string assembly = null, string dictionary = null)
46 | {
47 | _key = key;
48 | _assembly = assembly;
49 | _dictionary = dictionary;
50 | }
51 |
52 | ///
53 | /// Converts the object to a string.
54 | ///
55 | /// The joined version of the assembly, dictionary and key.
56 | public
57 | override string ToString()
58 | {
59 | return string.Join(":", new[] { Assembly, Dictionary, Key }.Where(x => !string.IsNullOrEmpty(x)).ToArray());
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/Providers/FullyQualifiedResourceKeyBase.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Justin Pihony
7 | // Uwe Mayer
8 | #endregion
9 |
10 | namespace WPFLocalizeExtension.Providers
11 | {
12 | ///
13 | /// An abstract class for key identification.
14 | ///
15 | public abstract class FullyQualifiedResourceKeyBase
16 | {
17 | ///
18 | /// Implicit string operator.
19 | ///
20 | /// The object.
21 | /// The joined version of the assembly, dictionary and key.
22 | public static implicit operator string(FullyQualifiedResourceKeyBase fullyQualifiedResourceKey)
23 | {
24 | return fullyQualifiedResourceKey?.ToString();
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Providers/IInheritingLocalizationProvider.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Uwe Mayer
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.Providers
10 | {
11 | #region Usings
12 | using System.Collections.ObjectModel;
13 | using System.Globalization;
14 | using System.Windows;
15 | #endregion
16 |
17 | ///
18 | /// An interface describing classes that provide localized values based on a source/dictionary/key combination.
19 | /// and used for a localization provider that uses Inheriting Dependency Properties
20 | ///
21 | public interface IInheritingLocalizationProvider: ILocalizationProvider
22 | {
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Providers/ILocalizationProvider.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Uwe Mayer
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.Providers
10 | {
11 | #region Usings
12 | using System.Collections.ObjectModel;
13 | using System.Globalization;
14 | using System.Windows;
15 | #endregion
16 |
17 | ///
18 | /// An interface describing classes that provide localized values based on a source/dictionary/key combination.
19 | ///
20 | public interface ILocalizationProvider
21 | {
22 | ///
23 | /// Uses the key and target to build a fully qualified resource key (Assembly, Dictionary, Key)
24 | ///
25 | /// Key used as a base to find the full key
26 | /// Target used to help determine key information
27 | /// Returns an object with all possible pieces of the given key (Assembly, Dictionary, Key)
28 | FullyQualifiedResourceKeyBase GetFullyQualifiedResourceKey(string key, DependencyObject target);
29 |
30 | ///
31 | /// Get the localized object.
32 | ///
33 | /// The key to the value.
34 | /// The target .
35 | /// The culture to use.
36 | /// The value corresponding to the source/dictionary/key path for the given culture (otherwise NULL).
37 | object GetLocalizedObject(string key, DependencyObject target, CultureInfo culture);
38 |
39 | ///
40 | /// An observable list of available cultures.
41 | ///
42 | ObservableCollection AvailableCultures { get; }
43 |
44 | ///
45 | /// An event that is fired when the provider changed.
46 | ///
47 | event ProviderChangedEventHandler ProviderChanged;
48 |
49 | ///
50 | /// An event that is fired when an error occurred.
51 | ///
52 | event ProviderErrorEventHandler ProviderError;
53 |
54 | ///
55 | /// An event that is fired when a value changed.
56 | ///
57 | event ValueChangedEventHandler ValueChanged;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/Themes/Generic.xaml:
--------------------------------------------------------------------------------
1 |
5 |
19 |
20 |
--------------------------------------------------------------------------------
/src/TypeConverters/RegisterMissingTypeConverters.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Uwe Mayer
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.TypeConverters
10 | {
11 | #region Usings
12 | using System.ComponentModel;
13 | using System.Windows.Media.Imaging;
14 | #endregion
15 |
16 | ///
17 | /// Register missing type converters here.
18 | ///
19 | public static class RegisterMissingTypeConverters
20 | {
21 | ///
22 | /// A flag indication if the registration was successful.
23 | ///
24 | private static bool _registered;
25 |
26 | ///
27 | /// Registers the missing type converters.
28 | ///
29 | public static void Register()
30 | {
31 | if (_registered)
32 | return;
33 |
34 | TypeDescriptor.AddAttributes(typeof(BitmapSource), new TypeConverterAttribute(typeof(BitmapSourceTypeConverter)));
35 |
36 | _registered = true;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/TypeConverters/ThicknessConverter.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Uwe Mayer
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.TypeConverters
10 | {
11 | #region Usings
12 | using System.ComponentModel;
13 | using System.Globalization;
14 | using System.Windows;
15 | #endregion
16 |
17 | ///
18 | /// A converter for the type .
19 | ///
20 | public class ThicknessConverter : TypeConverter
21 | {
22 | ///
23 | public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType)
24 | {
25 | return sourceType == typeof(string);
26 | }
27 |
28 | ///
29 | public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
30 | {
31 | var result = new Thickness();
32 | double d1, d2, d3, d4;
33 |
34 | if (value is string s)
35 | {
36 | var parts = s.Split(",".ToCharArray());
37 |
38 | switch (parts.Length)
39 | {
40 | case 1:
41 | double.TryParse(parts[0], NumberStyles.Any, culture, out d1);
42 | result = new Thickness(d1);
43 | break;
44 |
45 | case 2:
46 | double.TryParse(parts[0], NumberStyles.Any, culture, out d1);
47 | double.TryParse(parts[1], NumberStyles.Any, culture, out d2);
48 | result = new Thickness(d1, d2, d1, d2);
49 | break;
50 |
51 | case 4:
52 | double.TryParse(parts[0], NumberStyles.Any, culture, out d1);
53 | double.TryParse(parts[1], NumberStyles.Any, culture, out d2);
54 | double.TryParse(parts[2], NumberStyles.Any, culture, out d3);
55 | double.TryParse(parts[3], NumberStyles.Any, culture, out d4);
56 | result = new Thickness(d1, d2, d3, d4);
57 | break;
58 | }
59 | }
60 |
61 | return result;
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/src/ValueConverters/PrependTypeConverter.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Konrad Mattheis
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.ValueConverters
10 | {
11 | #region Usings
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Globalization;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Threading.Tasks;
18 | using System.Windows.Data;
19 | using System.Windows.Markup;
20 | #endregion
21 |
22 | ///
23 | /// PrependTypeConverter allows to prepend the type of the value as string with the default _ separator. To change the default separator just us the converterparamater
24 | ///
25 | public class PrependTypeConverter : TypeValueConverterBase, IValueConverter
26 | {
27 | #region IValueConverter
28 | ///
29 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
30 | {
31 | if (value != null)
32 | {
33 | var separator = "_";
34 | if (parameter != null && parameter.GetType() == typeof(string))
35 | separator = parameter.ToString();
36 | return value.GetType().Name + separator + value.ToString();
37 | }
38 |
39 | return null;
40 | }
41 |
42 | ///
43 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
44 | {
45 | throw new NotImplementedException();
46 | }
47 | #endregion
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/ValueConverters/StringFormatConverter.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Konrad Mattheis
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.ValueConverters
10 | {
11 | #region Usings
12 | using System;
13 | using System.Globalization;
14 | using System.Reflection;
15 | using System.Windows;
16 | using System.Windows.Data;
17 | using System.Linq;
18 | #endregion
19 |
20 | ///
21 | /// Takes the first value as StringFormat and the other values as Parameter for the StringFormat
22 | ///
23 | public class StringFormatConverter : TypeValueConverterBase, IMultiValueConverter
24 | {
25 | private static MethodInfo miFormat = null;
26 |
27 | #region IMultiValueConverter
28 | ///
29 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
30 | {
31 | if (miFormat == null)
32 | {
33 | try
34 | {
35 | // try to load SmartFormat Assembly
36 | var asSmartFormat = Assembly.Load("SmartFormat");
37 | var tt = asSmartFormat.GetType("SmartFormat.Smart");
38 | miFormat = tt.GetMethod("Format", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(string), typeof(object[]) }, null);
39 | }
40 | catch
41 | {
42 | // fallback just take String.Format
43 | miFormat = typeof(string).GetMethod("Format", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(string), typeof(object[]) }, null);
44 | }
45 | }
46 |
47 | if (!targetType.IsAssignableFrom(typeof(string)))
48 | throw new Exception("TargetType is not supported strings");
49 |
50 | if (values == null || values.Length < 1)
51 | throw new Exception("Not enough parameters");
52 |
53 | if (values[0] == null)
54 | return null;
55 |
56 | if (values.Length > 1 && values[1] == DependencyProperty.UnsetValue)
57 | return null;
58 |
59 | var format = values[0].ToString();
60 | if (values.Length == 1)
61 | return format;
62 |
63 | var args = values.Skip(1).ToArray();
64 | return (string)miFormat.Invoke(null, new object[] { format, args });
65 | }
66 |
67 | ///
68 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
69 | {
70 | return null;
71 | }
72 | #endregion
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/ValueConverters/ToLowerConverter.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Konrad Mattheis
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.ValueConverters
10 | {
11 | #region Usings
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Globalization;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Threading.Tasks;
18 | using System.Windows.Data;
19 | using System.Windows.Markup;
20 | #endregion
21 |
22 | ///
23 | /// ToLowerConverter return the value as value.ToUpper()
24 | ///
25 | public class ToLowerConverter : TypeValueConverterBase, IValueConverter
26 | {
27 | #region IValueConverter
28 | ///
29 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
30 | {
31 | if (value != null)
32 | {
33 | return value.ToString().ToLower();
34 | }
35 |
36 | return null;
37 | }
38 |
39 | ///
40 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
41 | {
42 | throw new NotImplementedException();
43 | }
44 | #endregion
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/ValueConverters/ToUpperConverter.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Konrad Mattheis
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.ValueConverters
10 | {
11 | #region Usings
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Globalization;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Threading.Tasks;
18 | using System.Windows.Data;
19 | using System.Windows.Markup;
20 | #endregion
21 |
22 | ///
23 | /// ToUpperConverter return the value as value.ToUpper()
24 | ///
25 | public class ToUpperConverter : TypeValueConverterBase, IValueConverter
26 | {
27 | #region IValueConverter
28 | ///
29 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
30 | {
31 | if (value != null)
32 | {
33 | return value.ToString().ToUpper();
34 | }
35 |
36 | return null;
37 | }
38 |
39 | ///
40 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
41 | {
42 | throw new NotImplementedException();
43 | }
44 | #endregion
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/ValueConverters/TypeValueConverterBase.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Konrad Mattheis
7 | #endregion
8 |
9 | namespace WPFLocalizeExtension.ValueConverters
10 | {
11 | #region Usings
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Text;
16 | using System.Threading.Tasks;
17 | using System.Windows.Markup;
18 | #endregion
19 |
20 | ///
21 | /// Baseclass for ValueTypeConvertes which implements easy usage as MarkupExtension
22 | ///
23 | public abstract class TypeValueConverterBase : MarkupExtension
24 | {
25 | #region MarkupExtension
26 | ///
27 | public override object ProvideValue(IServiceProvider serviceProvider)
28 | {
29 | return this;
30 | }
31 | #endregion
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/WPFLocalizeExtension.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28010.2019
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WPFLocalizeExtension", "WPFLocalizeExtension.csproj", "{E8C5B094-2CB4-4C26-87F0-351B03612179}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {E8C5B094-2CB4-4C26-87F0-351B03612179}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {E8C5B094-2CB4-4C26-87F0-351B03612179}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {E8C5B094-2CB4-4C26-87F0-351B03612179}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(SolutionProperties) = preSolution
19 | HideSolutionNode = FALSE
20 | EndGlobalSection
21 | GlobalSection(ExtensibilityGlobals) = postSolution
22 | SolutionGuid = {A2E7E737-0020-457E-924B-1A8F5D9CF409}
23 | EndGlobalSection
24 | EndGlobal
25 |
--------------------------------------------------------------------------------
/src/XmlnsPrefix.cs:
--------------------------------------------------------------------------------
1 | #region Copyright information
2 | //
3 | // Licensed under Microsoft Public License (Ms-PL)
4 | // https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/blob/master/LICENSE
5 | //
6 | // Uwe Mayer
7 | #endregion
8 |
9 | using System.Windows.Markup;
10 |
11 | // Register this namespace one with prefix
12 | [assembly: XmlnsDefinition("http://wpflocalizeextension.codeplex.com", "WPFLocalizeExtension.Engine")]
13 | [assembly: XmlnsDefinition("http://wpflocalizeextension.codeplex.com", "WPFLocalizeExtension.Extensions")]
14 | [assembly: XmlnsDefinition("http://wpflocalizeextension.codeplex.com", "WPFLocalizeExtension.Providers")]
15 | [assembly: XmlnsDefinition("http://wpflocalizeextension.codeplex.com", "WPFLocalizeExtension.TypeConverters")]
16 | [assembly: XmlnsDefinition("http://wpflocalizeextension.codeplex.com", "WPFLocalizeExtension.ValueConverters")]
17 | [assembly: XmlnsDefinition("http://wpflocalizeextension.codeplex.com", "WPFLocalizeExtension.Deprecated.Engine")]
18 | [assembly: XmlnsDefinition("http://wpflocalizeextension.codeplex.com", "WPFLocalizeExtension.Deprecated.Extensions")]
19 | [assembly: XmlnsDefinition("http://wpflocalizeextension.codeplex.com", "WPFLocalizeExtension.Deprecated.Providers")]
20 |
21 |
22 | [assembly: XmlnsDefinition("https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension", "WPFLocalizeExtension.Engine")]
23 | [assembly: XmlnsDefinition("https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension", "WPFLocalizeExtension.Extensions")]
24 | [assembly: XmlnsDefinition("https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension", "WPFLocalizeExtension.Providers")]
25 | [assembly: XmlnsDefinition("https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension", "WPFLocalizeExtension.TypeConverters")]
26 | [assembly: XmlnsDefinition("https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension", "WPFLocalizeExtension.ValueConverters")]
27 |
28 | // Assign a default namespace prefix for the schema
29 | [assembly: XmlnsPrefix("http://wpflocalizeextension.codeplex.com", "lex")]
30 |
--------------------------------------------------------------------------------
/src/public.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/src/public.snk
--------------------------------------------------------------------------------
/tests/AssemblyTest/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/tests/AssemblyTest/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Windows;
7 |
8 | namespace AssemblyTest
9 | {
10 | ///
11 | /// Interaction logic for App.xaml
12 | ///
13 | public partial class App : Application
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/tests/AssemblyTest/AssemblyTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net452;netcoreapp3.1
5 | True
6 | true
7 |
8 | CurrentArchitecture
9 | AssemblyTest
10 | WinExe
11 |
12 |
13 |
14 |
15 |
16 |
17 | Always
18 |
19 |
20 | Always
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/tests/AssemblyTest/CaseConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows.Data;
7 |
8 | namespace AssemblyTest
9 | {
10 | public class CaseConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13 | {
14 | if (!(parameter is string) || !(value is string))
15 | return Binding.DoNothing;
16 |
17 | var input = (string)value;
18 |
19 | if ((string)parameter == "Upper")
20 | return input.ToUpper();
21 | else if ((string)parameter == "Lower")
22 | return input.ToLower();
23 | else
24 | return input;
25 | }
26 |
27 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
28 | {
29 | throw new NotImplementedException();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/tests/AssemblyTest/Example.csv:
--------------------------------------------------------------------------------
1 | Key;Value
2 | ButtonAssembly_Background;Aqua
3 | ButtonAssembly_Content;Change Assembly!
4 | ButtonAssembly_FlowDirection;LeftToRight
5 | ButtonAssembly_Margin;10,5,20,15
6 | ButtonAssembly_Width;150
7 | ButtonDE;de
8 | ButtonEN;en
9 | TestText;This is a test.
10 | Width;75
11 | Area;Area
12 | Country;Country
13 | CountryKey;Country
14 | TestFormat;The area of {0} amounts {1} sqkm.
15 | Tab1;Foo
16 | Tab2;Bar
17 | Tab3;Baz
18 | TestEnum_Input;InputCSV
19 | TestEnum_Output;OutputCSV
20 | TestEnum_Processing;ProcessingCSV
--------------------------------------------------------------------------------
/tests/AssemblyTest/Example.de.csv:
--------------------------------------------------------------------------------
1 | Key;Value
2 | ButtonAssembly_Background;Yellow
3 | ButtonAssembly_Content;Assembly ändern!
4 | ButtonAssembly_FlowDirection;RightToLeft
5 | ButtonAssembly_Margin;5
6 | ButtonAssembly_Width;100
7 | ButtonDE;de
8 | ButtonEN;en
9 | TestText;Dies ist ein Test.
10 | Area;Fläche
11 | Country;Land
12 | CountryKey;CountryDE
13 | TestFormat;Die Fläche von {0} beträgt {1} km².
14 | Tab1;Bla
15 | Tab2;Blup
16 | Tab3;Tralala
17 | TestEnum_Input;EingabeCSV
18 | TestEnum_Output;AusgabeCSV
19 | TestEnum_Processing;VerarbeitungCSV
--------------------------------------------------------------------------------
/tests/AssemblyTest/Item.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AssemblyTest
8 | {
9 | public class Item : ViewModelBase
10 | {
11 | public string DisplayName
12 | {
13 | get { return "HOW TO GET TRANSLATED VALUE ?!"; }
14 | }
15 |
16 | public string TranslationKey { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/tests/AssemblyTest/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace AssemblyTest
2 | {
3 | using System;
4 | using System.Diagnostics;
5 | using System.Globalization;
6 | using System.Threading;
7 | using System.Windows;
8 | using System.Windows.Documents;
9 | using WPFLocalizeExtension.Extensions;
10 | using WPFLocalizeExtension.Providers;
11 | using XAMLMarkupExtensions.Base;
12 |
13 | ///
14 | /// Interaction logic for MainWindow.xaml
15 | ///
16 | public partial class MainWindow : Window
17 | {
18 | public MainWindow()
19 | {
20 | ResxLocalizationProvider.Instance.ProviderError += (s, e) =>
21 | {
22 | Debug.WriteLine("Missing Key: " + e.Key);
23 | };
24 |
25 | this.DataContext = new MyViewModel();
26 | InitializeComponent();
27 |
28 | string localisedValue = string.Empty;
29 |
30 | //ILocalizationProvider cvsProvider = new CSVLocalizationProvider() { FileName = "Example", HasHeader = true };
31 | //LocalizeDictionary.Instance.DefaultProvider = cvsProvider;
32 |
33 | //LocExtension locExtension = new LocExtension();
34 | //locExtension.Key = "TestText";
35 |
36 | //locExtension.ResolveLocalizedValue(out localisedValue, new CultureInfo("de"));
37 |
38 | //localisedValue = (string)LocalizeDictionary.Instance.GetLocalizedObject("TestText", null, new CultureInfo("de"), cvsProvider);
39 |
40 | localisedValue = LocExtension.GetLocalizedValue("AssemblyTestResourceLib:Strings:TestText");
41 |
42 | Console.WriteLine(localisedValue);
43 | }
44 |
45 | private void ButtonAssembly_Click(object sender, RoutedEventArgs e)
46 | {
47 | this.SetValue(ResxLocalizationProvider.DefaultAssemblyProperty, "AssemblyTest");
48 | }
49 |
50 | private void Button_Click(object sender, RoutedEventArgs e)
51 | {
52 | //var ext = LocExtension.GetBoundExtension(TestObject, "Text", -1);
53 | //MessageBox.Show(ext.ToString());
54 | }
55 |
56 | private static int threadCount = 0;
57 |
58 | private void ButtonMultiThreading_Click(object sender, RoutedEventArgs e)
59 | {
60 | Thread newWindowThread = new Thread(new ThreadStart(ThreadStartingPoint));
61 | newWindowThread.SetApartmentState(ApartmentState.STA);
62 | newWindowThread.Name = "Thread #" + (++threadCount);
63 | //newWindowThread.IsBackground = true;
64 | newWindowThread.Start();
65 | //newWindowThread.Join();
66 | }
67 |
68 | private void ThreadStartingPoint()
69 | {
70 | MainWindow tempWindow = new MainWindow();
71 | tempWindow.Closed += tempWindow_Closed;
72 | tempWindow.Show();
73 | System.Windows.Threading.Dispatcher.Run();
74 | }
75 |
76 | private void tempWindow_Closed(object sender, EventArgs e)
77 | {
78 | (sender as Window).Dispatcher.InvokeShutdown();
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/tests/AssemblyTest/MyViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.ComponentModel;
5 | using System.Linq;
6 | using System.Text;
7 | using WPFLocalizeExtension.Providers;
8 |
9 | namespace AssemblyTest
10 | {
11 | public class MyViewModel : ViewModelBase
12 | {
13 | private ObservableCollection- _items;
14 |
15 | public ObservableCollection
- Items
16 | {
17 | get
18 | {
19 | if (_items == null)
20 | {
21 | _items = new ObservableCollection
- ();
22 | _items.Add(new Item() { TranslationKey = "AssemblyTest:Strings:Tab1" });
23 | _items.Add(new Item() { TranslationKey = "AssemblyTest:Strings:Tab2" });
24 | _items.Add(new Item() { TranslationKey = "AssemblyTest:Strings:Tab3" });
25 | }
26 | return _items;
27 | }
28 | }
29 |
30 | private TestEnum enumValue = TestEnum.Processing;
31 | ///
32 | /// Gets or sets the enumValue.
33 | ///
34 | public TestEnum EnumValue
35 | {
36 | get { return enumValue; }
37 | set
38 | {
39 | if (enumValue != value)
40 | {
41 | enumValue = value;
42 | RaisePropertyChanged("EnumValue");
43 | }
44 | }
45 | }
46 |
47 | public MyViewModel()
48 | {
49 | ResxLocalizationProvider.Instance.UpdateCultureList("AssemblyTest", "Strings");
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/tests/AssemblyTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // Setting ComVisible to false makes the types in this assembly not visible
8 | // to COM components. If you need to access a type in this assembly from
9 | // COM, set the ComVisible attribute to true on that type.
10 | [assembly: ComVisible(false)]
11 |
12 | //In order to begin building localizable applications, set
13 | //CultureYouAreCodingWith in your .csproj file
14 | //inside a . For example, if you are using US english
15 | //in your source files, set the to en-US. Then uncomment
16 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
17 | //the line below to match the UICulture setting in the project file.
18 |
19 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
20 |
21 | [assembly: ThemeInfo(
22 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
23 | //(used if a resource is not found in the page,
24 | // or application resource dictionaries)
25 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
26 | //(used if a resource is not found in the page,
27 | // app, or any theme specific resource dictionaries)
28 | )]
--------------------------------------------------------------------------------
/tests/AssemblyTest/Resource.With.Dot.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18051
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace AssemblyTest {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | public class Resource_With_Dot {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resource_With_Dot() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | public static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AssemblyTest.Resource.With.Dot", typeof(Resource_With_Dot).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | public static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized string similar to Test.
65 | ///
66 | public static string Test {
67 | get {
68 | return ResourceManager.GetString("Test", resourceCulture);
69 | }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/tests/AssemblyTest/Resources/Austria.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTest/Resources/Austria.png
--------------------------------------------------------------------------------
/tests/AssemblyTest/Resources/France.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTest/Resources/France.png
--------------------------------------------------------------------------------
/tests/AssemblyTest/Resources/Germany.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTest/Resources/Germany.png
--------------------------------------------------------------------------------
/tests/AssemblyTest/Resources/Test.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTest/Resources/Test.bmp
--------------------------------------------------------------------------------
/tests/AssemblyTest/Resources/Test1.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTest/Resources/Test1.bmp
--------------------------------------------------------------------------------
/tests/AssemblyTest/Resources/Test11.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTest/Resources/Test11.bmp
--------------------------------------------------------------------------------
/tests/AssemblyTest/Resources/Test12.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTest/Resources/Test12.bmp
--------------------------------------------------------------------------------
/tests/AssemblyTest/Resources/United_Kingdom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTest/Resources/United_Kingdom.png
--------------------------------------------------------------------------------
/tests/AssemblyTest/StringFormatProxy.cs:
--------------------------------------------------------------------------------
1 | namespace AssemblyTest
2 | {
3 | using System;
4 | using System.Windows;
5 |
6 | public class StringFormatProxy : FrameworkElement
7 | {
8 | ///
9 | /// StringFormat.
10 | ///
11 | public static readonly DependencyProperty StringFormatProperty =
12 | DependencyProperty.Register(
13 | "StringFormat",
14 | typeof(string),
15 | typeof(StringFormatProxy),
16 | new PropertyMetadata("{0}", DataChanged));
17 |
18 | ///
19 | /// The format of the result string.
20 | ///
21 | public string StringFormat
22 | {
23 | get { return (string)GetValue(StringFormatProperty); }
24 | set { SetValue(StringFormatProperty, value); }
25 | }
26 |
27 | ///
28 | /// Value.
29 | ///
30 | public static readonly DependencyProperty ValueProperty =
31 | DependencyProperty.Register(
32 | "Value",
33 | typeof(object),
34 | typeof(StringFormatProxy),
35 | new PropertyMetadata("{0}", DataChanged));
36 |
37 | ///
38 | /// The value of the result string.
39 | ///
40 | public object Value
41 | {
42 | get { return GetValue(ValueProperty); }
43 | set { SetValue(ValueProperty, value); }
44 | }
45 |
46 | private static void DataChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
47 | {
48 | var sfp = sender as StringFormatProxy;
49 | if (sfp != null && sfp.StringFormat != null)
50 | sfp.Result = String.Format(sfp.StringFormat, sfp.Value);
51 | }
52 |
53 | ///
54 | /// Result.
55 | ///
56 | public static readonly DependencyProperty ResultProperty =
57 | DependencyProperty.Register(
58 | "Result",
59 | typeof(string),
60 | typeof(StringFormatProxy),
61 | new PropertyMetadata(null));
62 |
63 | ///
64 | /// The result string.
65 | ///
66 | public string Result
67 | {
68 | get { return (string)GetValue(ResultProperty); }
69 | set { SetValue(ResultProperty, value); }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/tests/AssemblyTest/TestDataClass.cs:
--------------------------------------------------------------------------------
1 | namespace AssemblyTest
2 | {
3 | #region Uses
4 | using System;
5 | using System.Collections.Generic;
6 | using System.ComponentModel;
7 | using System.Linq;
8 | using System.Text;
9 | #endregion
10 |
11 | public class Countries : INotifyPropertyChanged
12 | {
13 | #region PropertyChanged Logic
14 | ///
15 | /// Informiert über sich ändernde Eigenschaften.
16 | ///
17 | public event PropertyChangedEventHandler PropertyChanged;
18 |
19 | ///
20 | /// Notify that a property has changed
21 | ///
22 | ///
23 | /// The property that changed
24 | ///
25 | internal void OnNotifyPropertyChanged(string property)
26 | {
27 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
28 | }
29 | #endregion
30 |
31 | #region Properties
32 | private string country = "";
33 | public string Country
34 | {
35 | get { return country; }
36 | set
37 | {
38 | country = value;
39 | OnNotifyPropertyChanged("Country");
40 | OnNotifyPropertyChanged("FlagSource");
41 | }
42 | }
43 |
44 | private string countryDE = "";
45 | public string CountryDE
46 | {
47 | get { return countryDE; }
48 | set
49 | {
50 | countryDE = value;
51 | OnNotifyPropertyChanged("CountryDE");
52 | }
53 | }
54 |
55 | private double area = 0;
56 | public double Area
57 | {
58 | get { return area; }
59 | set
60 | {
61 | area = value;
62 | OnNotifyPropertyChanged("Area");
63 | }
64 | }
65 |
66 | public string FlagSource
67 | {
68 | get { return this.country.Replace(' ', '_'); }
69 | set { }
70 | }
71 | #endregion
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/tests/AssemblyTest/TestEnum.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace AssemblyTest
8 | {
9 | public enum TestEnum
10 | {
11 | Input,
12 | Processing,
13 | [Browsable(false)]
14 | SomeMoreProcessing,
15 | Output,
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tests/AssemblyTest/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace AssemblyTest
8 | {
9 | public class ViewModelBase : INotifyPropertyChanged
10 | {
11 | public event PropertyChangedEventHandler PropertyChanged;
12 |
13 | protected void RaisePropertyChanged(string propertyName)
14 | {
15 | if (PropertyChanged != null)
16 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/tests/AssemblyTestResourceLib/AssemblyTestResourceLib.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net452;netcoreapp3.1
5 | True
6 | true
7 |
8 | CurrentArchitecture
9 | AssemblyTestResourceLib
10 | 1.0.0
11 |
12 |
13 |
14 |
15 | True
16 | True
17 | Resource.resx
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/tests/AssemblyTestResourceLib/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Setting ComVisible to false makes the types in this assembly not visible
6 | // to COM components. If you need to access a type in this assembly from
7 | // COM, set the ComVisible attribute to true on that type.
8 | [assembly: ComVisible(false)]
9 |
10 | // The following GUID is for the ID of the typelib if this project is exposed to COM
11 | [assembly: Guid("f93184d1-dced-4f91-9220-93cbea59733b")]
--------------------------------------------------------------------------------
/tests/AssemblyTestResourceLib/Resources/Test.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTestResourceLib/Resources/Test.bmp
--------------------------------------------------------------------------------
/tests/AssemblyTestResourceLib/Resources/Test1.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTestResourceLib/Resources/Test1.bmp
--------------------------------------------------------------------------------
/tests/AssemblyTestResourceLib/Resources/Test11.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTestResourceLib/Resources/Test11.bmp
--------------------------------------------------------------------------------
/tests/AssemblyTestResourceLib/Resources/Test12.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XAMLMarkupExtensions/WPFLocalizeExtension/6cb138bb0c63d06390c4a1aa3533705607733853/tests/AssemblyTestResourceLib/Resources/Test12.bmp
--------------------------------------------------------------------------------
/tests/FluentLexTest/Application.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/tests/FluentLexTest/Application.xaml.cs:
--------------------------------------------------------------------------------
1 | #region Copyright and License Information
2 |
3 | // Fluent Ribbon Control Suite
4 | // http://fluent.codeplex.com/
5 | // Copyright © Degtyarev Daniel, Rikker Serg., Weegen Patrick 2009-2013. All rights reserved.
6 | //
7 | // Distributed under the terms of the Microsoft Public License (Ms-PL).
8 | // The license is available online http://fluent.codeplex.com/license
9 |
10 | #endregion
11 |
12 | namespace Fluent.Sample.Foundation
13 | {
14 | ///
15 | /// Entry point of the application
16 | ///
17 | public partial class Application : System.Windows.Application
18 | {
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/FluentLexTest/Fluent.Sample.Foundation.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net452;netcoreapp3.1
6 | True
7 | true
8 |
9 | CurrentArchitecture
10 | Fluent.Sample.Foundation
11 | WinExe
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/tests/FluentLexTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // Setting ComVisible to false makes the types in this assembly not visible
8 | // to COM components. If you need to access a type in this assembly from
9 | // COM, set the ComVisible attribute to true on that type.
10 | [assembly: ComVisible(false)]
11 |
12 | //In order to begin building localizable applications, set
13 | //CultureYouAreCodingWith in your .csproj file
14 | //inside a . For example, if you are using US english
15 | //in your source files, set the to en-US. Then uncomment
16 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
17 | //the line below to match the UICulture setting in the project file.
18 |
19 | [assembly: NeutralResourcesLanguage("en-US")]
20 |
21 | [assembly: ThemeInfo(
22 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
23 | //(used if a resource is not found in the page,
24 | // or application resource dictionaries)
25 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
26 | //(used if a resource is not found in the page,
27 | // app, or any theme specific resource dictionaries)
28 | )]
--------------------------------------------------------------------------------
/tests/FluentLexTest/Window.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/tests/FluentLexTest/Window.xaml.cs:
--------------------------------------------------------------------------------
1 | #region Copyright and License Information
2 |
3 | // Fluent Ribbon Control Suite
4 | // http://fluent.codeplex.com/
5 | // Copyright © Degtyarev Daniel, Rikker Serg., Weegen Patrick 2009-2013. All rights reserved.
6 | //
7 | // Distributed under the terms of the Microsoft Public License (Ms-PL).
8 | // The license is available online http://fluent.codeplex.com/license
9 |
10 | #endregion
11 |
12 | using System.Globalization;
13 | using WPFLocalizeExtension.Engine;
14 | namespace Fluent.Sample.Foundation
15 | {
16 | // ATTENTION: You need use Fluent.RibbonWindow.
17 | // RibbonWindow designed to provide proper office-like glass style.
18 | // RibbonWindow automatically will use special non-DWM style in case of
19 | // Windows XP or basic Windows 7/Vista theme.
20 | // You still can use usual System.Windows.Window
21 |
22 | ///
23 | /// Represents the main window of the application
24 | ///
25 | public partial class Window : RibbonWindow
26 | {
27 | ///
28 | /// Default constructor
29 | ///
30 | public Window()
31 | {
32 | InitializeComponent();
33 | }
34 |
35 | private void buttonLanguage_Click(object sender, System.Windows.RoutedEventArgs e)
36 | {
37 | CultureInfo newCulture;
38 | if (LocalizeDictionary.Instance.Culture.Name.Contains("de"))
39 | {
40 | newCulture = CultureInfo.GetCultureInfo("en-US");
41 | }
42 | else
43 | {
44 | newCulture = CultureInfo.GetCultureInfo("de");
45 | }
46 |
47 | LocalizeDictionary.Instance.SetCurrentThreadCulture = true;
48 | LocalizeDictionary.Instance.Culture = newCulture;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/tests/FluentLexTest/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/tests/GapTextWpfTest/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/tests/GapTextWpfTest/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/tests/GapTextWpfTest/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace GapTextWpfTest
10 | {
11 | ///
12 | /// Interaktionslogik für "App.xaml"
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tests/GapTextWpfTest/Converters/ObjectTypeEqualsConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace GapTextWpfTest.Converters
6 | {
7 | public class ObjectTypeEqualsConverter : IValueConverter
8 | {
9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
10 | {
11 | // returns true if and only if value is of type parameter
12 | var comparedType = parameter as Type;
13 | return comparedType != null && comparedType.IsInstanceOfType(value);
14 | }
15 |
16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | throw new NotSupportedException();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/GapTextWpfTest/GapTextWpfTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net452;netcoreapp3.1
6 | True
7 | true
8 |
9 | CurrentArchitecture
10 |
11 | GapTextWpfTest
12 | WinExe
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/tests/GapTextWpfTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
8 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
9 | // COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
10 | [assembly: ComVisible(false)]
11 |
12 | //Um mit dem Erstellen lokalisierbarer Anwendungen zu beginnen, legen Sie
13 | //ImCodeVerwendeteKultur in der .csproj-Datei
14 | //in einer fest. Wenn Sie in den Quelldateien beispielsweise Deutsch
15 | //(Deutschland) verwenden, legen Sie auf \"de-DE\" fest. Heben Sie dann die Auskommentierung
16 | //des nachstehenden NeutralResourceLanguage-Attributs auf. Aktualisieren Sie "en-US" in der nachstehenden Zeile,
17 | //sodass es mit der UICulture-Einstellung in der Projektdatei übereinstimmt.
18 |
19 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
20 |
21 | [assembly: ThemeInfo(
22 | ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher
23 | //(wird verwendet, wenn eine Ressource auf der Seite
24 | // oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.)
25 | ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs
26 | //(wird verwendet, wenn eine Ressource auf der Seite, in der Anwendung oder einem
27 | // designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.)
28 | )]
--------------------------------------------------------------------------------
/tests/GapTextWpfTest/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/tests/HelloWorldWPF.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30011.22
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloWorldWPF", "HelloWorldWPF\HelloWorldWPF.csproj", "{64B54D1A-1445-4514-9DEC-7DA11D028F54}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WPFLocalizeExtension", "..\src\WPFLocalizeExtension.csproj", "{3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Debug|Mixed Platforms = Debug|Mixed Platforms
14 | Debug|x86 = Debug|x86
15 | Release|Any CPU = Release|Any CPU
16 | Release|Mixed Platforms = Release|Mixed Platforms
17 | Release|x86 = Release|x86
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
23 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
24 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Debug|x86.ActiveCfg = Debug|Any CPU
25 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Debug|x86.Build.0 = Debug|Any CPU
26 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
29 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Release|Mixed Platforms.Build.0 = Release|Any CPU
30 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Release|x86.ActiveCfg = Release|Any CPU
31 | {64B54D1A-1445-4514-9DEC-7DA11D028F54}.Release|x86.Build.0 = Release|Any CPU
32 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
35 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
36 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Debug|x86.ActiveCfg = Debug|Any CPU
37 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Debug|x86.Build.0 = Debug|Any CPU
38 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Release|Any CPU.Build.0 = Release|Any CPU
40 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
41 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
42 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Release|x86.ActiveCfg = Release|Any CPU
43 | {3B2FA6D1-6EC0-4C0F-BDF0-D90158904ED3}.Release|x86.Build.0 = Release|Any CPU
44 | EndGlobalSection
45 | GlobalSection(SolutionProperties) = preSolution
46 | HideSolutionNode = FALSE
47 | EndGlobalSection
48 | GlobalSection(ExtensibilityGlobals) = postSolution
49 | SolutionGuid = {F0544A03-17E3-4EFB-BB50-4EDEB145B721}
50 | EndGlobalSection
51 | EndGlobal
52 |
--------------------------------------------------------------------------------
/tests/HelloWorldWPF/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/tests/HelloWorldWPF/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Windows;
7 |
8 | namespace HalloWeltWPF
9 | {
10 | ///
11 | /// Interaction logic for App.xaml
12 | ///
13 | public partial class App : Application
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/tests/HelloWorldWPF/HelloWorldWPF.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | netcoreapp3.1
6 | HalloWeltWPF
7 | WinExe
8 |
9 | True
10 | true
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | True
49 | True
50 | Ressourcen.resx
51 |
52 |
53 |
--------------------------------------------------------------------------------
/tests/HelloWorldWPF/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Runtime.CompilerServices;
7 | using System.Text;
8 | using System.Windows;
9 | using System.Windows.Controls;
10 | using System.Windows.Data;
11 | using System.Windows.Documents;
12 | using System.Windows.Input;
13 | using System.Windows.Media;
14 | using System.Windows.Media.Imaging;
15 | using System.Windows.Navigation;
16 | using System.Windows.Shapes;
17 | using WPFLocalizeExtension.Engine;
18 | using WPFLocalizeExtension.Providers;
19 |
20 | namespace HalloWeltWPF
21 | {
22 | ///
23 | /// Interaction logic for MainWindow.xaml
24 | ///
25 | public partial class MainWindow : Window
26 | {
27 | TestVM vm = new TestVM();
28 |
29 | public MainWindow()
30 | {
31 | vm.language = "de";
32 | vm.color = "Background";
33 | vm.Hours = 0;
34 | this.DataContext = vm;
35 |
36 | LocalizeDictionary.Instance.Culture = new System.Globalization.CultureInfo("de");
37 | (LocalizeDictionary.Instance.DefaultProvider as ResxLocalizationProvider).SearchCultures =
38 | new List()
39 | {
40 | System.Globalization.CultureInfo.GetCultureInfo("de-de"),
41 | System.Globalization.CultureInfo.GetCultureInfo("en"),
42 | System.Globalization.CultureInfo.GetCultureInfo("he"),
43 | System.Globalization.CultureInfo.GetCultureInfo("ar"),
44 | };
45 | LocalizeDictionary.Instance.OutputMissingKeys = true;
46 | LocalizeDictionary.Instance.MissingKeyEvent += Instance_MissingKeyEvent;
47 | }
48 |
49 | private void Instance_MissingKeyEvent(object sender, MissingKeyEventArgs e)
50 | {
51 | // Test of FallbackBehavior.
52 | if (e.Key == "UndefinedKey")
53 | return;
54 |
55 | e.MissingKeyResult = "Hello World";
56 | }
57 |
58 | private void BindeTestButton_Click(object sender, RoutedEventArgs e)
59 | {
60 | vm.Hours = vm.Hours + 1;
61 |
62 | vm.language = vm.language switch
63 | {
64 | "en" => "de",
65 | "de" => "error",
66 | _ => "en",
67 | };
68 | if (vm.tenum == TestVM.TestEnum.Test1)
69 | vm.tenum = TestVM.TestEnum.Test2;
70 | else
71 | vm.tenum = TestVM.TestEnum.Test1;
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/tests/HelloWorldWPF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // Setting ComVisible to false makes the types in this assembly not visible
8 | // to COM components. If you need to access a type in this assembly from
9 | // COM, set the ComVisible attribute to true on that type.
10 | [assembly: ComVisible(false)]
11 |
12 | //In order to begin building localizable applications, set
13 | //CultureYouAreCodingWith in your .csproj file
14 | //inside a . For example, if you are using US english
15 | //in your source files, set the to en-US. Then uncomment
16 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
17 | //the line below to match the UICulture setting in the project file.
18 |
19 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
20 |
21 | [assembly: ThemeInfo(
22 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
23 | //(used if a resource is not found in the page,
24 | // or application resource dictionaries)
25 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
26 | //(used if a resource is not found in the page,
27 | // app, or any theme specific resource dictionaries)
28 | )]
29 |
--------------------------------------------------------------------------------
/tests/HelloWorldWPF/TestVM.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Navigation;
8 |
9 | namespace HalloWeltWPF
10 | {
11 | public class TestVM : INotifyPropertyChanged
12 | {
13 | #region INotifyPropertyChanged Implementation
14 | ///
15 | /// Informiert über sich ändernde Eigenschaften.
16 | ///
17 | public event PropertyChangedEventHandler PropertyChanged;
18 |
19 | ///
20 | /// Notify that a property has changed
21 | ///
22 | ///
23 | /// The property that changed
24 | ///
25 | internal void RaisePropertyChanged(string property)
26 | {
27 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
28 | }
29 | #endregion
30 |
31 | public enum TestEnum
32 | {
33 | Test1,
34 | Test2
35 | }
36 |
37 | private TestEnum _tenum;
38 | public TestEnum tenum {
39 | get => _tenum;
40 | set {
41 | _tenum = value;
42 | RaisePropertyChanged(nameof(tenum));
43 | }
44 | }
45 |
46 | private int _hours;
47 | public int Hours
48 | {
49 | get => _hours;
50 | set
51 | {
52 | _hours = value;
53 | RaisePropertyChanged(nameof(Hours));
54 | }
55 | }
56 |
57 | private string _language;
58 | public string language
59 | {
60 | get => _language;
61 | set
62 | {
63 | _language = value;
64 | RaisePropertyChanged(nameof(language));
65 | }
66 | }
67 |
68 | private string _color;
69 | public string color {
70 | get => _color;
71 | set {
72 | _color = value;
73 | RaisePropertyChanged(nameof(color));
74 | }
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/tests/LeakSample.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29920.165
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LeakSample", "LeakSample\LeakSample.csproj", "{D2C371CA-7769-40A6-89B8-06B10B917E25}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WPFLocalizeExtension", "..\src\WPFLocalizeExtension.csproj", "{321E7D1C-DCA9-4B48-B1BF-4BE0AA22FDE0}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {D2C371CA-7769-40A6-89B8-06B10B917E25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {D2C371CA-7769-40A6-89B8-06B10B917E25}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {D2C371CA-7769-40A6-89B8-06B10B917E25}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {D2C371CA-7769-40A6-89B8-06B10B917E25}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {321E7D1C-DCA9-4B48-B1BF-4BE0AA22FDE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {321E7D1C-DCA9-4B48-B1BF-4BE0AA22FDE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {321E7D1C-DCA9-4B48-B1BF-4BE0AA22FDE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {321E7D1C-DCA9-4B48-B1BF-4BE0AA22FDE0}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {C504E6AC-896D-49F4-8E79-9150BB0E3D9A}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/tests/LeakSample/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/tests/LeakSample/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/tests/LeakSample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace LeakSample
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tests/LeakSample/LeakSample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net452;netcoreapp3.1
6 | LeakSample
7 | WinExe
8 |
9 | True
10 | true
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/tests/LeakSample/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/tests/LeakSample/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 |
4 | namespace LeakSample
5 | {
6 | ///
7 | /// Interaction logic for MainWindow.xaml
8 | ///
9 | public partial class MainWindow : Window
10 | {
11 | public MainWindow()
12 | {
13 | InitializeComponent();
14 | }
15 |
16 | private void OnReload(object sender, RoutedEventArgs e)
17 | {
18 | ItemsControl.ItemsSource = new object[new Random().Next(10, 30)];
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/LeakSample/MainWindowViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Runtime.CompilerServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using LeakSample.Annotations;
9 |
10 | namespace LeakSample
11 | {
12 | public class MainWindowViewModel : INotifyPropertyChanged
13 | {
14 | public IReadOnlyList