Hi,
I have develop a custom tagger in order to format some specific words.
My problem is that the format is applying to this words even if they are used as strings (inside quotes).
I would like that the format only applies when the word is not in quotes.
In. Ex:
WORD -> Apply Format
"WORD" -> Do not apply format
This is my code:
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using AutoMapper.Internal;
using Telerik.WinControls.UI;
using Telerik.WinForms.Controls.SyntaxEditor.Taggers;
using Telerik.WinForms.Controls.SyntaxEditor.UI;
using Telerik.WinForms.SyntaxEditor.Core.Tagging;
namespace Simulation.UX.Forms.Controls.Neptune
{
public class CustomTagger : CSharpTagger
{
public static readonly ClassificationType CustomClassificationType = new("Custom");
public static readonly Dictionary<string, ClassificationType> WordsToClassificationType = new();
public static readonly TextFormatDefinition Format = new(new SolidBrush(Color.DarkGoldenrod));
private readonly List<string> _words;
public NeptuneTagger(RadSyntaxEditorElement editor, List<string> words) : base(editor)
{
_words = words;
}
protected override Dictionary<string, ClassificationType> GetWordsToClassificationTypes()
{
Dictionary<string, ClassificationType> baseTypes = base.GetWordsToClassificationTypes();
_words?.ForAll(w =>
{
if (!baseTypes.ContainsKey(w))
{
baseTypes.Add(w, CustomClassificationType);
}
});
return baseTypes;
}
}
}
Hi,
I'm looking into the viability of using the WinForms RadSyntaxEditor for a small project.
I think I've come across a bug when it comes to DPI scaling.
The component itself seems to work fine with DPI scaling except for the search/find functionality. When you search for some text and click to go to the first instance it finds, the actual text is off screen, though it is highlighted correctly (when you scroll down you can see it highlighted).
If I set the CaretPosition manually to a line further in the document, it also displays correctly so it seems to be specifically limited to the built-in Search/Find panel.
This is easy to replicate by changing Windows display scale to anything other than 100%.
I am attempting to add a RadSyntaxEditorElement to Telerik Chat UI for Winforms using 2023.3.1010 Trial.
I receive a null reference exception in RadSyntaxEditorElement.cs > SyncZoomComboText line 1312. It says base.Dispatcher = null. (see attached image).
Is it possible to add the SyntaxEditorElement to chat? If, not do you have any other recommendations for display code in chat?
Here is my test code modified from the examples found on your site.
public class MyCodeMessageItemElement : TextMessageItemElement
{
protected override Type ThemeEffectiveType
{
get
{
return typeof(TextMessageItemElement);
}
}
protected override LightVisualElement CreateMainMessageElement()
{
return new CustomCodeMessageBubbleElement();
}
public override void Synchronize()
{
base.Synchronize();
CustomCodeMessageBubbleElement bubble = this.MainMessageElement as CustomCodeMessageBubbleElement;
bubble.DrawText = false;
}
}
public class CustomCodeMessageBubbleElement : ChatMessageBubbleElement
{
protected override Type ThemeEffectiveType
{
get
{
return typeof(ChatMessageBubbleElement);
}
}
//RadTextBoxControlElement textBoxElement;
RadSyntaxEditor radSyntaxEditor;
RadSyntaxEditorElement radSyntaxEditorElement;
public RadSyntaxEditor SyntaxEditor1
{
get
{
return this.radSyntaxEditor;
}
}
protected override void CreateChildElements()
{
base.CreateChildElements();
radSyntaxEditorElement = new RadSyntaxEditorElement();
radSyntaxEditorElement.ZoomComboBox.Enabled = false;
//radSyntaxEditor.ContextMenuOpening += textBoxElement_ContextMenuOpening;
this.Children.Add(radSyntaxEditorElement);
}
//private void textBoxElement_ContextMenuOpening(object sender, TreeBoxContextMenuOpeningEventArgs e)
//{
// foreach (RadItem item in e.ContextMenu.Items)
// {
// if (item.Text.Contains("&Copy"))
// {
// item.Visibility = ElementVisibility.Visible;
// }
// else
// {
// item.Visibility = ElementVisibility.Collapsed;
// }
// }
//}
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
this.radSyntaxEditor.Text = value;
}
}
}
I'm using the example for the radfontdropdownlist control to attempt to set the font for the radsyntaxeditor. So far, I haven't had any luck changing it.
Here is an example:
I attempted to set editor.SyntaxEditorElement.Font = font as well, but while that doesn't blow up, it doesn't seem to change anything either.
Here's the full code for this event:
Private Sub fontDropdown_SelectedFontChanged(sender As Object, e As EventArgs) Handles fontDropdown.SelectedFontChanged
Dim editor As RadSyntaxEditor = GetActiveEditor()
If IsNothing(editor) Then Exit Sub
Dim ff As FontFamily = New FontFamily(fontDropdown.SelectedFont)
If ff.IsStyleAvailable(FontStyle.Regular) Then
Dim font As Font = New Font(ff.Name, 10, FontStyle.Regular)
editor.SyntaxEditorElement.EditorFontFamily = font.FontFamily
Else
For Each style As FontStyle In [Enum].GetValues(GetType(FontStyle))
If ff.IsStyleAvailable(style) Then
Dim font As Font = New Font(ff.Name, 10, style)
editor.Font = font
Exit For
End If
Next
End If
End Sub
I'm trying to save the current zoom level that a user has set for a document. I can get the value of the zoom level, but what I can't figure out how to do, is set the zoomcombobox to that value.
As an example, the default combo box has a list of values. If a user sets it to say 150%, I can save that value. I can use the zoomto method to set it and the document will scale to 150%. However, this doesn't change the zoomcombobox value, it stays at whatever it was (default of 100%).
The next problem is, the user can CTRL-Mousewheel to change the zoom level. This will add values to the zoomcombobox that were not previously there (meaning, the values will be different than those available in the zoomcombobox). Not really a problem on the surface, the document scales correctly, the zoomcombobox has the correct values.
But, if I reload the document and want to reset the zoom level to the users zoom preference, the odds are, the scale is not in the default set of values for the zoomcombobox.
I hope this makes some sense. =)
Reading this document: https://docs.telerik.com/devtools/winforms/controls/syntax-editor/features/word-wrap
States that wordwrap should now be a thing. However, it isn't for me.
I've updated to the latest Telerik (already was), and no luck.
Basically what the title says. I've selected part of a document, and I want to replace only part of the text, within that selection. Is this possible? I've been trying various things, but so far, no luck.
In short, I've added commenting to my text. That works fine, but I can't uncomment (remove the comment characters) from the selected text.
Hi,
with custom taggers is it possibile to manage insentive custom grammar?
thank you
First, thanks for the awesome stuff, getting it going was easy.
However, I'm having a few issues and can't seem to figure out a way around them. I'm trying to make a JSON tagger.
Here is how I'm defining things:
Private Shared ReadOnly Keywords As String() = New String() {""""}
Private Shared ReadOnly Operators As String() = New String() {"{", "}", "[", "]", ":", ","}
Here is an example of the output
The problems I see are:
The second double quote isn't colored like the first one.
The colon isn't colored
The comma after the double quote isn't colored
The closing brace and comma aren't colored
Also, is there a way to highlight the text between characters? I'd like to highlight the keys and values, and differently from each other if possible.
I'm sure I'm doing it wrong, but haven't been able to figure it out.
Thanks!