├── .gitignore ├── LICENSE ├── README.md ├── screenshots ├── ClassicHighlighting.png ├── Dark.png ├── HighlightingLoaders.png ├── HighlightingManager.png ├── HighlightingManager.vsdx ├── HighlightingManagerV2.png ├── Light.png ├── More │ ├── Dark_LightHighlighting.png │ ├── Light_DarkHighlighting.png │ └── Solution.png ├── ThemedHighlightingManager.png ├── Themes.png ├── TrueBlue_Dark.png ├── TrueBlue_Light.png ├── VS2019_Dark.png ├── icons │ ├── desk-lamp-dark.ico │ ├── desk-lamp-dark.svg │ ├── desk-lamp-dark_128x.png │ ├── desk-lamp-dark_16x.png │ ├── desk-lamp-dark_256x.png │ ├── desk-lamp-dark_32x.png │ ├── desk-lamp-dark_48x.png │ ├── desk-lamp-dark_64x.png │ ├── desk-lamp-light.ico │ ├── desk-lamp-light.svg │ ├── desk-lamp_128x.png │ ├── desk-lamp_16x.png │ ├── desk-lamp_256x.png │ ├── desk-lamp_32x.png │ ├── desk-lamp_48x.png │ └── desk-lamp_64x.png └── xshtd_objects.png └── source ├── CleanAll.bat ├── Components ├── ServiceLocator │ ├── ServiceContainer.cs │ ├── ServiceInjector.cs │ └── ServiceLocator.csproj └── Settings │ ├── Settings │ ├── AssemblyInfo.cs │ ├── Interfaces │ │ ├── IOptions.cs │ │ ├── IOptionsPanel.cs │ │ ├── IProfile.cs │ │ ├── ISettingsManager.cs │ │ └── IViewPosSizeModel.cs │ ├── Internal │ │ └── SettingsManagerImpl.cs │ ├── ProgramSettings │ │ ├── LanguageCollection.cs │ │ └── OptionsPanel.cs │ ├── SerializableDictionary.cs │ ├── Settings.csproj │ ├── SettingsManager.cs │ └── UserProfile │ │ ├── IViewSize.cs │ │ ├── LocalizabilityAttribute.cs │ │ ├── Profile.cs │ │ ├── ViewPosSizeModel.cs │ │ └── ViewSize.cs │ └── 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 │ └── SettingsModel.csproj ├── HL ├── AssemblyInfo.cs ├── HL.csproj ├── HighlightingTheme │ ├── GlobalStyle.cs │ └── SyntaxDefinition.cs ├── Interfaces │ ├── IHLTheme.cs │ └── IThemedHighlightingManager.cs ├── LICENSE ├── Manager │ ├── BusyManager.cs │ ├── DefaultHighlightingManager.cs │ ├── DelayLoadedHighlightingDefinition.cs │ ├── ExtensionMethods.cs │ ├── HLTheme.cs │ ├── HighlightingBrush.cs │ ├── HighlightingLoader.cs │ ├── HighlightingThemeLoader.cs │ ├── ThemedHighlightingManager.cs │ ├── V1Loader.cs │ ├── V2Loader.cs │ ├── XmlHighlightingDefinition.cs │ └── XshtdLoader.cs ├── Modes │ ├── ModeV1.xsd │ ├── ModeV2.xsd │ └── ModeV2_htd.xsd ├── Resources │ ├── HLResources.cs │ ├── Light │ │ ├── AS3.xshd │ │ ├── ASPX.xshd │ │ ├── Boo.xshd │ │ ├── CPP-Mode.xshd │ │ ├── CSS-Mode.xshd │ │ ├── CSharp-Mode.xshd │ │ ├── Coco-Mode.xshd │ │ ├── DOSBATCH.xshd │ │ ├── FSharp-Mode.xshd │ │ ├── HLSL.xshd │ │ ├── HTML-Mode.xshd │ │ ├── INI.xshd │ │ ├── Java-Mode.xshd │ │ ├── JavaScript-Mode.xshd │ │ ├── Log.xshd │ │ ├── MarkDown-Mode.xshd │ │ ├── PHP-Mode.xshd │ │ ├── PLSQL.xshd │ │ ├── Pascal.xshd │ │ ├── Patch-Mode.xshd │ │ ├── PowerShell.xshd │ │ ├── Python-Mode.xshd │ │ ├── Ruby.xshd │ │ ├── TSQL-Mode.xshd │ │ ├── TXT.xshd │ │ ├── Tex-Mode.xshd │ │ ├── VB-Mode.xshd │ │ ├── XML-Mode.xshd │ │ ├── XmlDoc.xshd │ │ ├── scheme.xshd │ │ ├── squirrel.xshd │ │ └── vtl.xshd │ └── Themes │ │ ├── Dark.xshtd │ │ ├── TrueBlue.xshtd │ │ └── VS2019_Dark.xshtd ├── Xshtd │ ├── IXshtdVisitor.cs │ ├── XhstdThemeDefinition.cs │ ├── XmlHighlightingThemeDefinition.cs │ ├── XshtdColor.cs │ ├── XshtdElement.cs │ ├── XshtdGlobalStyle.cs │ ├── XshtdGlobalStyles.cs │ ├── XshtdSyntaxDefinition.cs │ └── interfaces │ │ ├── IFreezable.cs │ │ ├── IHighlightingDefinitionReferenceResolver.cs │ │ └── IHighlightingThemeDefinition.cs └── images │ └── icon.png ├── Readme.txt ├── TextEditLib ├── AssemblyInfo.cs ├── Extensions │ └── HighlightCurrentLineBackgroundRenderer.cs ├── Resources │ └── Icons │ │ ├── Copy.ico │ │ ├── Copy_16x.svg │ │ ├── Cut.ico │ │ ├── Cut_16x.svg │ │ ├── Delete.ico │ │ ├── Delete_16x.svg │ │ ├── OpenFile.ico │ │ ├── OpenFile_16x.svg │ │ ├── Paste.ico │ │ ├── Paste_16x.svg │ │ ├── Redo.ico │ │ ├── Redo_16x.svg │ │ ├── Undo.ico │ │ └── Undo_16x.svg ├── TextEdit.xaml ├── TextEdit.xaml.cs ├── TextEditLib.csproj └── Themes │ ├── DarkBrushs.xaml │ ├── Generic.xaml │ ├── Icons.xaml │ ├── LightBrushs.xaml │ └── ResourceKeys.cs ├── ThemedAvalonEditDemo.sln └── ThemedDemo ├── App.config ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── Behaviors └── SelectionChangedBehavior.cs ├── BindToMLib └── MWindowLib │ └── DarkLightBrushs.xaml ├── Converters └── NullToVisibilityConverter.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Models ├── AppCore.cs ├── SettingDefaults.cs └── ThemeDefinition.cs ├── ThemedDemo.csproj └── ViewModels ├── AppLifeCycleViewModel.cs ├── AppViewModel.cs ├── Base ├── ModelBase.cs ├── RelayCommand.cs └── ViewModelBase.cs ├── DocumentRootViewModel.cs ├── ThemeDefinitionViewModel.cs └── ThemeViewModel.cs /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Dirkster99 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 | -------------------------------------------------------------------------------- /screenshots/ClassicHighlighting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/ClassicHighlighting.png -------------------------------------------------------------------------------- /screenshots/Dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/Dark.png -------------------------------------------------------------------------------- /screenshots/HighlightingLoaders.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/HighlightingLoaders.png -------------------------------------------------------------------------------- /screenshots/HighlightingManager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/HighlightingManager.png -------------------------------------------------------------------------------- /screenshots/HighlightingManager.vsdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/HighlightingManager.vsdx -------------------------------------------------------------------------------- /screenshots/HighlightingManagerV2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/HighlightingManagerV2.png -------------------------------------------------------------------------------- /screenshots/Light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/Light.png -------------------------------------------------------------------------------- /screenshots/More/Dark_LightHighlighting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/More/Dark_LightHighlighting.png -------------------------------------------------------------------------------- /screenshots/More/Light_DarkHighlighting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/More/Light_DarkHighlighting.png -------------------------------------------------------------------------------- /screenshots/More/Solution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/More/Solution.png -------------------------------------------------------------------------------- /screenshots/ThemedHighlightingManager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/ThemedHighlightingManager.png -------------------------------------------------------------------------------- /screenshots/Themes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/Themes.png -------------------------------------------------------------------------------- /screenshots/TrueBlue_Dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/TrueBlue_Dark.png -------------------------------------------------------------------------------- /screenshots/TrueBlue_Light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/TrueBlue_Light.png -------------------------------------------------------------------------------- /screenshots/VS2019_Dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/VS2019_Dark.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp-dark.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp-dark.ico -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp-dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 20 | 22 | 23 | 25 | image/svg+xml 26 | 28 | 29 | 30 | 31 | 33 | 53 | 57 | 58 | -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp-dark_128x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp-dark_128x.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp-dark_16x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp-dark_16x.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp-dark_256x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp-dark_256x.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp-dark_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp-dark_32x.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp-dark_48x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp-dark_48x.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp-dark_64x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp-dark_64x.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp-light.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp-light.ico -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp-light.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp_128x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp_128x.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp_16x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp_16x.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp_256x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp_256x.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp_32x.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp_48x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp_48x.png -------------------------------------------------------------------------------- /screenshots/icons/desk-lamp_64x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/icons/desk-lamp_64x.png -------------------------------------------------------------------------------- /screenshots/xshtd_objects.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/screenshots/xshtd_objects.png -------------------------------------------------------------------------------- /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 Apps\ThemedDemo 10 | ECHO HL 11 | ECHO TextEditLib 12 | ECHO. 13 | ECHO Components\ServiceLocator 14 | ECHO Components\Settings\Settings 15 | ECHO Components\Settings\SettingsModel 16 | ECHO. 17 | REM Ask the user if hes really sure to continue beyond this point XXXXXXXX 18 | set /p choice=Are you sure to continue (Y/N)? 19 | if not '%choice%'=='Y' Goto EndOfBatch 20 | REM Script does not continue unless user types 'Y' in upper case letter 21 | ECHO. 22 | ECHO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 23 | ECHO. 24 | ECHO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 25 | RMDIR /S /Q .\.vs 26 | 27 | ECHO. 28 | ECHO Deleting BIN and OBJ Folders in Apps\ThemedDemo 29 | ECHO. 30 | RMDIR /S /Q .\Apps\ThemedDemo\bin 31 | RMDIR /S /Q .\Apps\ThemedDemo\obj 32 | ECHO. 33 | 34 | ECHO. 35 | ECHO Deleting BIN and OBJ Folders in HL 36 | ECHO. 37 | RMDIR /S /Q .\HL\bin 38 | RMDIR /S /Q .\HL\obj 39 | ECHO. 40 | 41 | ECHO. 42 | ECHO Deleting BIN and OBJ Folders in TextEditLib 43 | ECHO. 44 | RMDIR /S /Q .\TextEditLib\bin 45 | RMDIR /S /Q .\TextEditLib\obj 46 | ECHO. 47 | 48 | 49 | ECHO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 50 | ECHO. 51 | ECHO Deleting BIN and OBJ Folders in Components\ServiceLocator 52 | ECHO. 53 | RMDIR /S /Q .\Components\ServiceLocator\bin 54 | RMDIR /S /Q .\Components\ServiceLocator\obj 55 | ECHO. 56 | 57 | ECHO. 58 | ECHO Deleting BIN and OBJ Folders in Components\Settings\Settings 59 | ECHO. 60 | RMDIR /S /Q .\Components\Settings\Settings\bin 61 | RMDIR /S /Q .\Components\Settings\Settings\obj 62 | ECHO. 63 | 64 | ECHO. 65 | ECHO Deleting BIN and OBJ Folders in Components\Settings\SettingsModel 66 | ECHO. 67 | RMDIR /S /Q .\Components\Settings\SettingsModel\bin 68 | RMDIR /S /Q .\Components\Settings\SettingsModel\obj 69 | ECHO. 70 | 71 | ECHO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 72 | 73 | PAUSE 74 | 75 | :EndOfBatch 76 | -------------------------------------------------------------------------------- /source/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 | public static readonly ServiceContainer Instance = new ServiceContainer(); 13 | 14 | readonly Dictionary _serviceMap; 15 | readonly object _serviceMapLock; 16 | #endregion fields 17 | 18 | #region constructors 19 | /// 20 | /// Class Constructor 21 | /// 22 | private ServiceContainer() 23 | { 24 | _serviceMap = new Dictionary(); 25 | _serviceMapLock = new object(); 26 | } 27 | #endregion constructors 28 | 29 | #region methods 30 | public void AddService(TServiceContract implementation) 31 | where TServiceContract : class 32 | { 33 | lock (_serviceMapLock) 34 | { 35 | _serviceMap[typeof(TServiceContract)] = implementation; 36 | } 37 | } 38 | 39 | public TServiceContract GetService() 40 | where TServiceContract : class 41 | { 42 | object service; 43 | lock (_serviceMapLock) 44 | { 45 | _serviceMap.TryGetValue(typeof(TServiceContract), out service); 46 | } 47 | 48 | return service as TServiceContract; 49 | } 50 | #endregion methods 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /source/Components/ServiceLocator/ServiceInjector.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo 2 | { 3 | using HL.Interfaces; 4 | using HL.Manager; 5 | using MLib; 6 | using MLib.Interfaces; 7 | using ServiceLocator; 8 | using Settings; 9 | using Settings.Interfaces; 10 | 11 | /// 12 | /// Creates and initializes all services. 13 | /// 14 | public static class ServiceInjector 15 | { 16 | /// 17 | /// Loads service objects into the ServiceContainer on startup of application. 18 | /// 19 | /// Returns the current instance 20 | /// to let caller work with service container items right after creation. 21 | public static ServiceContainer InjectServices() 22 | { 23 | var appearance = AppearanceManager.GetInstance(); 24 | 25 | ServiceContainer.Instance.AddService(SettingsManager.GetInstance(appearance.CreateThemeInfos())); 26 | ServiceContainer.Instance.AddService(appearance); 27 | ServiceContainer.Instance.AddService(ThemedHighlightingManager.Instance); 28 | 29 | return ServiceContainer.Instance; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /source/Components/ServiceLocator/ServiceLocator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.0;net4.5.2 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Components/Settings/Settings/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 | )] 11 | -------------------------------------------------------------------------------- /source/Components/Settings/Settings/Interfaces/IOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.Interfaces 2 | { 3 | using Settings.ProgramSettings; 4 | using System.Collections.Generic; 5 | 6 | public interface IOptions 7 | { 8 | #region properties 9 | bool IsDirty { get; set; } 10 | string LanguageSelected { get; set; } 11 | bool ReloadOpenFilesOnAppStart { get; set; } 12 | string SourceFilePath { get; set; } 13 | 14 | string DefaultSourceLanguage { get; set; } 15 | string DefaultTargetLanguage { get; set; } 16 | 17 | string DefaultDefaultSourceLanguage { get; } 18 | string DefaultDefaultTargetLanguage { get; } 19 | 20 | int DefaultIconSize { get; } 21 | int IconSizeMin { get; } 22 | int IconSizeMax { get; } 23 | 24 | int DefaultFontSize { get; } 25 | int FontSizeMin { get; } 26 | int FontSizeMax { get; } 27 | #endregion properties 28 | 29 | #region methods 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 | void SetFontSize(int size); 38 | #endregion methods 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /source/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/Components/Settings/Settings/Interfaces/IProfile.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.Interfaces 2 | { 3 | using Settings.UserProfile; 4 | using SettingsModel.Models; 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | public interface IProfile 9 | { 10 | #region properties 11 | string GetLastActivePath(); 12 | string LastActiveSolution { get; set; } 13 | 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 | #endregion properties 31 | 32 | #region methods 33 | /// 34 | /// Checks the MainWindow for visibility when re-starting application 35 | /// (with different screen configuration). 36 | /// 37 | /// 38 | /// 39 | void CheckSettingsOnLoad(double SystemParameters_VirtualScreenLeft, double SystemParameters_VirtualScreenTop); 40 | 41 | /// 42 | /// Updates or inserts the requested window pos size item in the collection. 43 | /// 44 | /// 45 | /// 46 | /// 47 | void UpdateInsertWindowPosSize(string windowName, ViewPosSizeModel model); 48 | #endregion methods 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /source/Components/Settings/Settings/Interfaces/ISettingsManager.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.Interfaces 2 | { 3 | using Settings.ProgramSettings; 4 | using MLib.Interfaces; 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 | Settings.Interfaces.IProfile SessionData { get; } 26 | 27 | int IconSizeMin { get; } 28 | int IconSizeMax { get; } 29 | 30 | int FontSizeMin { get; } 31 | int FontSizeMax { get; } 32 | 33 | /// 34 | /// Gets the default icon size for the application. 35 | /// 36 | int DefaultIconSize { get; } 37 | 38 | /// 39 | /// Gets the default font size for the application. 40 | /// 41 | int DefaultFontSize { get; } 42 | 43 | /// 44 | /// Gets the default fixed font size for the application. 45 | /// 46 | int DefaultFixedFontSize { get; } 47 | 48 | /// 49 | /// Gets the internal name and Uri source for all available themes. 50 | /// 51 | [XmlIgnore] 52 | IThemeInfos Themes { get; } 53 | #endregion properties 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /source/Components/Settings/Settings/Interfaces/IViewPosSizeModel.cs: -------------------------------------------------------------------------------- 1 | namespace Settings.Interfaces 2 | { 3 | using System; 4 | 5 | public interface IViewPosSizeModel 6 | { 7 | bool DefaultConstruct { get; } 8 | double Height { get; set; } 9 | bool IsMaximized { get; set; } 10 | double Width { get; set; } 11 | double X { get; set; } 12 | double Y { get; set; } 13 | 14 | void SetValidPos(double SystemParameters_VirtualScreenLeft, double SystemParameters_VirtualScreenTop); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /source/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 | } 47 | -------------------------------------------------------------------------------- /source/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 | } 33 | -------------------------------------------------------------------------------- /source/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 | private XmlSerializer _keySerializer; 21 | private XmlSerializer _valueSerializer; 22 | #endregion 23 | 24 | #region Constructors 25 | public SerializableDictionary() 26 | { 27 | } 28 | 29 | public SerializableDictionary(IDictionary dictionary) 30 | : base(dictionary) 31 | { 32 | } 33 | 34 | public SerializableDictionary(IEqualityComparer comparer) 35 | : base(comparer) 36 | { 37 | } 38 | 39 | public SerializableDictionary(int capacity) 40 | : base(capacity) 41 | { 42 | } 43 | 44 | public SerializableDictionary(IDictionary dictionary, IEqualityComparer comparer) 45 | : base(dictionary, comparer) 46 | { 47 | } 48 | 49 | public SerializableDictionary(int capacity, IEqualityComparer comparer) 50 | : base(capacity, comparer) 51 | { 52 | } 53 | 54 | #endregion 55 | 56 | #region Private Properties 57 | protected XmlSerializer ValueSerializer 58 | { 59 | get { return _valueSerializer ?? (_valueSerializer = new XmlSerializer(typeof(TVal))); } 60 | } 61 | 62 | private XmlSerializer KeySerializer 63 | { 64 | get { return _keySerializer ?? (_keySerializer = new XmlSerializer(typeof(TKey))); } 65 | } 66 | #endregion 67 | 68 | #region ISerializable Members 69 | protected SerializableDictionary(SerializationInfo info, StreamingContext context) 70 | { 71 | int itemCount = info.GetInt32("itemsCount"); 72 | for (int i = 0; i < itemCount; i++) 73 | { 74 | KeyValuePair kvp = (KeyValuePair)info.GetValue(String.Format(CultureInfo.InvariantCulture, "Item{0}", i), typeof(KeyValuePair)); 75 | Add(kvp.Key, kvp.Value); 76 | } 77 | } 78 | 79 | void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) 80 | { 81 | info.AddValue("itemsCount", Count); 82 | int itemIdx = 0; 83 | foreach (KeyValuePair kvp in this) 84 | { 85 | info.AddValue(String.Format(CultureInfo.InvariantCulture, "Item{0}", itemIdx), kvp, typeof(KeyValuePair)); 86 | itemIdx++; 87 | } 88 | } 89 | #endregion 90 | 91 | #region IXmlSerializable Members 92 | void IXmlSerializable.WriteXml(XmlWriter writer) 93 | { 94 | foreach (KeyValuePair kvp in this) 95 | { 96 | writer.WriteStartElement("item"); 97 | writer.WriteStartElement("key"); 98 | KeySerializer.Serialize(writer, kvp.Key); 99 | writer.WriteEndElement(); 100 | writer.WriteStartElement("value"); 101 | ValueSerializer.Serialize(writer, kvp.Value); 102 | writer.WriteEndElement(); 103 | writer.WriteEndElement(); 104 | } 105 | } 106 | 107 | void IXmlSerializable.ReadXml(XmlReader reader) 108 | { 109 | if (reader.IsEmptyElement) 110 | { 111 | return; 112 | } 113 | // Move past container 114 | if (reader.NodeType == XmlNodeType.Element && !reader.Read()) 115 | { 116 | throw new XmlException("Error in Deserialization of SerializableDictionary"); 117 | } 118 | while (reader.NodeType != XmlNodeType.EndElement) 119 | { 120 | reader.ReadStartElement("item"); 121 | reader.ReadStartElement("key"); 122 | TKey key = (TKey)KeySerializer.Deserialize(reader); 123 | reader.ReadEndElement(); 124 | reader.ReadStartElement("value"); 125 | TVal value = (TVal)ValueSerializer.Deserialize(reader); 126 | reader.ReadEndElement(); 127 | reader.ReadEndElement(); 128 | Add(key, value); 129 | reader.MoveToContent(); 130 | } 131 | // Move past container 132 | if (reader.NodeType == XmlNodeType.EndElement) 133 | { 134 | reader.ReadEndElement(); 135 | } 136 | else 137 | { 138 | throw new XmlException("Error in Deserialization of SerializableDictionary"); 139 | } 140 | } 141 | 142 | System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() 143 | { 144 | return null; 145 | } 146 | #endregion 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /source/Components/Settings/Settings/Settings.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.0;net4.5.2 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /source/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 | } 31 | -------------------------------------------------------------------------------- /source/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 | } 60 | -------------------------------------------------------------------------------- /source/Components/Settings/Settings/UserProfile/LocalizabilityAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Settings.UserProfile 4 | { 5 | internal class LocalizabilityAttribute : Attribute 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /source/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 | } 20 | -------------------------------------------------------------------------------- /source/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 | } 43 | -------------------------------------------------------------------------------- /source/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 | /// Removes the value with the specified key 47 | /// from the internal dictionary. 48 | /// 49 | /// The key of the element to remove. 50 | /// 51 | /// true if the element is successfully found and removed; otherwise, false. 52 | /// This method returns false if key is not found in 53 | /// the System.Collections.Generic.Dictionary<TKey,TValue>. 54 | /// 55 | /// Exceptions: 56 | /// System.ArgumentNullException: 57 | /// key is null. 58 | /// 59 | bool List_Remove(string key); 60 | 61 | /// 62 | /// Gets the value associated with the specified key. 63 | /// 64 | /// 65 | /// The key of the value to get. 66 | /// 67 | /// 68 | /// When this method returns, contains the value associated with the specified 69 | /// key, if the key is found; otherwise, the default value for the type of the 70 | /// value parameter. This parameter is passed uninitialized. 71 | /// 72 | /// 73 | /// true if the System.Collections.Generic.Dictionary<TKey,TValue> contains an 74 | /// element with the specified key; otherwise, false. 75 | /// 76 | /// Exceptions: 77 | /// System.ArgumentNullException: 78 | /// key is null. 79 | /// 80 | bool List_TryGetValue(string key, out object value); 81 | 82 | /// 83 | /// Sets the value of a given option in this option object. 84 | /// 85 | /// true if data actually changed (for dirty state tracking). 86 | /// Otherwise, false if requested value was already present. 87 | /// 88 | bool SetValue(object newValue); 89 | 90 | /// 91 | /// Add a list item in a list schema 92 | /// 93 | /// 94 | /// 95 | /// 96 | /// Returns true if item was succesfully added or false 97 | /// if schema is not a list schema. 98 | /// 99 | bool List_AddValue(string name, object value); 100 | 101 | /// 102 | /// Clear all items contained in a list. 103 | /// 104 | /// 105 | bool List_Clear(); 106 | 107 | /// 108 | /// Gets a list of current values if this schema descripes a List. 109 | /// Return a single value schema as a list of 1 item. 110 | /// 111 | /// 112 | IEnumerable List_GetListOfValues(); 113 | 114 | /// 115 | /// Gets a list of current keys and values if this schema 116 | /// descripes a List. 117 | /// 118 | /// Return a single value schema as a list of 1 item. 119 | /// 120 | /// 121 | IEnumerable> List_GetListOfKeyValues(); 122 | #endregion methods 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /source/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 | } 22 | -------------------------------------------------------------------------------- /source/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 | } 18 | -------------------------------------------------------------------------------- /source/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 | private readonly Dictionary converters = null; 16 | #endregion fields 17 | 18 | public AlternativeDataTypeHandler() 19 | { 20 | converters = new Dictionary(); 21 | 22 | converters.Add(typeof(SecureString), new SecureStringHandler()); 23 | } 24 | 25 | /// 26 | /// Finds an alternative datatype handler to handle datatypes that are not 27 | /// supported through equivalent conversion in alternative datatypes. 28 | /// 29 | /// 30 | /// 31 | public IAlternativeDataTypeHandler FindHandler(Type typeOfDataType2Handle) 32 | { 33 | IAlternativeDataTypeHandler ret = null; 34 | 35 | try 36 | { 37 | converters.TryGetValue(typeOfDataType2Handle, out ret); 38 | } 39 | catch 40 | { 41 | } 42 | 43 | return ret; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /source/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 | object ConvertBack(object objectEncryptedData); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /source/Components/Settings/SettingsModel/SettingsModel.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.0;net4.0 5 | 6 | 7 | 8 | 9 | 4.7.0 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /source/HL/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 | )] 11 | -------------------------------------------------------------------------------- /source/HL/HighlightingTheme/GlobalStyle.cs: -------------------------------------------------------------------------------- 1 | namespace HL.HighlightingTheme 2 | { 3 | using HL.Xshtd.interfaces; 4 | using System.Windows.Media; 5 | 6 | /// 7 | /// Implements an object that holds general color and style definitions for the 8 | /// Editor. These style definitions are usually non-highlighting language specific 9 | /// (eg Hyperlink color) and can overwrite existing WPF definition (eg background or 10 | /// foreground color) 11 | /// 12 | public class GlobalStyle : AbstractFreezable, IFreezable 13 | { 14 | #region fields 15 | private string _TypeName; 16 | private Color? _Foregroundcolor; 17 | private Color? _Backgroundcolor; 18 | private Color? _Bordercolor; 19 | #endregion fields 20 | 21 | #region ctors 22 | /// 23 | /// Construct a named (eg. 'Comment') WordStyle object 24 | /// 25 | /// 26 | public GlobalStyle(string typeName) 27 | : this() 28 | { 29 | this.TypeName = typeName; 30 | } 31 | 32 | /// 33 | /// Hidden standard constructor 34 | /// 35 | protected GlobalStyle() 36 | { 37 | this.TypeName = string.Empty; 38 | _Foregroundcolor = null; 39 | _Backgroundcolor = null; 40 | _Bordercolor = null; 41 | } 42 | #endregion ctors 43 | 44 | #region properties 45 | /// 46 | /// Typed name of object 47 | /// 48 | /// (eg 'DefaultStyle', 'NonPrintableCharacter' ..., 49 | /// (this is usually the key in a collection of these styles) 50 | /// 51 | public string TypeName 52 | { 53 | get 54 | { 55 | return _TypeName; 56 | } 57 | set 58 | { 59 | if (IsFrozen) 60 | throw new System.InvalidOperationException("Property is already frozen."); 61 | 62 | _TypeName = value; 63 | } 64 | } 65 | 66 | /// 67 | /// Get/set brush definition for the foreground used in this style 68 | /// 69 | public Color? foregroundcolor 70 | { 71 | get 72 | { 73 | return _Foregroundcolor; 74 | } 75 | set 76 | { 77 | if (IsFrozen) 78 | throw new System.InvalidOperationException("Property is already frozen."); 79 | 80 | _Foregroundcolor = value; 81 | } 82 | } 83 | 84 | /// 85 | /// Get/set brush definition for the background used in this style 86 | /// 87 | public Color? backgroundcolor 88 | { 89 | get 90 | { 91 | return _Backgroundcolor; 92 | } 93 | set 94 | { 95 | if (IsFrozen) 96 | throw new System.InvalidOperationException("Property is already frozen."); 97 | 98 | _Backgroundcolor = value; 99 | } 100 | } 101 | 102 | /// 103 | /// Get/set brush definition for the border used in this style 104 | /// 105 | public Color? bordercolor 106 | { 107 | get 108 | { 109 | return _Bordercolor; 110 | } 111 | set 112 | { 113 | if (IsFrozen) 114 | throw new System.InvalidOperationException("Property is already frozen."); 115 | 116 | _Bordercolor = value; 117 | } 118 | } 119 | #endregion properties 120 | 121 | #region methods 122 | /// 123 | /// Returns a string that represents the current object. 124 | /// 125 | /// 126 | public override string ToString() 127 | { 128 | return "[" + (string.IsNullOrEmpty(this.TypeName) ? string.Empty : this.TypeName) + "]"; 129 | } 130 | #endregion methods 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /source/HL/HighlightingTheme/SyntaxDefinition.cs: -------------------------------------------------------------------------------- 1 | namespace HL.HighlightingTheme 2 | { 3 | using HL.Xshtd.interfaces; 4 | using ICSharpCode.AvalonEdit.Highlighting; 5 | using ICSharpCode.AvalonEdit.Utils; 6 | using System; 7 | using System.Collections.Generic; 8 | 9 | /// 10 | /// Implements the object that keeps track of each syntax definition reference 11 | /// within a highlighting theme definition. 12 | /// 13 | public class SyntaxDefinition : AbstractFreezable, IFreezable 14 | { 15 | #region fields 16 | string _Name; 17 | private readonly Dictionary _NamedHighlightingColors; 18 | #endregion fields 19 | 20 | #region ctors 21 | /// 22 | /// Class constructor 23 | /// 24 | public SyntaxDefinition(string paramName) 25 | : this() 26 | { 27 | this._Name = paramName; 28 | } 29 | 30 | /// 31 | /// Class constructor 32 | /// 33 | public SyntaxDefinition() 34 | { 35 | this.Extensions = new NullSafeCollection(); 36 | _NamedHighlightingColors = new Dictionary(); 37 | } 38 | #endregion ctors 39 | 40 | #region properties 41 | /// 42 | /// Gets/Sets the name of the color. 43 | /// 44 | public string Name 45 | { 46 | get 47 | { 48 | return _Name; 49 | } 50 | set 51 | { 52 | if (IsFrozen) 53 | throw new InvalidOperationException(); 54 | 55 | _Name = value; 56 | } 57 | } 58 | 59 | /// 60 | /// Gets the associated extensions. 61 | /// 62 | public IList Extensions { get; private set; } 63 | 64 | /// 65 | /// Gets an enumeration of all highlighting colors that are defined 66 | /// for this highlighting pattern (eg. C#) as part of a highlighting theme (eg 'True Blue'). 67 | /// 68 | public IEnumerable NamedHighlightingColors 69 | { 70 | get 71 | { 72 | return _NamedHighlightingColors.Values; 73 | } 74 | } 75 | #endregion properties 76 | 77 | #region methods 78 | /// 79 | /// Returns a string that represents the current object. 80 | /// 81 | /// 82 | public override string ToString() 83 | { 84 | return "[" + GetType().Name + " " + (string.IsNullOrEmpty(this.Name) ? string.Empty : this.Name) + "]"; 85 | } 86 | 87 | /// 88 | /// Gets a named color definition or null. 89 | /// 90 | /// 91 | /// 92 | public HighlightingColor ColorGet(string name) 93 | { 94 | HighlightingColor color; 95 | if (_NamedHighlightingColors.TryGetValue(name, out color)) 96 | return color; 97 | 98 | return null; 99 | } 100 | 101 | /// 102 | /// Adds another named color definition. 103 | /// Exceptions: 104 | /// 105 | /// key is null. 106 | /// 107 | /// 108 | /// An element with the same key already exists in the System.Collections.Generic.Dictionary`2. 109 | /// 110 | /// 111 | public void ColorAdd(HighlightingColor color) 112 | { 113 | _NamedHighlightingColors.Add(color.Name, color); 114 | } 115 | 116 | internal void ColorReplace(string name, HighlightingColor themeColor) 117 | { 118 | _NamedHighlightingColors.Remove(name); 119 | _NamedHighlightingColors.Add(name, themeColor); 120 | } 121 | #endregion methods 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /source/HL/Interfaces/IHLTheme.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Manager 2 | { 3 | using System.Collections.ObjectModel; 4 | using HL.HighlightingTheme; 5 | using HL.Xshtd; 6 | using HL.Xshtd.interfaces; 7 | using ICSharpCode.AvalonEdit.Highlighting; 8 | 9 | /// 10 | /// Defines a highlighting theme which is based on a WPF theme (eg. 'Light') 11 | /// with a corresponding set of highlighting definitions (eg. 'XML', 'C#' etc) 12 | /// to ensure that highlightings are correct in the contecxt of 13 | /// (different background colors) WPF themes. 14 | /// 15 | public interface IHLTheme 16 | { 17 | #region properties 18 | /// 19 | /// Gets the display independent key value that should by unique in an 20 | /// overall collection of highlighting themes and should be used for retrieval purposes. 21 | /// 22 | string Key { get; } 23 | 24 | /// 25 | /// Gets the prefix of the XSHD resources that should be used to lookup 26 | /// the actual resource for this theme. 27 | /// 28 | /// This property is null for a derived highlighting theme since finding its 29 | /// base highlighting should by performed through 30 | /// and the corresponding property of that entry. 31 | /// 32 | string HLBasePrefix { get; } 33 | 34 | /// 35 | /// Gets the name of theme (eg. 'Dark' or 'Light' which is used as 36 | /// the base of a derived highlighting theme. 37 | /// 38 | /// This property has the same value as the property 39 | /// if the highlighting is GENERIC (since these highlightings come without 40 | /// additional theme resources). 41 | /// 42 | string HLBaseKey { get; } 43 | 44 | /// 45 | /// Gets the prefix of the resource under which a theme resource definition 46 | /// file xshTd can be found (eg 'HL.Resources.Themes'). 47 | /// 48 | string HLThemePrefix { get; } 49 | 50 | /// 51 | /// Gets the file name under which a theme resource definition 52 | /// file xshTd can be found (eg 'Dark.xshtd'). 53 | /// 54 | string HLThemeFileName { get; } 55 | 56 | /// 57 | /// Gets the name of theme (eg. 'Dark', 'Light' or 'True Blue' for display purposes in the UI. 58 | /// 59 | string DisplayName { get; } 60 | 61 | /// 62 | /// Gets a copy of all highlightings defined in this object. 63 | /// 64 | ReadOnlyCollection HighlightingDefinitions { get; } 65 | 66 | /// 67 | /// Gets the theme highlighting definition for this theme 68 | /// or null (highlighting definition is generic and not based on a theme). 69 | /// 70 | IHighlightingThemeDefinition HlTheme { get; } 71 | 72 | /// 73 | /// Gets/sets whether built-in themes have already been registered or not 74 | /// Use this to avoid registration of built-in themes twice for one and the 75 | /// same highlighting theme. 76 | /// 77 | bool IsBuiltInThemesRegistered { get; set; } 78 | #endregion properties 79 | 80 | #region methods 81 | /// 82 | /// Gets the highlighting definition by name, or null if it is not found. 83 | /// 84 | IHighlightingDefinition GetDefinition(string name); 85 | 86 | /// 87 | /// Gets a highlighting definition by extension. 88 | /// Returns null if the definition is not found. 89 | /// 90 | IHighlightingDefinition GetDefinitionByExtension(string extension); 91 | 92 | /// 93 | /// Registers a highlighting definition. 94 | /// 95 | /// The name to register the definition with. 96 | /// The file extensions to register the definition for. 97 | /// The highlighting definition. 98 | void RegisterHighlighting(string name, string[] extensions, IHighlightingDefinition highlighting); 99 | 100 | /// 101 | /// Gets the highlighting theme definition by name, or null if it is not found. 102 | /// 103 | /// 104 | SyntaxDefinition GetThemeDefinition(string highlightingName); 105 | 106 | /// 107 | /// Converts a XSHD reference from namespace prefix and themename 108 | /// into a object and returns it. 109 | /// 110 | /// 111 | /// 112 | /// 113 | XhstdThemeDefinition ResolveHighLightingTheme(string hLPrefix, string hLThemeName); 114 | #endregion methods 115 | } 116 | } -------------------------------------------------------------------------------- /source/HL/Interfaces/IThemedHighlightingManager.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Interfaces 2 | { 3 | using HL.Manager; 4 | using HL.Xshtd.interfaces; 5 | using ICSharpCode.AvalonEdit.Highlighting; 6 | using System; 7 | using System.Collections.ObjectModel; 8 | 9 | /// 10 | /// Defines a Highlighting Manager that associates syntax highlighting definitions with file extentions 11 | /// (*.cs -> 'C#') with consideration of the current WPF App theme 12 | /// 13 | /// Extension App Theme SyntaxHighlighter 14 | /// (*.cs + 'Dark') -> 'C#' (with color definitions for 'Dark') 15 | /// 16 | public interface IThemedHighlightingManager : IHighlightingDefinitionReferenceResolver, 17 | IHighlightingThemeDefinitionReferenceResolver 18 | { 19 | #region properties 20 | /// 21 | /// Gets the current highlighting theme (eg 'Light' or 'Dark') that should be used as 22 | /// a base for the syntax highlighting in AvalonEdit. 23 | /// 24 | IHLTheme CurrentTheme { get; } 25 | #endregion properties 26 | 27 | #region methods 28 | /// 29 | /// Gets a copy of all highlightings. 30 | /// 31 | ReadOnlyCollection HighlightingDefinitions { get; } 32 | 33 | /// 34 | /// Gets a highlighting definition by extension. 35 | /// Returns null if the definition is not found. 36 | /// 37 | IHighlightingDefinition GetDefinitionByExtension(string extension); 38 | 39 | /// 40 | /// Registers a highlighting definition for the . 41 | /// 42 | /// The name to register the definition with. 43 | /// The file extensions to register the definition for. 44 | /// The highlighting definition. 45 | void RegisterHighlighting(string name, string[] extensions, IHighlightingDefinition highlighting); 46 | 47 | /// 48 | /// Registers a highlighting definition. 49 | /// 50 | /// The name to register the definition with. 51 | /// The file extensions to register the definition for. 52 | /// A function that loads the highlighting definition. 53 | void RegisterHighlighting(string name, string[] extensions, Func lazyLoadedHighlighting); 54 | 55 | /// 56 | /// Resets the highlighting theme based on the name of the WPF App Theme 57 | /// (eg: WPF APP Theme 'Dark' -> Resolve highlighting 'C#' to 'Dark'->'C#') 58 | /// 59 | /// Throws an if the WPF APP theme is not known. 60 | /// 61 | /// 62 | void SetCurrentTheme(string name); 63 | #endregion methods 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /source/HL/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019-2020 Dirkster99 2 | 3 | MIT License (https://opensource.org/licenses/MIT) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /source/HL/Manager/BusyManager.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Manager 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | /// 7 | /// This class is used to prevent stack overflows by representing a 'busy' flag 8 | /// that prevents reentrance when another call is running. 9 | /// However, using a simple 'bool busy' is not thread-safe, so we use a 10 | /// thread-static BusyManager. 11 | /// 12 | internal static class BusyManager 13 | { 14 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] 15 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", 16 | Justification = "Should always be used with 'var'")] 17 | public struct BusyLock : IDisposable 18 | { 19 | public static readonly BusyLock Failed = new BusyLock(null); 20 | 21 | readonly List objectList; 22 | 23 | internal BusyLock(List objectList) 24 | { 25 | this.objectList = objectList; 26 | } 27 | 28 | public bool Success 29 | { 30 | get { return objectList != null; } 31 | } 32 | 33 | public void Dispose() 34 | { 35 | if (objectList != null) 36 | { 37 | objectList.RemoveAt(objectList.Count - 1); 38 | } 39 | } 40 | } 41 | 42 | [ThreadStatic] static List _activeObjects; 43 | 44 | public static BusyLock Enter(object obj) 45 | { 46 | List activeObjects = _activeObjects; 47 | if (activeObjects == null) 48 | activeObjects = _activeObjects = new List(); 49 | for (int i = 0; i < activeObjects.Count; i++) 50 | { 51 | if (activeObjects[i] == obj) 52 | return BusyLock.Failed; 53 | } 54 | activeObjects.Add(obj); 55 | return new BusyLock(activeObjects); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /source/HL/Manager/DelayLoadedHighlightingDefinition.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Manager 2 | { 3 | using ICSharpCode.AvalonEdit.Highlighting; 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | internal sealed class DelayLoadedHighlightingDefinition : IHighlightingDefinition 8 | { 9 | readonly object lockObj = new object(); 10 | readonly string name; 11 | Func lazyLoadingFunction; 12 | IHighlightingDefinition definition; 13 | Exception storedException; 14 | 15 | public DelayLoadedHighlightingDefinition(string name, Func lazyLoadingFunction) 16 | { 17 | this.name = name; 18 | this.lazyLoadingFunction = lazyLoadingFunction; 19 | } 20 | 21 | public string Name 22 | { 23 | get 24 | { 25 | if (name != null) 26 | return name; 27 | else 28 | return GetDefinition().Name; 29 | } 30 | } 31 | 32 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", 33 | Justification = "The exception will be rethrown")] 34 | IHighlightingDefinition GetDefinition() 35 | { 36 | Func func; 37 | lock (lockObj) 38 | { 39 | if (this.definition != null) 40 | return this.definition; 41 | func = this.lazyLoadingFunction; 42 | } 43 | Exception exception = null; 44 | IHighlightingDefinition def = null; 45 | try 46 | { 47 | using (var busyLock = BusyManager.Enter(this)) 48 | { 49 | if (!busyLock.Success) 50 | throw new InvalidOperationException("Tried to create delay-loaded highlighting definition recursively. Make sure the are no cyclic references between the highlighting definitions."); 51 | def = func(); 52 | } 53 | if (def == null) 54 | throw new InvalidOperationException("Function for delay-loading highlighting definition returned null"); 55 | } 56 | catch (Exception ex) 57 | { 58 | exception = ex; 59 | } 60 | lock (lockObj) 61 | { 62 | this.lazyLoadingFunction = null; 63 | if (this.definition == null && this.storedException == null) 64 | { 65 | this.definition = def; 66 | this.storedException = exception; 67 | } 68 | if (this.storedException != null) 69 | throw new HighlightingDefinitionInvalidException("Error delay-loading highlighting definition", this.storedException); 70 | return this.definition; 71 | } 72 | } 73 | 74 | public HighlightingRuleSet MainRuleSet 75 | { 76 | get 77 | { 78 | return GetDefinition().MainRuleSet; 79 | } 80 | } 81 | 82 | public HighlightingRuleSet GetNamedRuleSet(string name) 83 | { 84 | return GetDefinition().GetNamedRuleSet(name); 85 | } 86 | 87 | public HighlightingColor GetNamedColor(string name) 88 | { 89 | return GetDefinition().GetNamedColor(name); 90 | } 91 | 92 | public IEnumerable NamedHighlightingColors 93 | { 94 | get 95 | { 96 | return GetDefinition().NamedHighlightingColors; 97 | } 98 | } 99 | 100 | public override string ToString() 101 | { 102 | return this.Name; 103 | } 104 | 105 | public IDictionary Properties 106 | { 107 | get 108 | { 109 | return GetDefinition().Properties; 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /source/HL/Manager/HighlightingBrush.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Manager 2 | { 3 | using System; 4 | using System.Diagnostics; 5 | using System.Reflection; 6 | using System.Runtime.Serialization; 7 | using System.Windows; 8 | using System.Windows.Media; 9 | using ICSharpCode.AvalonEdit.Highlighting; 10 | using ICSharpCode.AvalonEdit.Rendering; 11 | 12 | /// 13 | /// HighlightingBrush implementation that finds a brush using a resource. 14 | /// 15 | [Serializable] 16 | sealed class SystemColorHighlightingBrush : HighlightingBrush, ISerializable 17 | { 18 | readonly PropertyInfo property; 19 | 20 | public SystemColorHighlightingBrush(PropertyInfo property) 21 | { 22 | Debug.Assert(property.ReflectedType == typeof(SystemColors)); 23 | Debug.Assert(typeof(Brush).IsAssignableFrom(property.PropertyType)); 24 | this.property = property; 25 | } 26 | 27 | public override Brush GetBrush(ITextRunConstructionContext context) 28 | { 29 | return (Brush)property.GetValue(null, null); 30 | } 31 | 32 | public override string ToString() 33 | { 34 | return property.Name; 35 | } 36 | 37 | SystemColorHighlightingBrush(SerializationInfo info, StreamingContext context) 38 | { 39 | property = typeof(SystemColors).GetProperty(info.GetString("propertyName")); 40 | if (property == null) 41 | throw new ArgumentException("Error deserializing SystemColorHighlightingBrush"); 42 | } 43 | 44 | void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) 45 | { 46 | info.AddValue("propertyName", property.Name); 47 | } 48 | 49 | public override bool Equals(object obj) 50 | { 51 | SystemColorHighlightingBrush other = obj as SystemColorHighlightingBrush; 52 | if (other == null) 53 | return false; 54 | return object.Equals(this.property, other.property); 55 | } 56 | 57 | public override int GetHashCode() 58 | { 59 | return property.GetHashCode(); 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /source/HL/Manager/HighlightingLoader.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Manager 2 | { 3 | using HL.HighlightingTheme; 4 | using ICSharpCode.AvalonEdit.Highlighting; 5 | using ICSharpCode.AvalonEdit.Highlighting.Xshd; 6 | using System; 7 | using System.Xml; 8 | using System.Xml.Schema; 9 | 10 | /// 11 | /// Static class with helper methods to load XSHD highlighting files. 12 | /// 13 | public static class HighlightingLoader 14 | { 15 | #region XSHD loading 16 | /// 17 | /// Lodas a syntax definition from the xml reader. 18 | /// 19 | public static XshdSyntaxDefinition LoadXshd(XmlReader reader) 20 | { 21 | return LoadXshd(reader, false); 22 | } 23 | 24 | internal static XshdSyntaxDefinition LoadXshd(XmlReader reader, bool skipValidation) 25 | { 26 | if (reader == null) 27 | throw new ArgumentNullException("reader"); 28 | try 29 | { 30 | reader.MoveToContent(); 31 | //// if (reader.NamespaceURI == V2Loader.Namespace) 32 | //// { 33 | return V2Loader.LoadDefinition(reader, skipValidation); 34 | //// } 35 | //// else 36 | //// { 37 | //// return V1Loader.LoadDefinition(reader, skipValidation); 38 | //// } 39 | } 40 | catch (XmlSchemaException ex) 41 | { 42 | throw WrapException(ex, ex.LineNumber, ex.LinePosition); 43 | } 44 | catch (XmlException ex) 45 | { 46 | throw WrapException(ex, ex.LineNumber, ex.LinePosition); 47 | } 48 | } 49 | 50 | static Exception WrapException(Exception ex, int lineNumber, int linePosition) 51 | { 52 | return new HighlightingDefinitionInvalidException(FormatExceptionMessage(ex.Message, lineNumber, linePosition), ex); 53 | } 54 | 55 | internal static string FormatExceptionMessage(string message, int lineNumber, int linePosition) 56 | { 57 | if (lineNumber <= 0) 58 | return message; 59 | else 60 | return "Error at position (line " + lineNumber + ", column " + linePosition + "):\n" + message; 61 | } 62 | 63 | internal static XmlReader GetValidatingReader(XmlReader input, bool ignoreWhitespace, XmlSchemaSet schemaSet) 64 | { 65 | XmlReaderSettings settings = new XmlReaderSettings(); 66 | settings.CloseInput = true; 67 | settings.IgnoreComments = true; 68 | settings.IgnoreWhitespace = ignoreWhitespace; 69 | if (schemaSet != null) 70 | { 71 | settings.Schemas = schemaSet; 72 | settings.ValidationType = ValidationType.Schema; 73 | } 74 | return XmlReader.Create(input, settings); 75 | } 76 | 77 | internal static XmlSchemaSet LoadSchemaSet(XmlReader schemaInput) 78 | { 79 | XmlSchemaSet schemaSet = new XmlSchemaSet(); 80 | schemaSet.Add(null, schemaInput); 81 | schemaSet.ValidationEventHandler += delegate (object sender, ValidationEventArgs args) 82 | { 83 | throw new HighlightingDefinitionInvalidException(args.Message); 84 | }; 85 | return schemaSet; 86 | } 87 | #endregion 88 | 89 | #region Load Highlighting from XSHD 90 | /// 91 | /// Creates a highlighting definition from the XSHD file. 92 | /// 93 | public static IHighlightingDefinition Load(XshdSyntaxDefinition syntaxDefinition, 94 | IHighlightingDefinitionReferenceResolver resolver) 95 | { 96 | if (syntaxDefinition == null) 97 | throw new ArgumentNullException("syntaxDefinition"); 98 | 99 | return new XmlHighlightingDefinition(syntaxDefinition, resolver); 100 | } 101 | 102 | /// 103 | /// Loads a highlighting definition base on a: 104 | /// 105 | /// 106 | /// Themed Highlighting Definition 107 | /// (This contains the color definition for a highlighting in this theme) 108 | /// 109 | /// 110 | /// A Highlighting definition 111 | /// (This contains the pattern matching and color definitions where the later 112 | /// is usually overwritten be a highlighting theme) 113 | /// 114 | /// An object that can resolve a highlighting definition by its name. 115 | /// 116 | public static IHighlightingDefinition Load(SyntaxDefinition themedHighlights, 117 | XshdSyntaxDefinition syntaxDefinition, 118 | IHighlightingDefinitionReferenceResolver resolver 119 | ) 120 | { 121 | if (syntaxDefinition == null) 122 | throw new ArgumentNullException("syntaxDefinition"); 123 | 124 | return new XmlHighlightingDefinition(themedHighlights, syntaxDefinition, resolver); 125 | } 126 | 127 | /// 128 | /// Creates a highlighting definition from the XSHD file that is already initialled 129 | /// in the instance of the parameter. 130 | /// 131 | public static IHighlightingDefinition Load(XmlReader reader, 132 | IHighlightingDefinitionReferenceResolver resolver) 133 | { 134 | return Load(LoadXshd(reader), resolver); 135 | } 136 | #endregion 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /source/HL/Manager/HighlightingThemeLoader.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Manager 2 | { 3 | using HL.Xshtd; 4 | using HL.Xshtd.interfaces; 5 | using ICSharpCode.AvalonEdit.Highlighting; 6 | using System; 7 | using System.Xml; 8 | using System.Xml.Schema; 9 | 10 | /// 11 | /// Static class with helper methods to load XSHTD highlighting files. 12 | /// 13 | static class HighlightingThemeLoader 14 | { 15 | #region XSHD loading 16 | /// 17 | /// Lodas a syntax definition from the xml reader. 18 | /// 19 | public static XhstdThemeDefinition LoadXshd(XmlReader reader) 20 | { 21 | return LoadXshd(reader, false); 22 | } 23 | 24 | internal static XhstdThemeDefinition LoadXshd(XmlReader reader, bool skipValidation) 25 | { 26 | if (reader == null) 27 | throw new ArgumentNullException("reader"); 28 | try 29 | { 30 | reader.MoveToContent(); 31 | if (reader.NamespaceURI == XshtdLoader.Namespace) 32 | { 33 | return XshtdLoader.LoadDefinition(reader, skipValidation); 34 | } 35 | 36 | throw new ArgumentOutOfRangeException(reader.NamespaceURI); 37 | } 38 | catch (XmlSchemaException ex) 39 | { 40 | throw WrapException(ex, ex.LineNumber, ex.LinePosition); 41 | } 42 | catch (XmlException ex) 43 | { 44 | throw WrapException(ex, ex.LineNumber, ex.LinePosition); 45 | } 46 | } 47 | 48 | static Exception WrapException(Exception ex, int lineNumber, int linePosition) 49 | { 50 | return new HighlightingDefinitionInvalidException(FormatExceptionMessage(ex.Message, lineNumber, linePosition), ex); 51 | } 52 | 53 | internal static string FormatExceptionMessage(string message, int lineNumber, int linePosition) 54 | { 55 | if (lineNumber <= 0) 56 | return message; 57 | else 58 | return "Error at position (line " + lineNumber + ", column " + linePosition + "):\n" + message; 59 | } 60 | 61 | internal static XmlReader GetValidatingReader(XmlReader input, bool ignoreWhitespace, XmlSchemaSet schemaSet) 62 | { 63 | XmlReaderSettings settings = new XmlReaderSettings(); 64 | settings.CloseInput = true; 65 | settings.IgnoreComments = true; 66 | settings.IgnoreWhitespace = ignoreWhitespace; 67 | if (schemaSet != null) 68 | { 69 | settings.Schemas = schemaSet; 70 | settings.ValidationType = ValidationType.Schema; 71 | } 72 | return XmlReader.Create(input, settings); 73 | } 74 | 75 | internal static XmlSchemaSet LoadSchemaSet(XmlReader schemaInput) 76 | { 77 | XmlSchemaSet schemaSet = new XmlSchemaSet(); 78 | schemaSet.Add(null, schemaInput); 79 | schemaSet.ValidationEventHandler += delegate (object sender, ValidationEventArgs args) 80 | { 81 | throw new HighlightingDefinitionInvalidException(args.Message); 82 | }; 83 | return schemaSet; 84 | } 85 | #endregion 86 | 87 | #region Load Highlighting from XSHD 88 | /// 89 | /// Creates a highlighting definition from the XSHD file. 90 | /// 91 | public static IHighlightingThemeDefinition Load(XhstdThemeDefinition syntaxDefinition, 92 | IHighlightingThemeDefinitionReferenceResolver resolver) 93 | { 94 | if (syntaxDefinition == null) 95 | throw new ArgumentNullException("syntaxDefinition"); 96 | 97 | return new XmlHighlightingThemeDefinition(syntaxDefinition, resolver); 98 | } 99 | 100 | /// 101 | /// Creates a highlighting definition from the XSHD file. 102 | /// 103 | public static IHighlightingThemeDefinition Load(XmlReader reader, 104 | IHighlightingThemeDefinitionReferenceResolver resolver) 105 | { 106 | return Load(LoadXshd(reader), resolver); 107 | } 108 | #endregion 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /source/HL/Manager/ThemedHighlightingManager.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/source/HL/Manager/ThemedHighlightingManager.cs -------------------------------------------------------------------------------- /source/HL/Resources/HLResources.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Resources 2 | { 3 | using System.IO; 4 | using HL.Manager; 5 | 6 | internal class HLResources 7 | { 8 | /// 9 | /// Open a object to an internal resource (eg: xshd file) 10 | /// to load its contents from an 'Embedded Resource'. 11 | /// 12 | /// 13 | /// 14 | /// 15 | public static Stream OpenStream(string prefix, string name) 16 | { 17 | string fileRef = prefix + "." + name; 18 | 19 | Stream s = typeof(HLResources).Assembly.GetManifestResourceStream(fileRef); 20 | if (s == null) 21 | throw new FileNotFoundException("The resource file '" + fileRef + "' was not found."); 22 | 23 | return s; 24 | } 25 | 26 | /// 27 | /// Registers the built-in highlighting definitions on first time request for a definition 28 | /// or when the application changes its WPF Theme (eg. from 'Light' to 'Dark') to load the 29 | /// appropriate highlighting resource when queried for it. 30 | /// 31 | /// 32 | /// 33 | internal static void RegisterBuiltInHighlightings( 34 | DefaultHighlightingManager hlm, 35 | IHLTheme theme) 36 | { 37 | // This registration was already performed for this highlighting theme 38 | if (theme.IsBuiltInThemesRegistered == true) 39 | return; 40 | 41 | hlm.RegisterHighlighting(theme, "XmlDoc", null, "XmlDoc.xshd"); 42 | 43 | hlm.RegisterHighlighting(theme, "C#", new[] { ".cs" }, "CSharp-Mode.xshd"); 44 | 45 | hlm.RegisterHighlighting(theme, "JavaScript", new[] { ".js" }, "JavaScript-Mode.xshd"); 46 | hlm.RegisterHighlighting(theme, "HTML", new[] { ".htm", ".html" }, "HTML-Mode.xshd"); 47 | hlm.RegisterHighlighting(theme, "ASP/XHTML", new[] { ".asp", ".aspx", ".asax", ".asmx", ".ascx", ".master" }, "ASPX.xshd"); 48 | 49 | hlm.RegisterHighlighting(theme, "Boo", new[] { ".boo" }, "Boo.xshd"); 50 | hlm.RegisterHighlighting(theme, "Coco", new[] { ".atg" }, "Coco-Mode.xshd"); 51 | hlm.RegisterHighlighting(theme, "CSS", new[] { ".css" }, "CSS-Mode.xshd"); 52 | hlm.RegisterHighlighting(theme, "C++", new[] { ".c", ".h", ".cc", ".cpp", ".hpp" }, "CPP-Mode.xshd"); 53 | hlm.RegisterHighlighting(theme, "Java", new[] { ".java" }, "Java-Mode.xshd"); 54 | hlm.RegisterHighlighting(theme, "Patch", new[] { ".patch", ".diff" }, "Patch-Mode.xshd"); 55 | hlm.RegisterHighlighting(theme, "PowerShell", new[] { ".ps1", ".psm1", ".psd1" }, "PowerShell.xshd"); 56 | hlm.RegisterHighlighting(theme, "PHP", new[] { ".php" }, "PHP-Mode.xshd"); 57 | hlm.RegisterHighlighting(theme, "Python", new[] { ".py", ".pyw" }, "Python-Mode.xshd"); 58 | hlm.RegisterHighlighting(theme, "TeX", new[] { ".tex" }, "Tex-Mode.xshd"); 59 | hlm.RegisterHighlighting(theme, "TSQL", new[] { ".sql" }, "TSQL-Mode.xshd"); 60 | hlm.RegisterHighlighting(theme, "VB", new[] { ".vb" }, "VB-Mode.xshd"); 61 | hlm.RegisterHighlighting(theme, "XML", (".xml;.xsl;.xslt;.xsd;.manifest;.config;.addin;" + 62 | ".xshd;.wxs;.wxi;.wxl;.proj;.csproj;.vbproj;.ilproj;" + 63 | ".booproj;.build;.xfrm;.targets;.xaml;.xpt;" + 64 | ".xft;.map;.wsdl;.disco;.ps1xml;.nuspec").Split(';'), 65 | "XML-Mode.xshd"); 66 | 67 | hlm.RegisterHighlighting(theme, "MarkDown", new[] { ".md" }, "MarkDown-Mode.xshd"); 68 | 69 | // Additional Highlightings 70 | 71 | hlm.RegisterHighlighting(theme, "ActionScript3", new[] { ".as" }, "AS3.xshd"); 72 | hlm.RegisterHighlighting(theme, "BAT", new[] { ".bat", ".dos" }, "DOSBATCH.xshd"); 73 | hlm.RegisterHighlighting(theme, "F#", new[] { ".fs" }, "FSharp-Mode.xshd"); 74 | hlm.RegisterHighlighting(theme, "HLSL", new[] { ".fx" }, "HLSL.xshd"); 75 | hlm.RegisterHighlighting(theme, "INI", new[] { ".cfg", ".conf", ".ini", ".iss" }, "INI.xshd"); 76 | hlm.RegisterHighlighting(theme, "LOG", new[] { ".log" }, "Log.xshd"); 77 | hlm.RegisterHighlighting(theme, "Pascal", new[] { ".pas" }, "Pascal.xshd"); 78 | hlm.RegisterHighlighting(theme, "PLSQL", new[] { ".plsql" }, "PLSQL.xshd"); 79 | hlm.RegisterHighlighting(theme, "Ruby", new[] { ".rb" }, "Ruby.xshd"); 80 | hlm.RegisterHighlighting(theme, "Scheme", new[] { ".sls", ".sps", ".ss", ".scm" }, "scheme.xshd"); 81 | hlm.RegisterHighlighting(theme, "Squirrel", new[] { ".nut" }, "squirrel.xshd"); 82 | hlm.RegisterHighlighting(theme, "TXT", new[] { ".txt" }, "TXT.xshd"); 83 | hlm.RegisterHighlighting(theme, "VTL", new[] { ".vtl", ".vm" }, "vtl.xshd"); 84 | 85 | theme.IsBuiltInThemesRegistered = true; 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/ASPX.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <% 9 | %> 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/CSS-Mode.xshd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | /\* 13 | \*/ 14 | 15 | 19 | \{ 20 | \} 21 | 22 | 23 | \# 24 | \s 25 | 26 | [\d\w] 27 | 28 | 29 | 30 | 31 | /\* 32 | \*/ 33 | 34 | 35 | \: 36 | \;|(?=\}) 37 | 38 | 39 | " 40 | " 41 | 42 | 43 | 44 | 45 | 46 | ' 47 | ' 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/Coco-Mode.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | [{}\(\)\[\]|+\-=\.]+ 21 | 22 | 23 | ANY 24 | CHARACTERS 25 | COMMENTS 26 | COMPILER 27 | CONTEXT 28 | END 29 | FROM 30 | IF 31 | IGNORE 32 | NAMESPACE 33 | NESTED 34 | PRAGMAS 35 | PRODUCTIONS 36 | SYNC 37 | TO 38 | TOKENS 39 | TOKENNAMES 40 | WEAK 41 | using 42 | 43 | 44 | // 45 | 46 | 47 | /\* 48 | \*/ 49 | 50 | 51 | COMPILER 52 | TOKENNAMES 53 | 54 | 55 | " 56 | " 57 | 58 | 59 | ' 60 | ' 61 | 62 | 63 | < 64 | > 65 | 66 | 67 | \(\. 68 | \.\) 69 | 70 | \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? 71 | 72 | 73 | 74 | \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? 75 | 76 | 77 | 78 | \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? 79 | 80 | 81 | \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? 82 | 83 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/INI.xshd: -------------------------------------------------------------------------------- 1 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | ' 29 | ' 30 | 31 | 32 | 33 | " 34 | " 35 | 36 | 37 | 38 | 39 | ; 40 | 41 | 42 | \# 43 | 44 | 45 | 46 | \[ 47 | \] 48 | 49 | 50 | 51 | ^[0-9A-Z\-]+ 52 | = 53 | 54 | 55 | 56 | [?,.;()\[\]{}+\-/%*<>^+~!|&]+ 57 | 58 | 59 | 60 | [?,.;()\[\]{}+\-/%*<>^+~!|&]+[0-9]+[ ?,.;()\[\]{}+\-/%*<>^+~!|&]+\n 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/JavaScript-Mode.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | break 17 | continue 18 | delete 19 | else 20 | for 21 | function 22 | if 23 | in 24 | new 25 | return 26 | this 27 | typeof 28 | var 29 | void 30 | while 31 | with 32 | abstract 33 | boolean 34 | byte 35 | case 36 | catch 37 | char 38 | class 39 | const 40 | debugger 41 | default 42 | do 43 | double 44 | enum 45 | export 46 | extends 47 | final 48 | finally 49 | float 50 | goto 51 | implements 52 | import 53 | instanceof 54 | int 55 | interface 56 | long 57 | native 58 | package 59 | private 60 | protected 61 | public 62 | short 63 | static 64 | super 65 | switch 66 | synchronized 67 | throw 68 | throws 69 | transient 70 | try 71 | volatile 72 | 73 | 74 | Array 75 | Boolean 76 | Date 77 | Function 78 | Global 79 | Math 80 | Number 81 | Object 82 | RegExp 83 | String 84 | 85 | 86 | false 87 | null 88 | true 89 | NaN 90 | Infinity 91 | 92 | 93 | eval 94 | parseInt 95 | parseFloat 96 | escape 97 | unescape 98 | isNaN 99 | isFinite 100 | 101 | 102 | // 103 | 104 | 105 | /\* 106 | \*/ 107 | 108 | 109 | 110 | / 111 | / 112 | 113 | 114 | 115 | 116 | 117 | " 118 | " 119 | 120 | 121 | 122 | 123 | 124 | ' 125 | ' 126 | 127 | 128 | 129 | 130 | \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? 131 | 132 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/Log.xshd: -------------------------------------------------------------------------------- 1 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Info 30 | Information 31 | Trace 32 | Debug 33 | 34 | 35 | 36 | Error 37 | Warn 38 | Warning 39 | Exception 40 | Fatal 41 | 42 | 43 | 44 | ' 45 | ' 46 | 47 | 48 | 49 | " 50 | " 51 | 52 | 53 | 54 | 55 | ; 56 | 57 | 58 | \# 59 | 60 | 61 | 62 | \[ 63 | \] 64 | 65 | 66 | 67 | [?,.;()\[\]{}+\-/%*<>^+~!|&]+ 68 | 69 | 70 | 71 | [?,.;()\[\]{}+\-/%*<>^+~!|&]+[0-9]+[ ?,.;()\[\]{}+\-/%*<>^+~!|&]+\n 72 | 73 | 74 | 75 | 76 | [0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9] 77 | 78 | 79 | 80 | 81 | [0-9][0-9]\:[0-9][0-9]\:[0-9][0-9]\.[0-9][0-9][0-9] 82 | 83 | 84 | 85 | 86 | [0-9][0-9]\:[0-9][0-9]\:[0-9][0-9] 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/MarkDown-Mode.xshd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ^\#.* 15 | 16 | 17 | \*\*.*\*\* 18 | 19 | 20 | __.*__ 21 | 22 | 23 | \*(?![ ]).*\* 24 | 25 | 26 | _.*_ 27 | 28 | 29 | `.*` 30 | 31 | 32 | ^\t 33 | ^(?!\t) 34 | 35 | 36 | ^[ ]{4} 37 | ^(?![ ]{4}) 38 | 39 | 40 | ^> 41 | ^(?!>) 42 | 43 | 44 | \!\[.*\]\[.*\] 45 | 46 | 47 | \[.*\]\(.*\) 48 | 49 | 50 | \[.*\]\[.*\] 51 | 52 | 53 | [ ]{2}$ 54 | 55 | 56 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/PHP-Mode.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | \# 22 | 23 | 24 | 25 | // 26 | 27 | 28 | 29 | /\* 30 | \*/ 31 | 32 | 33 | 34 | 35 | \b0[xX][0-9a-fA-F]+ # hex number 36 | | 37 | \b0[0-9]+ # octal number 38 | | 39 | ( \b\d+(\.[0-9]+)? #number with optional floating point 40 | | \.[0-9]+ #or just starting with floating point 41 | ) 42 | ([eE][+-]?[0-9]+)? # optional exponent 43 | 44 | 45 | 46 | [?,.:;()\[\]{}+\-/%*<>&^!|~@]+ 47 | 48 | 49 | 50 | 51 | \b 52 | [\d\w_]+ # an identifier 53 | (?=\s*\() # followed by ( 54 | 55 | 56 | 57 | ' 58 | ' 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | " 67 | " 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | <<<\"?[\d\w_]+\"?$ 77 | ^[\d\w_]+; 78 | 79 | 80 | 81 | 82 | <<<\'[\d\w_]+\'$ 83 | ^[\d\w_]+; 84 | 85 | 86 | 87 | global 88 | my 89 | var 90 | 91 | 92 | 93 | and 94 | or 95 | new 96 | clone 97 | instanceof 98 | xor 99 | true 100 | false 101 | 102 | 103 | 104 | else 105 | else 106 | switch 107 | case 108 | endif 109 | elseif 110 | 111 | 112 | 113 | do 114 | for 115 | foreach 116 | while 117 | endwhile 118 | exit 119 | 120 | 121 | 122 | break 123 | continue 124 | default 125 | goto 126 | return 127 | 128 | 129 | 130 | require 131 | include 132 | require 133 | include 134 | function 135 | 136 | 137 | 138 | int 139 | integer 140 | real 141 | double 142 | float 143 | string 144 | array 145 | object 146 | 147 | 148 | 149 | class 150 | void 151 | 152 | 153 | 154 | public 155 | private 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/Patch-Mode.xshd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Index:\s 13 | 14 | 15 | == 16 | 17 | 18 | --- 19 | 20 | 21 | \+\+\+ 22 | 23 | 24 | @@ 25 | 26 | 27 | - 28 | 29 | 30 | \+ 31 | 32 | 33 | \s 34 | 35 | 36 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/PowerShell.xshd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | \# 19 | 20 | 21 | 22 | <\# 23 | \#> 24 | 25 | 26 | 27 | " 28 | " 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | ' 37 | ' 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | @" 46 | "@ 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | while 55 | param 56 | end 57 | define 58 | else 59 | from 60 | foreach 61 | var 62 | dynamicparam 63 | filter 64 | dp 65 | until 66 | for 67 | exit 68 | switch 69 | process 70 | begin 71 | elseif 72 | if 73 | in 74 | data 75 | class 76 | using 77 | function 78 | 79 | 80 | 81 | catch 82 | finally 83 | throw 84 | trap 85 | try 86 | 87 | 88 | 89 | break 90 | continue 91 | return 92 | 93 | 94 | 95 | class 96 | 97 | 98 | 99 | -not 100 | -band 101 | -bor 102 | -replace 103 | -ireplace 104 | -creplace 105 | -and 106 | -or 107 | -is 108 | -isnot 109 | -as 110 | -lt 111 | -le 112 | -gt 113 | -ge 114 | -eq 115 | -ne 116 | -contains 117 | -notcontains 118 | -like 119 | -notlike 120 | -match 121 | -notmatch 122 | 123 | 124 | 125 | \$[\d\w_]+ 126 | 127 | 128 | 129 | [\w]+-[\w]+ 130 | 131 | 132 | 133 | 134 | \b0[xX][0-9a-fA-F]+ # hex number 135 | | 136 | ( \b\d+(\.[0-9]+)? #number with optional floating point 137 | | \.[0-9]+ #or just starting with floating point 138 | ) 139 | ([eE][+-]?[0-9]+)? # optional exponent 140 | 141 | 142 | 143 | [?,.;()\[\]{}+\-/%*<>^+~!|&]+ 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/Python-Mode.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | TODO 14 | FIXME 15 | 16 | 17 | HACK 18 | UNDONE 19 | 20 | 21 | 22 | 23 | 24 | \# 25 | 26 | 27 | 28 | ''' 29 | ''' 30 | 31 | 32 | """ 33 | """ 34 | 35 | 36 | 37 | " 38 | " 39 | 40 | 41 | 42 | 43 | 44 | ' 45 | ' 46 | 47 | 48 | 49 | 50 | 51 | 52 | and 53 | as 54 | assert 55 | break 56 | class 57 | continue 58 | def 59 | del 60 | elif 61 | else 62 | except 63 | exec 64 | False 65 | finally 66 | for 67 | from 68 | global 69 | if 70 | import 71 | in 72 | is 73 | lambda 74 | None 75 | nonlocal 76 | not 77 | or 78 | pass 79 | print 80 | raise 81 | return 82 | True 83 | try 84 | while 85 | with 86 | yield 87 | async 88 | await 89 | 90 | 91 | 92 | \b 93 | [\d\w_]+ # an identifier 94 | (?=\s*\() # followed by ( 95 | 96 | 97 | \b0[xX][0-9a-fA-F]+ # hex number 98 | ( \b\d+(\.[0-9]+)? #number with optional floating point 99 | | \.[0-9]+ #or just starting with floating point 100 | ) 101 | ([eE][+-]?[0-9]+)? # optional exponent 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/TXT.xshd: -------------------------------------------------------------------------------- 1 |  2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 58 | 59 | 63 | 64 | 68 | 69 | 70 | 71 | 72 | /\* 73 | \*/ 74 | 75 | 76 | 77 | BUG FIX 78 | BUG 79 | BUGS 80 | HACK 81 | TODO 82 | TODOS 83 | 84 | 85 | 86 | DONE 87 | TICK 88 | 89 | 90 | 91 | [?,.;()\[\]{}+\-/%*<>^+~!|&]+ 92 | 93 | 94 | 95 | [ ?,.;()\[\]{}+\-/%*<>^+~!|&]+[0-9]+[ ?,.;()\[\]{}+\-/%*<>^+~!|&]+\n 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/Tex-Mode.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | TODO 26 | FIXME 27 | 28 | 29 | HACK 30 | UNDONE 31 | Bug 32 | Problem 33 | 34 | 35 | 36 | 37 | 38 | \d 39 | 40 | 41 | 42 | \$ 43 | \$ 44 | 45 | 46 | 47 | 48 | \\\( 49 | \\\) 50 | 51 | 52 | 53 | 54 | \\\[ 55 | \\\] 56 | 57 | 58 | 59 | 60 | \[ 61 | \] 62 | 63 | [^\\] 64 | 65 | 66 | 67 | 68 | (&)|(\\\ )|(\\\\)|(\\@)|(\\\$)|(\\&)|(\\%)|(\\\#)|(\\{)|(\\})|(\\/) 69 | 70 | (\\[\w]+) 71 | 72 | ({[\w]+.*}) 73 | 74 | (%)$ 75 | 76 | 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 | = 107 | ! 108 | + 109 | - 110 | / 111 | * 112 | > 113 | < 114 | & 115 | | 116 | ^ 117 | ~ 118 | . 119 | , 120 | ; 121 | ? 122 | : 123 | ' 124 | 125 | ` 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/XML-Mode.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | <!-- 15 | --> 16 | 17 | 18 | <!\[CDATA\[ 19 | ]]> 20 | 21 | 22 | <!DOCTYPE 23 | > 24 | 25 | 26 | <\? 27 | \?> 28 | 29 | 30 | < 31 | > 32 | 33 | 35 | 36 | " 37 | "|(?=<) 38 | 39 | 40 | ' 41 | '|(?=<) 42 | 43 | [\d\w_\-\.]+(?=(\s*=)) 44 | = 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | & 53 | [\w\d\#]+ 54 | ; 55 | 56 | 57 | 58 | & 59 | [\w\d\#]* 60 | #missing ; 61 | 62 | 63 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/XmlDoc.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | < 11 | > 12 | 13 | 14 | " 15 | " 16 | 17 | 18 | / 19 | | 20 | = 21 | 22 | 23 | c 24 | code 25 | example 26 | exception 27 | list 28 | para 29 | param 30 | paramref 31 | permission 32 | remarks 33 | returns 34 | see 35 | seealso 36 | summary 37 | value 38 | 39 | type 40 | name 41 | cref 42 | item 43 | term 44 | description 45 | listheader 46 | typeparam 47 | typeparamref 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/scheme.xshd: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ; 23 | 24 | 25 | \#\| 26 | \|\# 27 | 28 | 36 | 37 | 38 | import 39 | export 40 | library 41 | 42 | 43 | 44 | define 45 | set! 46 | lambda 47 | begin 48 | if 49 | cond 50 | let 51 | letrec 52 | 53 | 54 | 55 | else 56 | 57 | 58 | 59 | map 60 | cons 61 | car 62 | 63 | 64 | 65 | null 66 | value 67 | 68 | 69 | 70 | 71 | \b0[xX][0-9a-fA-F]+ # hex number 72 | | 73 | ( \b\d+(\.[0-9]+)? #number with optional floating point 74 | | \.[0-9]+ #or just starting with floating point 75 | ) 76 | ([eE][+-]?[0-9]+)? # optional exponent 77 | 78 | 79 | 80 | [?,.;()\[\]{}+\-/%*<>^+~!|&]+ 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/squirrel.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | TODO 22 | FIXME 23 | 24 | 25 | HACK 26 | UNDONE 27 | 28 | 29 | 30 | 31 | 32 | 33 | \# 34 | 35 | 36 | 37 | /// 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | // 46 | 47 | 48 | 49 | /\* 50 | \*/ 51 | 52 | 53 | 54 | " 55 | " 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | @" 64 | " 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | [?,.;()\[\]{}+\-/%*<>^+~!|&]+ 73 | 74 | 75 | 76 | GGen_Point 77 | GGen_Path 78 | GGen_Amplitudes 79 | GGen_Data_2D 80 | GGen_Data_1D 81 | 82 | 83 | 84 | else 85 | if 86 | switch 87 | case 88 | default 89 | for 90 | while 91 | break 92 | local 93 | catch 94 | clone 95 | continue 96 | const 97 | delegate 98 | delete 99 | else 100 | enum 101 | extends 102 | for 103 | function 104 | null 105 | resume 106 | return 107 | switch 108 | this 109 | throw 110 | typeof 111 | parent 112 | yield 113 | constructor 114 | vargc 115 | vargv 116 | instanceof 117 | true 118 | false 119 | static 120 | 121 | 122 | 123 | 124 | \b 125 | [\d\w_]+ # an identifier 126 | (?=\s*\() # followed by ( 127 | 128 | 129 | 130 | 131 | \b0[xX][0-9a-fA-F]+ # hex number 132 | | \b 133 | ( \d+(\.[0-9]+)? #number with optional floating point 134 | | \.[0-9]+ #or just starting with floating point 135 | ) 136 | ([eE][+-]?[0-9]+)? # optional exponent 137 | 138 | 139 | -------------------------------------------------------------------------------- /source/HL/Resources/Light/vtl.xshd: -------------------------------------------------------------------------------- 1 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ' 23 | ' 24 | 25 | 26 | 27 | " 28 | " 29 | 30 | 31 | 32 | \#\# 33 | 34 | 35 | 36 | \#\* 37 | \*\# 38 | 39 | 40 | 41 | \# 42 | [\w\d]+ 43 | 44 | 45 | \$([\d\w]+)([.])([\d\w]+) 46 | 47 | \$([\d\w]+)([.])([\d\w]+) 48 | 49 | ([.])([\d\w]+) 50 | 51 | \$([\d\w]+) 52 | 53 | 54 | [?,;()\[\]{}+\-/%*<>^+~!|&]+ 55 | 56 | 57 | 58 | [?,.;()\[\]{}+\-/%*<>^+~!|&]+[0-9]+[ ?,.;()\[\]{}+\-/%*<>^+~!|&]+\n 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /source/HL/Xshtd/IXshtdVisitor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | // software and associated documentation files (the "Software"), to deal in the Software 5 | // without restriction, including without limitation the rights to use, copy, modify, merge, 6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 7 | // to whom the Software is furnished to do so, subject to the following conditions: 8 | // 9 | // The above copyright notice and this permission notice shall be included in all copies or 10 | // substantial portions of the Software. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 17 | // DEALINGS IN THE SOFTWARE. 18 | namespace HL.Xshtd 19 | { 20 | /// 21 | /// Implements an interface for usage in a Visitor pattern based implementation. 22 | /// This visitor pattern can be used to visit the elements of an XSHTD element tree. 23 | /// 24 | /// A visitor pattern can be used in many ways, here its used for syntax checks and 25 | /// object conversion (from POCO XML object to non-xml .net object). 26 | /// 27 | public interface IXshtdVisitor 28 | { 29 | /// 30 | /// Implements the visitor for a named color ( object) 31 | /// that is contained in a object. 32 | /// 33 | /// 34 | /// 35 | /// 36 | object VisitColor(XshtdSyntaxDefinition syntax, XshtdColor color); 37 | 38 | /// 39 | /// Implements the visitor for the object. 40 | /// 41 | /// the element to be visited. 42 | /// 43 | object VisitSyntaxDefinition(XshtdSyntaxDefinition syntax); 44 | 45 | /// 46 | /// Implements the visitor for the object. 47 | /// 48 | /// the element to be visited. 49 | /// 50 | object VisitGlobalStyles(XshtdGlobalStyles globStyles); 51 | 52 | /// 53 | /// Implements the visitor for the object 54 | /// contained in a object. 55 | /// 56 | /// 57 | /// 58 | /// 59 | object VisitGlobalStyle(XshtdGlobalStyles globStyles, XshtdGlobalStyle style); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /source/HL/Xshtd/XhstdThemeDefinition.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | // software and associated documentation files (the "Software"), to deal in the Software 5 | // without restriction, including without limitation the rights to use, copy, modify, merge, 6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 7 | // to whom the Software is furnished to do so, subject to the following conditions: 8 | // 9 | // The above copyright notice and this permission notice shall be included in all copies or 10 | // substantial portions of the Software. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 17 | // DEALINGS IN THE SOFTWARE. 18 | namespace HL.Xshtd 19 | { 20 | using System; 21 | using System.Collections.Generic; 22 | using ICSharpCode.AvalonEdit.Utils; 23 | 24 | /// 25 | /// An Xml highlighting theme element. 26 | /// 27 | /// for equivalent run-time object. 28 | /// 29 | [Serializable] 30 | public class XhstdThemeDefinition : XshtdElement 31 | { 32 | /// 33 | /// Creates a new XhstdThemeDefinition object. 34 | /// 35 | public XhstdThemeDefinition() 36 | { 37 | this.Elements = new NullSafeCollection(); 38 | this.GlobalStyleElements = new XshtdGlobalStyles(); 39 | } 40 | 41 | /// 42 | /// Gets/sets the highlighting theme definition name (eg. 'Dark', 'TrueBlue') 43 | /// as stated in the Name attribute of the xshtd (xs highlighting theme definition) file. 44 | /// 45 | public string Name { get; set; } 46 | 47 | /// 48 | /// Gets the collection of elements. 49 | /// 50 | public IList Elements { get; private set; } 51 | 52 | /// 53 | /// Gets the collection of elements. 54 | /// 55 | public XshtdGlobalStyles GlobalStyleElements { get; private set; } 56 | 57 | /// 58 | /// Applies the visitor to all elements. 59 | /// 60 | public override object AcceptVisitor(IXshtdVisitor visitor) 61 | { 62 | foreach (XshtdElement element in Elements) 63 | { 64 | element.AcceptVisitor(visitor); 65 | } 66 | 67 | // Visit Global Styles 68 | foreach (XshtdElement element in GlobalStyleElements.Elements) 69 | { 70 | element.AcceptVisitor(visitor); 71 | } 72 | 73 | return null; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /source/HL/Xshtd/XshtdElement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | // software and associated documentation files (the "Software"), to deal in the Software 5 | // without restriction, including without limitation the rights to use, copy, modify, merge, 6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 7 | // to whom the Software is furnished to do so, subject to the following conditions: 8 | // 9 | // The above copyright notice and this permission notice shall be included in all copies or 10 | // substantial portions of the Software. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 17 | // DEALINGS IN THE SOFTWARE. 18 | namespace HL.Xshtd 19 | { 20 | using System; 21 | 22 | /// 23 | /// An element in a XSHD rule set. 24 | /// 25 | [Serializable] 26 | public abstract class XshtdElement 27 | { 28 | /// 29 | /// Gets the line number in the .xshd file. 30 | /// 31 | public int LineNumber { get; set; } 32 | 33 | /// 34 | /// Gets the column number in the .xshd file. 35 | /// 36 | public int ColumnNumber { get; set; } 37 | 38 | /// 39 | /// Applies the visitor to this element. 40 | /// 41 | public abstract object AcceptVisitor(IXshtdVisitor visitor); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /source/HL/Xshtd/XshtdGlobalStyle.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Xshtd 2 | { 3 | using System; 4 | using System.Windows.Media; 5 | 6 | /// 7 | /// An element contained in a <GlobalStyles> element. 8 | /// 9 | [Serializable] 10 | public class XshtdGlobalStyle : XshtdElement 11 | { 12 | #region fields 13 | private readonly XshtdGlobalStyles _styles; 14 | #endregion fields 15 | 16 | #region ctors 17 | /// 18 | /// Creates a new XshtdSyntaxDefinition object. 19 | /// 20 | /// Parent collection of styles in which this style occurs. 21 | public XshtdGlobalStyle(XshtdGlobalStyles styles) 22 | : this() 23 | { 24 | _styles = styles; 25 | } 26 | 27 | /// 28 | /// Hidden class constructor 29 | /// 30 | protected XshtdGlobalStyle() 31 | { 32 | } 33 | #endregion ctors 34 | 35 | /// 36 | /// Gets/sets the style definition name 37 | /// 38 | public string TypeName { get; set; } 39 | 40 | /// 41 | /// Gets/sets the style definition name 42 | /// 43 | public Color? foreground { get; set; } 44 | 45 | /// 46 | /// Gets/sets the style definition name 47 | /// 48 | public Color? background { get; set; } 49 | 50 | /// 51 | /// Gets/sets the style definition name 52 | /// 53 | public Color? bordercolor { get; set; } 54 | 55 | #region methods 56 | 57 | /// 58 | /// Applies the visitor to this element. 59 | /// 60 | /// 61 | /// 62 | public override object AcceptVisitor(IXshtdVisitor visitor) 63 | { 64 | return visitor.VisitGlobalStyle(_styles, this); 65 | } 66 | #endregion methods 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /source/HL/Xshtd/XshtdGlobalStyles.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Xshtd 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using ICSharpCode.AvalonEdit.Utils; 6 | 7 | /// 8 | /// A <GlobalStyles> element. 9 | /// 10 | [Serializable] 11 | public class XshtdGlobalStyles : XshtdElement 12 | { 13 | /// 14 | /// Creates a new XshtdSyntaxDefinition object. 15 | /// 16 | public XshtdGlobalStyles() 17 | { 18 | this.Elements = new NullSafeCollection(); 19 | } 20 | 21 | /// 22 | /// Gets the collection of elements. 23 | /// 24 | public IList Elements { get; private set; } 25 | 26 | /// 27 | /// Applies the visitor to all elements. 28 | /// 29 | public void AcceptElements(IXshtdVisitor visitor) 30 | { 31 | foreach (XshtdElement element in Elements) 32 | { 33 | element.AcceptVisitor(visitor); 34 | } 35 | } 36 | 37 | /// 38 | /// Applies the visitor to this element. 39 | /// 40 | /// 41 | /// 42 | public override object AcceptVisitor(IXshtdVisitor visitor) 43 | { 44 | return visitor.VisitGlobalStyles(this); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /source/HL/Xshtd/XshtdSyntaxDefinition.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | // software and associated documentation files (the "Software"), to deal in the Software 5 | // without restriction, including without limitation the rights to use, copy, modify, merge, 6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 7 | // to whom the Software is furnished to do so, subject to the following conditions: 8 | // 9 | // The above copyright notice and this permission notice shall be included in all copies or 10 | // substantial portions of the Software. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 17 | // DEALINGS IN THE SOFTWARE. 18 | namespace HL.Xshtd 19 | { 20 | using System; 21 | using System.Collections.Generic; 22 | using ICSharpCode.AvalonEdit.Utils; 23 | 24 | /// 25 | /// A <SyntaxDefinition> Xml element. 26 | /// 27 | [Serializable] 28 | public class XshtdSyntaxDefinition : XshtdElement 29 | { 30 | /// 31 | /// Creates a new XshtdSyntaxDefinition object. 32 | /// 33 | public XshtdSyntaxDefinition() 34 | { 35 | this.Elements = new NullSafeCollection(); 36 | this.Extensions = new NullSafeCollection(); 37 | } 38 | 39 | /// 40 | /// Gets/sets the definition name 41 | /// 42 | public string Name { get; set; } 43 | 44 | /// 45 | /// Gets the associated extensions. 46 | /// 47 | public IList Extensions { get; private set; } 48 | 49 | /// 50 | /// Gets the collection of elements. 51 | /// 52 | public IList Elements { get; private set; } 53 | 54 | /// 55 | /// Applies the visitor to all elements. 56 | /// 57 | public void AcceptElements(IXshtdVisitor visitor) 58 | { 59 | foreach (XshtdElement element in Elements) 60 | { 61 | element.AcceptVisitor(visitor); 62 | } 63 | } 64 | 65 | /// 66 | /// Applies the visitor to this element. 67 | /// 68 | /// 69 | /// 70 | public override object AcceptVisitor(IXshtdVisitor visitor) 71 | { 72 | return visitor.VisitSyntaxDefinition(this); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /source/HL/Xshtd/interfaces/IFreezable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | // software and associated documentation files (the "Software"), to deal in the Software 5 | // without restriction, including without limitation the rights to use, copy, modify, merge, 6 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 7 | // to whom the Software is furnished to do so, subject to the following conditions: 8 | // 9 | // The above copyright notice and this permission notice shall be included in all copies or 10 | // substantial portions of the Software. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 13 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 14 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 15 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 16 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 17 | // DEALINGS IN THE SOFTWARE. 18 | namespace HL.Xshtd.interfaces 19 | { 20 | using System; 21 | using System.Collections.Generic; 22 | using System.Collections.ObjectModel; 23 | using System.Linq; 24 | 25 | /// 26 | /// Defines a freezable base for all objects that should be freezable. 27 | /// Frozen instances are immutable and thus thread-safe. 28 | /// 29 | interface IFreezable 30 | { 31 | /// 32 | /// Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe. 33 | /// 34 | bool IsFrozen { get; } 35 | 36 | /// 37 | /// Freezes this instance. 38 | /// 39 | void Freeze(); 40 | } 41 | 42 | static class FreezableHelper 43 | { 44 | public static void ThrowIfFrozen(IFreezable freezable) 45 | { 46 | if (freezable.IsFrozen) 47 | throw new InvalidOperationException("Cannot mutate frozen " + freezable.GetType().Name); 48 | } 49 | 50 | public static IList FreezeListAndElements(IList list) 51 | { 52 | if (list != null) 53 | { 54 | foreach (T item in list) 55 | Freeze(item); 56 | } 57 | 58 | return FreezeList(list); 59 | } 60 | 61 | public static IList FreezeList(IList list) 62 | { 63 | if (list == null || list.Count == 0) 64 | return new T[0]; 65 | 66 | if (list.IsReadOnly) 67 | { 68 | // If the list is already read-only, return it directly. 69 | // This is important, otherwise we might undo the effects of interning. 70 | return list; 71 | } 72 | else 73 | { 74 | return new ReadOnlyCollection(list.ToArray()); 75 | } 76 | } 77 | 78 | public static void Freeze(object item) 79 | { 80 | IFreezable f = item as IFreezable; 81 | 82 | if (f != null) 83 | f.Freeze(); 84 | } 85 | 86 | public static T FreezeAndReturn(T item) where T : IFreezable 87 | { 88 | item.Freeze(); 89 | 90 | return item; 91 | } 92 | 93 | /// 94 | /// If the item is not frozen, this method creates and returns a frozen clone. 95 | /// If the item is already frozen, it is returned without creating a clone. 96 | /// 97 | public static T GetFrozenClone(T item) where T : IFreezable, ICloneable 98 | { 99 | if (!item.IsFrozen) 100 | { 101 | item = (T)item.Clone(); 102 | item.Freeze(); 103 | } 104 | 105 | return item; 106 | } 107 | } 108 | 109 | /// 110 | /// Implements a freezable base for all objects that should be freezable. 111 | /// Frozen instances are immutable and thus thread-safe. 112 | /// 113 | [Serializable] 114 | public abstract class AbstractFreezable : IFreezable 115 | { 116 | private bool isFrozen; 117 | 118 | /// 119 | /// Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe. 120 | /// 121 | public bool IsFrozen 122 | { 123 | get { return isFrozen; } 124 | } 125 | 126 | /// 127 | /// Freezes this instance. 128 | /// 129 | public void Freeze() 130 | { 131 | if (!isFrozen) 132 | { 133 | FreezeInternal(); 134 | isFrozen = true; 135 | } 136 | } 137 | 138 | /// 139 | /// Provides a way of freezing additional elements defined in inheriting 140 | /// classes through the invocation of the method. 141 | /// 142 | protected virtual void FreezeInternal() 143 | { 144 | } 145 | } 146 | } -------------------------------------------------------------------------------- /source/HL/Xshtd/interfaces/IHighlightingDefinitionReferenceResolver.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Xshtd.interfaces 2 | { 3 | using HL.HighlightingTheme; 4 | 5 | /// 6 | /// Defines a resolver interface that can find highlighting theme definitions 7 | /// based on a highlighting name (searches within the current highlighting theme) 8 | /// or based on a highlighting name and name of highlighting theme that should 9 | /// contain the highlighting definition. 10 | /// 11 | public interface IHighlightingThemeDefinitionReferenceResolver 12 | { 13 | /// 14 | /// Gets a highlighting definition within the current highlighting theme 15 | /// by name, or null. 16 | /// 17 | /// 18 | /// 19 | SyntaxDefinition GetThemeDefinition(string highlightingName); 20 | 21 | /// 22 | /// Gets a highlighting theme definition by name from a given highlighting 23 | /// theme obtained via or null. 24 | /// 25 | /// 26 | /// 27 | SyntaxDefinition GetThemeDefinition(string hlThemeName, 28 | string highlightingName); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /source/HL/Xshtd/interfaces/IHighlightingThemeDefinition.cs: -------------------------------------------------------------------------------- 1 | namespace HL.Xshtd.interfaces 2 | { 3 | using HL.HighlightingTheme; 4 | using System.Collections.Generic; 5 | 6 | /// 7 | /// A highlighting definition. 8 | /// 9 | public interface IHighlightingThemeDefinition 10 | { 11 | /// 12 | /// Gets the name of the highlighting theme definition. 13 | /// 14 | string Name { get; } 15 | 16 | /// 17 | /// Gets a named highlighting color. 18 | /// 19 | /// The highlighting color, or null if it is not found. 20 | ////HighlightingColor GetNamedColor(string name); 21 | SyntaxDefinition GetNamedSyntaxDefinition(string name); 22 | 23 | /// 24 | /// Gets all global stayles in the collection of global styles. 25 | /// 26 | IEnumerable GlobalStyles { get; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /source/HL/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/source/HL/images/icon.png -------------------------------------------------------------------------------- /source/Readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Overview 3 | -------- 4 | 5 | This project shows how syntax highlighting can be integrated into WPF Theming to make both 6 | theme coloring functions look like a seemless application. The project demos WPF themes: 7 | 8 | - Dark 9 | - Light 10 | - True Blue (Light) 11 | - True Blue (Dark) 12 | 13 | which implement MLib based theming with a black or white background. Each of these WPF themes 14 | is associated with a dark/light highlighting theme defined via xshd resources in the 15 | themeable highlighting manager: 16 | 17 | HL.Manager.ThemedHighlightingManager 18 | 19 | This means we cannot only use dark/light WPF themes but also concert their application in 20 | conjunction with a matching highlighting definition for a given text file. 21 | 22 | - Dark -> Dark C# highlighting, Dark Java Highlighting ... 23 | - Light -> Light C# highlighting, Light Java Highlighting ... 24 | 25 | Original Source 26 | --------------- 27 | 28 | This project originates from this source: 29 | https://github.com/Dirkster99/MLib/tree/master/source/00_DemoTemplates 30 | 31 | This solution is intended as a template for developing (demo) applications 32 | that use MLib or related components. 33 | 34 | The solution is empty but does already support: 35 | - Dark and Light Theming 36 | - Is ready to Save/Load Application settings (requires activation in code) 37 | 38 | based on MVVM pattern. 39 | -------------------------------------------------------------------------------- /source/TextEditLib/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 | )] 11 | -------------------------------------------------------------------------------- /source/TextEditLib/Extensions/HighlightCurrentLineBackgroundRenderer.cs: -------------------------------------------------------------------------------- 1 | namespace TextEditLib.Extensions 2 | { 3 | using ICSharpCode.AvalonEdit; 4 | using ICSharpCode.AvalonEdit.Rendering; 5 | using System.Windows.Media; 6 | using System.Windows; 7 | 8 | /// 9 | /// AvalonEdit: highlight current line even when not focused 10 | /// 11 | /// Source: http://stackoverflow.com/questions/5072761/avalonedit-highlight-current-line-even-when-not-focused 12 | /// 13 | internal class HighlightCurrentLineBackgroundRenderer : IBackgroundRenderer 14 | { 15 | #region fields 16 | private readonly TextEdit _Editor; 17 | #endregion fields 18 | 19 | #region ctors 20 | /// 21 | /// Class Constructor from editor and SolidColorBrush definition 22 | /// 23 | /// 24 | public HighlightCurrentLineBackgroundRenderer(TextEdit editor) 25 | : this() 26 | { 27 | _Editor = editor; 28 | } 29 | 30 | /// 31 | /// Hidden class standard constructor 32 | /// 33 | protected HighlightCurrentLineBackgroundRenderer() 34 | { 35 | // Nothing to initialize here... 36 | } 37 | #endregion ctors 38 | 39 | #region properties 40 | /// 41 | /// Get the of the control. 42 | /// 43 | public KnownLayer Layer 44 | { 45 | get { return KnownLayer.Background; } 46 | } 47 | #endregion properties 48 | 49 | #region methods 50 | /// 51 | /// Draw the background line highlighting of the current line. 52 | /// 53 | /// 54 | /// 55 | public void Draw(TextView textView, DrawingContext drawingContext) 56 | { 57 | if (this._Editor == null) 58 | return; 59 | 60 | if (this._Editor.Document == null) 61 | return; 62 | 63 | if (_Editor.EditorCurrentLineBorderThickness == 0 && _Editor.EditorCurrentLineBackground == null) 64 | return; 65 | 66 | Pen borderPen = null; 67 | 68 | if (_Editor.EditorCurrentLineBorder != null) 69 | { 70 | borderPen = new Pen(_Editor.EditorCurrentLineBorder, _Editor.EditorCurrentLineBorderThickness); 71 | 72 | if (borderPen.CanFreeze) 73 | borderPen.Freeze(); 74 | } 75 | 76 | textView.EnsureVisualLines(); 77 | var currentLine = _Editor.Document.GetLineByOffset(_Editor.CaretOffset); 78 | 79 | foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine)) 80 | { 81 | drawingContext.DrawRectangle(_Editor.EditorCurrentLineBackground, borderPen, 82 | new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height))); 83 | } 84 | } 85 | #endregion methods 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Copy.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/source/TextEditLib/Resources/Icons/Copy.ico -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Copy_16x.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Cut.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/source/TextEditLib/Resources/Icons/Cut.ico -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Cut_16x.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Delete.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/source/TextEditLib/Resources/Icons/Delete.ico -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Delete_16x.svg: -------------------------------------------------------------------------------- 1 | 2 | 18 | 20 | 21 | 23 | image/svg+xml 24 | 26 | 27 | 28 | 29 | 30 | 32 | 52 | 54 | 58 | 64 | 65 | -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/OpenFile.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/source/TextEditLib/Resources/Icons/OpenFile.ico -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/OpenFile_16x.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Paste.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/source/TextEditLib/Resources/Icons/Paste.ico -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Paste_16x.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Redo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/source/TextEditLib/Resources/Icons/Redo.ico -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Redo_16x.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Undo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/AvalonEditHighlightingThemes/2f124c2e5989b717c2be89106b96b658476eb6d9/source/TextEditLib/Resources/Icons/Undo.ico -------------------------------------------------------------------------------- /source/TextEditLib/Resources/Icons/Undo_16x.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/TextEditLib/TextEdit.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace TextEditLib 2 | { 3 | using ICSharpCode.AvalonEdit; 4 | using System.Windows; 5 | using System.Windows.Media; 6 | using TextEditLib.Extensions; 7 | 8 | /// 9 | /// Implements an AvalonEdit control textedit control with extensions. 10 | /// 11 | public class TextEdit : TextEditor 12 | { 13 | #region fields 14 | #region EditorCurrentLine Highlighting Colors 15 | private static readonly DependencyProperty EditorCurrentLineBackgroundProperty = 16 | DependencyProperty.Register("EditorCurrentLineBackground", 17 | typeof(Brush), 18 | typeof(TextEdit), 19 | new UIPropertyMetadata(new SolidColorBrush(Colors.Transparent))); 20 | 21 | public static readonly DependencyProperty EditorCurrentLineBorderProperty = 22 | DependencyProperty.Register("EditorCurrentLineBorder", typeof(Brush), 23 | typeof(TextEdit), new PropertyMetadata(new SolidColorBrush( 24 | Color.FromArgb(0x60, SystemColors.HighlightBrush.Color.R, 25 | SystemColors.HighlightBrush.Color.G, 26 | SystemColors.HighlightBrush.Color.B)))); 27 | 28 | public static readonly DependencyProperty EditorCurrentLineBorderThicknessProperty = 29 | DependencyProperty.Register("EditorCurrentLineBorderThickness", typeof(double), 30 | typeof(TextEdit), new PropertyMetadata(2.0d)); 31 | #endregion EditorCurrentLine Highlighting Colors 32 | #endregion fields 33 | 34 | #region ctors 35 | /// 36 | /// Static class constructor 37 | /// 38 | static TextEdit() 39 | { 40 | DefaultStyleKeyProperty.OverrideMetadata(typeof(TextEdit), 41 | new FrameworkPropertyMetadata(typeof(TextEdit))); 42 | } 43 | 44 | /// 45 | /// Class constructor 46 | /// 47 | public TextEdit() 48 | { 49 | this.Loaded += TextEdit_Loaded; 50 | } 51 | #endregion ctors 52 | 53 | #region properties 54 | #region EditorCurrentLine Highlighting Colors 55 | /// 56 | /// Style the background color of the current editor line 57 | /// 58 | public Brush EditorCurrentLineBackground 59 | { 60 | get { return (Brush)GetValue(EditorCurrentLineBackgroundProperty); } 61 | set { SetValue(EditorCurrentLineBackgroundProperty, value); } 62 | } 63 | 64 | public Brush EditorCurrentLineBorder 65 | { 66 | get { return (Brush)GetValue(EditorCurrentLineBorderProperty); } 67 | set { SetValue(EditorCurrentLineBorderProperty, value); } 68 | } 69 | 70 | public double EditorCurrentLineBorderThickness 71 | { 72 | get { return (double)GetValue(EditorCurrentLineBorderThicknessProperty); } 73 | set { SetValue(EditorCurrentLineBorderThicknessProperty, value); } 74 | } 75 | #endregion EditorCurrentLine Highlighting Colors 76 | #endregion properties 77 | 78 | #region methods 79 | /// 80 | /// Method is invoked when the control is loaded for the first time. 81 | /// 82 | /// 83 | /// 84 | private void TextEdit_Loaded(object sender, RoutedEventArgs e) 85 | { 86 | AdjustCurrentLineBackground(); 87 | } 88 | 89 | /// 90 | /// Reset the to be used for highlighting the current editor line. 91 | /// 92 | private void AdjustCurrentLineBackground() 93 | { 94 | HighlightCurrentLineBackgroundRenderer oldRenderer = null; 95 | 96 | // Make sure there is only one of this type of background renderer 97 | // Otherwise, we might keep adding and WPF keeps drawing them on top of each other 98 | foreach (var item in this.TextArea.TextView.BackgroundRenderers) 99 | { 100 | if (item != null) 101 | { 102 | if (item is HighlightCurrentLineBackgroundRenderer) 103 | { 104 | oldRenderer = item as HighlightCurrentLineBackgroundRenderer; 105 | } 106 | } 107 | } 108 | 109 | if (oldRenderer != null) 110 | this.TextArea.TextView.BackgroundRenderers.Remove(oldRenderer); 111 | 112 | this.TextArea.TextView.BackgroundRenderers.Add(new HighlightCurrentLineBackgroundRenderer(this)); 113 | } 114 | #endregion methods 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /source/TextEditLib/TextEditLib.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.0;net4.5.2 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | Code 52 | TextEdit.xaml 53 | 54 | 55 | 56 | 57 | 58 | Designer 59 | 60 | 61 | Designer 62 | 63 | 64 | Designer 65 | 66 | 67 | Designer 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /source/TextEditLib/Themes/DarkBrushs.xaml: -------------------------------------------------------------------------------- 1 |  7 | 11 | #1ba1e2 12 | 13 | 18 | 19 | 24 | 25 | 30 | 31 | 36 | 37 | 43 | 44 | 50 | 51 | 56 | 57 | 62 | 63 | 64 | 69 | 70 | 71 | 72 | 77 | 78 | 84 | 85 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /source/TextEditLib/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /source/TextEditLib/Themes/Icons.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /source/TextEditLib/Themes/LightBrushs.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 12 | #1ba1e2 13 | 14 | 19 | 20 | 25 | 26 | 31 | 32 | 37 | 38 | 44 | 45 | 51 | 52 | 57 | 58 | 59 | 64 | 65 | 70 | 71 | 72 | 77 | 78 | 84 | 85 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /source/TextEditLib/Themes/ResourceKeys.cs: -------------------------------------------------------------------------------- 1 | namespace TextEditLib.Themes 2 | { 3 | using System.Windows; 4 | 5 | public static class ResourceKeys 6 | { 7 | #region Accent Keys 8 | /// 9 | /// Accent Color Key - This Color key is used to accent elements in the UI 10 | /// (e.g.: Color of Activated Normal Window Frame, ResizeGrip, Focus or MouseOver input elements) 11 | /// 12 | public static readonly ComponentResourceKey ControlAccentColorKey = new ComponentResourceKey(typeof(ResourceKeys), "ControlAccentColorKey"); 13 | 14 | /// 15 | /// Accent Brush Key - This Brush key is used to accent elements in the UI 16 | /// (e.g.: Color of Activated Normal Window Frame, ResizeGrip, Focus or MouseOver input elements) 17 | /// 18 | public static readonly ComponentResourceKey ControlAccentBrushKey = new ComponentResourceKey(typeof(ResourceKeys), "ControlAccentBrushKey"); 19 | #endregion Accent Keys 20 | 21 | #region TextEditor BrushKeys 22 | public static readonly ComponentResourceKey EditorBackground = new ComponentResourceKey(typeof(ResourceKeys), "EditorBackground"); 23 | public static readonly ComponentResourceKey EditorForeground = new ComponentResourceKey(typeof(ResourceKeys), "EditorForeground"); 24 | public static readonly ComponentResourceKey EditorLineNumbersForeground = new ComponentResourceKey(typeof(ResourceKeys), "EditorLineNumbersForeground"); 25 | public static readonly ComponentResourceKey EditorSelectionBrush = new ComponentResourceKey(typeof(ResourceKeys), "EditorSelectionBrush"); 26 | public static readonly ComponentResourceKey EditorSelectionBorder = new ComponentResourceKey(typeof(ResourceKeys), "EditorSelectionBorder"); 27 | public static readonly ComponentResourceKey EditorNonPrintableCharacterBrush = new ComponentResourceKey(typeof(ResourceKeys), "EditorNonPrintableCharacterBrush"); 28 | public static readonly ComponentResourceKey EditorLinkTextForegroundBrush = new ComponentResourceKey(typeof(ResourceKeys), "EditorLinkTextForegroundBrush"); 29 | public static readonly ComponentResourceKey EditorLinkTextBackgroundBrush = new ComponentResourceKey(typeof(ResourceKeys), "EditorLinkTextBackgroundBrush"); 30 | 31 | #region DiffView Currentline Keys 32 | /// 33 | /// Gets the background color for highlighting for the currently highlighed line. 34 | /// 35 | public static readonly ComponentResourceKey EditorCurrentLineBackgroundBrushKey = new ComponentResourceKey(typeof(ResourceKeys), "EditorCurrentLineBackgroundBrushKey"); 36 | 37 | /// 38 | /// Gets the border color for highlighting for the currently highlighed line. 39 | /// 40 | public static readonly ComponentResourceKey EditorCurrentLineBorderBrushKey = new ComponentResourceKey(typeof(ResourceKeys), "EditorCurrentLineBorderBrushKey"); 41 | 42 | /// 43 | /// Gets the border thickness for highlighting for the currently highlighed line. 44 | /// 45 | public static readonly ComponentResourceKey EditorCurrentLineBorderThicknessKey = new ComponentResourceKey(typeof(ResourceKeys), "EditorCurrentLineBorderThicknessKey"); 46 | #endregion DiffView Currentline Keys 47 | #endregion TextEditor BrushKeys 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /source/ThemedDemo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /source/ThemedDemo/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /source/ThemedDemo/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 | )] 11 | -------------------------------------------------------------------------------- /source/ThemedDemo/BindToMLib/MWindowLib/DarkLightBrushs.xaml: -------------------------------------------------------------------------------- 1 |  9 | 11 | Blue 13 | 14 | 17 | 18 | 19 | #FFF4F4F5 21 | 22 | #FF2D2D30 24 | 25 | 28 | 29 | 32 | 33 | 34 | #FF3F3F41 36 | 37 | 40 | 41 | -------------------------------------------------------------------------------- /source/ThemedDemo/Converters/NullToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo.Converters 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows; 6 | using System.Windows.Data; 7 | 8 | [ValueConversion(typeof(object), typeof(Visibility))] 9 | public class NullToVisibilityConverter : IValueConverter 10 | { 11 | #region fields 12 | 13 | #endregion fields 14 | 15 | #region ctors 16 | /// 17 | /// Class constructor 18 | /// 19 | public NullToVisibilityConverter() 20 | { 21 | NullValue = Visibility.Collapsed; 22 | NotNullValue = Visibility.Visible; 23 | } 24 | #endregion ctors 25 | 26 | #region properties 27 | public Visibility NullValue { get; set; } 28 | 29 | public Visibility NotNullValue { get; set; } 30 | #endregion properties 31 | 32 | #region methods 33 | 34 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 35 | { 36 | if (value == null) 37 | return NullValue; 38 | 39 | return NotNullValue; 40 | } 41 | 42 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 43 | { 44 | throw new NotImplementedException(); 45 | } 46 | #endregion methods 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /source/ThemedDemo/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo 2 | { 3 | using Settings.UserProfile; 4 | 5 | /// 6 | /// Interaction logic for MainWindow.xaml 7 | /// 8 | public partial class MainWindow : MWindowLib.MetroWindow 9 | , IViewSize // Implements saving and loading/repositioning of Window 10 | { 11 | public MainWindow() 12 | { 13 | InitializeComponent(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /source/ThemedDemo/Models/AppCore.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo.Models 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Reflection; 6 | 7 | /// 8 | /// Class supplies a set of common static helper methodes that help 9 | /// localizing application specific items such as setting folders etc. 10 | /// 11 | public class AppCore 12 | { 13 | #region properties 14 | /// 15 | /// Get the name of the executing assembly (usually name of *.exe file) 16 | /// 17 | internal static string AssemblyTitle 18 | { 19 | get 20 | { 21 | return Assembly.GetEntryAssembly().GetName().Name; 22 | } 23 | } 24 | 25 | // 26 | // Summary: 27 | // Gets the path or UNC location of the loaded file that contains the manifest. 28 | // 29 | // Returns: 30 | // The location of the loaded file that contains the manifest. If the loaded 31 | // file was shadow-copied, the location is that of the file after being shadow-copied. 32 | // If the assembly is loaded from a byte array, such as when using the System.Reflection.Assembly.Load(System.Byte[]) 33 | // method overload, the value returned is an empty string (""). 34 | internal static string AssemblyEntryLocation 35 | { 36 | get 37 | { 38 | return System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); 39 | } 40 | } 41 | 42 | /// 43 | /// Get a path to the directory where the user store his documents 44 | /// 45 | public static string MyDocumentsUserDir 46 | { 47 | get 48 | { 49 | return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); 50 | } 51 | } 52 | 53 | public static string Company 54 | { 55 | get 56 | { 57 | return "ThemedDemo"; 58 | } 59 | } 60 | public static string Application_Title 61 | { 62 | get 63 | { 64 | return "ThemedDemo"; 65 | } 66 | } 67 | 68 | /// 69 | /// Get a path to the directory where the application 70 | /// can persist/load user data on session exit and re-start. 71 | /// 72 | public static string DirAppData 73 | { 74 | get 75 | { 76 | return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + 77 | System.IO.Path.DirectorySeparatorChar + 78 | AppCore.Company; 79 | } 80 | } 81 | 82 | //// /// 83 | //// /// Get path and file name to application specific settings file 84 | //// /// 85 | //// public static string DirFileAppSettingsData 86 | //// { 87 | //// get 88 | //// { 89 | //// return System.IO.Path.Combine(AppCore.DirAppData, 90 | //// string.Format(CultureInfo.InvariantCulture, "{0}.App.settings", AppCore.AssemblyTitle)); 91 | //// } 92 | //// } 93 | 94 | /// 95 | /// Get path and file name to application specific session file 96 | /// 97 | public static string DirFileAppSessionData 98 | { 99 | get 100 | { 101 | return System.IO.Path.Combine(AppCore.DirAppData, 102 | string.Format(CultureInfo.InvariantCulture, "{0}.App.session", AppCore.AssemblyTitle)); 103 | } 104 | } 105 | #endregion properties 106 | 107 | #region methods 108 | /// 109 | /// Create a dedicated directory to store program settings and session data 110 | /// 111 | /// 112 | public static bool CreateAppDataFolder() 113 | { 114 | try 115 | { 116 | if (System.IO.Directory.Exists(AppCore.DirAppData) == false) 117 | System.IO.Directory.CreateDirectory(AppCore.DirAppData); 118 | } 119 | catch 120 | { 121 | return false; 122 | } 123 | 124 | return true; 125 | } 126 | #endregion methods 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /source/ThemedDemo/Models/SettingDefaults.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo.Models 2 | { 3 | using Settings.Interfaces; 4 | using SettingsModel.Interfaces; 5 | using System.Windows.Media; 6 | 7 | /// 8 | /// Class contains all methods necessary to initialize the applications settings model. 9 | /// 10 | internal static class SettingDefaults 11 | { 12 | /// 13 | /// Create the minimal settings model that should be used for every application. 14 | /// This model does not include advanced features like theming etc... 15 | /// 16 | /// 17 | public static void CreateGeneralSettings(IEngine options) 18 | { 19 | const string groupName = "Options"; 20 | 21 | options.AddOption(groupName, "ReloadOpenFilesFromLastSession", typeof(bool), false, true); 22 | options.AddOption(groupName, "SourceFilePath", typeof(string), false, @"C:\temp\source\"); 23 | options.AddOption(groupName, "LanguageSelected", typeof(string), false, "en-US"); 24 | 25 | // var schema = optsEngine.AddListOption(groupName, "BookmarkedFolders", typeof(string), false, new List()); 26 | // schema.List_AddValue(@"C:\TEMP", @"C:\TEMP"); 27 | // schema.List_AddValue(@"C:\Windows", @"C:\Windows"); 28 | } 29 | 30 | /// 31 | /// Create the minimal settings model that should be used for every application. 32 | /// 33 | /// 34 | public static void CreateAppearanceSettings(IEngine options, ISettingsManager settings) 35 | { 36 | const string groupName = "Appearance"; 37 | 38 | options.AddOption(groupName, "ThemeDisplayName", typeof(string), false, "Light"); 39 | options.AddOption(groupName, "ApplyWindowsDefaultAccent", typeof(bool), false, true); 40 | options.AddOption(groupName, "AccentColor", typeof(Color), false, Color.FromRgb(0x33, 0x99, 0xff)); 41 | 42 | // options.AddOption(groupName, "DefaultIconSize", typeof(int), false, settings.DefaultIconSize); 43 | // options.AddOption(groupName, "DefaultFontSize", typeof(int), false, settings.DefaultFontSize); 44 | // options.AddOption(groupName, "FixedFontSize", typeof(int), false, settings.DefaultFixedFontSize); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /source/ThemedDemo/Models/ThemeDefinition.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo.Models 2 | { 3 | using MLib.Interfaces; 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | /// 8 | /// Implements a model that keeps track of all elements belonging to a WPF Theme 9 | /// including highlighting theme, display name, required resources (XAML) and so forth. 10 | /// 11 | public class ThemeDefinition : IThemeInfo 12 | { 13 | #region constructors 14 | /// 15 | /// Class constructor 16 | /// 17 | /// 18 | /// 19 | public ThemeDefinition(string themeName, 20 | List themeSources, 21 | string highlightingThemeName) 22 | : this() 23 | { 24 | DisplayName = themeName; 25 | 26 | if (themeSources != null) 27 | { 28 | foreach (var item in themeSources) 29 | ThemeSources.Add(new Uri(item.OriginalString, UriKind.Relative)); 30 | } 31 | 32 | HighlightingThemeName = highlightingThemeName; 33 | } 34 | 35 | /// 36 | /// Copy constructor from parameter. 37 | /// 38 | /// 39 | public ThemeDefinition(IThemeInfo theme) 40 | : this() 41 | { 42 | this.DisplayName = theme.DisplayName; 43 | this.ThemeSources = new List(theme.ThemeSources); 44 | } 45 | 46 | /// 47 | /// Hidden standard constructor 48 | /// 49 | protected ThemeDefinition() 50 | { 51 | DisplayName = string.Empty; 52 | ThemeSources = new List(); 53 | } 54 | #endregion constructors 55 | 56 | #region properties 57 | /// 58 | /// Gets the displayable (localized) name for this theme. 59 | /// 60 | public string DisplayName { get; private set; } 61 | 62 | /// 63 | /// Gets the Uri sources for this theme. 64 | /// 65 | public List ThemeSources { get; private set; } 66 | 67 | /// 68 | /// Gets the name of the associated Highlighting Theme for AvalonEdit. 69 | /// 70 | /// This highlighting theme should be configured such that it matches the 71 | /// themeing colors of the overall WPF theme that is defined in this object. 72 | /// 73 | public string HighlightingThemeName { get; private set; } 74 | #endregion properties 75 | 76 | #region methods 77 | /// 78 | /// Adds additional resource file references into the existing theme definition. 79 | /// 80 | /// 81 | public void AddResources(List additionalResource) 82 | { 83 | foreach (var item in additionalResource) 84 | ThemeSources.Add(item); 85 | } 86 | #endregion methods 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /source/ThemedDemo/ThemedDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | netcoreapp3.0;net4.5.2 6 | true 7 | 8 | 9 | 10 | 11 | 1.1.19 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | Designer 32 | MSBuild:Compile 33 | 34 | 35 | 36 | 37 | 38 | Code 39 | App.xaml 40 | 41 | 42 | Code 43 | MainWindow.xaml 44 | 45 | 46 | 47 | 48 | 49 | Designer 50 | 51 | 52 | Designer 53 | MSBuild:Compile 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /source/ThemedDemo/ViewModels/Base/ModelBase.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo.ViewModels.Base 2 | { 3 | public class ModelBase 4 | { 5 | /// 6 | /// Gets an instance of the service container and retrieves the requested service coponent. 7 | /// 8 | /// 9 | /// 10 | public TServiceContract GetService() where TServiceContract : class 11 | { 12 | return ServiceLocator.ServiceContainer.Instance.GetService(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /source/ThemedDemo/ViewModels/Base/ViewModelBase.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo.ViewModels.Base 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | using System.Linq.Expressions; 6 | 7 | /// 8 | /// Implements a base class for all viewmodel classes 9 | /// that implements interface for binding. 10 | /// 11 | public class ViewModelBase : ModelBase, INotifyPropertyChanged 12 | { 13 | /// 14 | /// Standard implementation of . 15 | /// 16 | public event PropertyChangedEventHandler PropertyChanged; 17 | 18 | /// 19 | /// Tell bound controls (via WPF binding) to refresh their display. 20 | /// 21 | /// Sample call: this.NotifyPropertyChanged(() => this.IsSelected); 22 | /// where 'this' is derived from 23 | /// and IsSelected is a property. 24 | /// 25 | /// 26 | /// 27 | public void NotifyPropertyChanged(Expression> property) 28 | { 29 | var lambda = (LambdaExpression)property; 30 | MemberExpression memberExpression; 31 | 32 | if (lambda.Body is UnaryExpression) 33 | { 34 | var unaryExpression = (UnaryExpression)lambda.Body; 35 | memberExpression = (MemberExpression)unaryExpression.Operand; 36 | } 37 | else 38 | memberExpression = (MemberExpression)lambda.Body; 39 | 40 | this.NotifyPropertyChanged(memberExpression.Member.Name); 41 | } 42 | 43 | /// 44 | /// Tell bound controls (via WPF binding) to refresh their display. 45 | /// Standard implementation through . 46 | /// 47 | /// 48 | protected virtual void NotifyPropertyChanged(string propertyName) 49 | { 50 | if (this.PropertyChanged != null) 51 | this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /source/ThemedDemo/ViewModels/ThemeDefinitionViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace ThemedDemo.ViewModels 2 | { 3 | using MLib.Interfaces; 4 | 5 | public class ThemeDefinitionViewModel : Base.ViewModelBase 6 | { 7 | #region private fields 8 | private bool _IsSelected; 9 | readonly private IThemeInfo _model; 10 | #endregion private fields 11 | 12 | #region constructors 13 | /// 14 | /// Class constructor 15 | /// 16 | /// 17 | public ThemeDefinitionViewModel(IThemeInfo model) 18 | { 19 | _model = model; 20 | } 21 | 22 | protected ThemeDefinitionViewModel() 23 | { 24 | _model = null; 25 | _IsSelected = false; 26 | } 27 | #endregion constructors 28 | 29 | #region properties 30 | /// 31 | /// Gets the static theme model based data items. 32 | /// 33 | public IThemeInfo Model 34 | { 35 | get 36 | { 37 | return _model; 38 | } 39 | } 40 | 41 | /// 42 | /// Determines whether this theme is currently selected or not. 43 | /// 44 | public bool IsSelected 45 | { 46 | get { return _IsSelected; } 47 | 48 | set 49 | { 50 | if (_IsSelected != value) 51 | { 52 | _IsSelected = value; 53 | } 54 | } 55 | } 56 | #endregion properties 57 | } 58 | } 59 | --------------------------------------------------------------------------------