This is a migrated thread and some comments may be shown as answers.

RadTimeBar initial Zoom + Keyboard zoom

2 Answers 19 Views
TimeBar
This is a migrated thread and some comments may be shown as answers.
Tulio
Top achievements
Rank 1
Tulio asked on 13 Sep 2017, 09:45 PM

Hi!

 

I have two issues with the zoom for the timebar (I am plotting a RadColumnSparkLine in it)

 

1) I want to be able to set the initial zoom level (I have the period start to end for 3 days). I want the initial zoom to be for 1 day and then the user can zoom out to see the whole 3 days period if he wants.

 

2) Allow keyboard integration so the user can zoom with Ctrl and + and zoom out with Ctrl and -

 

Thanks!

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 18 Sep 2017, 02:00 PM
Hi Tulio,

In order to set the initial zoom level of the control, you can use the MinZoomRange of the control as per your needs.
this.zoomTimeBar.MinZoomRange = new System.TimeSpan(24, 0, 0);

Then, in order to define the required keyboard behavior, you can subscribe to the KeyDown event of the control as demonstrated below.
this.AddHandler(RadTimeBar.KeyDownEvent,
new KeyEventHandler(zoomTimeBar_KeyDown), true);

Since you need to use the Ctrl modifier in conjunction with the Add and Subtract keys, the event handler would look similar to the code snippet below.
private void zoomTimeBar_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
    {
        if (e.Key == Key.Add)
        {
            this.zoomTimeBar.MinZoomRange += new System.TimeSpan(24, 0, 0);
        }
        else if (e.Key == Key.Subtract)
        {
            this.zoomTimeBar.MinZoomRange -= new System.TimeSpan(24, 0, 0);
        }
    }
}

I hope that these suggestions correspond to your needs. Can you please give them a try? I am staying at your disposal in case further assistance is needed.

Best Regards,
Stefan X1
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Tulio
Top achievements
Rank 1
answered on 21 Sep 2017, 09:32 PM
Thanks! Will try that!
Tags
TimeBar
Asked by
Tulio
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Tulio
Top achievements
Rank 1
Share this question
or