Syntax Editor - What is the correct way to set the zoom and the zoomcombobox value?

1 Answer 134 Views
SyntaxEditor
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Troy asked on 22 Mar 2023, 12:56 AM

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. =)

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 22 Mar 2023, 02:43 PM

Hello Troy,

Thank you for the provided details.

I have tested your scenario and you are right that using ZoomTo() method will not update the drop-down list if the passed value does not present. In this case, you can manually populate the Items collection of the ZoomComboBox and add the desired values. 

this.radSyntaxEditor1.SyntaxEditorElement.ZoomComboBox.Items.Insert(3,new RadListDataItem("80 %"));
this.radSyntaxEditor1.ZoomTo(0.8);

Can you try this approach and let me know if it is working for you?

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Troy
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 22 Mar 2023, 06:56 PM

Dinko,

Thanks for the response.  This would solve that issue, however as the zoom percentage appears differently depending on something (I don't know what), those values when scrolling the mouse wheel can be... anything.  91%, 78%, etc.  Add to that, I'd have to rebuild the entire zoom dropdown every time someone scrolled, so that I could get the items in order.

To me, either the control should add to the zoom combo box any values that are possible when scrolling the mouse wheel, or, only allow the mouse wheel to scroll through the values in the combo box.

Dinko | Tech Support Engineer
Telerik team
commented on 23 Mar 2023, 09:10 AM

The dropdown part of the zoom behavior contains static items. It is not intended to be updated every time when the user zoom in/out. Applying a zoom level not included in the dropdown is possible using the zoom combo box text box part. Adding every zoom level on the mouse wheel will significantly increase the item number. Generally, speaking RadSyntaxEditor control tries to mimic Visual Studio editor. You can observe the same behavior also there.

If you want to add more items in the dropdown part, you can use the approach mentioned in my previous reply.

Troy
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 23 Mar 2023, 10:26 PM

Dinko,

I'll ago ahead and only save values that are in the combo box.  However, Are there events for the zoom combobox changing values?  I can't seem to find any.  There are events for the scalefactor, but that fires when the mouse wheel changes as well.

Dinko | Tech Support Engineer
Telerik team
commented on 24 Mar 2023, 12:23 PM

You could subscribe to the TextChanged event of the ZoomComboBox. This event will be called when the text part of the control is changed manually or by the mouse wheel.

this.radSyntaxEditor1.SyntaxEditorElement.ZoomComboBox.TextChanged += ZoomComboBox_TextChanged;

private void ZoomComboBox_TextChanged(object sender, EventArgs e)
{
           
}

 

Tags
SyntaxEditor
Asked by
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or