PageRenderTime 63ms CodeModel.GetById 2ms app.highlight 47ms RepoModel.GetById 1ms app.codeStats 0ms

/DBDiff.Scintilla NET-2.0/ScintillaNET/Configuration/ConfigurationManager.cs

https://bitbucket.org/vadim/sql-dbdiff
C# | 1589 lines | 1275 code | 282 blank | 32 comment | 438 complexity | 1eea2612e4de1c41e493c2fe280a4621 MD5 | raw file
   1using System;
   2using System.Collections.Generic;
   3using System.Text;
   4using System.IO;
   5using System.Text.RegularExpressions;
   6using System.Drawing;
   7using System.ComponentModel;
   8using System.Windows.Forms;
   9namespace DBDiff.Scintilla.Configuration
  10{
  11	[TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConverter))]
  12	public class ConfigurationManager : ScintillaHelperBase
  13	{
  14		private bool _useXmlReader = true;
  15		public bool UseXmlReader
  16		{
  17			get { return _useXmlReader; }
  18			set
  19			{
  20				_useXmlReader = value;
  21			}
  22		}
  23        
  24		internal ConfigurationManager(Scintilla scintilla) : base(scintilla) { }
  25
  26		internal bool ShouldSerialize()
  27		{
  28			return ShouldSerializeClearKeyBindings() ||
  29				ShouldSerializeClearMargins() ||
  30				ShouldSerializeClearSnippets() ||
  31				ShouldSerializeClearStyles() ||
  32				ShouldSerializeCustomLocation() ||
  33				ShouldSerializeIsBuiltInEnabled() ||
  34				ShouldSerializeIsUserEnabled() ||
  35				ShouldSerializeLanguage() ||
  36				ShouldSerializeLoadOrder();
  37		}
  38
  39		
  40
  41		protected internal override void Initialize()
  42		{
  43			if (_language != null)
  44				Configure();
  45		}
  46
  47		#region Language
  48		private string _language;
  49		public string Language
  50		{
  51			get
  52			{
  53				return _language;
  54			}
  55			set
  56			{
  57				_language = value;
  58
  59				if (!Scintilla.IsDesignMode)
  60					Configure();
  61			}
  62		}
  63
  64		private bool ShouldSerializeLanguage()
  65		{
  66			return !string.IsNullOrEmpty(_language);
  67		}
  68
  69		private void ResetLanguage()
  70		{
  71			_language = null;
  72		} 
  73		#endregion
  74
  75		#region IsBuiltInEnabled
  76		private bool _isBuiltInEnabled = true;
  77		public bool IsBuiltInEnabled
  78		{
  79			get
  80			{
  81				return _isBuiltInEnabled;
  82			}
  83			set
  84			{
  85				_isBuiltInEnabled = value;
  86			}
  87		}
  88
  89		private bool ShouldSerializeIsBuiltInEnabled()
  90		{
  91			return !_isBuiltInEnabled;
  92		}
  93
  94		private void ResetIsBuiltInEnabled()
  95		{
  96			_isBuiltInEnabled = true;
  97		} 
  98		#endregion
  99
 100		#region IsUserEnabled
 101		private bool _isUserEnabled = true;
 102		public bool IsUserEnabled
 103		{
 104			get
 105			{
 106				return _isUserEnabled;
 107			}
 108			set
 109			{
 110				_isUserEnabled = value;
 111			}
 112		}
 113
 114		private bool ShouldSerializeIsUserEnabled()
 115		{
 116			return !_isUserEnabled;
 117		}
 118
 119		private void ResetIsUserEnabled()
 120		{
 121			_isUserEnabled = true;
 122		} 
 123		#endregion
 124
 125		#region CustomLocation
 126		private string _customLocation;
 127		public string CustomLocation
 128		{
 129			get
 130			{
 131				return _customLocation;
 132			}
 133			set
 134			{
 135				_customLocation = value;
 136			}
 137		}
 138
 139		private bool ShouldSerializeCustomLocation()
 140		{
 141			return !string.IsNullOrEmpty(_customLocation);
 142		}
 143
 144		private void ResetCustomLocation()
 145		{
 146			_customLocation = string.Empty;
 147		} 
 148		#endregion
 149
 150		#region ConfigurationLoadOrder
 151		private ConfigurationLoadOrder _loadOrder = ConfigurationLoadOrder.BuiltInCustomUser;
 152		public ConfigurationLoadOrder LoadOrder
 153		{
 154			get
 155			{
 156				return _loadOrder;
 157			}
 158			set
 159			{
 160				_loadOrder = value;
 161			}
 162		}
 163
 164		private bool ShouldSerializeLoadOrder()
 165		{
 166			return _loadOrder != ConfigurationLoadOrder.BuiltInCustomUser;
 167		}
 168
 169		private void ResetLoadOrder()
 170		{
 171			_loadOrder = ConfigurationLoadOrder.BuiltInCustomUser;
 172		} 
 173		#endregion
 174
 175		#region ClearKeyBindings
 176		private bool _clearKeyBindings = false;
 177		public bool ClearKeyBindings
 178		{
 179			get
 180			{
 181				return _clearKeyBindings;
 182			}
 183			set
 184			{
 185				_clearKeyBindings = value;
 186			}
 187		}
 188
 189		private bool ShouldSerializeClearKeyBindings()
 190		{
 191			return _clearKeyBindings;
 192		}
 193
 194		private void ResetClearKeyBindings()
 195		{
 196			_clearKeyBindings = false;
 197		}
 198
 199		#endregion
 200
 201		#region ClearStyles
 202		private bool _clearStyles = false;
 203		public bool ClearStyles
 204		{
 205			get
 206			{
 207				return _clearStyles;
 208			}
 209			set
 210			{
 211				_clearStyles = value;
 212			}
 213		}
 214
 215		private bool ShouldSerializeClearStyles()
 216		{
 217			return _clearStyles;
 218		}
 219
 220		private void ResetClearStyles()
 221		{
 222			_clearStyles = false;
 223		} 
 224		#endregion
 225
 226		#region ClearIndicators
 227		private bool _clearIndicators = false;
 228		public bool ClearIndicators
 229		{
 230			get
 231			{
 232				return _clearIndicators;
 233			}
 234			set
 235			{
 236				_clearIndicators = value;
 237			}
 238		}
 239
 240		private bool ShouldSerializeClearIndicators()
 241		{
 242			return _clearIndicators;
 243		}
 244
 245		private void ResetClearIndicators()
 246		{
 247			_clearIndicators = false;
 248		} 
 249		#endregion
 250
 251		#region ClearSnippets
 252		private bool _clearSnippets = false;
 253		public bool ClearSnippets
 254		{
 255			get
 256			{
 257				return _clearSnippets;
 258			}
 259			set
 260			{
 261				_clearSnippets = value;
 262			}
 263		}
 264
 265		private bool ShouldSerializeClearSnippets()
 266		{
 267			return _clearSnippets;
 268		}
 269
 270		private void ResetClearSnippets()
 271		{
 272			_clearSnippets = false;
 273		} 
 274		#endregion
 275
 276		#region ClearMargins
 277		private bool _clearMargins = false;
 278		public bool ClearMargins
 279		{
 280			get
 281			{
 282				return _clearMargins;
 283			}
 284			set
 285			{
 286				_clearMargins = value;
 287			}
 288		}
 289
 290		private bool ShouldSerializeClearMargins()
 291		{
 292			return _clearMargins;
 293		}
 294
 295		private void ResetClearMargins()
 296		{
 297			_clearMargins = true;
 298		} 
 299		#endregion
 300
 301		#region ClearMarkers
 302		private bool _clearMarkers = false;
 303		public bool ClearMarkers
 304		{
 305			get
 306			{
 307				return _clearMarkers;
 308			}
 309			set
 310			{
 311				_clearMarkers = value;
 312			}
 313		}
 314
 315		private bool ShouldSerializeClearMarkers()
 316		{
 317			return _clearMarkers;
 318		}
 319
 320		private void ResetClearMarkers()
 321		{
 322			_clearMarkers = false;
 323		} 
 324		#endregion
 325
 326		private string _appDataFolder;
 327		private string _userFolder;
 328		private string userFolder
 329		{
 330			get
 331			{
 332				if (_appDataFolder == null)
 333					_appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
 334
 335				if (_userFolder == null)
 336				{
 337					Version v = GetType().Assembly.GetName().Version;
 338					
 339					_userFolder = Path.Combine(Path.Combine(_appDataFolder, "ScintillaNET"), v.Major.ToString() + "." + v.Minor.ToString());
 340				}
 341
 342				return _userFolder;
 343			}
 344		}
 345
 346		public void Configure()
 347		{
 348			if (Scintilla.IsDesignMode || Scintilla.IsInitializing)
 349				return;
 350
 351			Configuration builtInDefault = null, 
 352				builtInLang = null, 
 353				customDefault = null, 
 354				customLang = null, 
 355				userDefault = null, 
 356				userLang = null;
 357
 358			if (_isBuiltInEnabled)
 359			{
 360                using (Stream s = GetType().Assembly.GetManifestResourceStream("DBDiff.Scintilla.Configuration.Builtin.default.xml"))
 361					builtInDefault = new Configuration(s, "default", _useXmlReader);
 362				if (!string.IsNullOrEmpty(_language))
 363                    using (Stream s = GetType().Assembly.GetManifestResourceStream("DBDiff.Scintilla.Configuration.Builtin." + _language + ".xml"))
 364						if (s != null)
 365							builtInLang = new Configuration(s, _language, _useXmlReader);
 366			}
 367
 368			if (_isUserEnabled)
 369			{
 370				string defPath = Path.Combine(userFolder, "default.xml");
 371				if (File.Exists(defPath))
 372					userDefault = new Configuration(defPath, "default", _useXmlReader);
 373
 374				if (!string.IsNullOrEmpty(_language))
 375				{
 376					string langPath = Path.Combine(userFolder, _language + ".xml");
 377					if (File.Exists(langPath))
 378						userLang = new Configuration(langPath, _language, _useXmlReader);
 379				}
 380			}
 381
 382			if (!string.IsNullOrEmpty(_customLocation))
 383			{
 384				string defPath = Path.Combine(_customLocation, "default.xml");
 385				if (File.Exists(defPath))
 386					customDefault = new Configuration(defPath, "default", _useXmlReader);
 387
 388				if (!string.IsNullOrEmpty(_language))
 389				{
 390					string langPath = Path.Combine(_customLocation, _language + ".xml");
 391					if (File.Exists(langPath))
 392						customLang = new Configuration(langPath, _language, _useXmlReader);
 393				}
 394			}
 395
 396			List<Configuration> configList = new List<Configuration>();
 397			if (_loadOrder == ConfigurationLoadOrder.BuiltInCustomUser)
 398			{
 399				if (builtInDefault != null)
 400					configList.Add(builtInDefault);
 401				if (builtInLang != null)
 402					configList.Add(builtInLang);
 403
 404				if (customDefault != null)
 405					configList.Add(customDefault);
 406
 407				if (customLang != null)
 408					configList.Add(customLang);
 409
 410				if (userDefault != null)
 411					configList.Add(userDefault);
 412
 413				if (userLang != null)
 414					configList.Add(userLang);
 415			}
 416			else if (_loadOrder == ConfigurationLoadOrder.BuiltInUserCustom)
 417			{
 418				if (builtInDefault != null)
 419					configList.Add(builtInDefault);
 420
 421				if (builtInLang != null)
 422					configList.Add(builtInLang);
 423
 424				if (userDefault != null)
 425					configList.Add(userDefault);
 426
 427				if (userLang != null)
 428					configList.Add(userLang);
 429
 430				if (customDefault != null)
 431					configList.Add(customDefault);
 432
 433				if (customLang != null)
 434					configList.Add(customLang);
 435			}
 436			else if (_loadOrder == ConfigurationLoadOrder.CustomBuiltInUser)
 437			{
 438				if (customDefault != null)
 439					configList.Add(customDefault);
 440
 441				if (customLang != null)
 442					configList.Add(customLang);
 443
 444				if (builtInDefault != null)
 445					configList.Add(builtInDefault);
 446
 447				if (builtInLang != null)
 448					configList.Add(builtInLang);
 449
 450				if (userDefault != null)
 451					configList.Add(userDefault);
 452
 453				if (userLang != null)
 454					configList.Add(userLang);
 455			}
 456			else if (_loadOrder == ConfigurationLoadOrder.CustomUserBuiltIn)
 457			{
 458				if (customDefault != null)
 459					configList.Add(customDefault);
 460
 461				if (customLang != null)
 462					configList.Add(customLang);
 463
 464				if (userDefault != null)
 465					configList.Add(userDefault);
 466
 467				if (userLang != null)
 468					configList.Add(userLang);
 469
 470				if (builtInDefault != null)
 471					configList.Add(builtInDefault);
 472
 473				if (builtInLang != null)
 474					configList.Add(builtInLang);
 475			}
 476			else if (_loadOrder == ConfigurationLoadOrder.UserBuiltInCustom)
 477			{
 478				if (userDefault != null)
 479					configList.Add(userDefault);
 480
 481				if (userLang != null)
 482					configList.Add(userLang);
 483
 484				if (builtInDefault != null)
 485					configList.Add(builtInDefault);
 486
 487				if (builtInLang != null)
 488					configList.Add(builtInLang);
 489
 490				if (customDefault != null)
 491					configList.Add(customDefault);
 492
 493				if (customLang != null)
 494					configList.Add(customLang);
 495
 496			}
 497			else if (_loadOrder == ConfigurationLoadOrder.UserCustomBuiltIn)
 498			{
 499				if (userDefault != null)
 500					configList.Add(userDefault);
 501
 502				if (userLang != null)
 503					configList.Add(userLang);
 504
 505				if (customDefault != null)
 506					configList.Add(customDefault);
 507
 508				if (customLang != null)
 509					configList.Add(customLang);
 510
 511				if (builtInDefault != null)
 512					configList.Add(builtInDefault);
 513
 514				if (builtInLang != null)
 515					configList.Add(builtInLang);
 516			}
 517
 518			Configure(configList);
 519		}
 520
 521		public void Configure(Configuration config)
 522		{
 523			Configure(new List<Configuration>(new Configuration[] { config }));			
 524		}
 525
 526		internal void Configure(List<Configuration> configList)
 527		{
 528			//	So here is the general pattern: We go through each of
 529			//	the configurations in the list (which has been ordered
 530			//	by priority). If the configuration has a value we're
 531			//	looking for it overwrites whatever was before it.
 532			//	In the end if the value isn't null, we set the
 533			//	corresponding Scintilla Value to this.
 534			bool? b = null;
 535			int? i = null;
 536			Color co = Color.Empty;
 537			char? ch = null;
 538			string s = null;
 539
 540			b = null;
 541			ch = null;
 542			s = null;
 543
 544			co = Color.Empty;
 545			foreach (Configuration c in configList)
 546			{
 547				if (c.CallTip_BackColor != Color.Empty)
 548					co = c.CallTip_BackColor;
 549
 550			}
 551			if (co != Color.Empty)
 552				Scintilla.CallTip.BackColor = co;
 553
 554			co = Color.Empty;
 555			foreach (Configuration c in configList)
 556			{
 557				if (c.CallTip_ForeColor != Color.Empty)
 558					co = c.CallTip_ForeColor;
 559
 560			}
 561			if (co != Color.Empty)
 562				Scintilla.CallTip.ForeColor = co;
 563
 564			co = Color.Empty;
 565			foreach (Configuration c in configList)
 566			{
 567				if (c.CallTip_HighlightTextColor != Color.Empty)
 568					co = c.CallTip_HighlightTextColor;
 569
 570			}
 571			if (co != Color.Empty)
 572				Scintilla.CallTip.HighlightTextColor = co;
 573
 574			i = null;
 575			foreach (Configuration c in configList)
 576			{
 577				if (c.Caret_BlinkRate.HasValue)
 578					i = c.Caret_BlinkRate;
 579			}
 580			if (i.HasValue)
 581				Scintilla.Caret.BlinkRate = i.Value;
 582
 583			co = Color.Empty;
 584			foreach (Configuration c in configList)
 585			{
 586				if (c.Caret_Color != Color.Empty)
 587					co = c.Caret_Color;
 588
 589			}
 590			if (co != Color.Empty)
 591				Scintilla.Caret.Color = co;
 592
 593			i = null;
 594			foreach (Configuration c in configList)
 595			{
 596				if (c.Caret_CurrentLineBackgroundAlpha.HasValue)
 597					i = c.Caret_CurrentLineBackgroundAlpha;
 598			}
 599			if (i.HasValue)
 600				Scintilla.Caret.CurrentLineBackgroundAlpha = i.Value;
 601
 602			co = Color.Empty;
 603			foreach (Configuration c in configList)
 604			{
 605				if (c.Caret_CurrentLineBackgroundColor != Color.Empty)
 606					co = c.Caret_CurrentLineBackgroundColor;
 607
 608			}
 609			if (co != Color.Empty)
 610				Scintilla.Caret.CurrentLineBackgroundColor = co;
 611
 612			b = null;
 613			foreach (Configuration c in configList)
 614			{
 615				if (c.Caret_HighlightCurrentLine.HasValue)
 616					b = c.Caret_HighlightCurrentLine;
 617
 618			}
 619			if (b.HasValue)
 620				Scintilla.Caret.HighlightCurrentLine = b.Value;
 621
 622			b = null;
 623			foreach (Configuration c in configList)
 624			{
 625				if (c.Caret_IsSticky.HasValue)
 626					b = c.Caret_IsSticky;
 627
 628			}
 629			if (b.HasValue)
 630				Scintilla.Caret.IsSticky = b.Value;
 631
 632
 633			CaretStyle? caretStyle = null;
 634			foreach (Configuration c in configList)
 635			{
 636				if (c.Caret_Style.HasValue)
 637					caretStyle = c.Caret_Style;
 638			}
 639			if (caretStyle.HasValue)
 640				Scintilla.Caret.Style = caretStyle.Value;
 641
 642			i = null;
 643			foreach (Configuration c in configList)
 644			{
 645				if (c.Caret_Width.HasValue)
 646					i = c.Caret_Width;
 647			}
 648			if (i.HasValue)
 649				Scintilla.Caret.Width = i.Value;
 650
 651			b = null;
 652			foreach (Configuration c in configList)
 653			{
 654				if (c.Clipboard_ConvertEndOfLineOnPaste.HasValue)
 655					b = c.Clipboard_ConvertEndOfLineOnPaste;
 656			}
 657			if (b.HasValue)
 658				Scintilla.Clipboard.ConvertEndOfLineOnPaste = b.Value;
 659
 660			b = null;
 661			foreach (Configuration c in configList)
 662			{
 663				if (c.Commands_KeyBindingList.AllowDuplicateBindings.HasValue)
 664					b = c.Commands_KeyBindingList.AllowDuplicateBindings;
 665			}
 666			if (b.HasValue)
 667				Scintilla.Commands.AllowDuplicateBindings = b.Value;
 668
 669			if (_clearKeyBindings)
 670				Scintilla.Commands.RemoveAllBindings();
 671
 672			CommandBindingConfigList cbcl = new CommandBindingConfigList();
 673			foreach (Configuration c in configList)
 674			{
 675				if (c.Commands_KeyBindingList.Inherit.HasValue && !c.Commands_KeyBindingList.Inherit.Value)
 676					cbcl.Clear();
 677
 678				foreach (CommandBindingConfig cbc in c.Commands_KeyBindingList)
 679					cbcl.Add(cbc);
 680			}
 681
 682			foreach (CommandBindingConfig cbc in cbcl)
 683			{
 684				//	This indicates that we should clear out any
 685				//	existing commands bound to this key combination
 686				if (cbc.ReplaceCurrent.HasValue && cbc.ReplaceCurrent.Value)
 687					Scintilla.Commands.RemoveBinding(cbc.KeyBinding.KeyCode, cbc.KeyBinding.Modifiers);
 688
 689				Scintilla.Commands.AddBinding(cbc.KeyBinding.KeyCode, cbc.KeyBinding.Modifiers, cbc.BindableCommand);
 690			}
 691
 692			s = null;
 693			foreach (Configuration c in configList)
 694			{
 695				if (c.DropMarkers_SharedStackName != null)
 696					s = c.DropMarkers_SharedStackName;
 697			}
 698			if (s != null)
 699				Scintilla.DropMarkers.SharedStackName = s;
 700			
 701			
 702			b = null;
 703			foreach (Configuration c in configList)
 704			{
 705				if (c.EndOfLine_ConvertOnPaste.HasValue)
 706					b = c.EndOfLine_ConvertOnPaste;
 707			}
 708			if (b.HasValue)
 709				Scintilla.EndOfLine.ConvertOnPaste = b.Value;
 710
 711
 712			b = null;
 713			foreach (Configuration c in configList)
 714			{
 715				if (c.EndOfLine_IsVisisble.HasValue)
 716					b = c.EndOfLine_IsVisisble;
 717			}
 718			if (b.HasValue)
 719				Scintilla.EndOfLine.IsVisible = b.Value;
 720
 721
 722			EndOfLineMode? endOfLineMode = null;
 723			foreach (Configuration c in configList)
 724			{
 725				if (c.EndOfLine_Mode.HasValue)
 726					endOfLineMode = c.EndOfLine_Mode;
 727			}
 728			if (endOfLineMode.HasValue)
 729				Scintilla.EndOfLine.Mode = endOfLineMode.Value;
 730
 731			//	FoldMarkerScheme moved to Markers section
 732			//	becuase Markers need to come first as the
 733			//	FoldMarkerScheme really just manipulates
 734			//	Markers.
 735
 736			b = null;			
 737			co = Color.Empty;
 738			foreach (Configuration c in configList)
 739			{
 740				if (c.Hotspot_ActiveBackColor != Color.Empty)
 741					co = c.Hotspot_ActiveBackColor;
 742
 743			}
 744			if (co != Color.Empty)
 745				Scintilla.HotspotStyle.ActiveBackColor = co;
 746			
 747			co = Color.Empty;
 748			foreach (Configuration c in configList)
 749			{
 750				if (c.Hotspot_ActiveForeColor != Color.Empty)
 751					co = c.Hotspot_ActiveForeColor;
 752
 753			}
 754			if (co != Color.Empty)
 755				Scintilla.HotspotStyle.ActiveForeColor = co;
 756			
 757			b = null;
 758			foreach (Configuration c in configList)
 759			{
 760				if (c.Hotspot_ActiveUnderline.HasValue)
 761					b = c.Hotspot_ActiveUnderline;
 762			}
 763			if (b.HasValue)
 764				Scintilla.HotspotStyle.ActiveUnderline = b.Value;			
 765
 766			b = null;
 767			foreach (Configuration c in configList)
 768			{
 769				if (c.Hotspot_SingleLine.HasValue)
 770					b = c.Hotspot_SingleLine;
 771			}
 772			if (b.HasValue)
 773				Scintilla.HotspotStyle.SingleLine = b.Value;
 774			
 775			
 776			b = null;
 777			foreach (Configuration c in configList)
 778			{
 779				if (c.Hotspot_UseActiveBackColor.HasValue)
 780					b = c.Hotspot_UseActiveBackColor;
 781			}
 782			if (b.HasValue)
 783				Scintilla.HotspotStyle.UseActiveBackColor = b.Value;
 784
 785			b = null;
 786			foreach (Configuration c in configList)
 787			{
 788				if (c.Hotspot_UseActiveForeColor.HasValue)
 789					b = c.Hotspot_UseActiveForeColor;
 790			}
 791			if (b.HasValue)
 792				Scintilla.HotspotStyle.UseActiveForeColor = b.Value;
 793			
 794			b = null;
 795			foreach (Configuration c in configList)
 796			{
 797				if (c.Indentation_BackspaceUnindents.HasValue)
 798					b = c.Indentation_BackspaceUnindents;
 799			}
 800			if (b.HasValue)
 801				Scintilla.Indentation.BackspaceUnindents = b.Value;
 802
 803
 804			i = null;
 805			foreach (Configuration c in configList)
 806			{
 807				if (c.Indentation_IndentWidth.HasValue)
 808					i = c.Indentation_IndentWidth;
 809			}
 810			if (i.HasValue)
 811				Scintilla.Indentation.IndentWidth = i.Value;
 812
 813
 814			b = null;
 815			foreach (Configuration c in configList)
 816			{
 817				if (c.Indentation_ShowGuides.HasValue)
 818					b = c.Indentation_ShowGuides;
 819			}
 820			if (b.HasValue)
 821				Scintilla.Indentation.ShowGuides = b.Value;
 822			
 823			b = null;
 824			foreach (Configuration c in configList)
 825			{
 826				if (c.Indentation_TabIndents.HasValue)
 827					b = c.Indentation_TabIndents;
 828			}
 829			if (b.HasValue)
 830				Scintilla.Indentation.TabIndents = b.Value;			
 831
 832
 833			i = null;
 834			foreach (Configuration c in configList)
 835			{
 836				if (c.Indentation_TabWidth.HasValue)
 837					i = c.Indentation_TabWidth;
 838			}
 839			if (i.HasValue)
 840				Scintilla.Indentation.TabWidth = i.Value;			
 841			
 842			b = null;
 843			foreach (Configuration c in configList)
 844			{
 845				if (c.Indentation_UseTabs.HasValue)
 846					b = c.Indentation_UseTabs;
 847			}
 848			if (b.HasValue)
 849				Scintilla.Indentation.UseTabs = b.Value;
 850
 851			SmartIndent? si = null;
 852			foreach (Configuration c in configList)
 853			{
 854				if (c.Indentation_SmartIndentType.HasValue)
 855					si = c.Indentation_SmartIndentType;
 856			}
 857			if (si.HasValue)
 858				Scintilla.Indentation.SmartIndentType = si.Value;
 859
 860			if (_clearIndicators)
 861				Scintilla.Indicators.Reset();
 862
 863			IndicatorConfigList resolvedIndicators = new IndicatorConfigList();
 864			foreach (Configuration c in configList)
 865			{
 866				if (c.Indicator_List.Inherit.HasValue && !c.Indicator_List.Inherit.Value)
 867					resolvedIndicators.Clear();
 868
 869				foreach (IndicatorConfig ic in c.Indicator_List)
 870				{
 871					if (!resolvedIndicators.Contains(ic.Number) || !(ic.Inherit.HasValue && ic.Inherit.Value))
 872					{
 873						resolvedIndicators.Remove(ic.Number);
 874						resolvedIndicators.Add(ic);
 875					}
 876					else
 877					{
 878						IndicatorConfig rc = resolvedIndicators[ic.Number];
 879						if (ic.Color != Color.Empty)
 880							rc.Color = ic.Color;
 881
 882						if (ic.Style.HasValue)
 883							rc.Style = ic.Style;
 884
 885						if (ic.IsDrawnUnder.HasValue)
 886							rc.IsDrawnUnder = ic.IsDrawnUnder;
 887					}
 888				}
 889			}
 890
 891			foreach (IndicatorConfig ic in resolvedIndicators)
 892			{
 893				Indicator ind = Scintilla.Indicators[ic.Number];
 894				if (ic.Color != Color.Empty)
 895					ind.Color = ic.Color;
 896
 897				if (ic.IsDrawnUnder.HasValue)
 898					ind.IsDrawnUnder = ic.IsDrawnUnder.Value;
 899
 900				if (ic.Style.HasValue)
 901					ind.Style = ic.Style.Value;
 902			}
 903
 904			foreach(Configuration c in configList)
 905            {
 906            	foreach (KeyWordConfig kwc in c.Lexing_Keywords)
 907				{
 908					if (kwc.Inherit.HasValue && kwc.Inherit.Value)
 909						Scintilla.Lexing.Keywords[kwc.List] += kwc.Value;
 910					else
 911						Scintilla.Lexing.Keywords[kwc.List] = kwc.Value;
 912				}
 913            }
 914
 915			//	Hrm... unfortunately there's no way to clear
 916			//	Scintilla's Lexing Properties. Guess we'll just
 917			//	have to live with adding to the existing list 
 918			//	and/or just overriding with new values. This
 919			//	means that the "Inherit" attribute is really
 920			//	meaningless. Nevertheless I'm leaving it in
 921			//	just in case it ever becomes useful.
 922			foreach (Configuration c in configList)
 923			{
 924				foreach (KeyValuePair<string,string> item in c.Lexing_Properties)
 925				{
 926					Scintilla.Lexing.SetProperty(item.Key, item.Value);
 927				}
 928			}
 929			
 930			s = null;
 931			foreach (Configuration c in configList)
 932			{
 933				if (c.Lexing_WhiteSpaceChars != null)
 934					s = c.Lexing_WhiteSpaceChars;
 935			}
 936			if (s != null)
 937				Scintilla.Lexing.WhiteSpaceChars = s;
 938
 939
 940			s = null;
 941			foreach (Configuration c in configList)
 942			{
 943				if (c.Lexing_WordChars != null)
 944					s = c.Lexing_WordChars;
 945			}
 946			if (s != null)
 947				Scintilla.Lexing.WordChars = s;
 948
 949			s = null;
 950			foreach (Configuration c in configList)
 951			{
 952				if (c.Lexing_LineCommentPrefix != null)
 953					s = c.Lexing_LineCommentPrefix;
 954			}
 955			if (s != null)
 956				Scintilla.Lexing.LineCommentPrefix = s;
 957
 958			s = null;
 959			foreach (Configuration c in configList)
 960			{
 961				if (c.Lexing_StreamCommentPrefix != null)
 962					s = c.Lexing_StreamCommentPrefix;
 963			}
 964			if (s != null)
 965				Scintilla.Lexing.StreamCommentPrefix = s;
 966
 967			s = null;	
 968			foreach (Configuration c in configList)
 969			{
 970				if (c.Lexing_StreamCommentSuffix != null)
 971					s = c.Lexing_StreamCommentSuffix;
 972			}
 973			if (s != null)
 974				Scintilla.Lexing.StreamCommentSufix = s;
 975
 976			s = null;
 977			foreach (Configuration c in configList)
 978			{
 979				if (c.Lexing_Language != null)
 980					s = c.Lexing_Language;
 981			}
 982			
 983			if (s == null)
 984			{
 985				//	None of the configs specified a lexer. First let's see if
 986				//	we have a Language-Lexer map defined:
 987				if (Scintilla.Lexing.LexerLanguageMap.ContainsKey(_language))
 988				{
 989					s = Scintilla.Lexing.LexerLanguageMap[_language];
 990				}
 991				else
 992				{
 993					try
 994					{
 995						Enum.Parse(typeof(Lexer), _language, true);
 996
 997						//	If we made it here, the language matches one of
 998						//	the lexer names, just use that.
 999						s = _language;
1000					}
1001					catch (ArgumentException) 
1002					{ 
1003						//	No match, oh well. Don't set the lexer.
1004					}
1005				}
1006			}
1007			Scintilla.Lexing.LexerName = s;
1008
1009			LineCache? lc = null;
1010			foreach (Configuration c in configList)
1011			{
1012				if (c.LineWrap_LayoutCache.HasValue)
1013					lc = c.LineWrap_LayoutCache;
1014			}
1015			if (lc.HasValue)
1016				Scintilla.LineWrap.LayoutCache = lc.Value;
1017
1018			WrapMode? wm = null;
1019			foreach (Configuration c in configList)
1020			{
1021				if (c.LineWrap_Mode.HasValue)
1022					wm = c.LineWrap_Mode;
1023			}
1024			if (wm.HasValue)
1025				Scintilla.LineWrap.Mode = wm.Value;
1026			
1027
1028			i = null;
1029			foreach (Configuration c in configList)
1030			{
1031				if (c.LineWrap_PositionCacheSize.HasValue)
1032					i = c.LineWrap_PositionCacheSize;
1033			}
1034			if (i.HasValue)
1035				Scintilla.LineWrap.PositionCacheSize = i.Value;			
1036			
1037			i = null;
1038			foreach (Configuration c in configList)
1039			{
1040				if (c.LineWrap_StartIndent.HasValue)
1041					i = c.LineWrap_StartIndent;
1042			}
1043			if (i.HasValue)
1044				Scintilla.LineWrap.StartIndent = i.Value;
1045
1046
1047			WrapVisualFlag? wvf = null;
1048			foreach (Configuration c in configList)
1049			{
1050				if (c.LineWrap_VisualFlags.HasValue)
1051					wvf = c.LineWrap_VisualFlags;
1052			}
1053			if (wvf.HasValue)
1054				Scintilla.LineWrap.VisualFlags = wvf.Value;
1055
1056			WrapVisualLocation? wvl = null;
1057			foreach (Configuration c in configList)
1058			{
1059				if (c.LineWrap_VisualFlagsLocation.HasValue)
1060					wvl = c.LineWrap_VisualFlagsLocation;
1061			}
1062			if (wvl.HasValue)
1063				Scintilla.LineWrap.VisualFlagsLocation = wvl.Value;
1064			
1065
1066			co = Color.Empty;
1067			foreach (Configuration c in configList)
1068			{
1069				if (c.LongLines_EdgeColor != Color.Empty)
1070					co = c.LongLines_EdgeColor;
1071
1072			}
1073			if (co != Color.Empty)
1074				Scintilla.LongLines.EdgeColor = co;
1075
1076
1077			i = null;
1078			foreach (Configuration c in configList)
1079			{
1080				if (c.LongLines_EdgeColumn.HasValue)
1081					i = c.LongLines_EdgeColumn;
1082			}
1083			if (i.HasValue)
1084				Scintilla.LongLines.EdgeColumn = i.Value;
1085
1086
1087			EdgeMode? em = null;
1088			foreach (Configuration c in configList)
1089			{
1090				if (c.LongLines_EdgeMode.HasValue)
1091					em = c.LongLines_EdgeMode;
1092
1093			}
1094			if (em.HasValue)
1095				Scintilla.LongLines.EdgeMode = em.Value;
1096
1097			
1098			if (_clearMargins)
1099				Scintilla.Margins.Reset();
1100
1101			Dictionary<int, MarginConfig> margins = new Dictionary<int, MarginConfig>();
1102			foreach (Configuration c in configList)
1103			{
1104				if (c.Margin_List.Inherit.HasValue && !c.Margin_List.Inherit.Value)
1105					margins.Clear();
1106
1107				foreach (MarginConfig mc in c.Margin_List)
1108				{
1109					
1110					if (!margins.ContainsKey(mc.Number) || (mc.Inherit.HasValue && !mc.Inherit.Value))
1111					{
1112						margins.Remove(mc.Number);
1113						margins.Add(mc.Number, mc);
1114					}
1115					else
1116					{	
1117						MarginConfig m = margins[mc.Number];
1118
1119						if (mc.AutoToggleMarkerNumber.HasValue)
1120							m.AutoToggleMarkerNumber = mc.AutoToggleMarkerNumber.Value;
1121
1122						if (mc.IsClickable.HasValue)
1123							m.IsClickable = mc.IsClickable.Value;
1124
1125						if (mc.IsFoldMargin.HasValue)
1126							m.IsFoldMargin = mc.IsFoldMargin.Value;
1127
1128						if (mc.IsMarkerMargin.HasValue)
1129							m.IsMarkerMargin = mc.IsMarkerMargin.Value;
1130
1131						if (mc.Type.HasValue)
1132							m.Type = mc.Type.Value;
1133
1134						if (mc.Width.HasValue)
1135							m.Width = mc.Width.Value;
1136					}
1137				}
1138			}
1139
1140			foreach (MarginConfig mc in margins.Values)
1141			{
1142				Margin m = Scintilla.Margins[mc.Number];
1143
1144				if (mc.AutoToggleMarkerNumber.HasValue)
1145					m.AutoToggleMarkerNumber = mc.AutoToggleMarkerNumber.Value;
1146
1147				if (mc.IsClickable.HasValue)
1148					m.IsClickable = mc.IsClickable.Value;
1149
1150				if (mc.IsFoldMargin.HasValue)
1151					m.IsFoldMargin = mc.IsFoldMargin.Value;
1152
1153				if (mc.IsMarkerMargin.HasValue)
1154					m.IsMarkerMargin = mc.IsMarkerMargin.Value;
1155
1156				if (mc.Type.HasValue)
1157					m.Type = mc.Type.Value;
1158
1159				if (mc.Width.HasValue)
1160					m.Width = mc.Width.Value;
1161			}
1162
1163			MarkersConfigList resolvedMarkers = new MarkersConfigList();
1164			foreach (Configuration c in configList)
1165			{
1166				if (c.Markers_List.Inherit.HasValue && !c.Markers_List.Inherit.Value)
1167					resolvedMarkers.Clear();
1168
1169				foreach (MarkersConfig mc in c.Markers_List)
1170				{
1171					if (!resolvedMarkers.Contains(mc.Number.Value) || (mc.Inherit.HasValue && !mc.Inherit.Value))
1172					{
1173						resolvedMarkers.Remove(mc.Number.Value);
1174						resolvedMarkers.Add(mc);
1175					}
1176					else
1177					{
1178						if (!mc.Number.HasValue)
1179							mc.Number = (int)(MarkerOutline)Enum.Parse(typeof(MarkerOutline), mc.Name, true);
1180
1181						MarkersConfig m = resolvedMarkers[mc.Number.Value];
1182						if (mc.Alpha.HasValue)
1183							m.Alpha = mc.Alpha;
1184
1185						if (mc.BackColor != Color.Empty)
1186							m.BackColor = mc.BackColor;
1187
1188						if (mc.ForeColor != Color.Empty)
1189							m.ForeColor = mc.ForeColor;
1190
1191						if (mc.Symbol.HasValue)
1192							m.Symbol = mc.Symbol;
1193					}
1194				}
1195			}
1196					
1197			b = null;
1198			foreach (Configuration c in configList)
1199			{
1200				if (c.Scrolling_EndAtLastLine.HasValue)
1201					b = c.Scrolling_EndAtLastLine;
1202			}
1203			if (b.HasValue)
1204				Scintilla.Scrolling.EndAtLastLine = b.Value;			
1205
1206			i = null;
1207			foreach (Configuration c in configList)
1208			{
1209				if (c.Scrolling_HorizontalWidth.HasValue)
1210					i = c.Scrolling_HorizontalWidth;
1211			}
1212			if (i.HasValue)
1213				Scintilla.Scrolling.HorizontalWidth = i.Value;
1214
1215			ScrollBars? sb = null;
1216			foreach (Configuration c in configList)
1217			{
1218				if (c.Scrolling_ScrollBars.HasValue)
1219					sb = c.Scrolling_ScrollBars;
1220			}
1221			if (sb.HasValue)
1222				Scintilla.Scrolling.ScrollBars = sb.Value;
1223
1224
1225			i = null;
1226			foreach (Configuration c in configList)
1227			{
1228				if (c.Scrolling_XOffset.HasValue)
1229					i = c.Scrolling_XOffset;
1230			}
1231			if (i.HasValue)
1232				Scintilla.Scrolling.XOffset = i.Value;
1233
1234
1235			co = Color.Empty;
1236			foreach (Configuration c in configList)
1237			{
1238				if (c.Selection_BackColor != Color.Empty)
1239					co = c.Selection_BackColor;
1240
1241			}
1242			if (co != Color.Empty)
1243				Scintilla.Selection.BackColor = co;
1244			
1245
1246			co = Color.Empty;
1247			foreach (Configuration c in configList)
1248			{
1249				if (c.Selection_BackColorUnfocused != Color.Empty)
1250					co = c.Selection_BackColorUnfocused;
1251
1252			}
1253			if (co != Color.Empty)
1254				Scintilla.Selection.BackColorUnfocused = co;
1255			
1256			co = Color.Empty;
1257			foreach (Configuration c in configList)
1258			{
1259				if (c.Selection_ForeColor != Color.Empty)
1260					co = c.Selection_ForeColor;
1261
1262			}
1263			if (co != Color.Empty)
1264				Scintilla.Selection.ForeColor = co;
1265			
1266			co = Color.Empty;
1267			foreach (Configuration c in configList)
1268			{
1269				if (c.Selection_ForeColorUnfocused != Color.Empty)
1270					co = c.Selection_ForeColorUnfocused;
1271
1272			}
1273			if (co != Color.Empty)
1274				Scintilla.Selection.ForeColorUnfocused = co;
1275
1276
1277			b = null;
1278			foreach (Configuration c in configList)
1279			{
1280				if (c.Selection_Hidden.HasValue)
1281					b = c.Selection_Hidden;
1282			}
1283			if (b.HasValue)
1284				Scintilla.Selection.Hidden = b.Value;	
1285		
1286
1287			b = null;
1288			foreach (Configuration c in configList)
1289			{
1290				if (c.Selection_HideSelection.HasValue)
1291					b = c.Selection_HideSelection;
1292			}
1293			if (b.HasValue)
1294				Scintilla.Selection.HideSelection = b.Value;
1295
1296			SelectionMode? selectionMode = null;
1297			foreach (Configuration c in configList)
1298			{
1299				if (c.Selection_Mode.HasValue)
1300					selectionMode = c.Selection_Mode;
1301			}
1302			if (selectionMode.HasValue)
1303				Scintilla.Selection.Mode = selectionMode.Value;
1304
1305
1306			b = null;
1307			foreach (Configuration c in configList)
1308			{
1309				if (c.UndoRedoIsUndoEnabled.HasValue)
1310					b = c.UndoRedoIsUndoEnabled;
1311			}
1312			if (b.HasValue)
1313				Scintilla.UndoRedo.IsUndoEnabled = b.Value;
1314
1315			co = Color.Empty;
1316			foreach (Configuration c in configList)
1317			{
1318				if (c.WhiteSpace_BackColor != Color.Empty)
1319					co = c.WhiteSpace_BackColor;
1320
1321			}
1322			if (co != Color.Empty)
1323				Scintilla.WhiteSpace.BackColor = co;
1324
1325
1326			co = Color.Empty;
1327			foreach (Configuration c in configList)
1328			{
1329				if (c.WhiteSpace_ForeColor != Color.Empty)
1330					co = c.WhiteSpace_ForeColor;
1331			}
1332			if (co != Color.Empty)
1333				Scintilla.WhiteSpace.ForeColor = co;
1334
1335			WhiteSpaceMode? wsm = null;
1336			foreach (Configuration c in configList)
1337			{
1338				if (c.WhiteSpace_Mode.HasValue)
1339					wsm = c.WhiteSpace_Mode;
1340			}
1341			if (wsm.HasValue)
1342				Scintilla.WhiteSpace.Mode = wsm.Value;
1343
1344
1345			b = null;
1346			foreach (Configuration c in configList)
1347			{
1348				if (c.WhiteSpace_UseWhiteSpaceBackColor.HasValue)
1349					b = c.WhiteSpace_UseWhiteSpaceBackColor.HasValue;
1350			}
1351			if (b.HasValue)
1352				Scintilla.WhiteSpace.UseWhiteSpaceBackColor = b.Value;
1353
1354
1355			b = null;
1356			foreach (Configuration c in configList)
1357			{
1358				if (c.WhiteSpace_UseWhiteSpaceForeColor.HasValue)
1359					b = c.WhiteSpace_UseWhiteSpaceForeColor.HasValue;
1360			}
1361			if (co != Color.Empty)
1362				Scintilla.WhiteSpace.UseWhiteSpaceForeColor = b.Value;
1363
1364
1365
1366
1367			//	OK so we saved the best for last instead of going in
1368			//	strict lexical order. Styles! This is really the section
1369			//	that people care about most in the config, and is also
1370			//	the most complex.
1371			if (_clearStyles)
1372				Scintilla.Styles.Reset();
1373
1374			i = null;
1375			foreach (Configuration c in configList)
1376			{
1377				if (c.Styles.Bits.HasValue)
1378					i = c.Styles.Bits;
1379			}
1380			if (i.HasValue)
1381				Scintilla.Styles.Bits = i.Value;
1382
1383			Dictionary<string, int> styleNameMap =  Scintilla.Lexing.StyleNameMap;
1384			ResolvedStyleList resolvedStyles = new ResolvedStyleList();
1385
1386			int _unmappedStyleNumber = -1;
1387			Dictionary<string, int> _unmappedStyleMap = new Dictionary<string,int>();
1388			foreach (Configuration c in configList)
1389			{
1390				if (c.Styles.Inherit.HasValue && !c.Styles.Inherit.Value)
1391					resolvedStyles.Clear();
1392
1393				foreach (StyleConfig sc in c.Styles)
1394				{
1395					i = sc.Number;
1396
1397					if (!i.HasValue)
1398					{
1399						if (!styleNameMap.ContainsKey(sc.Name))
1400						{
1401							if (_unmappedStyleMap.ContainsKey(sc.Name))
1402							{
1403								i = _unmappedStyleMap[sc.Name];
1404								sc.Number = i;
1405							}
1406							else
1407							{
1408								i = _unmappedStyleNumber--;
1409								sc.Number = i;
1410
1411								_unmappedStyleMap[sc.Name] = sc.Number.Value;
1412							}							
1413						}
1414						else
1415						{
1416							i = styleNameMap[sc.Name];
1417							sc.Number = i;
1418						}
1419					}
1420
1421					StyleConfig baseStyleConfig = null;
1422					if (!string.IsNullOrEmpty(sc.Name) && sc.Name.Contains("."))
1423					{
1424						baseStyleConfig = resolvedStyles.FindByName(sc.Name.Substring(sc.Name.IndexOf(".") + 1));
1425					}
1426
1427					if (!resolvedStyles.ContainsKey(i.Value) || (sc.Inherit.HasValue && !sc.Inherit.Value))
1428					{
1429						resolvedStyles.Remove(i.Value);
1430						resolvedStyles.Add(i.Value, sc);
1431					}
1432
1433					StyleConfig rs = resolvedStyles[i.Value];
1434
1435					if (sc.BackColor != Color.Empty)
1436						rs.BackColor = sc.BackColor;
1437					else if (baseStyleConfig != null && baseStyleConfig.BackColor != Color.Empty)
1438						rs.BackColor = baseStyleConfig.BackColor;
1439
1440					if (sc.Bold.HasValue)
1441						rs.Bold = sc.Bold.Value;
1442					else if (baseStyleConfig != null && baseStyleConfig.Bold.HasValue)
1443						rs.Bold = baseStyleConfig.Bold.Value;
1444
1445					if (sc.Case.HasValue)
1446						rs.Case = sc.Case.Value;
1447					else if (baseStyleConfig != null && baseStyleConfig.Case.HasValue)
1448						rs.Case = baseStyleConfig.Case.Value;
1449
1450					if (sc.CharacterSet.HasValue)
1451						rs.CharacterSet = sc.CharacterSet.Value;
1452					else if (baseStyleConfig != null && baseStyleConfig.CharacterSet.HasValue)
1453						rs.CharacterSet = baseStyleConfig.CharacterSet.Value;
1454
1455					if (sc.FontName != null)
1456						rs.FontName = sc.FontName;
1457					else if (baseStyleConfig != null && baseStyleConfig.FontName != null)
1458						rs.FontName = baseStyleConfig.FontName;
1459
1460					if (sc.ForeColor != Color.Empty)
1461						rs.ForeColor = sc.ForeColor;
1462					else if (baseStyleConfig != null && baseStyleConfig.ForeColor != Color.Empty)
1463						rs.ForeColor = baseStyleConfig.ForeColor;
1464
1465					if (sc.IsChangeable.HasValue)
1466						rs.IsChangeable = sc.IsChangeable.Value;
1467					else if (baseStyleConfig != null && baseStyleConfig.IsChangeable.HasValue)
1468						rs.IsChangeable = baseStyleConfig.IsChangeable.Value;
1469
1470					if (sc.IsHotspot.HasValue)
1471						rs.IsHotspot = sc.IsHotspot.Value;
1472					else if (baseStyleConfig != null && baseStyleConfig.IsHotspot.HasValue)
1473						rs.IsHotspot = baseStyleConfig.IsHotspot.Value;
1474
1475					if (sc.IsSelectionEolFilled.HasValue)
1476						rs.IsSelectionEolFilled = sc.IsSelectionEolFilled.Value;
1477					else if (baseStyleConfig != null && baseStyleConfig.IsSelectionEolFilled.HasValue)
1478						rs.IsSelectionEolFilled = baseStyleConfig.IsSelectionEolFilled.Value;
1479
1480					if (sc.IsVisible.HasValue)
1481						rs.IsVisible = sc.IsVisible.Value;
1482					else if (baseStyleConfig != null && baseStyleConfig.IsVisible.HasValue)
1483						rs.IsVisible = baseStyleConfig.IsVisible.Value;
1484
1485					if (sc.Italic.HasValue)
1486						rs.Italic = sc.Italic.Value;
1487					else if (baseStyleConfig != null && baseStyleConfig.Italic.HasValue)
1488						rs.Italic = baseStyleConfig.Italic.Value;
1489
1490					if (sc.Size.HasValue)
1491						rs.Size = sc.Size.Value;
1492					else if (baseStyleConfig != null && baseStyleConfig.Size.HasValue)
1493						rs.Size = baseStyleConfig.Size.Value;
1494
1495					if (sc.Underline.HasValue)
1496						rs.Underline = sc.Underline.Value;
1497					else if (baseStyleConfig != null && baseStyleConfig.Underline.HasValue)
1498						rs.Underline = baseStyleConfig.Underline.Value;
1499				}
1500
1501
1502			}
1503			//	If a Default styles exist we want them at the top of the list because
1504			//	it needs to be applied first, then StyleClearAll() called so that all
1505			//	other styles will "inherit" this style. Then the other styles will 
1506			//	override the default with any defined properties.
1507			StyleConfig[] arr = new StyleConfig[resolvedStyles.Count];
1508			resolvedStyles.Values.CopyTo(arr, 0);
1509			Array.Sort<StyleConfig>(arr, new Comparison<StyleConfig>(delegate(StyleConfig sc1, StyleConfig sc2)
1510			{
1511				int v1 = sc1.Number.Value == Constants.STYLE_DEFAULT ? -1 : sc1.Number.Value;
1512				int v2 = sc2.Number.Value == Constants.STYLE_DEFAULT ? -1 : sc2.Number.Value;
1513
1514				if (v1 < v2)
1515					return -1;
1516				else if (v2 < v1)
1517					return 1;
1518
1519				return 0;
1520			}));
1521			
1522
1523			foreach (StyleConfig sc in arr)
1524			{
1525				if (sc.Number < 0)
1526					continue;
1527
1528				Style style = Scintilla.Styles[sc.Number.Value];
1529
1530				if (sc.BackColor != Color.Empty)
1531					style.BackColor = sc.BackColor;
1532
1533				if (sc.Bold.HasValue)
1534					style.Bold = sc.Bold.Value;
1535
1536				if (sc.Case.HasValue)
1537					style.Case = sc.Case.Value;
1538
1539				if (sc.CharacterSet.HasValue)
1540					style.CharacterSet = sc.CharacterSet.Value;
1541
1542				if (sc.FontName != null)
1543					style.FontName = sc.FontName;
1544
1545				if (sc.ForeColor != Color.Empty)
1546					style.ForeColor = sc.ForeColor;
1547
1548				if (sc.IsChangeable.HasValue)
1549					style.IsChangeable = sc.IsChangeable.Value;
1550
1551				if (sc.IsHotspot.HasValue)
1552					style.IsHotspot = sc.IsHotspot.Value;
1553
1554				if (sc.IsSelectionEolFilled.HasValue)
1555					style.IsSelectionEolFilled = sc.IsSelectionEolFilled.Value;
1556
1557				if (sc.IsVisible.HasValue)
1558					style.IsVisible = sc.IsVisible.Value;
1559
1560				if (sc.Italic.HasValue)
1561					style.Italic = sc.Italic.Value;
1562
1563				if (sc.Size.HasValue)
1564					style.Size = sc.Size.Value;
1565
1566				if (sc.Underline.HasValue)
1567					style.Underline = sc.Underline.Value;
1568
1569				if (sc.Number == Constants.STYLE_DEFAULT)
1570					Scintilla.Styles.ClearAll();
1571			}
1572			
1573		}
1574
1575
1576
1577	}
1578
1579	public enum ConfigurationLoadOrder
1580	{
1581		BuiltInCustomUser,
1582		BuiltInUserCustom,
1583		CustomBuiltInUser,
1584		CustomUserBuiltIn,		
1585		UserBuiltInCustom,
1586		UserCustomBuiltIn
1587	}
1588}
1589