private void GetColor(TokenViewModel value) { if (value.Text == "\"") { value.Color = Color.green; return; } if (Keywords.Contains(value.Text)) { value.Color = Color.blue; value.Bold = true; lastWasKeyword = true; return; } if (lastWasKeyword && !value.Text.Any(char.IsWhiteSpace)) { value.Color = Color.grey; lastWasKeyword = false; return; } if (Literals.Contains(value.Text)) { value.Color = Color.gray; value.Bold = true; } value.Color = Color.black; }
private LineViewModel ParseLine(string line) { var lineViewModel = new LineViewModel(this); var matchList = Regex.Matches(line, CSHARP_TOKENS + @"|.|\s+",RegexOptions.None); foreach (Match match in matchList) { var token = new TokenViewModel(lineViewModel, match.Value, Color.gray); GetColor(token); lineViewModel.Tokens.AddLast(token); } return lineViewModel; }
private LineViewModel ParseLine(string line) { var lineViewModel = new LineViewModel(this); var matchList = Regex.Matches(line, CSHARP_TOKENS + @"|.|\s+", RegexOptions.None); foreach (Match match in matchList) { var token = new TokenViewModel(lineViewModel, match.Value, Color.gray); GetColor(token); lineViewModel.Tokens.AddLast(token); } return(lineViewModel); }