├── .gitignore ├── LICENSE ├── README.md ├── appveyor.yml └── source ├── CleanAll.bat ├── ColorPickerDemo.sln ├── ColorPickerDemo ├── App.config ├── App.xaml ├── App.xaml.cs ├── ColorPickerDemo.csproj ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── ViewModels │ ├── AppViewModel.cs │ └── Base │ │ └── ViewModelBase.cs └── packages.config ├── ColorPickerDemoLib ├── ColorPickerDemoLib.csproj ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Themes │ └── Generic.xaml └── Views │ ├── ColorSelectionView.xaml │ └── ColorSelectionView.xaml.cs ├── ColorPickerLib ├── AssemblyInfo.cs ├── Behaviours │ └── AllowableCharactersTextBoxBehavior .cs ├── ColorPickerLib.csproj ├── ColorPickerLib.csproj.user ├── Controls │ ├── ColorCanvas.xaml │ ├── ColorCanvas.xaml.cs │ ├── ColorCanvasTextBoxStyle.xaml │ ├── ColorPicker.xaml │ ├── ColorPicker.xaml.cs │ ├── ColorSpectrumSlider.xaml │ ├── ColorSpectrumSlider.xaml.cs │ ├── SliderRepeatButtonStyle.xaml │ └── VerticalSlideThumbTemplate.xaml ├── Converters │ ├── CenterTitleConverter.cs │ ├── ColorToSolidColorBrushConverter.cs │ ├── InverseBoolConverter.cs │ ├── WindowContentBorderMarginConverter.cs │ └── WindowControlBackgroundConverter.cs ├── Core │ ├── Input │ │ ├── IValidateInput.cs │ │ ├── InputValidationErrorEventArgs.cs │ │ ├── KeyModifier.cs │ │ ├── KeyModifierCollection.cs │ │ └── KeyModifierCollectionConverter.cs │ ├── Media │ │ └── WindowColors.cs │ └── Utilities │ │ ├── ColorUtilities.cs │ │ ├── KeyboardUtilities.cs │ │ ├── TreeHelper.cs │ │ └── ValueChangeHelper.cs ├── Localized │ ├── Strings.Designer.cs │ ├── Strings.cs-CZ.resx │ ├── Strings.de-DE.Designer.cs │ ├── Strings.de-DE.resx │ ├── Strings.es-ES.Designer.cs │ ├── Strings.es-ES.resx │ ├── Strings.fr-FR.Designer.cs │ ├── Strings.fr-FR.resx │ ├── Strings.hi.Designer.cs │ ├── Strings.hi.resx │ ├── Strings.id-ID.Designer.cs │ ├── Strings.id-ID.resx │ ├── Strings.it-IT.Designer.cs │ ├── Strings.it-IT.resx │ ├── Strings.ja-JP.Designer.cs │ ├── Strings.ja-JP.resx │ ├── Strings.nl-NL.Designer.cs │ ├── Strings.nl-NL.resx │ ├── Strings.resx │ ├── Strings.zh-CHS.Designer.cs │ ├── Strings.zh-CHS.resx │ ├── Strings.zh-CHT.Designer.cs │ └── Strings.zh-CHT.resx ├── Models │ ├── ColorItem.cs │ └── ColorSorter.cs ├── Primitives │ ├── HsvColor.cs │ ├── InputBase.cs │ ├── MouseWheelActiveTrigger.cs │ ├── Selector.cs │ ├── SelectorItem.cs │ └── Themes │ │ └── Generic │ │ └── SelectorItem.xaml ├── Resources │ └── icon.png └── Themes │ ├── DarkBrushs.xaml │ ├── Generic.xaml │ ├── Generic │ ├── Brushes.xaml │ ├── Common.xaml │ └── Glyphs.xaml │ ├── LightBrushs.xaml │ └── ResourceKeys.cs └── MLibTest ├── Components ├── ServiceLocator │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ServiceContainer.cs │ └── ServiceLocator.csproj └── Settings │ ├── Settings │ ├── Interfaces │ │ ├── IOptions.cs │ │ ├── IOptionsPanel.cs │ │ ├── IProfile.cs │ │ ├── ISettingsManager.cs │ │ └── IViewPosSizeModel.cs │ ├── Internal │ │ └── SettingsManagerImpl.cs │ ├── ProgramSettings │ │ ├── LanguageCollection.cs │ │ └── OptionsPanel.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SerializableDictionary.cs │ ├── Settings.csproj │ ├── SettingsManager.cs │ ├── UserProfile │ │ ├── IViewSize.cs │ │ ├── LocalizabilityAttribute.cs │ │ ├── Profile.cs │ │ ├── ViewPosSizeModel.cs │ │ └── ViewSize.cs │ └── packages.config │ └── SettingsModel │ ├── ExtensionMethods │ └── SecureStringExtensionMethod.cs │ ├── Interfaces │ ├── IEngine.cs │ ├── IOptionGroup.cs │ └── IOptionsSchema.cs │ ├── Models │ ├── Engine.cs │ ├── Factory.cs │ ├── FileReference.cs │ ├── OptionGroup.cs │ ├── OptionsSchema.cs │ └── XML │ │ ├── Converters │ │ ├── AlternativeDataTypeHandler.cs │ │ ├── IAlternativeDataTypeHandler.cs │ │ └── SecureStringHandler.cs │ │ └── XMLLayer.cs │ ├── Overview.cd │ ├── Properties │ └── AssemblyInfo.cs │ ├── SettingsModel.csproj │ └── packages.config └── ThemedDemo ├── App.config ├── App.xaml ├── App.xaml.cs ├── Behaviors └── SelectionChangedBehavior.cs ├── BindToMLib ├── ColorPickerLib │ └── DarkLightBrushs.xaml ├── MWindowLib │ └── DarkLightBrushs.xaml └── NumericUpDownLib │ └── DarkLightBrushs.xaml ├── Demos ├── Behaviors │ └── SelectionChangedBehavior.cs .cs ├── Models │ └── FolderBrowserResult.cs ├── ViewModels │ └── DemoViewModel.cs └── Views │ ├── FolderBrowserContentDialogView.xaml │ ├── FolderBrowserContentDialogView.xaml.cs │ ├── FolderBrowserDialog.xaml │ └── FolderBrowserDialog.xaml.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Models ├── AppCore.cs └── SettingDefaults.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── ServiceInjector.cs ├── ThemedDemo.csproj ├── ViewModels ├── AppLifeCycleViewModel.cs ├── AppViewModel.cs ├── Base │ ├── ModelBase.cs │ ├── RelayCommand.cs │ └── ViewModelBase.cs ├── ThemeDefinitionViewModel.cs └── ThemeViewModel.cs └── packages.config /.gitignore: -------------------------------------------------------------------------------- 1 | /source/.vs/ 2 | source/packages/ 3 | packages/ 4 | 00_Release/ 5 | 01_Nuget/ 6 | debug/ 7 | release/ 8 | build/ 9 | bin/ 10 | obj/ 11 | cache/ 12 | log/ 13 | tmp/ 14 | 15 | *~ 16 | *.lock 17 | *.DS_Store 18 | *.swp 19 | *.out 20 | *.sou 21 | *.suo 22 | *.sqlite 23 | 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build status](https://ci.appveyor.com/api/projects/status/0e19uif3f40tsppi?svg=true)](https://ci.appveyor.com/project/Dirkster99/colorpickerlib) 2 | [![Release](https://img.shields.io/github/release/Dirkster99/colorpickerlib.svg)](https://github.com/Dirkster99/colorpickerlib/releases/latest) 3 | [![NuGet](https://img.shields.io/nuget/dt/Dirkster.colorpickerlib.svg)](http://nuget.org/packages/Dirkster.colorpickerlib) 4 | 5 | ![Net4](https://badgen.net/badge/Framework/.Net 4/blue) ![NetCore3](https://badgen.net/badge/Framework/NetCore 3/blue) 6 | 7 | # ColorPickerLib 8 | A WPF/MVVM implementation of a themeable color picker control 9 | 10 | 11 | 12 | 15 | 18 | 19 |
13 | 14 | 16 | 17 |
20 | 21 | ![](https://github.com/Dirkster99/Docu/blob/master/ColorPickerLib/DemoProgramm_Screenshot_PopUp1.png) 22 | 23 | # Project Description 24 | 25 | This project implements a Color Picker control using MVVM/Windows Presentation Foundation (WPF) pattern and technology. These controls can be themed in dark and light themes and are localized. 26 | 27 | You can test these controls with the demo applications provided in this repository. 28 | 29 | # Features 30 | 31 | This version of the control implements: 32 | 33 | * a few bug fixes (eg.: you cannot enter letters or more than 3 digits in a channel input element). 34 | 35 | Supports localization for: 36 | * Chinese (Simplified) and Chinese (Traditional) 37 | * Czech 38 | * Dutch 39 | * English 40 | * French 41 | * German 42 | * Hindi 43 | * Indonesian 44 | * Italian 45 | * Japanese 46 | * Spanish 47 | 48 | ## Theming 49 | 50 | Load *Light* or *Dark* brush resources in you resource dictionary to take advantage of existing definitions. 51 | 52 | ```XAML 53 | 54 | 55 | 56 | ``` 57 | 58 | ```XAML 59 | 60 | 61 | 62 | ``` 63 | 64 | These definitions do not theme all controls used within this library. You should use a standard theming library, such as: 65 | - [MahApps.Metro](https://github.com/MahApps/MahApps.Metro), 66 | - [MLib](https://github.com/Dirkster99/MLib), or 67 | - [MUI](https://github.com/firstfloorsoftware/mui) 68 | 69 | to also theme standard elements, such as, button and textblock etc. 70 | 71 | # References 72 | 73 | This project implements a WPF Color Picker control. 74 | 75 | The project is based on: 76 | * The color picker control contained in the Extended WPF Toolkit™ Community Edition: https://github.com/xceedsoftware/wpftoolkit from Xceed 77 | 78 | * See also [WPF Color Picker Control](https://wpfcolorpickercontrol.codeplex.com/) on [Codeplex](https://codeplex.com/). 79 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.6.{build} 2 | 3 | branches: 4 | only: 5 | - master 6 | 7 | configuration: Release 8 | 9 | platform: Any CPU 10 | 11 | image: Visual Studio 2019 Preview 12 | 13 | install: 14 | - cmd: choco install dotnetcore-sdk --pre 15 | 16 | before_build: 17 | - cmd: nuget restore source/ColorPickerDemo.sln 18 | 19 | build: 20 | 21 | verbosity: minimal 22 | 23 | artifacts: 24 | 25 | - path: source\ColorPickerDemo\bin\Release 26 | name: ColorPickerDemo 27 | 28 | - path: source\MLibTest\ThemedDemo\bin\Release 29 | name: ThemedDemo 30 | 31 | - path: source\ColorPickerLib\bin\Release 32 | name: ColorPickerLib 33 | -------------------------------------------------------------------------------- /source/CleanAll.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | pushd "%~dp0" 3 | ECHO. 4 | ECHO. 5 | ECHO. 6 | ECHO This script deletes all temporary build files in their 7 | ECHO corresponding BIN and OBJ Folder contained in the following projects 8 | ECHO. 9 | ECHO ColorPickerDemo 10 | ECHO ColorPickerDemoLib 11 | ECHO ColorPickerLib 12 | ECHO. 13 | ECHO MLibTest\ThemedDemo 14 | ECHO MLibTest\Components\ServiceLocator 15 | ECHO MLibTest\Components\Settings\Settings 16 | ECHO MLibTest\Components\Settings\SettingsModel 17 | ECHO. 18 | REM Ask the user if hes really sure to continue beyond this point XXXXXXXX 19 | set /p choice=Are you sure to continue (Y/N)? 20 | if not '%choice%'=='Y' Goto EndOfBatch 21 | REM Script does not continue unless user types 'Y' in upper case letter 22 | ECHO. 23 | ECHO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 24 | ECHO. 25 | ECHO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 26 | 27 | RMDIR /S /Q .\.vs 28 | 29 | ECHO. 30 | ECHO Deleting BIN and OBJ Folders in Demos_Tests\ColorPicker\ColorPickerDemo project folder 31 | ECHO. 32 | RMDIR /S /Q ColorPickerDemo\bin 33 | RMDIR /S /Q ColorPickerDemo\obj 34 | ECHO. 35 | ECHO 36 | 37 | ECHO. 38 | ECHO Deleting BIN and OBJ Folders in Demos_Tests\ColorPicker\ColorPickerDemoLib project folder 39 | ECHO. 40 | RMDIR /S /Q ColorPickerDemoLib\bin 41 | RMDIR /S /Q ColorPickerDemoLib\obj 42 | ECHO. 43 | ECHO 44 | 45 | ECHO. 46 | ECHO Deleting BIN and OBJ Folders in Demos_Tests\ColorPicker\ColorPickerLib project folder 47 | ECHO. 48 | RMDIR /S /Q ColorPickerLib\bin 49 | RMDIR /S /Q ColorPickerLib\obj 50 | ECHO. 51 | ECHO 52 | 53 | ECHO. 54 | ECHO Deleting BIN and OBJ Folders in MLibTest\ThemedDemo project folder 55 | ECHO. 56 | RMDIR /S /Q MLibTest\ThemedDemo\bin 57 | RMDIR /S /Q MLibTest\ThemedDemo\obj 58 | ECHO. 59 | 60 | ECHO. 61 | ECHO Deleting BIN and OBJ Folders in MLibTest\Components\ServiceLocator project folder 62 | ECHO. 63 | RMDIR /S /Q MLibTest\Components\ServiceLocator\bin 64 | RMDIR /S /Q MLibTest\Components\ServiceLocator\obj 65 | ECHO. 66 | 67 | ECHO. 68 | ECHO Deleting BIN and OBJ Folders in MLibTest\Components\Settings\Settings project folder 69 | ECHO. 70 | RMDIR /S /Q MLibTest\Components\Settings\Settings\bin 71 | RMDIR /S /Q MLibTest\Components\Settings\Settings\obj 72 | ECHO. 73 | 74 | ECHO. 75 | ECHO Deleting BIN and OBJ Folders in MLibTest\Components\Settings\SettingsModel project folder 76 | ECHO. 77 | RMDIR /S /Q MLibTest\Components\Settings\SettingsModel\bin 78 | RMDIR /S /Q MLibTest\Components\Settings\SettingsModel\obj 79 | ECHO. 80 | 81 | PAUSE -------------------------------------------------------------------------------- /source/ColorPickerDemo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /source/ColorPickerDemo/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /source/ColorPickerDemo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerDemo 2 | { 3 | using System.Windows; 4 | 5 | /// 6 | /// Interaction logic for App.xaml 7 | /// 8 | public partial class App : Application 9 | { 10 | public App() 11 | { 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /source/ColorPickerDemo/ColorPickerDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D2AEE076-83D6-4B96-B420-B6782CAA0E44} 8 | WinExe 9 | Properties 10 | ColorPickerDemo 11 | ColorPickerDemo 12 | v4.5 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | ..\packages\Dirkster.NumericUpDownLib.2.4.2\lib\net40\NumericUpDownLib.dll 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 4.0 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | MSBuild:Compile 57 | Designer 58 | 59 | 60 | 61 | 62 | MSBuild:Compile 63 | Designer 64 | 65 | 66 | App.xaml 67 | Code 68 | 69 | 70 | MainWindow.xaml 71 | Code 72 | 73 | 74 | 75 | 76 | Code 77 | 78 | 79 | True 80 | True 81 | Resources.resx 82 | 83 | 84 | True 85 | Settings.settings 86 | True 87 | 88 | 89 | ResXFileCodeGenerator 90 | Resources.Designer.cs 91 | 92 | 93 | 94 | SettingsSingleFileGenerator 95 | Settings.Designer.cs 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | {6fb67ef1-8867-4c75-8c5d-3952a85c27da} 105 | ColorPickerDemoLib 106 | 107 | 108 | {120b4f72-0bf6-4272-b1bf-68444131570c} 109 | ColorPickerLib 110 | 111 | 112 | 113 | 120 | -------------------------------------------------------------------------------- /source/ColorPickerDemo/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /source/ColorPickerDemo/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerDemo 2 | { 3 | using ColorPickerDemo.ViewModels; 4 | using System.Windows; 5 | 6 | /// 7 | /// Interaction logic for MainWindow.xaml 8 | /// 9 | public partial class MainWindow : Window 10 | { 11 | public MainWindow() 12 | { 13 | InitializeComponent(); 14 | 15 | this.DataContext = new AppViewModel(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /source/ColorPickerDemo/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 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("ColorPickerDemo")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("HP")] 14 | [assembly: AssemblyProduct("ColorPickerDemo")] 15 | [assembly: AssemblyCopyright("Copyright © 2015")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /source/ColorPickerDemo/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34209 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 ColorPickerDemo.Properties 12 | { 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 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ColorPickerDemo.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /source/ColorPickerDemo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34209 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 ColorPickerDemo.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /source/ColorPickerDemo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /source/ColorPickerDemo/ViewModels/AppViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerDemo.ViewModels 2 | { 3 | using System.Windows.Media; 4 | 5 | internal class AppViewModel : Base.ViewModelBase 6 | { 7 | #region fields 8 | 9 | private Color _SelectedAccentColor; 10 | 11 | #endregion fields 12 | 13 | #region ctors 14 | 15 | /// 16 | /// Class constructor 17 | /// 18 | public AppViewModel() 19 | { 20 | // Explicit use of opacity is recommended here to initialize all components as expected 21 | _SelectedAccentColor = Color.FromArgb(128, 180, 0, 0); 22 | } 23 | 24 | #endregion ctors 25 | 26 | #region properties 27 | 28 | /// 29 | /// Gets/sets the currently selected color. 30 | /// 31 | public Color SelectedAccentColor 32 | { 33 | get { return _SelectedAccentColor; } 34 | set 35 | { 36 | if (_SelectedAccentColor != value) 37 | { 38 | _SelectedAccentColor = value; 39 | RaisePropertyChanged(() => SelectedAccentColor); 40 | } 41 | } 42 | } 43 | 44 | /// 45 | /// Gets/sets a description for the currently selected color. 46 | /// 47 | public string Description 48 | { 49 | get 50 | { 51 | return "The ColorCanvas and ColorPicker controls allow the user to input a color. Not shown in the sample are the ColorPicker's Available, Standard and Recent color lists, which are entirely customizable."; 52 | } 53 | } 54 | 55 | #endregion properties 56 | } 57 | } -------------------------------------------------------------------------------- /source/ColorPickerDemo/ViewModels/Base/ViewModelBase.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerDemo.ViewModels.Base 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | using System.Linq.Expressions; 6 | 7 | public class ViewModelBase : INotifyPropertyChanged 8 | { 9 | protected virtual void RaisePropertyChanged(string propertyName) 10 | { 11 | // Cache the handler to make this thread safe 12 | var handler = PropertyChanged; 13 | 14 | if (handler != null) 15 | handler(this, new PropertyChangedEventArgs(propertyName)); 16 | } 17 | 18 | public event PropertyChangedEventHandler PropertyChanged; 19 | 20 | /// 21 | /// Tell bound controls (via WPF binding) to refresh their display. 22 | /// 23 | /// Sample call: this.NotifyPropertyChanged(() => this.IsSelected); 24 | /// where 'this' is derived from 25 | /// and IsSelected is a property. 26 | /// 27 | /// 28 | /// 29 | public void RaisePropertyChanged(Expression> property) 30 | { 31 | var lambda = (LambdaExpression)property; 32 | MemberExpression memberExpression; 33 | 34 | if (lambda.Body is UnaryExpression) 35 | { 36 | var unaryExpression = (UnaryExpression)lambda.Body; 37 | memberExpression = (MemberExpression)unaryExpression.Operand; 38 | } 39 | else 40 | memberExpression = (MemberExpression)lambda.Body; 41 | 42 | RaisePropertyChanged(memberExpression.Member.Name); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /source/ColorPickerDemo/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /source/ColorPickerDemoLib/ColorPickerDemoLib.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {6FB67EF1-8867-4C75-8C5D-3952A85C27DA} 8 | library 9 | ColorPickerDemoLib 10 | ColorPickerDemoLib 11 | v4.0 12 | 512 13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 4 15 | true 16 | Client 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 4.0 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | MSBuild:Compile 53 | Designer 54 | 55 | 56 | MSBuild:Compile 57 | Designer 58 | 59 | 60 | 61 | 62 | Code 63 | 64 | 65 | True 66 | True 67 | Resources.resx 68 | 69 | 70 | True 71 | Settings.settings 72 | True 73 | 74 | 75 | ColorSelectionView.xaml 76 | 77 | 78 | ResXFileCodeGenerator 79 | Resources.Designer.cs 80 | 81 | 82 | SettingsSingleFileGenerator 83 | Settings.Designer.cs 84 | 85 | 86 | 87 | 88 | {120b4f72-0bf6-4272-b1bf-68444131570c} 89 | ColorPickerLib 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /source/ColorPickerDemoLib/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 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("ColorPickerDemoLib")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("ColorPickerDemoLib")] 15 | [assembly: AssemblyCopyright("Copyright © 2018-2019")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly:ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /source/ColorPickerDemoLib/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 ColorPickerDemoLib.Properties { 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", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 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 Resources() { 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 | internal 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("ColorPickerDemoLib.Properties.Resources", typeof(Resources).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 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /source/ColorPickerDemoLib/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 ColorPickerDemoLib.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /source/ColorPickerDemoLib/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /source/ColorPickerDemoLib/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | -------------------------------------------------------------------------------- /source/ColorPickerDemoLib/Views/ColorSelectionView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerDemoLib.Views 2 | { 3 | using System.Windows.Controls; 4 | 5 | /// 6 | /// Interaction logic for ColorSelectionView.xaml 7 | /// 8 | public partial class ColorSelectionView : UserControl 9 | { 10 | public ColorSelectionView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] -------------------------------------------------------------------------------- /source/ColorPickerLib/Behaviours/AllowableCharactersTextBoxBehavior .cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Behaviours 2 | { 3 | using System.Text.RegularExpressions; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | 7 | /// 8 | /// Class implements a textbox behaviour that can help filter textbox characters 9 | /// for valid characters only. Filtering for hex input is, for example, realized 10 | /// by attaching this behaviour to a textbox and setting the RegularExpression 11 | /// property to: "^[0-9|a-f|A-F]+$" 12 | /// 13 | public class AllowableCharactersTextBoxBehavior 14 | { 15 | #region fields 16 | 17 | // Using a DependencyProperty as the backing store for RegularExpressionProperty. This enables animation, styling, binding, etc... 18 | public static readonly DependencyProperty RegularExpressionPropertyProperty = 19 | DependencyProperty.RegisterAttached("RegularExpressionProperty", 20 | typeof(string), typeof(AllowableCharactersTextBoxBehavior), 21 | new PropertyMetadata(".*", OnRegularExpressionPropertyChanged)); 22 | 23 | #endregion fields 24 | 25 | #region methods 26 | 27 | /// 28 | /// Implements the getter method of the regular expression dependency property. 29 | /// 30 | /// 31 | /// 32 | public static string GetRegularExpressionProperty(DependencyObject obj) 33 | { 34 | return (string)obj.GetValue(RegularExpressionPropertyProperty); 35 | } 36 | 37 | /// 38 | /// Implements the setter method of the regular expression dependency property. 39 | /// 40 | /// 41 | /// 42 | public static void SetRegularExpressionProperty(DependencyObject obj, string value) 43 | { 44 | obj.SetValue(RegularExpressionPropertyProperty, value); 45 | } 46 | 47 | /// 48 | /// Attach detach behaviour when regular expression property has changed. 49 | /// 50 | /// 51 | /// 52 | private static void OnRegularExpressionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 53 | { 54 | var uiElement = d as TextBox; // Remove the handler if it exist to avoid memory leaks 55 | uiElement.PreviewTextInput -= uiElement_PreviewTextInput; 56 | 57 | var value = e.NewValue as string; 58 | if (value != null) 59 | { 60 | // the property is attached so we attach the Drop event handler 61 | uiElement.PreviewTextInput += uiElement_PreviewTextInput; 62 | 63 | DataObject.AddPastingHandler(uiElement, OnPaste); 64 | } 65 | } 66 | 67 | /// 68 | /// Method checks if pasted string contains input that is invalid and cancels 69 | /// past command if string is not conforming to regular expression. 70 | /// 71 | /// 72 | /// 73 | private static void OnPaste(object sender, DataObjectPastingEventArgs e) 74 | { 75 | if (e.DataObject.GetDataPresent(DataFormats.Text)) 76 | { 77 | var RegularExpression = AllowableCharactersTextBoxBehavior.GetRegularExpressionProperty(sender as TextBox); 78 | 79 | string text = System.Convert.ToString(e.DataObject.GetData(DataFormats.Text)); 80 | 81 | if (!IsValid(text, true, RegularExpression)) 82 | { 83 | e.CancelCommand(); 84 | } 85 | } 86 | else 87 | { 88 | e.CancelCommand(); 89 | } 90 | } 91 | 92 | /// 93 | /// Determines whether string conforms to regurlar expression or not. 94 | /// 95 | /// 96 | /// 97 | /// 98 | /// 99 | private static bool IsValid(string newText, bool paste, string regularExpression) 100 | { 101 | return Regex.IsMatch(newText, regularExpression); 102 | } 103 | 104 | /// 105 | /// Previews a text change and cancels the change if text appears to be invalid. 106 | /// 107 | /// 108 | /// 109 | private static void uiElement_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e) 110 | { 111 | var RegularExpression = AllowableCharactersTextBoxBehavior.GetRegularExpressionProperty(sender as TextBox); 112 | 113 | e.Handled = !IsValid(e.Text, false, RegularExpression); 114 | } 115 | 116 | #endregion methods 117 | } 118 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/ColorPickerLib.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Designer 7 | 8 | 9 | 10 | 11 | Designer 12 | 13 | 14 | Designer 15 | 16 | 17 | Designer 18 | 19 | 20 | Designer 21 | 22 | 23 | Designer 24 | 25 | 26 | Designer 27 | 28 | 29 | Designer 30 | 31 | 32 | Designer 33 | 34 | 35 | Designer 36 | 37 | 38 | Designer 39 | 40 | 41 | Designer 42 | 43 | 44 | Designer 45 | 46 | 47 | Designer 48 | 49 | 50 | -------------------------------------------------------------------------------- /source/ColorPickerLib/Controls/ColorCanvasTextBoxStyle.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 15 | 16 | 25 | -------------------------------------------------------------------------------- /source/ColorPickerLib/Controls/ColorSpectrumSlider.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 62 | -------------------------------------------------------------------------------- /source/ColorPickerLib/Controls/ColorSpectrumSlider.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Controls 2 | { 3 | using ColorPickerLib.Core.Utilities; 4 | using ColorPickerLib.Primitives; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Media; 10 | using System.Windows.Shapes; 11 | 12 | [TemplatePart(Name = PART_SpectrumDisplay, Type = typeof(Rectangle))] 13 | public class ColorSpectrumSlider : Slider 14 | { 15 | private const string PART_SpectrumDisplay = "PART_SpectrumDisplay"; 16 | 17 | #region Private Members 18 | 19 | private Rectangle _Part_SpectrumDisplay; 20 | private LinearGradientBrush _pickerBrush; 21 | 22 | #endregion Private Members 23 | 24 | #region Constructors 25 | 26 | /// 27 | /// Class constructor 28 | /// 29 | static ColorSpectrumSlider() 30 | { 31 | DefaultStyleKeyProperty.OverrideMetadata(typeof(ColorSpectrumSlider), new FrameworkPropertyMetadata(typeof(ColorSpectrumSlider))); 32 | } 33 | 34 | #endregion Constructors 35 | 36 | #region Dependency Properties 37 | 38 | public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorSpectrumSlider), new PropertyMetadata(System.Windows.Media.Colors.Transparent)); 39 | 40 | public Color SelectedColor 41 | { 42 | get 43 | { 44 | return (Color)GetValue(SelectedColorProperty); 45 | } 46 | set 47 | { 48 | SetValue(SelectedColorProperty, value); 49 | } 50 | } 51 | 52 | #endregion Dependency Properties 53 | 54 | #region Base Class Overrides 55 | 56 | public override void OnApplyTemplate() 57 | { 58 | base.OnApplyTemplate(); 59 | 60 | _Part_SpectrumDisplay = (Rectangle)GetTemplateChild(PART_SpectrumDisplay); 61 | 62 | if (_Part_SpectrumDisplay == null) 63 | return; 64 | 65 | CreateSpectrum(); 66 | OnValueChanged(Double.NaN, Value); 67 | } 68 | 69 | protected override void OnValueChanged(double oldValue, double newValue) 70 | { 71 | base.OnValueChanged(oldValue, newValue); 72 | 73 | Color color = HsvColor.RGBFromHSV(new HsvColor(359 - newValue, 1, 1)); 74 | SelectedColor = color; 75 | } 76 | 77 | #endregion Base Class Overrides 78 | 79 | #region Methods 80 | 81 | private void CreateSpectrum() 82 | { 83 | _pickerBrush = new LinearGradientBrush(); 84 | _pickerBrush.StartPoint = new Point(0.5, 0); 85 | _pickerBrush.EndPoint = new Point(0.5, 1); 86 | _pickerBrush.ColorInterpolationMode = ColorInterpolationMode.SRgbLinearInterpolation; 87 | 88 | List colorsList = ColorUtilities.GenerateHsvSpectrum(); 89 | 90 | double stopIncrement = (double)1 / colorsList.Count; 91 | 92 | int i; 93 | for (i = 0; i < colorsList.Count; i++) 94 | { 95 | _pickerBrush.GradientStops.Add(new GradientStop(colorsList[i], i * stopIncrement)); 96 | } 97 | 98 | _pickerBrush.GradientStops[i - 1].Offset = 1.0; 99 | _Part_SpectrumDisplay.Fill = _pickerBrush; 100 | } 101 | 102 | #endregion Methods 103 | } 104 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Controls/SliderRepeatButtonStyle.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | -------------------------------------------------------------------------------- /source/ColorPickerLib/Controls/VerticalSlideThumbTemplate.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 78 | -------------------------------------------------------------------------------- /source/ColorPickerLib/Converters/CenterTitleConverter.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Converters 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | 9 | public class CenterTitleConverter : IMultiValueConverter 10 | { 11 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | // Parameters: DesiredSize, WindowWidth, HeaderColumns 14 | double titleTextWidth = ((Size)values[0]).Width; 15 | double windowWidth = (double)values[1]; 16 | 17 | ColumnDefinitionCollection headerColumns = (ColumnDefinitionCollection)values[2]; 18 | double titleColWidth = headerColumns[2].ActualWidth; 19 | double buttonsColWidth = headerColumns[3].ActualWidth; 20 | 21 | // Result (1) Title is Centered across all HeaderColumns 22 | if ((titleTextWidth + buttonsColWidth * 2) < windowWidth) 23 | return 1; 24 | 25 | // Result (2) Title is Centered in HeaderColumns[2] 26 | if (titleTextWidth < titleColWidth) 27 | return 2; 28 | 29 | // Result (3) Title is Left-Aligned in HeaderColumns[2] 30 | return 3; 31 | } 32 | 33 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 34 | { 35 | throw new NotImplementedException(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Converters/ColorToSolidColorBrushConverter.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Converters 2 | { 3 | using System; 4 | using System.Windows.Data; 5 | using System.Windows.Media; 6 | 7 | public class ColorToSolidColorBrushConverter : IValueConverter 8 | { 9 | #region IValueConverter Members 10 | 11 | /// 12 | /// Converts a Color to a SolidColorBrush. 13 | /// 14 | /// The Color produced by the binding source. 15 | /// The type of the binding target property. 16 | /// The converter parameter to use. 17 | /// The culture to use in the converter. 18 | /// 19 | /// A converted SolidColorBrush. If the method returns null, the valid null value is used. 20 | /// 21 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 22 | { 23 | if (value != null) 24 | return new SolidColorBrush((Color)value); 25 | 26 | return value; 27 | } 28 | 29 | /// 30 | /// Converts a SolidColorBrush to a Color. 31 | /// 32 | /// Currently not used in toolkit, but provided for developer use in their own projects 33 | /// The SolidColorBrush that is produced by the binding target. 34 | /// The type to convert to. 35 | /// The converter parameter to use. 36 | /// The culture to use in the converter. 37 | /// 38 | /// A converted value. If the method returns null, the valid null value is used. 39 | /// 40 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 41 | { 42 | if (value != null) 43 | return ((SolidColorBrush)value).Color; 44 | 45 | return value; 46 | } 47 | 48 | #endregion IValueConverter Members 49 | } 50 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Converters/InverseBoolConverter.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Converters 2 | { 3 | using System; 4 | using System.Windows.Data; 5 | 6 | public class InverseBoolConverter : IValueConverter 7 | { 8 | #region IValueConverter Members 9 | 10 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 11 | { 12 | return !(bool)value; 13 | } 14 | 15 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 16 | { 17 | throw new NotImplementedException(); 18 | } 19 | 20 | #endregion IValueConverter Members 21 | } 22 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Converters/WindowContentBorderMarginConverter.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Converters 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows 6 | ; 7 | using System.Windows.Data; 8 | 9 | /// 10 | /// Sets the margin for the thumb grip, the top buttons, or for the content border in the WindowControl. 11 | /// 12 | public class WindowContentBorderMarginConverter : IMultiValueConverter 13 | { 14 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | double horizontalContentBorderOffset = (double)values[0]; 17 | double verticalContentBorderOffset = (double)values[1]; 18 | 19 | switch ((string)parameter) 20 | { 21 | // Content Border Margin in the WindowControl 22 | case "0": 23 | return new Thickness(horizontalContentBorderOffset 24 | , 0d 25 | , horizontalContentBorderOffset 26 | , verticalContentBorderOffset); 27 | // Thumb Grip Margin in the WindowControl 28 | case "1": 29 | return new Thickness(0d 30 | , 0d 31 | , horizontalContentBorderOffset 32 | , verticalContentBorderOffset); 33 | // Header Buttons Margin in the WindowControl 34 | case "2": 35 | return new Thickness(0d 36 | , 0d 37 | , horizontalContentBorderOffset 38 | , 0d); 39 | 40 | default: 41 | throw new NotSupportedException("'parameter' for WindowContentBorderMarginConverter is not valid."); 42 | } 43 | } 44 | 45 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 46 | { 47 | throw new NotImplementedException(); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Converters/WindowControlBackgroundConverter.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Converters 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows.Data; 6 | using System.Windows.Media; 7 | 8 | public class WindowControlBackgroundConverter : IMultiValueConverter 9 | { 10 | /// 11 | /// Used in the WindowContainer Template to calculate the resulting background brush 12 | /// from the WindowBackground (values[0]) and WindowOpacity (values[1]) propreties. 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | /// 19 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | Brush backgroundColor = (Brush)values[0]; 22 | double opacity = (double)values[1]; 23 | 24 | if (backgroundColor != null) 25 | { 26 | // Do not override any possible opacity value specifically set by the user. 27 | // Only use WindowOpacity value if the user did not set an opacity first. 28 | if (backgroundColor.ReadLocalValue(Brush.OpacityProperty) == System.Windows.DependencyProperty.UnsetValue) 29 | { 30 | backgroundColor = backgroundColor.Clone(); 31 | backgroundColor.Opacity = opacity; 32 | } 33 | } 34 | return backgroundColor; 35 | } 36 | 37 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 38 | { 39 | throw new NotImplementedException(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Core/Input/IValidateInput.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Core.Input 2 | { 3 | public interface IValidateInput 4 | { 5 | event InputValidationErrorEventHandler InputValidationError; 6 | 7 | bool CommitInput(); 8 | } 9 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Core/Input/InputValidationErrorEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Core.Input 2 | { 3 | using System; 4 | 5 | public delegate void InputValidationErrorEventHandler(object sender, InputValidationErrorEventArgs e); 6 | 7 | public class InputValidationErrorEventArgs : EventArgs 8 | { 9 | #region Constructors 10 | 11 | public InputValidationErrorEventArgs(Exception e) 12 | { 13 | Exception = e; 14 | } 15 | 16 | #endregion Constructors 17 | 18 | #region Exception Property 19 | 20 | public Exception Exception 21 | { 22 | get 23 | { 24 | return exception; 25 | } 26 | private set 27 | { 28 | exception = value; 29 | } 30 | } 31 | 32 | private Exception exception; 33 | 34 | #endregion Exception Property 35 | 36 | #region ThrowException Property 37 | 38 | public bool ThrowException 39 | { 40 | get 41 | { 42 | return _throwException; 43 | } 44 | set 45 | { 46 | _throwException = value; 47 | } 48 | } 49 | 50 | private bool _throwException; 51 | 52 | #endregion ThrowException Property 53 | } 54 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Core/Input/KeyModifier.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Core.Input 2 | { 3 | public enum KeyModifier 4 | { 5 | None, 6 | Blocked, 7 | Ctrl, 8 | LeftCtrl, 9 | RightCtrl, 10 | Shift, 11 | LeftShift, 12 | RightShift, 13 | Alt, 14 | LeftAlt, 15 | RightAlt, 16 | Exact, 17 | } 18 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Core/Input/KeyModifierCollectionConverter.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Core.Input 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | using System.ComponentModel.Design.Serialization; 6 | using System.Globalization; 7 | using System.Reflection; 8 | using System.Security; 9 | 10 | public sealed class KeyModifierCollectionConverter : TypeConverter 11 | { 12 | #region Static Fields 13 | 14 | private static readonly TypeConverter _keyModifierConverter = TypeDescriptor.GetConverter(typeof(KeyModifier)); 15 | 16 | #endregion Static Fields 17 | 18 | public override bool CanConvertFrom(ITypeDescriptorContext typeDescriptorContext, Type type) 19 | { 20 | return _keyModifierConverter.CanConvertFrom(typeDescriptorContext, type); 21 | } 22 | 23 | public override bool CanConvertTo(ITypeDescriptorContext typeDescriptorContext, Type type) 24 | { 25 | return (type == typeof(InstanceDescriptor) 26 | || type == typeof(KeyModifierCollection) 27 | || type == typeof(string)); 28 | } 29 | 30 | public override object ConvertFrom(ITypeDescriptorContext typeDescriptorContext, 31 | CultureInfo cultureInfo, object value) 32 | { 33 | KeyModifierCollection result = new KeyModifierCollection(); 34 | string stringValue = value as string; 35 | 36 | // convert null as None 37 | if (value == null 38 | || (stringValue != null && stringValue.Trim() == string.Empty)) 39 | { 40 | result.Add(KeyModifier.None); 41 | } 42 | else 43 | { 44 | // respect the following separators: '+', ' ', '|', or ',' 45 | foreach (string token in stringValue.Split(new char[] { '+', ' ', '|', ',' }, 46 | StringSplitOptions.RemoveEmptyEntries)) 47 | result.Add((KeyModifier)_keyModifierConverter.ConvertFrom(typeDescriptorContext, cultureInfo, token)); 48 | 49 | // if nothing added, assume None 50 | if (result.Count == 0) 51 | result.Add(KeyModifier.None); 52 | } 53 | return result; 54 | } 55 | 56 | public override object ConvertTo(ITypeDescriptorContext typeDescriptorContext, 57 | CultureInfo cultureInfo, object value, Type destinationType) 58 | { 59 | // special handling for null or an empty collection 60 | if (value == null || ((KeyModifierCollection)value).Count == 0) 61 | { 62 | if (destinationType == typeof(InstanceDescriptor)) 63 | { 64 | object result = null; 65 | try 66 | { 67 | result = ConstructInstanceDescriptor(); 68 | } 69 | catch (SecurityException) 70 | { 71 | } 72 | return result; 73 | } 74 | else if (destinationType == typeof(string)) 75 | { 76 | return _keyModifierConverter.ConvertTo(typeDescriptorContext, 77 | cultureInfo, KeyModifier.None, destinationType); 78 | } 79 | } 80 | 81 | // return a '+' delimited string containing the modifiers 82 | if (destinationType == typeof(string)) 83 | { 84 | string result = string.Empty; 85 | foreach (KeyModifier modifier in (KeyModifierCollection)value) 86 | { 87 | if (result != string.Empty) 88 | result = result + '+'; 89 | 90 | result = result + _keyModifierConverter.ConvertTo(typeDescriptorContext, 91 | cultureInfo, modifier, destinationType); 92 | } 93 | return result; 94 | } 95 | 96 | // unexpected type requested so return null 97 | return null; 98 | } 99 | 100 | private static object ConstructInstanceDescriptor() 101 | { 102 | ConstructorInfo ci = typeof(KeyModifierCollection).GetConstructor(new Type[] { }); 103 | return new InstanceDescriptor(ci, new Object[] { }); 104 | } 105 | } 106 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Core/Media/WindowColors.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Core.Media 2 | { 3 | using System; 4 | using System.Windows.Media; 5 | 6 | /// 7 | /// Contains system colors and configurations that can be used by the control themes. 8 | /// 9 | /// Mainly extracted from the registry because theses values are not exposed by the standard .NET API. 10 | /// 11 | public static class WindowColors 12 | { 13 | private static Color? _colorizationMode; 14 | private static bool? _colorizationOpaqueBlend; 15 | 16 | /// 17 | /// Relative to the \HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM\ColorizationColor Registry key. 18 | /// 19 | /// Gets the window chrome color. 20 | /// 21 | public static Color ColorizationColor 22 | { 23 | get 24 | { 25 | if (_colorizationMode.HasValue) 26 | return _colorizationMode.Value; 27 | 28 | try 29 | { 30 | _colorizationMode = WindowColors.GetDWMColorValue("ColorizationColor"); 31 | } 32 | catch 33 | { 34 | // If for any reason (for example, a SecurityException for XBAP apps) 35 | // we cannot read the value in the registry, fall back on some color. 36 | _colorizationMode = Color.FromArgb(255, 175, 175, 175); 37 | } 38 | 39 | return _colorizationMode.Value; 40 | } 41 | } 42 | 43 | /// 44 | /// Relative to the \HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM\ColorizationOpaqueBlend Registry key: 45 | /// 46 | /// Gets whether transparency is disabled. 47 | /// 48 | /// Returns true if transparency is disabled; false otherwise. 49 | /// 50 | public static bool ColorizationOpaqueBlend 51 | { 52 | get 53 | { 54 | if (_colorizationOpaqueBlend.HasValue) 55 | return _colorizationOpaqueBlend.Value; 56 | 57 | try 58 | { 59 | _colorizationOpaqueBlend = WindowColors.GetDWMBoolValue("ColorizationOpaqueBlend"); 60 | } 61 | catch 62 | { 63 | // If for any reason (for example, a SecurityException for XBAP apps) 64 | // we cannot read the value in the registry, fall back on some color. 65 | _colorizationOpaqueBlend = false; 66 | } 67 | 68 | return _colorizationOpaqueBlend.Value; 69 | } 70 | } 71 | 72 | private static int GetDWMIntValue(string keyName) 73 | { 74 | // This value is not accessible throught the standard WPF API. 75 | // We must dig into the registry to get the value. 76 | var curUser = Microsoft.Win32.Registry.CurrentUser; 77 | var subKey = curUser.CreateSubKey( 78 | @"Software\Microsoft\Windows\DWM", 79 | Microsoft.Win32.RegistryKeyPermissionCheck.ReadSubTree 80 | #if VS2008 81 | ); 82 | #else 83 | , Microsoft.Win32.RegistryOptions.None); 84 | #endif 85 | return (int)subKey.GetValue(keyName); 86 | } 87 | 88 | private static Color GetDWMColorValue(string keyName) 89 | { 90 | int value = WindowColors.GetDWMIntValue(keyName); 91 | byte[] bytes = BitConverter.GetBytes(value); 92 | return new Color() 93 | { 94 | B = bytes[0], 95 | G = bytes[1], 96 | R = bytes[2], 97 | A = 255 98 | }; 99 | } 100 | 101 | private static bool GetDWMBoolValue(string keyName) 102 | { 103 | int value = WindowColors.GetDWMIntValue(keyName); 104 | return (value != 0); 105 | } 106 | } 107 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Core/Utilities/KeyboardUtilities.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Core.Utilities 2 | { 3 | using System.Windows.Input; 4 | 5 | internal class KeyboardUtilities 6 | { 7 | internal static bool IsKeyModifyingPopupState(KeyEventArgs e) 8 | { 9 | return ((((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) && ((e.SystemKey == Key.Down) || (e.SystemKey == Key.Up))) 10 | || (e.Key == Key.F4)); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Core/Utilities/ValueChangeHelper.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Core.Utilities 2 | { 3 | using System; 4 | using System.Collections; 5 | using System.Windows; 6 | using System.Windows.Data; 7 | 8 | /// 9 | /// This helper class will raise events when a specific 10 | /// path value on one or many items changes. 11 | /// 12 | internal class ValueChangeHelper : DependencyObject 13 | { 14 | #region Value Property 15 | 16 | /// 17 | /// This private property serves as the target of a binding that monitors the value of the binding 18 | /// of each item in the source. 19 | /// 20 | private static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(object), typeof(ValueChangeHelper), new UIPropertyMetadata(null, OnValueChanged)); 21 | 22 | private object Value 23 | { 24 | get 25 | { 26 | return (object)GetValue(ValueProperty); 27 | } 28 | set 29 | { 30 | SetValue(ValueProperty, value); 31 | } 32 | } 33 | 34 | private static void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) 35 | { 36 | ((ValueChangeHelper)sender).RaiseValueChanged(); 37 | } 38 | 39 | #endregion Value Property 40 | 41 | public event EventHandler ValueChanged; 42 | 43 | #region Constructor 44 | 45 | public ValueChangeHelper(Action changeCallback) 46 | { 47 | if (changeCallback == null) 48 | throw new ArgumentNullException("changeCallback"); 49 | 50 | this.ValueChanged += (s, args) => changeCallback(); 51 | } 52 | 53 | #endregion Constructor 54 | 55 | #region Methods 56 | 57 | public void UpdateValueSource(object sourceItem, string path) 58 | { 59 | BindingBase binding = null; 60 | if (sourceItem != null && path != null) 61 | { 62 | binding = new Binding(path) { Source = sourceItem }; 63 | } 64 | 65 | this.UpdateBinding(binding); 66 | } 67 | 68 | public void UpdateValueSource(IEnumerable sourceItems, string path) 69 | { 70 | BindingBase binding = null; 71 | if (sourceItems != null && path != null) 72 | { 73 | MultiBinding multiBinding = new MultiBinding(); 74 | multiBinding.Converter = new BlankMultiValueConverter(); 75 | 76 | foreach (var item in sourceItems) 77 | { 78 | multiBinding.Bindings.Add(new Binding(path) { Source = item }); 79 | } 80 | 81 | binding = multiBinding; 82 | } 83 | 84 | this.UpdateBinding(binding); 85 | } 86 | 87 | private void UpdateBinding(BindingBase binding) 88 | { 89 | if (binding != null) 90 | { 91 | BindingOperations.SetBinding(this, ValueChangeHelper.ValueProperty, binding); 92 | } 93 | else 94 | { 95 | this.ClearBinding(); 96 | } 97 | } 98 | 99 | private void ClearBinding() 100 | { 101 | BindingOperations.ClearBinding(this, ValueChangeHelper.ValueProperty); 102 | } 103 | 104 | private void RaiseValueChanged() 105 | { 106 | if (this.ValueChanged != null) 107 | { 108 | this.ValueChanged(this, EventArgs.Empty); 109 | } 110 | } 111 | 112 | #endregion Methods 113 | 114 | #region BlankMultiValueConverter private class 115 | 116 | private class BlankMultiValueConverter : IMultiValueConverter 117 | { 118 | public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) 119 | { 120 | // We will not use the result anyway. We just want the change notification to kick in. 121 | // Return a new object to have a different value. 122 | return new object(); 123 | } 124 | 125 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) 126 | { 127 | throw new InvalidOperationException(); 128 | } 129 | } 130 | 131 | #endregion BlankMultiValueConverter private class 132 | } 133 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Localized/Strings.de-DE.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/ColorPickerLib/9af9f0ba1f262eed85ea0b949b5be2dcf099032c/source/ColorPickerLib/Localized/Strings.de-DE.Designer.cs -------------------------------------------------------------------------------- /source/ColorPickerLib/Localized/Strings.es-ES.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/ColorPickerLib/9af9f0ba1f262eed85ea0b949b5be2dcf099032c/source/ColorPickerLib/Localized/Strings.es-ES.Designer.cs -------------------------------------------------------------------------------- /source/ColorPickerLib/Localized/Strings.fr-FR.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/ColorPickerLib/9af9f0ba1f262eed85ea0b949b5be2dcf099032c/source/ColorPickerLib/Localized/Strings.fr-FR.Designer.cs -------------------------------------------------------------------------------- /source/ColorPickerLib/Localized/Strings.hi.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/ColorPickerLib/9af9f0ba1f262eed85ea0b949b5be2dcf099032c/source/ColorPickerLib/Localized/Strings.hi.Designer.cs -------------------------------------------------------------------------------- /source/ColorPickerLib/Localized/Strings.id-ID.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/ColorPickerLib/9af9f0ba1f262eed85ea0b949b5be2dcf099032c/source/ColorPickerLib/Localized/Strings.id-ID.Designer.cs -------------------------------------------------------------------------------- /source/ColorPickerLib/Localized/Strings.it-IT.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/ColorPickerLib/9af9f0ba1f262eed85ea0b949b5be2dcf099032c/source/ColorPickerLib/Localized/Strings.it-IT.Designer.cs -------------------------------------------------------------------------------- /source/ColorPickerLib/Localized/Strings.ja-JP.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/ColorPickerLib/9af9f0ba1f262eed85ea0b949b5be2dcf099032c/source/ColorPickerLib/Localized/Strings.ja-JP.Designer.cs -------------------------------------------------------------------------------- /source/ColorPickerLib/Localized/Strings.nl-NL.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/ColorPickerLib/9af9f0ba1f262eed85ea0b949b5be2dcf099032c/source/ColorPickerLib/Localized/Strings.nl-NL.Designer.cs -------------------------------------------------------------------------------- /source/ColorPickerLib/Localized/Strings.zh-CHS.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/ColorPickerLib/9af9f0ba1f262eed85ea0b949b5be2dcf099032c/source/ColorPickerLib/Localized/Strings.zh-CHS.Designer.cs -------------------------------------------------------------------------------- /source/ColorPickerLib/Localized/Strings.zh-CHT.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/ColorPickerLib/9af9f0ba1f262eed85ea0b949b5be2dcf099032c/source/ColorPickerLib/Localized/Strings.zh-CHT.Designer.cs -------------------------------------------------------------------------------- /source/ColorPickerLib/Models/ColorItem.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Models 2 | { 3 | using System.Windows.Media; 4 | 5 | /// 6 | /// Model a color with a color value and name. 7 | /// 8 | public class ColorItem 9 | { 10 | /// 11 | /// Class constructor 12 | /// 13 | /// 14 | /// 15 | public ColorItem(Color? color, string name) 16 | { 17 | Color = color; 18 | Name = name; 19 | } 20 | 21 | /// 22 | /// Gets/sets the color value of this item. 23 | /// 24 | public Color? Color 25 | { 26 | get; 27 | set; 28 | } 29 | 30 | /// 31 | /// Gets/sets the name of this item. 32 | /// 33 | public string Name 34 | { 35 | get; 36 | set; 37 | } 38 | 39 | /// 40 | /// Standard object method to compute equality between 2 color items. 41 | /// 42 | /// 43 | /// 44 | public override bool Equals(object obj) 45 | { 46 | var ci = obj as ColorItem; 47 | if (ci == null) 48 | return false; 49 | 50 | return (ci.Color.Equals(Color) && ci.Name.Equals(Name)); 51 | } 52 | 53 | /// 54 | /// Serves as a hash function. 55 | /// 56 | /// 57 | public override int GetHashCode() 58 | { 59 | return this.Color.GetHashCode() ^ this.Name.GetHashCode(); 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Models/ColorSorter.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Models 2 | { 3 | using System; 4 | using System.Collections; 5 | 6 | /// 7 | /// Class exposes a method that compares two objects. 8 | /// 9 | internal class ColorSorter : IComparer 10 | { 11 | /// 12 | /// Method compares 2 objects and returns an int value to indicate equality, 13 | /// less, or greater value. 14 | /// 15 | /// 16 | /// 17 | /// 18 | public int Compare(object firstItem, object secondItem) 19 | { 20 | if (firstItem == null || secondItem == null) 21 | return -1; 22 | 23 | ColorItem colorItem1 = (ColorItem)firstItem; 24 | ColorItem colorItem2 = (ColorItem)secondItem; 25 | 26 | if ((colorItem1.Color == null) || !colorItem1.Color.HasValue || 27 | (colorItem2.Color == null) || !colorItem2.Color.HasValue) 28 | return -1; 29 | 30 | System.Drawing.Color drawingColor1 = System.Drawing.Color.FromArgb(colorItem1.Color.Value.A, colorItem1.Color.Value.R, colorItem1.Color.Value.G, colorItem1.Color.Value.B); 31 | System.Drawing.Color drawingColor2 = System.Drawing.Color.FromArgb(colorItem2.Color.Value.A, colorItem2.Color.Value.R, colorItem2.Color.Value.G, colorItem2.Color.Value.B); 32 | 33 | // Compare Hue 34 | double hueColor1 = Math.Round((double)drawingColor1.GetHue(), 3); 35 | double hueColor2 = Math.Round((double)drawingColor2.GetHue(), 3); 36 | 37 | if (hueColor1 > hueColor2) 38 | return 1; 39 | else if (hueColor1 < hueColor2) 40 | return -1; 41 | else 42 | { 43 | // Hue is equal, compare Saturation 44 | double satColor1 = Math.Round((double)drawingColor1.GetSaturation(), 3); 45 | double satColor2 = Math.Round((double)drawingColor2.GetSaturation(), 3); 46 | 47 | if (satColor1 > satColor2) 48 | return 1; 49 | else if (satColor1 < satColor2) 50 | return -1; 51 | else 52 | { 53 | // Saturation is equal, compare Brightness 54 | double brightColor1 = Math.Round((double)drawingColor1.GetBrightness(), 3); 55 | double brightColor2 = Math.Round((double)drawingColor2.GetBrightness(), 3); 56 | 57 | if (brightColor1 > brightColor2) 58 | return 1; 59 | else if (brightColor1 < brightColor2) 60 | return -1; 61 | } 62 | } 63 | 64 | return 0; 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Primitives/HsvColor.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Primitives 2 | { 3 | using System; 4 | using System.Windows.Media; 5 | 6 | /// 7 | /// Class models a color using the HSV (Hue, Saturation, Value) color space 8 | /// instead of RGB values generally used for the RGB (Red, Green, Blue) color space. 9 | /// 10 | internal class HsvColor 11 | { 12 | /// 13 | /// Class constructor. 14 | /// 15 | /// 16 | /// 17 | /// 18 | public HsvColor(double hue, 19 | double saturation, 20 | double value) 21 | { 22 | if (hue < 0) 23 | throw new ArgumentOutOfRangeException(string.Format("Hue: {0}", hue)); 24 | 25 | if (hue > 360) 26 | { 27 | hue = ((int)hue) % 360; 28 | 29 | if (hue > 359) 30 | hue = 359; 31 | } 32 | 33 | if (saturation < 0 || saturation > 1.0) 34 | throw new ArgumentOutOfRangeException(string.Format("Saturation: {0}", saturation)); 35 | 36 | if (value < 0 || value > 1.0) 37 | throw new ArgumentOutOfRangeException(string.Format("Value: {0}", value)); 38 | 39 | this.Hue = hue; 40 | this.Saturation = saturation; 41 | this.Value = value; 42 | } 43 | 44 | /// 45 | /// Gets/sets the Hue (H) component of the HSV color space object. 46 | /// 47 | public double Hue { get; protected set; } 48 | 49 | /// 50 | /// Gets/sets the Saturation (S) component of the HSV color space object. 51 | /// 52 | public double Saturation { get; protected set; } 53 | 54 | /// 55 | /// Gets/sets the Value (V) component of the HSV color space object. 56 | /// 57 | public double Value { get; protected set; } 58 | 59 | /// 60 | /// Converts the given RGB color values into a HSV color. 61 | /// 62 | /// 63 | /// 64 | public static HsvColor RGBToHSV(Color? color) 65 | { 66 | if (color is null) 67 | return new HsvColor(0, 0, 0); 68 | 69 | System.Drawing.Color convColor = System.Drawing.Color.FromArgb(color.Value.A, 70 | color.Value.R, 71 | color.Value.G, 72 | color.Value.B); 73 | 74 | int max = Math.Max(convColor.R, Math.Max(convColor.G, convColor.B)); 75 | int min = Math.Min(convColor.R, Math.Min(convColor.G, convColor.B)); 76 | 77 | double hue = convColor.GetHue(); 78 | if (hue > 359) 79 | hue = 359; 80 | 81 | double saturation = (max == 0) ? 0 : 1d - (1d * min / max); 82 | double value = max / 255d; 83 | 84 | return new HsvColor(hue, saturation, value); 85 | } 86 | 87 | /// 88 | /// Converts the given HSV color values into a RGB color. 89 | /// 90 | /// 91 | /// 92 | public static Color RGBFromHSV(HsvColor hsvColor) 93 | { 94 | int hi = Convert.ToInt32(Math.Floor(hsvColor.Hue / 60)) % 6; 95 | double f = hsvColor.Hue / 60 - Math.Floor(hsvColor.Hue / 60); 96 | 97 | double value = hsvColor.Value * 255; 98 | byte v = Convert.ToByte(value); 99 | byte p = Convert.ToByte(value * (1 - hsvColor.Saturation)); 100 | byte q = Convert.ToByte(value * (1 - f * hsvColor.Saturation)); 101 | byte t = Convert.ToByte(value * (1 - (1 - f) * hsvColor.Saturation)); 102 | 103 | if (hi == 0) 104 | return Color.FromArgb(255, v, t, p); 105 | else if (hi == 1) 106 | return Color.FromArgb(255, q, v, p); 107 | else if (hi == 2) 108 | return Color.FromArgb(255, p, v, t); 109 | else if (hi == 3) 110 | return Color.FromArgb(255, p, q, v); 111 | else if (hi == 4) 112 | return Color.FromArgb(255, t, p, v); 113 | else 114 | return Color.FromArgb(255, v, p, q); 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Primitives/MouseWheelActiveTrigger.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Primitives 2 | { 3 | /// 4 | /// Specify when the mouse wheel is active. 5 | /// 6 | public enum MouseWheelActiveTrigger 7 | { 8 | Focused, 9 | FocusedMouseOver, 10 | MouseOver, 11 | Disabled 12 | } 13 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Primitives/SelectorItem.cs: -------------------------------------------------------------------------------- 1 | namespace ColorPickerLib.Primitives 2 | { 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | 6 | public class SelectorItem : ContentControl 7 | { 8 | #region Constructors 9 | 10 | static SelectorItem() 11 | { 12 | DefaultStyleKeyProperty.OverrideMetadata(typeof(SelectorItem), new FrameworkPropertyMetadata(typeof(SelectorItem))); 13 | } 14 | 15 | #endregion Constructors 16 | 17 | #region Properties 18 | 19 | public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(SelectorItem), new UIPropertyMetadata(false, OnIsSelectedChanged)); 20 | 21 | public bool IsSelected 22 | { 23 | get 24 | { 25 | return (bool)GetValue(IsSelectedProperty); 26 | } 27 | set 28 | { 29 | SetValue(IsSelectedProperty, value); 30 | } 31 | } 32 | 33 | private static void OnIsSelectedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) 34 | { 35 | SelectorItem selectorItem = o as SelectorItem; 36 | if (selectorItem != null) 37 | selectorItem.OnIsSelectedChanged((bool)e.OldValue, (bool)e.NewValue); 38 | } 39 | 40 | protected virtual void OnIsSelectedChanged(bool oldValue, bool newValue) 41 | { 42 | if (newValue) 43 | this.RaiseEvent(new RoutedEventArgs(Selector.SelectedEvent, this)); 44 | else 45 | this.RaiseEvent(new RoutedEventArgs(Selector.UnSelectedEvent, this)); 46 | } 47 | 48 | internal Selector ParentSelector 49 | { 50 | get 51 | { 52 | return ItemsControl.ItemsControlFromItemContainer(this) as Selector; 53 | } 54 | } 55 | 56 | #endregion Properties 57 | 58 | #region Events 59 | 60 | public static readonly RoutedEvent SelectedEvent = Selector.SelectedEvent.AddOwner(typeof(SelectorItem)); 61 | public static readonly RoutedEvent UnselectedEvent = Selector.UnSelectedEvent.AddOwner(typeof(SelectorItem)); 62 | 63 | #endregion Events 64 | } 65 | } -------------------------------------------------------------------------------- /source/ColorPickerLib/Primitives/Themes/Generic/SelectorItem.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 10 | 49 | -------------------------------------------------------------------------------- /source/ColorPickerLib/Resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/ColorPickerLib/9af9f0ba1f262eed85ea0b949b5be2dcf099032c/source/ColorPickerLib/Resources/icon.png -------------------------------------------------------------------------------- /source/ColorPickerLib/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /source/ColorPickerLib/Themes/Generic/Glyphs.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | M 0,3 C0,3 0,4 0,4 0,4 3,4 3,4 3,4 3,3 3,3 3,3 4,3 4,3 4,3 4,4 4,4 4,4 7,4 7,4 7,4 7,3 7,3 7,3 6,3 6,3 6,3 6,2 6,2 6,2 5,2 5,2 5,2 5,1 5,1 5,1 4,1 4,1 4,1 4,0 4,0 4,0 3,0 3,0 3,0 3,1 3,1 3,1 2,1 2,1 2,1 2,2 2,2 2,2 1,2 1,2 1,2 1,3 1,3 1,3 0,3 0,3 z 7 | M 0,1 C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1 z 8 | 9 | 10 | 19 | 20 | 21 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 54 | 55 | -------------------------------------------------------------------------------- /source/MLibTest/Components/ServiceLocator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ServiceLocator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("HP")] 12 | [assembly: AssemblyProduct("ServiceLocator")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2516097b-2435-44a4-a9b8-9899bca81a6e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /source/MLibTest/Components/ServiceLocator/ServiceContainer.cs: -------------------------------------------------------------------------------- 1 | namespace ServiceLocator 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | /// 7 | /// Source: http://www.codeproject.com/Articles/70223/Using-a-Service-Locator-to-Work-with-MessageBoxes 8 | /// 9 | public class ServiceContainer 10 | { 11 | #region fields 12 | 13 | public static readonly ServiceContainer Instance = new ServiceContainer(); 14 | 15 | private readonly Dictionary _serviceMap; 16 | private readonly object _serviceMapLock; 17 | 18 | #endregion fields 19 | 20 | #region constructors 21 | 22 | /// 23 | /// Class Constructor 24 | /// 25 | private ServiceContainer() 26 | { 27 | _serviceMap = new Dictionary(); 28 | _serviceMapLock = new object(); 29 | } 30 | 31 | #endregion constructors 32 | 33 | #region methods 34 | 35 | public void AddService(TServiceContract implementation) 36 | where TServiceContract : class 37 | { 38 | lock (_serviceMapLock) 39 | { 40 | _serviceMap[typeof(TServiceContract)] = implementation; 41 | } 42 | } 43 | 44 | public TServiceContract GetService() 45 | where TServiceContract : class 46 | { 47 | object service; 48 | lock (_serviceMapLock) 49 | { 50 | _serviceMap.TryGetValue(typeof(TServiceContract), out service); 51 | } 52 | 53 | return service as TServiceContract; 54 | } 55 | 56 | #endregion methods 57 | } 58 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/ServiceLocator/ServiceLocator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {252126D1-E1D9-49C3-910B-FCF2266265EF} 8 | Library 9 | Properties 10 | ServiceLocator 11 | ServiceLocator 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | true 34 | bin\x64\Debug\ 35 | DEBUG;TRACE 36 | full 37 | x64 38 | prompt 39 | MinimumRecommendedRules.ruleset 40 | 41 | 42 | bin\x64\Release\ 43 | TRACE 44 | true 45 | pdbonly 46 | x64 47 | prompt 48 | MinimumRecommendedRules.ruleset 49 | 50 | 51 | true 52 | bin\x86\Debug\ 53 | DEBUG;TRACE 54 | full 55 | x86 56 | prompt 57 | MinimumRecommendedRules.ruleset 58 | 59 | 60 | bin\x86\Release\ 61 | TRACE 62 | true 63 | pdbonly 64 | x86 65 | prompt 66 | MinimumRecommendedRules.ruleset 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 87 | -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/Interfaces/IOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.Interfaces 2 | { 3 | public interface IOptions 4 | { 5 | #region properties 6 | 7 | bool IsDirty { get; set; } 8 | string LanguageSelected { get; set; } 9 | bool ReloadOpenFilesOnAppStart { get; set; } 10 | string SourceFilePath { get; set; } 11 | 12 | string DefaultSourceLanguage { get; set; } 13 | string DefaultTargetLanguage { get; set; } 14 | 15 | string DefaultDefaultSourceLanguage { get; } 16 | string DefaultDefaultTargetLanguage { get; } 17 | 18 | int DefaultIconSize { get; } 19 | int IconSizeMin { get; } 20 | int IconSizeMax { get; } 21 | 22 | int DefaultFontSize { get; } 23 | int FontSizeMin { get; } 24 | int FontSizeMax { get; } 25 | 26 | #endregion properties 27 | 28 | #region methods 29 | 30 | /// 31 | /// Reset the dirty flag (e.g. after saving program options when they where edit). 32 | /// 33 | /// 34 | void SetDirtyFlag(bool flag); 35 | 36 | void SetIconSize(int size); 37 | 38 | void SetFontSize(int size); 39 | 40 | #endregion methods 41 | } 42 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/Interfaces/IOptionsPanel.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.Interfaces 2 | { 3 | using SettingsModel.Interfaces; 4 | 5 | public interface IOptionsPanel 6 | { 7 | IEngine Options { get; } 8 | } 9 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/Interfaces/IProfile.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.Interfaces 2 | { 3 | using Settings.UserProfile; 4 | using SettingsModel.Models; 5 | using System.Collections.Generic; 6 | 7 | public interface IProfile 8 | { 9 | #region properties 10 | 11 | string GetLastActivePath(); 12 | 13 | string LastActiveSolution { get; set; } 14 | 15 | string LastActiveTargetFile { get; set; } 16 | 17 | List LastActiveSourceFiles { get; set; } 18 | 19 | /// 20 | /// Gets the key name of the MainWindow item in the collection. 21 | /// Ths name can be used as key in the WindowPosSz property 22 | /// to read and write MainWindow position and size information. 23 | /// 24 | string MainWindowName { get; } 25 | 26 | /// 27 | /// Gets a collection of window position and size items. 28 | /// 29 | SerializableDictionary WindowPosSz { get; } 30 | 31 | #endregion properties 32 | 33 | #region methods 34 | 35 | /// 36 | /// Checks the MainWindow for visibility when re-starting application 37 | /// (with different screen configuration). 38 | /// 39 | /// 40 | /// 41 | void CheckSettingsOnLoad(double SystemParameters_VirtualScreenLeft, double SystemParameters_VirtualScreenTop); 42 | 43 | /// 44 | /// Updates or inserts the requested window pos size item in the collection. 45 | /// 46 | /// 47 | /// 48 | /// 49 | void UpdateInsertWindowPosSize(string windowName, ViewPosSizeModel model); 50 | 51 | #endregion methods 52 | } 53 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/Interfaces/ISettingsManager.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.Interfaces 2 | { 3 | using MLib.Interfaces; 4 | using Settings.ProgramSettings; 5 | using System.Collections.Generic; 6 | using System.Xml.Serialization; 7 | 8 | public interface ISettingsManager : IOptionsPanel 9 | { 10 | void CheckSettingsOnLoad(double SystemParameters_VirtualScreenLeft, double SystemParameters_VirtualScreenTop); 11 | 12 | ////void LoadOptions(string settingsFileName); 13 | void LoadSessionData(string sessionDataFileName); 14 | 15 | ////bool SaveOptions(string settingsFileName, Settings.Interfaces.IOptions optionsModel); 16 | bool SaveSessionData(string sessionDataFileName, Settings.Interfaces.IProfile model); 17 | 18 | /// 19 | /// Get a list of all supported languages in Edi. 20 | /// 21 | /// 22 | IEnumerable GetSupportedLanguages(); 23 | 24 | #region properties 25 | 26 | Settings.Interfaces.IProfile SessionData { get; } 27 | 28 | int IconSizeMin { get; } 29 | int IconSizeMax { get; } 30 | 31 | int FontSizeMin { get; } 32 | int FontSizeMax { get; } 33 | 34 | /// 35 | /// Gets the default icon size for the application. 36 | /// 37 | int DefaultIconSize { get; } 38 | 39 | /// 40 | /// Gets the default font size for the application. 41 | /// 42 | int DefaultFontSize { get; } 43 | 44 | /// 45 | /// Gets the default fixed font size for the application. 46 | /// 47 | int DefaultFixedFontSize { get; } 48 | 49 | /// 50 | /// Gets the internal name and Uri source for all available themes. 51 | /// 52 | [XmlIgnore] 53 | IThemeInfos Themes { get; } 54 | 55 | #endregion properties 56 | } 57 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/Interfaces/IViewPosSizeModel.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.Interfaces 2 | { 3 | public interface IViewPosSizeModel 4 | { 5 | bool DefaultConstruct { get; } 6 | double Height { get; set; } 7 | bool IsMaximized { get; set; } 8 | double Width { get; set; } 9 | double X { get; set; } 10 | double Y { get; set; } 11 | 12 | void SetValidPos(double SystemParameters_VirtualScreenLeft, double SystemParameters_VirtualScreenTop); 13 | } 14 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/ProgramSettings/LanguageCollection.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.ProgramSettings 2 | { 3 | using System; 4 | 5 | /// 6 | /// Base class for enumeration over languages (and their locale) that 7 | /// are supported with specific (non-English) button and tool tip strings. 8 | /// 9 | /// The class definition is based on BCP 47 which in turn is used to 10 | /// set the UI and thread culture (which in turn selects the correct 11 | /// string resource in MsgBox assembly). 12 | /// 13 | public class LanguageCollection 14 | { 15 | public string Language { get; set; } 16 | public string Locale { get; set; } 17 | public string Name { get; set; } 18 | 19 | /// 20 | /// Get BCP47 language tag for this language 21 | /// See also http://en.wikipedia.org/wiki/IETF_language_tag 22 | /// 23 | public string BCP47 24 | { 25 | get 26 | { 27 | if (string.IsNullOrEmpty(Locale) == false) 28 | return String.Format("{0}-{1}", Language, Locale); 29 | else 30 | return String.Format("{0}", Language); 31 | } 32 | } 33 | 34 | /// 35 | /// Get BCP47 language tag for this language 36 | /// See also http://en.wikipedia.org/wiki/IETF_language_tag 37 | /// 38 | public string DisplayName 39 | { 40 | get 41 | { 42 | return String.Format("{0} {1}", Name, BCP47); 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/ProgramSettings/OptionsPanel.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.ProgramSettings 2 | { 3 | using Settings.Interfaces; 4 | using SettingsModel.Interfaces; 5 | using SettingsModel.Models; 6 | 7 | internal class OptionsPanel : IOptionsPanel 8 | { 9 | private IEngine mQuery = null; 10 | 11 | public OptionsPanel() 12 | { 13 | mQuery = Factory.CreateEngine(); 14 | } 15 | 16 | /// 17 | /// Gets the options that used to manage program options. 18 | /// 19 | public IEngine Options 20 | { 21 | get 22 | { 23 | return mQuery; 24 | } 25 | 26 | private set 27 | { 28 | mQuery = value; 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Settings")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("HP")] 12 | [assembly: AssemblyProduct("Settings")] 13 | [assembly: AssemblyCopyright("The MIT License (MIT) Copyright © 2013 - 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("7f13f2b5-a017-4045-8ead-f5496101a616")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/SerializableDictionary.cs: -------------------------------------------------------------------------------- 1 | namespace Settings 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Globalization; 6 | using System.Runtime.Serialization; 7 | using System.Xml; 8 | using System.Xml.Serialization; 9 | 10 | /// 11 | /// This class represents a serializable dictionary implementation 12 | /// of the standard generic dictionary class in .Net. 13 | /// 14 | /// Source: http://www.jankowskimichal.pl/en/2010/10/serializabledictionary/ 15 | /// 16 | [Serializable] 17 | public class SerializableDictionary : Dictionary, IXmlSerializable, ISerializable 18 | { 19 | #region Private Members 20 | 21 | private XmlSerializer _keySerializer; 22 | private XmlSerializer _valueSerializer; 23 | 24 | #endregion Private Members 25 | 26 | #region Constructors 27 | 28 | public SerializableDictionary() 29 | { 30 | } 31 | 32 | public SerializableDictionary(IDictionary dictionary) 33 | : base(dictionary) 34 | { 35 | } 36 | 37 | public SerializableDictionary(IEqualityComparer comparer) 38 | : base(comparer) 39 | { 40 | } 41 | 42 | public SerializableDictionary(int capacity) 43 | : base(capacity) 44 | { 45 | } 46 | 47 | public SerializableDictionary(IDictionary dictionary, IEqualityComparer comparer) 48 | : base(dictionary, comparer) 49 | { 50 | } 51 | 52 | public SerializableDictionary(int capacity, IEqualityComparer comparer) 53 | : base(capacity, comparer) 54 | { 55 | } 56 | 57 | #endregion Constructors 58 | 59 | #region Private Properties 60 | 61 | protected XmlSerializer ValueSerializer 62 | { 63 | get { return _valueSerializer ?? (_valueSerializer = new XmlSerializer(typeof(TVal))); } 64 | } 65 | 66 | private XmlSerializer KeySerializer 67 | { 68 | get { return _keySerializer ?? (_keySerializer = new XmlSerializer(typeof(TKey))); } 69 | } 70 | 71 | #endregion Private Properties 72 | 73 | #region ISerializable Members 74 | 75 | protected SerializableDictionary(SerializationInfo info, StreamingContext context) 76 | { 77 | int itemCount = info.GetInt32("itemsCount"); 78 | for (int i = 0; i < itemCount; i++) 79 | { 80 | KeyValuePair kvp = (KeyValuePair)info.GetValue(String.Format(CultureInfo.InvariantCulture, "Item{0}", i), typeof(KeyValuePair)); 81 | Add(kvp.Key, kvp.Value); 82 | } 83 | } 84 | 85 | void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) 86 | { 87 | info.AddValue("itemsCount", Count); 88 | int itemIdx = 0; 89 | foreach (KeyValuePair kvp in this) 90 | { 91 | info.AddValue(String.Format(CultureInfo.InvariantCulture, "Item{0}", itemIdx), kvp, typeof(KeyValuePair)); 92 | itemIdx++; 93 | } 94 | } 95 | 96 | #endregion ISerializable Members 97 | 98 | #region IXmlSerializable Members 99 | 100 | void IXmlSerializable.WriteXml(XmlWriter writer) 101 | { 102 | foreach (KeyValuePair kvp in this) 103 | { 104 | writer.WriteStartElement("item"); 105 | writer.WriteStartElement("key"); 106 | KeySerializer.Serialize(writer, kvp.Key); 107 | writer.WriteEndElement(); 108 | writer.WriteStartElement("value"); 109 | ValueSerializer.Serialize(writer, kvp.Value); 110 | writer.WriteEndElement(); 111 | writer.WriteEndElement(); 112 | } 113 | } 114 | 115 | void IXmlSerializable.ReadXml(XmlReader reader) 116 | { 117 | if (reader.IsEmptyElement) 118 | { 119 | return; 120 | } 121 | // Move past container 122 | if (reader.NodeType == XmlNodeType.Element && !reader.Read()) 123 | { 124 | throw new XmlException("Error in Deserialization of SerializableDictionary"); 125 | } 126 | while (reader.NodeType != XmlNodeType.EndElement) 127 | { 128 | reader.ReadStartElement("item"); 129 | reader.ReadStartElement("key"); 130 | TKey key = (TKey)KeySerializer.Deserialize(reader); 131 | reader.ReadEndElement(); 132 | reader.ReadStartElement("value"); 133 | TVal value = (TVal)ValueSerializer.Deserialize(reader); 134 | reader.ReadEndElement(); 135 | reader.ReadEndElement(); 136 | Add(key, value); 137 | reader.MoveToContent(); 138 | } 139 | // Move past container 140 | if (reader.NodeType == XmlNodeType.EndElement) 141 | { 142 | reader.ReadEndElement(); 143 | } 144 | else 145 | { 146 | throw new XmlException("Error in Deserialization of SerializableDictionary"); 147 | } 148 | } 149 | 150 | System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() 151 | { 152 | return null; 153 | } 154 | 155 | #endregion IXmlSerializable Members 156 | } 157 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/SettingsManager.cs: -------------------------------------------------------------------------------- 1 | namespace Settings 2 | { 3 | using MLib.Interfaces; 4 | using Settings.Interfaces; 5 | using Settings.Internal; 6 | 7 | /// 8 | /// Helper class to initialize an 9 | /// service interface. 10 | /// 11 | public sealed class SettingsManager 12 | { 13 | /// 14 | /// Hidden default constructor. 15 | /// 16 | private SettingsManager() 17 | { 18 | } 19 | 20 | /// 21 | /// Gets an instance of an object that implements the 22 | /// interface. 23 | /// 24 | /// 25 | public static ISettingsManager GetInstance(IThemeInfos themeInfos) 26 | { 27 | return new SettingsManagerImpl(themeInfos); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/UserProfile/IViewSize.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.UserProfile 2 | { 3 | using System.Windows; 4 | 5 | /// 6 | /// Provide an interface to implement saving and loading/repositioning of Window or view. 7 | /// 8 | public interface IViewSize 9 | { 10 | // 11 | // Zusammenfassung: 12 | // Ruft die Position des linken Fensterrands im Verhältnis zum Desktop ab oder legt 13 | // diese fest. 14 | // 15 | // Rückgabewerte: 16 | // Die Position des linken Fensterrands in logischen Einheiten (1/96 Zoll). 17 | double Left { get; set; } 18 | 19 | // 20 | // Zusammenfassung: 21 | // Ruft die Position des oberen Fensterrands im Verhältnis zum Desktop ab oder legt 22 | // diese fest. 23 | // 24 | // Rückgabewerte: 25 | // Die Position des oberen Fensterrands in logischen Einheiten (1/96 "). 26 | double Top { get; set; } 27 | 28 | // 29 | // Zusammenfassung: 30 | // Ruft die Breite des Elements ab bzw. legt diese fest. 31 | // 32 | // Rückgabewerte: 33 | // Die Breite des Elements in geräteunabhängige Einheiten (1/96th inch per unit).Der 34 | // Standardwert ist System.Double.NaN.Dieser Wert muss größer oder gleich 0,0 sein.In 35 | // den Hinweisen finden Sie Informationen über obere Grenzen. 36 | double Width { get; set; } 37 | 38 | // 39 | // Zusammenfassung: 40 | // Ruft die vorgeschlagene Höhe des Elements ab oder legt diese fest. 41 | // 42 | // Rückgabewerte: 43 | // Die Höhe des Elements in geräteunabhängige Einheiten (1/96th inch per unit).Der 44 | // Standardwert ist System.Double.NaN.Dieser Wert muss größer oder gleich 0,0 sein.In 45 | // den Hinweisen finden Sie Informationen über obere Grenzen. 46 | double Height { get; set; } 47 | 48 | // 49 | // Zusammenfassung: 50 | // Ruft einen Wert ab, der angibt, ob ein Fenster wiederhergestellt, minimiert oder 51 | // maximiert ist, oder legt diesen fest. 52 | // 53 | // Rückgabewerte: 54 | // Ein System.Windows.WindowState, der bestimmt, ob ein Fenster wiederhergestellt, 55 | // minimiert oder maximiert ist.Der Standardwert ist System.Windows.WindowState.Normal 56 | // (wiederhergestellt). 57 | WindowState WindowState { get; set; } 58 | } 59 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/UserProfile/LocalizabilityAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Settings.UserProfile 4 | { 5 | internal class LocalizabilityAttribute : Attribute 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/UserProfile/Profile.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.UserProfile 2 | { 3 | using Settings.Interfaces; 4 | using SettingsModel.Models; 5 | using System.Collections.Generic; 6 | using System.Xml.Serialization; 7 | 8 | /// 9 | /// This class implements the model of the user profile part 10 | /// of the application. Typically, users have implicit run-time 11 | /// settings that should be re-activated when the application 12 | /// is re-started at a later point in time (e.g. window size 13 | /// and position). 14 | /// 15 | /// This class organizes these per user specific profile settings 16 | /// and is responsible for their storage (at program end) and 17 | /// retrieval at the start-up of the application. 18 | /// 19 | public class Profile : IProfile 20 | { 21 | #region fields 22 | 23 | protected static readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 24 | 25 | #endregion fields 26 | 27 | #region constructor 28 | 29 | /// 30 | /// Class constructor 31 | /// 32 | public Profile() 33 | { 34 | // Session Data 35 | WindowPosSz = new SerializableDictionary(); 36 | WindowPosSz.Add(MainWindowName, new ViewPosSizeModel(ViewPosSizeModel.DefaultSize)); 37 | 38 | LastActiveSolution = LastActiveTargetFile = string.Empty; 39 | 40 | LastActiveSourceFiles = new List(); 41 | } 42 | 43 | #endregion constructor 44 | 45 | #region properties 46 | 47 | /// 48 | /// Gets the key name of the MainWindow item in the collection. 49 | /// Ths name can be used as key in the WindowPosSz property 50 | /// to read and write MainWindow position and size information. 51 | /// 52 | [XmlIgnore] 53 | public string MainWindowName 54 | { 55 | get { return "MainWindow"; } 56 | } 57 | 58 | /// 59 | /// Get/set position and size of MainWindow and other windows in the collection. 60 | /// 61 | [XmlElement(ElementName = "WindowPosSz")] 62 | public SerializableDictionary WindowPosSz { get; set; } 63 | 64 | /// 65 | /// Remember the last active solution file name and path of last session. 66 | /// 67 | /// This can be useful when selecting active document in next session or 68 | /// determining a useful default path when there is no document currently open. 69 | /// 70 | [XmlAttribute(AttributeName = "LastActiveSolution")] 71 | public string LastActiveSolution { get; set; } 72 | 73 | /// 74 | /// Remember the last active path and name of last active document. 75 | /// 76 | /// This can be useful when selecting active document in next session or 77 | /// determining a useful default path when there is no document currently open. 78 | /// 79 | [XmlArrayItem("LastActiveSourceFiles", IsNullable = true)] 80 | public List LastActiveSourceFiles { get; set; } 81 | 82 | /// 83 | /// Remember the last active path and name of last active document. 84 | /// 85 | /// This can be useful when selecting active document in next session or 86 | /// determining a useful default path when there is no document currently open. 87 | /// 88 | [XmlAttribute(AttributeName = "LastActiveTargetFile")] 89 | public string LastActiveTargetFile { get; set; } 90 | 91 | #endregion properties 92 | 93 | #region methods 94 | 95 | /// 96 | /// Checks the MainWindow for visibility when re-starting application 97 | /// (with different screen configuration). 98 | /// 99 | /// 100 | /// 101 | public void CheckSettingsOnLoad(double SystemParameters_VirtualScreenLeft, 102 | double SystemParameters_VirtualScreenTop) 103 | { 104 | var defaultWindow = new ViewPosSizeModel(ViewPosSizeModel.DefaultSize); 105 | 106 | if (WindowPosSz == null) 107 | { 108 | WindowPosSz = new SerializableDictionary(); 109 | WindowPosSz.Add(MainWindowName, defaultWindow); 110 | } 111 | else 112 | { 113 | ViewPosSizeModel win; 114 | if (WindowPosSz.TryGetValue(MainWindowName, out win) == true) 115 | { 116 | if (win.DefaultConstruct == true) 117 | { 118 | WindowPosSz.Remove(MainWindowName); 119 | WindowPosSz.Add(MainWindowName, defaultWindow); 120 | } 121 | } 122 | } 123 | 124 | // Ensure window visibility on different screens and sizes... 125 | defaultWindow.SetValidPos(SystemParameters_VirtualScreenLeft, 126 | SystemParameters_VirtualScreenTop); 127 | } 128 | 129 | /// 130 | /// Updates or inserts the requested window pos size item in the collection. 131 | /// 132 | /// 133 | /// 134 | /// 135 | public void UpdateInsertWindowPosSize(string windowName, ViewPosSizeModel model) 136 | { 137 | ViewPosSizeModel checkModel; 138 | if (WindowPosSz.TryGetValue(windowName, out checkModel) == true) 139 | WindowPosSz.Remove(windowName); 140 | 141 | WindowPosSz.Add(windowName, model); 142 | } 143 | 144 | /// 145 | /// Get the path of the file or empty string if file does not exists on disk. 146 | /// 147 | /// 148 | public string GetLastActivePath() 149 | { 150 | try 151 | { 152 | if (System.IO.File.Exists(LastActiveSolution)) 153 | return System.IO.Path.GetDirectoryName(LastActiveSolution); 154 | } 155 | catch 156 | { 157 | } 158 | 159 | return string.Empty; 160 | } 161 | 162 | #endregion methods 163 | } 164 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/UserProfile/ViewSize.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.UserProfile 2 | { 3 | // 50, 50, 800, 550 4 | public class ViewSize 5 | { 6 | public ViewSize(double x, double y, double width, double height) 7 | { 8 | X = x; 9 | Y = y; 10 | Width = width; 11 | Height = height; 12 | } 13 | 14 | public double X { get; private set; } 15 | public double Y { get; private set; } 16 | public double Width { get; private set; } 17 | public double Height { get; private set; } 18 | } 19 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/Settings/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/ExtensionMethods/SecureStringExtensionMethod.cs: -------------------------------------------------------------------------------- 1 | namespace SettingsModel.ExtensionMethods 2 | { 3 | using System; 4 | using System.Runtime.InteropServices; 5 | using System.Security; 6 | 7 | /// 8 | /// Source: http://blogs.msdn.com/b/fpintos/archive/2009/06/12/how-to-properly-convert-securestring-to-string.aspx 9 | /// 10 | internal static class SecureStringExtensionMethod 11 | { 12 | public static string ConvertToUnsecureString(this SecureString securePassword) 13 | { 14 | if (securePassword == null) 15 | throw new ArgumentNullException("securePassword"); 16 | 17 | IntPtr unmanagedString = IntPtr.Zero; 18 | try 19 | { 20 | unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(securePassword); 21 | return Marshal.PtrToStringUni(unmanagedString); 22 | } 23 | finally 24 | { 25 | Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString); 26 | } 27 | } 28 | 29 | public static SecureString ConvertToSecureString(this string password) 30 | { 31 | if (password == null) 32 | throw new ArgumentNullException("password"); 33 | 34 | var securePassword = new SecureString(); 35 | foreach (char c in password) 36 | securePassword.AppendChar(c); 37 | 38 | securePassword.MakeReadOnly(); 39 | return securePassword; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/Interfaces/IOptionGroup.cs: -------------------------------------------------------------------------------- 1 | namespace SettingsModel.Interfaces 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | /// 7 | /// An option group is a logical group of options 8 | /// (setting values or preferences) of an application. 9 | /// 10 | public interface IOptionGroup 11 | { 12 | /// 13 | /// Gets the name of this options group. This name is used to 14 | /// cluster related options around a technically relevant name. 15 | /// 16 | string Name { get; } 17 | 18 | /// 19 | /// Retrieves the schema of each option in this optiongroup. 20 | /// 21 | /// 22 | IEnumerable GetOptionDefinitions(); 23 | 24 | /// 25 | /// Retrieves the schema of an option in this optiongroup. 26 | /// 27 | /// 28 | IOptionsSchema GetOptionDefinition(string optionName); 29 | 30 | /// 31 | /// Gets the value of an option in a given or null 32 | /// if either option or does not exist. 33 | /// 34 | /// Method returns false if option or are not known. 35 | /// 36 | /// 37 | /// Indicates whether option and exist or not. 38 | /// 39 | bool GetValue(string optionName, out object optValue); 40 | 41 | /// 42 | /// Gets the value of an option in a given or 43 | /// throws an exception if either option or 44 | /// does not exist. 45 | /// 46 | /// Method the requested option value if option and are known. 47 | /// 48 | /// 49 | /// 50 | object GetValue(string optionName); 51 | 52 | /// 53 | /// Gets the requested option and returns it as typed <T> value. 54 | /// The method throws an exception if: 55 | /// - requested option value is not stored as typed <T> or 56 | /// - the and option name does not exist. 57 | /// 58 | /// 59 | /// current value of this option. 60 | T GetValue(string optionName); 61 | 62 | /// 63 | /// Sets the value of a given option in this option table. 64 | /// 65 | /// 66 | /// 67 | /// 68 | bool SetValue(string optionName, object newValue); 69 | 70 | /// 71 | /// Add a list item in a list schema 72 | /// 73 | /// 74 | /// 75 | /// 76 | /// 77 | /// Returns true if item was succesfully added or false 78 | /// if schema is not a list schema. 79 | /// 80 | bool List_AddValue(string optionName, string keyName, object value); 81 | 82 | /// 83 | /// Clear all items contained in a list. 84 | /// 85 | /// 86 | /// 87 | bool List_Clear(string optionName); 88 | 89 | /// 90 | /// Create a new option that can hold a list of items. 91 | /// 92 | /// 93 | /// 94 | /// 95 | /// 96 | /// 97 | /// 98 | IOptionsSchema List_CreateOption(string optionName, Type type, bool isOptional, List list); 99 | 100 | /// 101 | /// Gets a list of current values if this schema descripes a List. 102 | /// Return a single value schema as a list of 1 item. 103 | /// 104 | /// 105 | /// 106 | IEnumerable List_GetListOfValues(string optionName); 107 | 108 | /// 109 | /// Gets a list of current keys and values if this schema 110 | /// descripes a List. 111 | /// 112 | /// Return a single value schema as a list of 1 item. 113 | /// 114 | /// 115 | /// 116 | IEnumerable> List_GetListOfKeyValues(string optionName); 117 | 118 | /// 119 | /// Resets the IsDirty flag to false to indicate that the current 120 | /// data was not changed/edited by a user request, yet. This is 121 | /// useful after defining a new options model and starting to work 122 | /// with it, as well, as after reading options from persistance... 123 | /// 124 | /// 125 | void SetUndirty(bool isDirty); 126 | } 127 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/Interfaces/IOptionsSchema.cs: -------------------------------------------------------------------------------- 1 | namespace SettingsModel.Interfaces 2 | { 3 | using SettingsModel.Models; 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | /// 8 | /// Defines available schema information for 1 option. 9 | /// 10 | public interface IOptionsSchema 11 | { 12 | /// 13 | /// Gets the type of schema (list or single value) 14 | /// 15 | OptionSchemaType SchemaType { get; } 16 | 17 | /// 18 | /// Gets the name of an option. 19 | /// 20 | string OptionName { get; } 21 | 22 | /// 23 | /// Gets the type of the option being defined here. 24 | /// 25 | Type TypeOfValue { get; } 26 | 27 | /// 28 | /// Gets whether this options is optional or required. 29 | /// This is important when perisiting data and when reading 30 | /// data from persistance. 31 | /// 32 | bool IsOptional { get; } 33 | 34 | /// 35 | /// Gets the value of this option. 36 | /// 37 | object Value { get; } 38 | 39 | /// 40 | /// Gets/sets the default value of this option. 41 | /// 42 | object DefaultValue { get; } 43 | 44 | #region methods 45 | 46 | /// 47 | /// Removes the value with the specified key 48 | /// from the internal dictionary. 49 | /// 50 | /// The key of the element to remove. 51 | /// 52 | /// true if the element is successfully found and removed; otherwise, false. 53 | /// This method returns false if key is not found in 54 | /// the System.Collections.Generic.Dictionary<TKey,TValue>. 55 | /// 56 | /// Exceptions: 57 | /// System.ArgumentNullException: 58 | /// key is null. 59 | /// 60 | bool List_Remove(string key); 61 | 62 | /// 63 | /// Gets the value associated with the specified key. 64 | /// 65 | /// 66 | /// The key of the value to get. 67 | /// 68 | /// 69 | /// When this method returns, contains the value associated with the specified 70 | /// key, if the key is found; otherwise, the default value for the type of the 71 | /// value parameter. This parameter is passed uninitialized. 72 | /// 73 | /// 74 | /// true if the System.Collections.Generic.Dictionary<TKey,TValue> contains an 75 | /// element with the specified key; otherwise, false. 76 | /// 77 | /// Exceptions: 78 | /// System.ArgumentNullException: 79 | /// key is null. 80 | /// 81 | bool List_TryGetValue(string key, out object value); 82 | 83 | /// 84 | /// Sets the value of a given option in this option object. 85 | /// 86 | /// true if data actually changed (for dirty state tracking). 87 | /// Otherwise, false if requested value was already present. 88 | /// 89 | bool SetValue(object newValue); 90 | 91 | /// 92 | /// Add a list item in a list schema 93 | /// 94 | /// 95 | /// 96 | /// 97 | /// Returns true if item was succesfully added or false 98 | /// if schema is not a list schema. 99 | /// 100 | bool List_AddValue(string name, object value); 101 | 102 | /// 103 | /// Clear all items contained in a list. 104 | /// 105 | /// 106 | bool List_Clear(); 107 | 108 | /// 109 | /// Gets a list of current values if this schema descripes a List. 110 | /// Return a single value schema as a list of 1 item. 111 | /// 112 | /// 113 | IEnumerable List_GetListOfValues(); 114 | 115 | /// 116 | /// Gets a list of current keys and values if this schema 117 | /// descripes a List. 118 | /// 119 | /// Return a single value schema as a list of 1 item. 120 | /// 121 | /// 122 | IEnumerable> List_GetListOfKeyValues(); 123 | 124 | #endregion methods 125 | } 126 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/Models/Factory.cs: -------------------------------------------------------------------------------- 1 | namespace SettingsModel.Models 2 | { 3 | using SettingsModel.Interfaces; 4 | 5 | /// 6 | /// Factory class to create an 7 | /// object from a class that is otherwise unknown to the outside world. 8 | /// 9 | public static class Factory 10 | { 11 | /// 12 | /// Create a new engine object that provides all root functions required 13 | /// to model, track, persist, and load data at run-time. 14 | /// 15 | /// 16 | public static IEngine CreateEngine() 17 | { 18 | return new OptionsEngine(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/Models/FileReference.cs: -------------------------------------------------------------------------------- 1 | namespace SettingsModel.Models 2 | { 3 | using System.Xml.Serialization; 4 | 5 | /// 6 | /// Implement a simple file reverence model to allow XML persistence 7 | /// of a List via this class. 8 | /// 9 | public class FileReference 10 | { 11 | /// 12 | /// Gets/sets the path to a file. 13 | /// 14 | [XmlAttribute(AttributeName = "path")] 15 | public string path { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/Models/XML/Converters/AlternativeDataTypeHandler.cs: -------------------------------------------------------------------------------- 1 | namespace SettingsModel.Models.XML.Converters 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Security; 6 | 7 | /// 8 | /// Holds a collection of alternative datatype 9 | /// handlers to handle datatypes that are not supported through equivalent conversion 10 | /// in alternative datatypes. 11 | /// 12 | internal class AlternativeDataTypeHandler 13 | { 14 | #region fields 15 | 16 | private readonly Dictionary converters = null; 17 | 18 | #endregion fields 19 | 20 | public AlternativeDataTypeHandler() 21 | { 22 | converters = new Dictionary(); 23 | 24 | converters.Add(typeof(SecureString), new SecureStringHandler()); 25 | } 26 | 27 | /// 28 | /// Finds an alternative datatype handler to handle datatypes that are not 29 | /// supported through equivalent conversion in alternative datatypes. 30 | /// 31 | /// 32 | /// 33 | public IAlternativeDataTypeHandler FindHandler(Type typeOfDataType2Handle) 34 | { 35 | IAlternativeDataTypeHandler ret = null; 36 | 37 | try 38 | { 39 | converters.TryGetValue(typeOfDataType2Handle, out ret); 40 | } 41 | catch 42 | { 43 | } 44 | 45 | return ret; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/Models/XML/Converters/IAlternativeDataTypeHandler.cs: -------------------------------------------------------------------------------- 1 | namespace SettingsModel.Models.XML.Converters 2 | { 3 | using System; 4 | 5 | internal interface IAlternativeDataTypeHandler 6 | { 7 | Type SourceDataType { get; } 8 | Type TargetDataType { get; } 9 | 10 | object Convert(object objectInput); 11 | 12 | object ConvertBack(object objectEncryptedData); 13 | } 14 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/Models/XML/Converters/SecureStringHandler.cs: -------------------------------------------------------------------------------- 1 | namespace SettingsModel.Models.XML.Converters 2 | { 3 | using System; 4 | using System.Security; 5 | 6 | /// 7 | /// Source of string encryption and decryption: 8 | /// http://weblogs.asp.net/jongalloway//encrypting-passwords-in-a-net-app-config-file 9 | /// 10 | internal class SecureStringHandler : SettingsModel.Models.XML.Converters.IAlternativeDataTypeHandler 11 | { 12 | #region fields 13 | 14 | private static byte[] entropy = System.Text.Encoding.Unicode.GetBytes("Salt Is Usually Not A Password"); 15 | 16 | #endregion fields 17 | 18 | #region constructors 19 | 20 | /// 21 | /// Class constructor 22 | /// 23 | public SecureStringHandler() 24 | { 25 | } 26 | 27 | #endregion constructors 28 | 29 | #region properties 30 | 31 | /// 32 | /// Gets the type of the original data type that is to be replaced 33 | /// with an alternative (typed) representation. 34 | /// 35 | public Type SourceDataType 36 | { 37 | get 38 | { 39 | return typeof(SecureString); 40 | } 41 | } 42 | 43 | /// 44 | /// Gets the type of the target data type that is to be used 45 | /// instead of the original (typed) representation. 46 | /// 47 | public Type TargetDataType 48 | { 49 | get 50 | { 51 | return typeof(string); 52 | } 53 | } 54 | 55 | #endregion properties 56 | 57 | #region methods 58 | 59 | /// 60 | /// Converts from the source datatype into the target data type representation. 61 | /// 62 | /// 63 | /// 64 | public object Convert(object objectInput) 65 | { 66 | SecureString input = objectInput as SecureString; 67 | 68 | if (input == null) 69 | return null; 70 | 71 | byte[] encryptedData = null; 72 | try 73 | { 74 | encryptedData = System.Security.Cryptography.ProtectedData.Protect( 75 | System.Text.Encoding.Unicode.GetBytes(ToInsecureString(input)), 76 | entropy, 77 | System.Security.Cryptography.DataProtectionScope.CurrentUser); 78 | 79 | string result = System.Convert.ToBase64String(encryptedData); 80 | return result; 81 | } 82 | catch (Exception) 83 | { 84 | throw; 85 | } 86 | finally 87 | { 88 | if (encryptedData != null) 89 | { 90 | for (int i = 0; i < encryptedData.Length; i++) 91 | { 92 | encryptedData[i] = 0; 93 | } 94 | encryptedData = null; 95 | } 96 | } 97 | } 98 | 99 | /// 100 | /// Converts from the target datatype into the source data type representation. 101 | /// 102 | /// 103 | /// 104 | public object ConvertBack(object objectEncryptedData) 105 | { 106 | string encryptedData = objectEncryptedData as string; 107 | 108 | if (encryptedData == null) 109 | return null; 110 | 111 | byte[] decryptedData = null; 112 | try 113 | { 114 | decryptedData = System.Security.Cryptography.ProtectedData.Unprotect( 115 | System.Convert.FromBase64String(encryptedData), 116 | entropy, 117 | System.Security.Cryptography.DataProtectionScope.CurrentUser); 118 | 119 | SecureString s = ToSecureString(System.Text.Encoding.Unicode.GetString(decryptedData)); 120 | 121 | return s; 122 | } 123 | catch 124 | { 125 | return new SecureString(); 126 | } 127 | finally 128 | { 129 | if (decryptedData != null) 130 | { 131 | for (int i = 0; i < decryptedData.Length; i++) 132 | { 133 | decryptedData[i] = 0; 134 | } 135 | decryptedData = null; 136 | } 137 | } 138 | } 139 | 140 | #region private methods 141 | 142 | private SecureString ToSecureString(string input) 143 | { 144 | SecureString secure = new SecureString(); 145 | foreach (char c in input) 146 | { 147 | secure.AppendChar(c); 148 | } 149 | secure.MakeReadOnly(); 150 | return secure; 151 | } 152 | 153 | private string ToInsecureString(SecureString input) 154 | { 155 | string returnValue = string.Empty; 156 | IntPtr ptr = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(input); 157 | try 158 | { 159 | returnValue = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(ptr); 160 | } 161 | finally 162 | { 163 | System.Runtime.InteropServices.Marshal.ZeroFreeBSTR(ptr); 164 | } 165 | return returnValue; 166 | } 167 | 168 | #endregion private methods 169 | 170 | #endregion methods 171 | } 172 | } -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/Overview.cd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | ABAAAgABAAESAAAiggBAAABBACQAAIAAAABBAAIAAAA= 18 | Models\Engine.cs 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | AAAAACAAIBAAAgIgAAAAAAQBAgAAAAAQAQABAIIAIAA= 34 | Models\OptionGroup.cs 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ= 45 | Models\Factory.cs 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | EACAAAAAAAAAAAACBgAAAAAAQAAAAkAAACAAAQAAgAA= 55 | Models\XML\XMLLayer.cs 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | CAAAADAAABAABmAgAAAABAAAAgBAAAgAIAAiAAAAAAA= 70 | Models\OptionsSchema.cs 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | ABIAAgAAAAAAAAAAAggAAABBAAQAAgAAAAABCAIAAAA= 81 | Interfaces\IEngine.cs 82 | 83 | 84 | 85 | 86 | 87 | AAAAACAAIBAAAgIgAAAAAAQAAgAAAAAQAAAAAIIAAAA= 88 | Interfaces\IOptionGroup.cs 89 | 90 | 91 | 92 | 93 | 94 | CAAAADAAABAABgAgAAAABAAAAgBAAAAAIAAiAAAAAAA= 95 | Interfaces\IOptionsSchema.cs 96 | 97 | 98 | 99 | 100 | 101 | AAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAI= 102 | Models\OptionsSchema.cs 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SettingsModel")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SettingsModel")] 13 | [assembly: AssemblyCopyright("The MIT License (MIT) Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9b0ba841-5a2f-4ed3-a908-253dbca70e77")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/SettingsModel.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {9B0BA841-5A2F-4ED3-A908-253DBCA70E77} 8 | Library 9 | Properties 10 | SettingsModel 11 | SettingsModel 12 | v4.0 13 | 512 14 | Client 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | bin\Release\SettingsModel.XML 33 | 34 | 35 | true 36 | bin\x64\Debug\ 37 | DEBUG;TRACE 38 | full 39 | x64 40 | prompt 41 | MinimumRecommendedRules.ruleset 42 | 43 | 44 | bin\x64\Release\ 45 | TRACE 46 | bin\Release\SettingsModel.XML 47 | true 48 | pdbonly 49 | x64 50 | prompt 51 | MinimumRecommendedRules.ruleset 52 | 53 | 54 | true 55 | bin\x86\Debug\ 56 | DEBUG;TRACE 57 | full 58 | x86 59 | prompt 60 | MinimumRecommendedRules.ruleset 61 | 62 | 63 | bin\x86\Release\ 64 | TRACE 65 | bin\Release\SettingsModel.XML 66 | true 67 | pdbonly 68 | x86 69 | prompt 70 | MinimumRecommendedRules.ruleset 71 | 72 | 73 | 74 | ..\..\..\..\packages\log4net.2.0.8\lib\net40-client\log4net.dll 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 113 | -------------------------------------------------------------------------------- /source/MLibTest/Components/Settings/SettingsModel/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /source/MLibTest/ThemedDemo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /source/MLibTest/ThemedDemo/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | -------------------------------------------------------------------------------- /source/MLibTest/ThemedDemo/Behaviors/SelectionChangedBehavior.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo.Behaviors 2 | { 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Controls.Primitives; 6 | using System.Windows.Input; 7 | 8 | /// 9 | /// Attached behaviour to implement a selection changed command on a Selector (combobox). 10 | /// The Selector (combobox) generates a SelectionChanged event which in turn generates a 11 | /// Command (in this behavior), which in turn is, when bound, invoked on the viewmodel. 12 | /// 13 | public static class SelectionChangedCommand 14 | { 15 | // Field of attached ICommand property 16 | private static readonly DependencyProperty ChangedCommandProperty = DependencyProperty.RegisterAttached( 17 | "ChangedCommand", 18 | typeof(ICommand), 19 | typeof(SelectionChangedCommand), 20 | new PropertyMetadata(null, OnSelectionChangedCommandChange)); 21 | 22 | /// 23 | /// Setter method of the attached DropCommand property 24 | /// 25 | /// 26 | /// 27 | public static void SetChangedCommand(DependencyObject source, ICommand value) 28 | { 29 | source.SetValue(ChangedCommandProperty, value); 30 | } 31 | 32 | /// 33 | /// Getter method of the attached DropCommand property 34 | /// 35 | /// 36 | /// 37 | public static ICommand GetChangedCommand(DependencyObject source) 38 | { 39 | return (ICommand)source.GetValue(ChangedCommandProperty); 40 | } 41 | 42 | /// 43 | /// This method is hooked in the definition of the . 44 | /// It is called whenever the attached property changes - in our case the event of binding 45 | /// and unbinding the property to a sink is what we are looking for. 46 | /// 47 | /// 48 | /// 49 | private static void OnSelectionChangedCommandChange(DependencyObject d, DependencyPropertyChangedEventArgs e) 50 | { 51 | Selector uiElement = d as Selector; // Remove the handler if it exist to avoid memory leaks 52 | 53 | if (uiElement != null) 54 | { 55 | uiElement.SelectionChanged -= Selection_Changed; 56 | uiElement.KeyUp -= uiElement_KeyUp; 57 | 58 | var command = e.NewValue as ICommand; 59 | if (command != null) 60 | { 61 | // the property is attached so we attach the Drop event handler 62 | uiElement.SelectionChanged += Selection_Changed; 63 | uiElement.KeyUp += uiElement_KeyUp; 64 | } 65 | } 66 | } 67 | 68 | private static void uiElement_KeyUp(object sender, KeyEventArgs e) 69 | { 70 | if (e == null) 71 | return; 72 | 73 | // Forward key event only if user has hit the return, BackSlash, or Slash key 74 | if (e.Key != Key.Return) 75 | return; 76 | 77 | ComboBox uiElement = sender as ComboBox; 78 | 79 | // Sanity check just in case this was somehow send by something else 80 | if (uiElement == null) 81 | return; 82 | 83 | ICommand changedCommand = SelectionChangedCommand.GetChangedCommand(uiElement); 84 | 85 | // There may not be a command bound to this after all 86 | if (changedCommand == null) 87 | return; 88 | 89 | // Check whether this attached behaviour is bound to a RoutedCommand 90 | if (changedCommand is RoutedCommand) 91 | { 92 | // Execute the routed command 93 | (changedCommand as RoutedCommand).Execute(uiElement.Text, uiElement); 94 | } 95 | else 96 | { 97 | // Execute the Command as bound delegate 98 | changedCommand.Execute(uiElement.Text); 99 | } 100 | } 101 | 102 | /// 103 | /// This method is called when the selection changed event occurs. The sender should be the control 104 | /// on which this behaviour is attached - so we convert the sender into a 105 | /// and receive the Command through the getter listed above. 106 | /// 107 | /// This implementation supports binding of delegate commands and routed commands. 108 | /// 109 | /// 110 | /// 111 | private static void Selection_Changed(object sender, System.Windows.Controls.SelectionChangedEventArgs e) 112 | { 113 | Selector uiElement = sender as Selector; 114 | 115 | // Sanity check just in case this was somehow send by something else 116 | if (uiElement == null) 117 | return; 118 | 119 | ICommand changedCommand = SelectionChangedCommand.GetChangedCommand(uiElement); 120 | 121 | // There may not be a command bound to this after all 122 | if (changedCommand == null) 123 | return; 124 | 125 | // Check whether this attached behaviour is bound to a RoutedCommand 126 | if (changedCommand is RoutedCommand) 127 | { 128 | // Execute the routed command 129 | (changedCommand as RoutedCommand).Execute(e.AddedItems, uiElement); 130 | } 131 | else 132 | { 133 | // Execute the Command as bound delegate 134 | changedCommand.Execute(e.AddedItems); 135 | } 136 | } 137 | } 138 | } -------------------------------------------------------------------------------- /source/MLibTest/ThemedDemo/BindToMLib/ColorPickerLib/DarkLightBrushs.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 9 | #FF1888b8 11 | 12 | 15 | 16 | 18 | 19 | 20 | 23 | 24 | 27 | -------------------------------------------------------------------------------- /source/MLibTest/ThemedDemo/BindToMLib/MWindowLib/DarkLightBrushs.xaml: -------------------------------------------------------------------------------- 1 |  8 | 10 | Blue 12 | 13 | 16 | 17 | 18 | #FFF4F4F5 20 | 21 | #FF2D2D30 23 | 24 | 27 | 28 | 31 | 32 | 33 | #FF3F3F41 35 | 36 | 39 | -------------------------------------------------------------------------------- /source/MLibTest/ThemedDemo/BindToMLib/NumericUpDownLib/DarkLightBrushs.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 11 | #FF1888b8 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /source/MLibTest/ThemedDemo/Demos/Models/FolderBrowserResult.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo.Demos.Models 2 | { 3 | public class FolderBrowserResult 4 | { 5 | #region constructors 6 | public FolderBrowserResult() 7 | { 8 | this.Path = default(string); 9 | this.Result = null; 10 | } 11 | #endregion constructors 12 | 13 | #region properties 14 | public string Path { get; private set; } 15 | 16 | public bool? Result { get; private set; } 17 | #endregion properties 18 | 19 | #region methods 20 | public void SetResult(bool result) 21 | { 22 | this.Result = result; 23 | } 24 | 25 | public void SetPath(string path) 26 | { 27 | if (string.IsNullOrEmpty(path) == false) 28 | Path = path; 29 | else 30 | Path = default(string); 31 | } 32 | #endregion methods 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /source/MLibTest/ThemedDemo/Demos/ViewModels/DemoViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo.Demos.ViewModels 2 | { 3 | using System.Windows.Media; 4 | 5 | /// 6 | /// This viewmodel controls all aspects of the themed control demo in this test application. 7 | /// 8 | public class DemoViewModel : ThemedDemo.ViewModels.Base.ViewModelBase 9 | { 10 | #region private fields 11 | 12 | private Color _SelectedAccentColor; 13 | 14 | #endregion private fields 15 | 16 | #region constructors 17 | 18 | /// 19 | /// Class constructor 20 | /// 21 | public DemoViewModel() 22 | { 23 | // Explicit use of opacity is recommended here to initialize all components as expected 24 | _SelectedAccentColor = Color.FromArgb(128, 180, 0, 0); 25 | } 26 | 27 | #endregion constructors 28 | 29 | #region properties 30 | 31 | /// 32 | /// Gets/sets the currently selected color. 33 | /// 34 | public Color SelectedAccentColor 35 | { 36 | get { return _SelectedAccentColor; } 37 | set 38 | { 39 | if (_SelectedAccentColor != value) 40 | { 41 | _SelectedAccentColor = value; 42 | RaisePropertyChanged(() => SelectedAccentColor); 43 | } 44 | } 45 | } 46 | 47 | /// 48 | /// Gets/sets a description for the currently selected color. 49 | /// 50 | public string Description 51 | { 52 | get 53 | { 54 | return "The ColorCanvas and ColorPicker controls allow the user to input a color. Not shown in the sample are the ColorPicker's Available, Standard and Recent color lists, which are entirely customizable."; 55 | } 56 | } 57 | 58 | #endregion properties 59 | } 60 | } -------------------------------------------------------------------------------- /source/MLibTest/ThemedDemo/Demos/Views/FolderBrowserContentDialogView.xaml: -------------------------------------------------------------------------------- 1 |  15 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 53 | 54 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /source/MLibTest/ThemedDemo/Demos/Views/FolderBrowserContentDialogView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo.Demos.Views 2 | { 3 | using System.Windows.Controls; 4 | 5 | /// 6 | /// Interaction logic for FolderBrowserContentDialogView.xaml 7 | /// 8 | /// This type of dialog can be shown as overlay over the actual MainWindow. 9 | /// 10 | public partial class FolderBrowserContentDialogView : UserControl 11 | { 12 | public FolderBrowserContentDialogView() 13 | { 14 | InitializeComponent(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /source/MLibTest/ThemedDemo/Demos/Views/FolderBrowserDialog.xaml: -------------------------------------------------------------------------------- 1 |  26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |