void LanguageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            listBox.ItemsSource = null;
            XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem;

            if (xshd != null)
            {
                IHighlightingItem defaultText;
                ObservableCollection <IHighlightingItem> list = new ObservableCollection <IHighlightingItem>();
                CreateDefaultEntries(languageComboBox.SelectedIndex == 0 ? null : xshd.Name, out defaultText, list);
                listBox.ItemsSource = list;

                if (languageComboBox.SelectedIndex > 0)
                {
                    // Create entries for all customizable colors in the syntax highlighting definition
                    // (but don't do this for the "All languages" pseudo-entry)
                    IHighlightingDefinition def = HighlightingManager.Instance.GetDefinition(xshd.Name);
                    if (def == null)
                    {
                        throw new InvalidOperationException("Expected that all XSHDs are registered in default highlighting manager; but highlighting definition was not found");
                    }
                    else
                    {
                        var visitor = new ColorVisitor(allSyntaxDefinitions);
                        xshd.AcceptElements(visitor);
                        foreach (XshdColor namedColor in visitor.foundColors)
                        {
                            if (namedColor.ExampleText != null)
                            {
                                IHighlightingItem item = new NamedColorHighlightingItem(defaultText, namedColor)
                                {
                                    ParentDefinition = def
                                };
                                item = new CustomizedHighlightingItem(customizationList, item, xshd.Name);
                                list.Add(item);
                                item.PropertyChanged += item_PropertyChanged;
                            }
                        }
                    }
                }
                if (listBox.Items.Count > 0)
                {
                    listBox.SelectedIndex = 0;
                }
            }
        }
        bool FindSDColor(string sdKey, out IHighlightingItem item)
        {
            string language = null;
            int    dot      = sdKey.IndexOf('.');

            if (dot > 0)
            {
                language = sdKey.Substring(0, dot);
                sdKey    = sdKey.Substring(dot + 1);
            }
            if ((language == null && languageComboBox.SelectedIndex == 0) ||
                (language == ((XshdSyntaxDefinition)languageComboBox.SelectedItem).Name))
            {
                item = listBox.Items.OfType <IHighlightingItem>().FirstOrDefault(i => i.Name == sdKey);
            }
            else if (language == null)
            {
                item = defaultEntries.FirstOrDefault(i => i.Name == sdKey);
            }
            else
            {
                var def          = allSyntaxDefinitions.FirstOrDefault(d => d.Name == language);
                var highlighting = HighlightingManager.Instance.GetDefinition(language);
                item = null;
                if (def != null && highlighting != null)
                {
                    var visitor = new ColorVisitor(allSyntaxDefinitions);
                    def.AcceptElements(visitor);
                    var color = visitor.foundColors.FirstOrDefault(i => i.Name == sdKey);
                    if (color != null)
                    {
                        item = new NamedColorHighlightingItem(defaultText, color)
                        {
                            ParentDefinition = highlighting
                        };
                        item = new CustomizedHighlightingItem(customizationList, item, language);
                    }
                }
            }
            return(item != null);
        }
		bool FindSDColor(string sdKey, out IHighlightingItem item)
		{
			string language = null;
			int dot = sdKey.IndexOf('.');
			if (dot > 0) {
				language = sdKey.Substring(0, dot);
				sdKey = sdKey.Substring(dot + 1);
			}
			if ((language == null && languageComboBox.SelectedIndex == 0)
			    || (language == ((XshdSyntaxDefinition)languageComboBox.SelectedItem).Name)) {
				item = listBox.Items.OfType<IHighlightingItem>().FirstOrDefault(i => i.Name == sdKey);
			} else if (language == null) {
				item = defaultEntries.FirstOrDefault(i => i.Name == sdKey);
			} else {
				var def = allSyntaxDefinitions.FirstOrDefault(d => d.Name == language);
				var highlighting = HighlightingManager.Instance.GetDefinition(language);
				item = null;
				if (def != null && highlighting != null) {
					var visitor = new ColorVisitor(allSyntaxDefinitions);
					def.AcceptElements(visitor);
					var color = visitor.foundColors.FirstOrDefault(i => i.Name == sdKey);
					if (color != null) {
						item = new NamedColorHighlightingItem(defaultText, color) { ParentDefinition = highlighting };
						item = new CustomizedHighlightingItem(customizationList, item, language);
					}
				}
			}
			return item != null;
		}
		void CreateDefaultEntries(string language, out IHighlightingItem defaultText, IList<IHighlightingItem> items)
		{
			// Create entry for "default text/background"
			defaultText = new SimpleHighlightingItem(CustomizingHighlighter.DefaultTextAndBackground, ta => ta.Document.Text = "Normal text") {
				Foreground = SystemColors.WindowTextColor,
				Background = SystemColors.WindowColor
			};
			defaultText = new CustomizedHighlightingItem(customizationList, defaultText, language, canSetFont: false);
			defaultText.PropertyChanged += item_PropertyChanged;
			items.Add(defaultText);
			
			// Create entry for "Selected text"
			IHighlightingItem selectedText = new SimpleHighlightingItem(
				CustomizingHighlighter.SelectedText,
				ta => {
					ta.Document.Text = "Selected text";
					ta.Selection = Selection.Create(ta, 0, 13);
				})
			{
				Foreground = SystemColors.HighlightTextColor,
				Background = SystemColors.HighlightColor
			};
			selectedText = new CustomizedHighlightingItem(customizationList, selectedText, language, canSetFont: false);
			selectedText.PropertyChanged += item_PropertyChanged;
			items.Add(selectedText);
			
			// Create entry for "Non-printable characters"
			IHighlightingItem nonPrintChars = new SimpleHighlightingItem(
				CustomizingHighlighter.NonPrintableCharacters,
				ta => {
					ta.Document.Text = "	    \r \r\n \n";
				})
			{
				Foreground = Colors.LightGray
			};
			nonPrintChars = new CustomizedHighlightingItem(customizationList, nonPrintChars, language, canSetFont: false, canSetBackground: false);
			nonPrintChars.PropertyChanged += item_PropertyChanged;
			items.Add(nonPrintChars);
			
			// Create entry for "Line numbers"
			IHighlightingItem lineNumbers = new SimpleHighlightingItem(
				CustomizingHighlighter.LineNumbers,
				ta => {
					ta.Document.Text = "These are just" + Environment.NewLine +
						"multiple" + Environment.NewLine +
						"lines of" + Environment.NewLine +
						"text";
				})
			{
				Foreground = Colors.Gray
			};
			lineNumbers = new CustomizedHighlightingItem(customizationList, lineNumbers, language, canSetFont: false, canSetBackground: false);
			lineNumbers.PropertyChanged += item_PropertyChanged;
			items.Add(lineNumbers);
			
			// Create entry for "Bracket highlight"
			IHighlightingItem bracketHighlight = new SimpleHighlightingItem(
				BracketHighlightRenderer.BracketHighlight,
				ta => {
					ta.Document.Text = "(simple) example";
					XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem;
					if (xshd == null)
						return;
					var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name);
					BracketHighlightRenderer.ApplyCustomizationsToRendering(bracketHighlighter, customizationsForCurrentLanguage);
					bracketHighlighter.SetHighlight(new BracketSearchResult(0, 1, 7, 1));
				})
			{
				Foreground = BracketHighlightRenderer.DefaultBorder,
				Background = BracketHighlightRenderer.DefaultBackground
			};
			bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, language, canSetFont: false);
			bracketHighlight.PropertyChanged += item_PropertyChanged;
			items.Add(bracketHighlight);
			
			// Create entry for "Folding controls"
			IHighlightingItem foldingControls = new SimpleHighlightingItem(
				FoldingControls,
				ta => {
					ta.Document.Text = "This" + Environment.NewLine +
						"is a folding" + Environment.NewLine +
						"example";
					foldingManager.CreateFolding(0, 10);
				})
			{
				Foreground = Colors.Gray,
				Background = Colors.White
			};
			foldingControls = new CustomizedHighlightingItem(customizationList, foldingControls, language, canSetFont: false);
			foldingControls.PropertyChanged += item_PropertyChanged;
			items.Add(foldingControls);
			
			// Create entry for "Selected folding controls"
			IHighlightingItem selectedFoldingControls = new SimpleHighlightingItem(
				FoldingSelectedControls,
				ta => {
					ta.Document.Text = "This" + Environment.NewLine +
						"is a folding" + Environment.NewLine +
						"example";
					foldingManager.CreateFolding(0, 10);
				})
			{
				Foreground = Colors.Black,
				Background = Colors.White
			};
			selectedFoldingControls = new CustomizedHighlightingItem(customizationList, selectedFoldingControls, language, canSetFont: false);
			selectedFoldingControls.PropertyChanged += item_PropertyChanged;
			items.Add(selectedFoldingControls);
			
			// Create entry for "Folding text markers"
			IHighlightingItem foldingTextMarker = new SimpleHighlightingItem(
				FoldingTextMarkers,
				ta => {
					ta.Document.Text = "This" + Environment.NewLine +
						"is a folding" + Environment.NewLine +
						"example";
					foldingManager.CreateFolding(0, 10).IsFolded = true;
				})
			{
				Foreground = Colors.Gray
			};
			foldingTextMarker = new CustomizedHighlightingItem(customizationList, foldingTextMarker, language, canSetFont: false, canSetBackground: false);
			foldingTextMarker.PropertyChanged += item_PropertyChanged;
			items.Add(foldingTextMarker);
			
			IHighlightingItem linkText = new SimpleHighlightingItem(
				CustomizingHighlighter.LinkText,
				ta => {
					ta.Document.Text = "http://icsharpcode.net" + Environment.NewLine + "*****@*****.**";
				})
			{
				Foreground = Colors.Blue,
				Background = Colors.Transparent
			};
			linkText = new CustomizedHighlightingItem(customizationList, linkText, language, canSetFont: false);
			linkText.PropertyChanged += item_PropertyChanged;
			items.Add(linkText);
			
			IHighlightingItem errorMarker = new SimpleHighlightingItem(
				ErrorPainter.ErrorColorName,
				ta => {
					ta.Document.Text = "some error";
					ITextMarker marker = textMarkerService.Create(0, 5);
					marker.Tag = (Action<IHighlightingItem, ITextMarker>)delegate(IHighlightingItem item, ITextMarker m) {
						m.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
						m.MarkerColor = item.Foreground;
					};
				})
			{
				Foreground = Colors.Red
			};
			errorMarker = new CustomizedHighlightingItem(customizationList, errorMarker, language, canSetFont: false, canSetBackground: false);
			errorMarker.PropertyChanged += item_PropertyChanged;
			items.Add(errorMarker);
			
			IHighlightingItem warningMarker = new SimpleHighlightingItem(
				ErrorPainter.WarningColorName,
				ta => {
					ta.Document.Text = "some warning";
					ITextMarker marker = textMarkerService.Create(0, 5);
					marker.Tag = (Action<IHighlightingItem, ITextMarker>)delegate(IHighlightingItem item, ITextMarker m) {
						m.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
						m.MarkerColor = item.Foreground;
					};
				})
			{
				Foreground = Colors.Orange
			};
			warningMarker = new CustomizedHighlightingItem(customizationList, warningMarker, language, canSetFont: false, canSetBackground: false);
			warningMarker.PropertyChanged += item_PropertyChanged;
			items.Add(warningMarker);
			
			IHighlightingItem messageMarker = new SimpleHighlightingItem(
				ErrorPainter.MessageColorName,
				ta => {
					ta.Document.Text = "some message";
					ITextMarker marker = textMarkerService.Create(0, 5);
					marker.Tag = (Action<IHighlightingItem, ITextMarker>)delegate(IHighlightingItem item, ITextMarker m) {
						m.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
						m.MarkerColor = item.Foreground;
					};
				})
			{
				Foreground = Colors.Blue
			};
			messageMarker = new CustomizedHighlightingItem(customizationList, messageMarker, language, canSetFont: false, canSetBackground: false);
			messageMarker.PropertyChanged += item_PropertyChanged;
			items.Add(messageMarker);
			
			IHighlightingItem breakpointMarker = new SimpleHighlightingItem(
				BreakpointBookmark.BreakpointMarker,
				ta => {
					ta.Document.Text = "some code with a breakpoint";
					ITextMarker marker = textMarkerService.Create(0, ta.Document.TextLength);
					marker.Tag = (Action<IHighlightingItem, ITextMarker>)delegate(IHighlightingItem item, ITextMarker m) {
						m.BackgroundColor = item.Background;
						m.ForegroundColor = item.Foreground;
					};
				})
			{
				Background = BreakpointBookmark.DefaultBackground,
				Foreground = BreakpointBookmark.DefaultForeground
			};
			breakpointMarker = new CustomizedHighlightingItem(customizationList, breakpointMarker, language, canSetFont: false);
			breakpointMarker.PropertyChanged += item_PropertyChanged;
			items.Add(breakpointMarker);
			
			IHighlightingItem currentStatementMarker = new SimpleHighlightingItem(
				CurrentLineBookmark.Name,
				ta => {
					ta.Document.Text = "current statement line";
					ITextMarker marker = textMarkerService.Create(0, ta.Document.TextLength);
					marker.Tag = (Action<IHighlightingItem, ITextMarker>)delegate(IHighlightingItem item, ITextMarker m) {
						m.BackgroundColor = item.Background;
						m.ForegroundColor = item.Foreground;
					};
				})
			{
				Background = CurrentLineBookmark.DefaultBackground,
				Foreground = CurrentLineBookmark.DefaultForeground
			};
			currentStatementMarker = new CustomizedHighlightingItem(customizationList, currentStatementMarker, language, canSetFont: false);
			currentStatementMarker.PropertyChanged += item_PropertyChanged;
			items.Add(currentStatementMarker);
			
			IHighlightingItem columnRuler = new SimpleHighlightingItem(
				CustomizingHighlighter.ColumnRuler,
				ta => {
					ta.Document.Text = "some line with a lot of text";
					ta.TextView.Options.ColumnRulerPosition = 15;
					ta.TextView.Options.ShowColumnRuler = true;
				})
			{
				Foreground = Colors.LightGray
			};
			columnRuler = new CustomizedHighlightingItem(customizationList, columnRuler, language, canSetFont: false, canSetBackground: false);
			columnRuler.PropertyChanged += item_PropertyChanged;
			items.Add(columnRuler);
		}
		void LanguageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			listBox.ItemsSource = null;
			XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem;
			if (xshd != null) {
				IHighlightingItem defaultText;
				ObservableCollection<IHighlightingItem> list = new ObservableCollection<IHighlightingItem>();
				CreateDefaultEntries(languageComboBox.SelectedIndex == 0 ? null : xshd.Name, out defaultText, list);
				listBox.ItemsSource = list;
				
				if (languageComboBox.SelectedIndex > 0) {
					// Create entries for all customizable colors in the syntax highlighting definition
					// (but don't do this for the "All languages" pseudo-entry)
					IHighlightingDefinition def = HighlightingManager.Instance.GetDefinition(xshd.Name);
					if (def == null) {
						throw new InvalidOperationException("Expected that all XSHDs are registered in default highlighting manager; but highlighting definition was not found");
					} else {
						var visitor = new ColorVisitor(allSyntaxDefinitions);
						xshd.AcceptElements(visitor);
						foreach (XshdColor namedColor in visitor.foundColors) {
							if (namedColor.ExampleText != null) {
								IHighlightingItem item = new NamedColorHighlightingItem(defaultText, namedColor) { ParentDefinition = def };
								item = new CustomizedHighlightingItem(customizationList, item, xshd.Name);
								list.Add(item);
								item.PropertyChanged += item_PropertyChanged;
							}
						}
					}
				}
				if (listBox.Items.Count > 0)
					listBox.SelectedIndex = 0;
			}
		}
        void CreateDefaultEntries(string language, out IHighlightingItem defaultText, IList <IHighlightingItem> items)
        {
            // Create entry for "default text/background"
            defaultText = new SimpleHighlightingItem(CustomizingHighlighter.DefaultTextAndBackground, ta => ta.Document.Text = "Normal text")
            {
                Foreground = SystemColors.WindowTextColor,
                Background = SystemColors.WindowColor
            };
            defaultText = new CustomizedHighlightingItem(customizationList, defaultText, language, canSetFont: false);
            defaultText.PropertyChanged += item_PropertyChanged;
            items.Add(defaultText);

            // Create entry for "Selected text"
            IHighlightingItem selectedText = new SimpleHighlightingItem(
                CustomizingHighlighter.SelectedText,
                ta => {
                ta.Document.Text = "Selected text";
                ta.Selection     = Selection.Create(ta, 0, 13);
            })
            {
                Foreground = SystemColors.HighlightTextColor,
                Background = SystemColors.HighlightColor
            };

            selectedText = new CustomizedHighlightingItem(customizationList, selectedText, language, canSetFont: false);
            selectedText.PropertyChanged += item_PropertyChanged;
            items.Add(selectedText);

            // Create entry for "Non-printable characters"
            IHighlightingItem nonPrintChars = new SimpleHighlightingItem(
                CustomizingHighlighter.NonPrintableCharacters,
                ta => {
                ta.Document.Text = "	    \r \r\n \n";
            })
            {
                Foreground = Colors.LightGray
            };

            nonPrintChars = new CustomizedHighlightingItem(customizationList, nonPrintChars, language, canSetFont: false, canSetBackground: false);
            nonPrintChars.PropertyChanged += item_PropertyChanged;
            items.Add(nonPrintChars);

            // Create entry for "Line numbers"
            IHighlightingItem lineNumbers = new SimpleHighlightingItem(
                CustomizingHighlighter.LineNumbers,
                ta => {
                ta.Document.Text = "These are just" + Environment.NewLine +
                                   "multiple" + Environment.NewLine +
                                   "lines of" + Environment.NewLine +
                                   "text";
            })
            {
                Foreground = Colors.Gray
            };

            lineNumbers = new CustomizedHighlightingItem(customizationList, lineNumbers, language, canSetFont: false, canSetBackground: false);
            lineNumbers.PropertyChanged += item_PropertyChanged;
            items.Add(lineNumbers);

            // Create entry for "Bracket highlight"
            IHighlightingItem bracketHighlight = new SimpleHighlightingItem(
                BracketHighlightRenderer.BracketHighlight,
                ta => {
                ta.Document.Text          = "(simple) example";
                XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem;
                if (xshd == null)
                {
                    return;
                }
                var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name);
                BracketHighlightRenderer.ApplyCustomizationsToRendering(bracketHighlighter, customizationsForCurrentLanguage);
                bracketHighlighter.SetHighlight(new BracketSearchResult(0, 1, 7, 1));
            })
            {
                Foreground = BracketHighlightRenderer.DefaultBorder,
                Background = BracketHighlightRenderer.DefaultBackground
            };

            bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, language, canSetFont: false);
            bracketHighlight.PropertyChanged += item_PropertyChanged;
            items.Add(bracketHighlight);

            // Create entry for "Current Line highlight"
            IHighlightingItem currentLineHighlight = new SimpleHighlightingItem(
                CustomizingHighlighter.CurrentLineHighlighter,
                ta => {
                ta.Document.Text = "example text line";
                ta.TextView.Options.HighlightCurrentLine = true;
            })
            {
                Foreground = Color.FromArgb(52, 0, 255, 110),
                Background = Color.FromArgb(22, 20, 220, 224)
            };

            currentLineHighlight = new CustomizedHighlightingItem(customizationList, currentLineHighlight, language, canSetFont: false);
            currentLineHighlight.PropertyChanged += item_PropertyChanged;
            items.Add(currentLineHighlight);

            // Create entry for "Folding controls"
            IHighlightingItem foldingControls = new SimpleHighlightingItem(
                FoldingControls,
                ta => {
                ta.Document.Text = "This" + Environment.NewLine +
                                   "is a folding" + Environment.NewLine +
                                   "example";
                foldingManager.CreateFolding(0, 10);
            })
            {
                Foreground = Colors.Gray,
                Background = Colors.White
            };

            foldingControls = new CustomizedHighlightingItem(customizationList, foldingControls, language, canSetFont: false);
            foldingControls.PropertyChanged += item_PropertyChanged;
            items.Add(foldingControls);

            // Create entry for "Selected folding controls"
            IHighlightingItem selectedFoldingControls = new SimpleHighlightingItem(
                FoldingSelectedControls,
                ta => {
                ta.Document.Text = "This" + Environment.NewLine +
                                   "is a folding" + Environment.NewLine +
                                   "example";
                foldingManager.CreateFolding(0, 10);
            })
            {
                Foreground = Colors.Black,
                Background = Colors.White
            };

            selectedFoldingControls = new CustomizedHighlightingItem(customizationList, selectedFoldingControls, language, canSetFont: false);
            selectedFoldingControls.PropertyChanged += item_PropertyChanged;
            items.Add(selectedFoldingControls);

            // Create entry for "Folding text markers"
            IHighlightingItem foldingTextMarker = new SimpleHighlightingItem(
                FoldingTextMarkers,
                ta => {
                ta.Document.Text = "This" + Environment.NewLine +
                                   "is a folding" + Environment.NewLine +
                                   "example";
                foldingManager.CreateFolding(0, 10).IsFolded = true;
            })
            {
                Foreground = Colors.Gray
            };

            foldingTextMarker = new CustomizedHighlightingItem(customizationList, foldingTextMarker, language, canSetFont: false, canSetBackground: false);
            foldingTextMarker.PropertyChanged += item_PropertyChanged;
            items.Add(foldingTextMarker);

            IHighlightingItem linkText = new SimpleHighlightingItem(
                CustomizingHighlighter.LinkText,
                ta => {
                ta.Document.Text = "http://icsharpcode.net" + Environment.NewLine + "*****@*****.**";
            })
            {
                Foreground = Colors.Blue,
                Background = Colors.Transparent
            };

            linkText = new CustomizedHighlightingItem(customizationList, linkText, language, canSetFont: false);
            linkText.PropertyChanged += item_PropertyChanged;
            items.Add(linkText);

            IHighlightingItem errorMarker = new SimpleHighlightingItem(
                ErrorPainter.ErrorColorName,
                ta => {
                ta.Document.Text   = "some error";
                ITextMarker marker = textMarkerService.Create(0, 5);
                marker.Tag         = (Action <IHighlightingItem, ITextMarker>) delegate(IHighlightingItem item, ITextMarker m) {
                    m.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
                    m.MarkerColor = item.Foreground;
                };
            })
            {
                Foreground = Colors.Red
            };

            errorMarker = new CustomizedHighlightingItem(customizationList, errorMarker, language, canSetFont: false, canSetBackground: false);
            errorMarker.PropertyChanged += item_PropertyChanged;
            items.Add(errorMarker);

            IHighlightingItem warningMarker = new SimpleHighlightingItem(
                ErrorPainter.WarningColorName,
                ta => {
                ta.Document.Text   = "some warning";
                ITextMarker marker = textMarkerService.Create(0, 5);
                marker.Tag         = (Action <IHighlightingItem, ITextMarker>) delegate(IHighlightingItem item, ITextMarker m) {
                    m.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
                    m.MarkerColor = item.Foreground;
                };
            })
            {
                Foreground = Colors.Orange
            };

            warningMarker = new CustomizedHighlightingItem(customizationList, warningMarker, language, canSetFont: false, canSetBackground: false);
            warningMarker.PropertyChanged += item_PropertyChanged;
            items.Add(warningMarker);

            IHighlightingItem messageMarker = new SimpleHighlightingItem(
                ErrorPainter.MessageColorName,
                ta => {
                ta.Document.Text   = "some message";
                ITextMarker marker = textMarkerService.Create(0, 5);
                marker.Tag         = (Action <IHighlightingItem, ITextMarker>) delegate(IHighlightingItem item, ITextMarker m) {
                    m.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
                    m.MarkerColor = item.Foreground;
                };
            })
            {
                Foreground = Colors.Blue
            };

            messageMarker = new CustomizedHighlightingItem(customizationList, messageMarker, language, canSetFont: false, canSetBackground: false);
            messageMarker.PropertyChanged += item_PropertyChanged;
            items.Add(messageMarker);

            IHighlightingItem breakpointMarker = new SimpleHighlightingItem(
                BookmarkBase.BreakpointMarkerName,
                ta => {
                ta.Document.Text   = "some code with a breakpoint";
                ITextMarker marker = textMarkerService.Create(0, ta.Document.TextLength);
                marker.Tag         = (Action <IHighlightingItem, ITextMarker>) delegate(IHighlightingItem item, ITextMarker m) {
                    m.BackgroundColor = item.Background;
                    m.ForegroundColor = item.Foreground;
                };
            })
            {
                Background = BookmarkBase.BreakpointDefaultBackground,
                Foreground = BookmarkBase.BreakpointDefaultForeground
            };

            breakpointMarker = new CustomizedHighlightingItem(customizationList, breakpointMarker, language, canSetFont: false);
            breakpointMarker.PropertyChanged += item_PropertyChanged;
            items.Add(breakpointMarker);

            IHighlightingItem currentStatementMarker = new SimpleHighlightingItem(
                BookmarkBase.CurrentLineBookmarkName,
                ta => {
                ta.Document.Text   = "current statement line";
                ITextMarker marker = textMarkerService.Create(0, ta.Document.TextLength);
                marker.Tag         = (Action <IHighlightingItem, ITextMarker>) delegate(IHighlightingItem item, ITextMarker m) {
                    m.BackgroundColor = item.Background;
                    m.ForegroundColor = item.Foreground;
                };
            })
            {
                Background = BookmarkBase.CurrentLineDefaultBackground,
                Foreground = BookmarkBase.CurrentLineDefaultForeground
            };

            currentStatementMarker = new CustomizedHighlightingItem(customizationList, currentStatementMarker, language, canSetFont: false);
            currentStatementMarker.PropertyChanged += item_PropertyChanged;
            items.Add(currentStatementMarker);

            IHighlightingItem columnRuler = new SimpleHighlightingItem(
                CustomizingHighlighter.ColumnRuler,
                ta => {
                ta.Document.Text = "some line with a lot of text";
                ta.TextView.Options.ColumnRulerPosition = 15;
                ta.TextView.Options.ShowColumnRuler     = true;
            })
            {
                Foreground = Colors.LightGray
            };

            columnRuler = new CustomizedHighlightingItem(customizationList, columnRuler, language, canSetFont: false, canSetBackground: false);
            columnRuler.PropertyChanged += item_PropertyChanged;
            items.Add(columnRuler);
        }
		void CreateDefaultEntries(string language, out IHighlightingItem defaultText)
		{
			// Create entry for "default text/background"
			defaultText = new SimpleHighlightingItem(CustomizableHighlightingColorizer.DefaultTextAndBackground, ta => ta.Document.Text = "Normal text") {
				Foreground = SystemColors.WindowTextColor,
				Background = SystemColors.WindowColor
			};
			defaultText = new CustomizedHighlightingItem(customizationList, defaultText, null, canSetFont: false);
			if (language != null)
				defaultText = new CustomizedHighlightingItem(customizationList, defaultText, language, canSetFont: false);
			defaultText.PropertyChanged += item_PropertyChanged;
			listBox.Items.Add(defaultText);
			
			// Create entry for "Selected text"
			IHighlightingItem selectedText = new SimpleHighlightingItem(
				CustomizableHighlightingColorizer.SelectedText,
				ta => {
					ta.Document.Text = "Selected text";
					ta.Selection = new SimpleSelection(0, 13);
				})
			{
				Foreground = SystemColors.HighlightTextColor,
				Background = SystemColors.HighlightColor
			};
			selectedText = new CustomizedHighlightingItem(customizationList, selectedText, null, canSetFont: false);
			if (language != null)
				selectedText = new CustomizedHighlightingItem(customizationList, selectedText, language, canSetFont: false);
			selectedText.PropertyChanged += item_PropertyChanged;
			listBox.Items.Add(selectedText);
		}
		void CreateDefaultEntries(string language, out IHighlightingItem defaultText)
		{
			// Create entry for "default text/background"
			defaultText = new SimpleHighlightingItem(CustomizableHighlightingColorizer.DefaultTextAndBackground, ta => ta.Document.Text = "Normal text") {
				Foreground = SystemColors.WindowTextColor,
				Background = SystemColors.WindowColor
			};
			defaultText = new CustomizedHighlightingItem(customizationList, defaultText, null, canSetFont: false);
			if (language != null)
				defaultText = new CustomizedHighlightingItem(customizationList, defaultText, language, canSetFont: false);
			defaultText.PropertyChanged += item_PropertyChanged;
			listBox.Items.Add(defaultText);
			
			// Create entry for "Selected text"
			IHighlightingItem selectedText = new SimpleHighlightingItem(
				CustomizableHighlightingColorizer.SelectedText,
				ta => {
					ta.Document.Text = "Selected text";
					ta.Selection = Selection.Create(ta, 0, 13);
				})
			{
				Foreground = SystemColors.HighlightTextColor,
				Background = SystemColors.HighlightColor
			};
			selectedText = new CustomizedHighlightingItem(customizationList, selectedText, null, canSetFont: false);
			if (language != null)
				selectedText = new CustomizedHighlightingItem(customizationList, selectedText, language, canSetFont: false);
			selectedText.PropertyChanged += item_PropertyChanged;
			listBox.Items.Add(selectedText);
			
			// Create entry for "Non-printable characters"
			IHighlightingItem nonPrintChars = new SimpleHighlightingItem(
				CustomizableHighlightingColorizer.NonPrintableCharacters,
				ta => {
					ta.Document.Text = "	    \r \r\n \n";
				})
			{
				Foreground = Colors.LightGray
			};
			nonPrintChars = new CustomizedHighlightingItem(customizationList, nonPrintChars, null, canSetFont: false, canSetBackground: false);
			if (language != null)
				nonPrintChars = new CustomizedHighlightingItem(customizationList, nonPrintChars, language, canSetFont: false);
			nonPrintChars.PropertyChanged += item_PropertyChanged;
			listBox.Items.Add(nonPrintChars);
			
			// Create entry for "Line numbers"
			IHighlightingItem lineNumbers = new SimpleHighlightingItem(
				CustomizableHighlightingColorizer.LineNumbers,
				ta => {
					ta.Document.Text = "These are just" + Environment.NewLine +
						"multiple" + Environment.NewLine +
						"lines of" + Environment.NewLine +
						"text";
				})
			{
				Foreground = Colors.Gray
			};
			lineNumbers = new CustomizedHighlightingItem(customizationList, lineNumbers, null, canSetFont: false, canSetBackground: false);
			if (language != null)
				lineNumbers = new CustomizedHighlightingItem(customizationList, lineNumbers, language, canSetFont: false);
			lineNumbers.PropertyChanged += item_PropertyChanged;
			listBox.Items.Add(lineNumbers);
			
			// Create entry for "Bracket highlight"
			IHighlightingItem bracketHighlight = new SimpleHighlightingItem(
				BracketHighlightRenderer.BracketHighlight,
				ta => {
					ta.Document.Text = "(simple) example";
					XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem;
					if (xshd == null)
						return;
					var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name);
					BracketHighlightRenderer.ApplyCustomizationsToRendering(bracketHighlighter, customizationsForCurrentLanguage);
					bracketHighlighter.SetHighlight(new BracketSearchResult(0, 1, 7, 1));
				})
			{
				Foreground = BracketHighlightRenderer.DefaultBorder,
				Background = BracketHighlightRenderer.DefaultBackground
			};
			bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, null, canSetFont: false);
			if (language != null)
				bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, language, canSetFont: false);
			bracketHighlight.PropertyChanged += item_PropertyChanged;
			listBox.Items.Add(bracketHighlight);
			
			// Create entry for "Folding controls"
			IHighlightingItem foldingControls = new SimpleHighlightingItem(
				FoldingControls,
				ta => {
					ta.Document.Text = "This" + Environment.NewLine +
						"is a folding" + Environment.NewLine +
						"example";
					foldingManager.CreateFolding(0, 10);
				})
			{
				Foreground = Colors.Gray,
				Background = Colors.White
			};
			foldingControls = new CustomizedHighlightingItem(customizationList, foldingControls, null, canSetFont: false);
			if (language != null)
				foldingControls = new CustomizedHighlightingItem(customizationList, foldingControls, language, canSetFont: false);
			foldingControls.PropertyChanged += item_PropertyChanged;
			listBox.Items.Add(foldingControls);
			
			// Create entry for "Selected folding controls"
			IHighlightingItem selectedFoldingControls = new SimpleHighlightingItem(
				FoldingSelectedControls,
				ta => {
					ta.Document.Text = "This" + Environment.NewLine +
						"is a folding" + Environment.NewLine +
						"example";
					foldingManager.CreateFolding(0, 10);
				})
			{
				Foreground = Colors.Black,
				Background = Colors.White
			};
			selectedFoldingControls = new CustomizedHighlightingItem(customizationList, selectedFoldingControls, null, canSetFont: false);
			if (language != null)
				selectedFoldingControls = new CustomizedHighlightingItem(customizationList, selectedFoldingControls, language, canSetFont: false);
			selectedFoldingControls.PropertyChanged += item_PropertyChanged;
			listBox.Items.Add(selectedFoldingControls);
			
			// Create entry for "Folding text markers"
			IHighlightingItem foldingTextMarker = new SimpleHighlightingItem(
				FoldingTextMarkers,
				ta => {
					ta.Document.Text = "This" + Environment.NewLine +
						"is a folding" + Environment.NewLine +
						"example";
					foldingManager.CreateFolding(0, 10).IsFolded = true;
				})
			{
				Foreground = Colors.Gray
			};
			foldingTextMarker = new CustomizedHighlightingItem(customizationList, foldingTextMarker, null, canSetFont: false, canSetBackground: false);
			if (language != null)
				foldingControls = new CustomizedHighlightingItem(customizationList, foldingTextMarker, language, canSetFont: false, canSetBackground: false);
			foldingTextMarker.PropertyChanged += item_PropertyChanged;
			listBox.Items.Add(foldingTextMarker);
		}
Exemple #9
0
        void CreateDefaultEntries(string language, out IHighlightingItem defaultText)
        {
            // Create entry for "default text/background"
            defaultText = new SimpleHighlightingItem(CustomizableHighlightingColorizer.DefaultTextAndBackground, ta => ta.Document.Text = "Normal text")
            {
                Foreground = SystemColors.WindowTextColor,
                Background = SystemColors.WindowColor
            };
            defaultText = new CustomizedHighlightingItem(customizationList, defaultText, null, canSetFont: false);
            if (language != null)
            {
                defaultText = new CustomizedHighlightingItem(customizationList, defaultText, language, canSetFont: false);
            }
            defaultText.PropertyChanged += item_PropertyChanged;
            listBox.Items.Add(defaultText);

            // Create entry for "Selected text"
            IHighlightingItem selectedText = new SimpleHighlightingItem(
                CustomizableHighlightingColorizer.SelectedText,
                ta => {
                ta.Document.Text = "Selected text";
                ta.Selection     = Selection.Create(ta, 0, 13);
            })
            {
                Foreground = SystemColors.HighlightTextColor,
                Background = SystemColors.HighlightColor
            };

            selectedText = new CustomizedHighlightingItem(customizationList, selectedText, null, canSetFont: false);
            if (language != null)
            {
                selectedText = new CustomizedHighlightingItem(customizationList, selectedText, language, canSetFont: false);
            }
            selectedText.PropertyChanged += item_PropertyChanged;
            listBox.Items.Add(selectedText);

            // Create entry for "Non-printable characters"
            IHighlightingItem nonPrintChars = new SimpleHighlightingItem(
                CustomizableHighlightingColorizer.NonPrintableCharacters,
                ta => {
                ta.Document.Text = "	    \r \r\n \n";
            })
            {
                Foreground = Colors.LightGray
            };

            nonPrintChars = new CustomizedHighlightingItem(customizationList, nonPrintChars, null, canSetFont: false, canSetBackground: false);
            if (language != null)
            {
                nonPrintChars = new CustomizedHighlightingItem(customizationList, nonPrintChars, language, canSetFont: false);
            }
            nonPrintChars.PropertyChanged += item_PropertyChanged;
            listBox.Items.Add(nonPrintChars);

            // Create entry for "Line numbers"
            IHighlightingItem lineNumbers = new SimpleHighlightingItem(
                CustomizableHighlightingColorizer.LineNumbers,
                ta => {
                ta.Document.Text = "These are just" + Environment.NewLine +
                                   "multiple" + Environment.NewLine +
                                   "lines of" + Environment.NewLine +
                                   "text";
            })
            {
                Foreground = Colors.Gray
            };

            lineNumbers = new CustomizedHighlightingItem(customizationList, lineNumbers, null, canSetFont: false, canSetBackground: false);
            if (language != null)
            {
                lineNumbers = new CustomizedHighlightingItem(customizationList, lineNumbers, language, canSetFont: false);
            }
            lineNumbers.PropertyChanged += item_PropertyChanged;
            listBox.Items.Add(lineNumbers);

            // Create entry for "Bracket highlight"
            IHighlightingItem bracketHighlight = new SimpleHighlightingItem(
                BracketHighlightRenderer.BracketHighlight,
                ta => {
                ta.Document.Text          = "(simple) example";
                XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem;
                if (xshd == null)
                {
                    return;
                }
                var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name);
                BracketHighlightRenderer.ApplyCustomizationsToRendering(bracketHighlighter, customizationsForCurrentLanguage);
                bracketHighlighter.SetHighlight(new BracketSearchResult(0, 1, 7, 1));
            })
            {
                Foreground = BracketHighlightRenderer.DefaultBorder,
                Background = BracketHighlightRenderer.DefaultBackground
            };

            bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, null, canSetFont: false);
            if (language != null)
            {
                bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, language, canSetFont: false);
            }
            bracketHighlight.PropertyChanged += item_PropertyChanged;
            listBox.Items.Add(bracketHighlight);

            // Create entry for "Folding controls"
            IHighlightingItem foldingControls = new SimpleHighlightingItem(
                FoldingControls,
                ta => {
                ta.Document.Text = "This" + Environment.NewLine +
                                   "is a folding" + Environment.NewLine +
                                   "example";
                foldingManager.CreateFolding(0, 10);
            })
            {
                Foreground = Colors.Gray,
                Background = Colors.White
            };

            foldingControls = new CustomizedHighlightingItem(customizationList, foldingControls, null, canSetFont: false);
            if (language != null)
            {
                foldingControls = new CustomizedHighlightingItem(customizationList, foldingControls, language, canSetFont: false);
            }
            foldingControls.PropertyChanged += item_PropertyChanged;
            listBox.Items.Add(foldingControls);

            // Create entry for "Selected folding controls"
            IHighlightingItem selectedFoldingControls = new SimpleHighlightingItem(
                FoldingSelectedControls,
                ta => {
                ta.Document.Text = "This" + Environment.NewLine +
                                   "is a folding" + Environment.NewLine +
                                   "example";
                foldingManager.CreateFolding(0, 10);
            })
            {
                Foreground = Colors.Black,
                Background = Colors.White
            };

            selectedFoldingControls = new CustomizedHighlightingItem(customizationList, selectedFoldingControls, null, canSetFont: false);
            if (language != null)
            {
                selectedFoldingControls = new CustomizedHighlightingItem(customizationList, selectedFoldingControls, language, canSetFont: false);
            }
            selectedFoldingControls.PropertyChanged += item_PropertyChanged;
            listBox.Items.Add(selectedFoldingControls);

            // Create entry for "Folding text markers"
            IHighlightingItem foldingTextMarker = new SimpleHighlightingItem(
                FoldingTextMarkers,
                ta => {
                ta.Document.Text = "This" + Environment.NewLine +
                                   "is a folding" + Environment.NewLine +
                                   "example";
                foldingManager.CreateFolding(0, 10).IsFolded = true;
            })
            {
                Foreground = Colors.Gray
            };

            foldingTextMarker = new CustomizedHighlightingItem(customizationList, foldingTextMarker, null, canSetFont: false, canSetBackground: false);
            if (language != null)
            {
                foldingControls = new CustomizedHighlightingItem(customizationList, foldingTextMarker, language, canSetFont: false, canSetBackground: false);
            }
            foldingTextMarker.PropertyChanged += item_PropertyChanged;
            listBox.Items.Add(foldingTextMarker);
        }