Skip to content

Commit 517cf32

Browse files
authored
Merge pull request #52 from SyncfusionExamples/948164
948164: Zoom using mouse is not working in Custom toolbar
2 parents d6456e2 + 69609c3 commit 517cf32

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Toolbar/CustomToolbar/ViewModel/ViewModel.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void Loaded(object sender, RoutedEventArgs e)
125125
m_customToolbarWindow.find_text.LauncherButton.Visibility = Visibility.Collapsed;
126126
m_customToolbarWindow.Stamp.LauncherButton.Visibility = Visibility.Collapsed;
127127
m_customToolbarWindow.pdfviewer.CurrentPageChanged += pdfviewer1_CurrentPageChanged;
128-
128+
m_customToolbarWindow.pdfviewer.PreviewMouseWheel += pdfviewer_PreviewMouseWheel;
129129
if (m_customToolbarWindow.pdfviewer.LoadedDocument == null)
130130
{
131131
m_customToolbarWindow.txtCurrentPageIndex.Text = "0";
@@ -153,6 +153,29 @@ public void Loaded(object sender, RoutedEventArgs e)
153153
m_customToolbarWindow.ZoomComboBox.SelectedIndex = 2;
154154
}
155155
}
156+
157+
private void pdfviewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
158+
{
159+
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
160+
{
161+
if (e.Delta != 0 && m_customToolbarWindow.ZoomComboBox.Text != m_customToolbarWindow.pdfviewer.ZoomPercentage.ToString())
162+
{
163+
m_customToolbarWindow.ZoomComboBox.Text = m_customToolbarWindow.pdfviewer.ZoomPercentage.ToString();
164+
if(m_customToolbarWindow.pdfviewer.ZoomMode == Syncfusion.Windows.PdfViewer.ZoomMode.Default)
165+
{
166+
if(!m_customToolbarWindow.FitWidth.IsEnabled)
167+
{
168+
m_customToolbarWindow.FitWidth.IsEnabled = true;
169+
}
170+
if (!m_customToolbarWindow.FitPage.IsEnabled)
171+
{
172+
m_customToolbarWindow.FitPage.IsEnabled = true;
173+
}
174+
}
175+
}
176+
}
177+
}
178+
156179
/// <summary>
157180
/// Handles cleanup operations when the custom toolbar window is closed.
158181
/// </summary>

0 commit comments

Comments
 (0)