private void SetDragHeight(DragDeltaEventArgs e)
{
if (!canSizeY) return;
if (double.IsNaN(scrollViewer.Height)) scrollViewer.Height = scrollViewer.ActualHeight;
if (ShowPopupOnTop)
{
double monitorTop = RibbonControl.GetControlMonitor(this).Top;
// Calc shadow height
double delta = this.PointToScreen(new Point()).Y - dropDownBorder.ActualHeight - e.VerticalChange - monitorTop;
if (delta > 0)
{
scrollViewer.Height =
Math.Min(Math.Max(galleryPanel.GetItemSize().Height, scrollViewer.Height + e.VerticalChange),
MaxDropDownHeight);
}
else
{
delta = this.PointToScreen(new Point()).Y - dropDownBorder.ActualHeight - monitorTop;
scrollViewer.Height =
Math.Min(Math.Max(galleryPanel.GetItemSize().Height, scrollViewer.Height + delta),
MaxDropDownHeight);
}
}
else
{
double monitorBottom = RibbonControl.GetControlMonitor(this).Bottom;
FrameworkElement popupChild = popup.Child as FrameworkElement;
double delta = monitorBottom - this.PointToScreen(new Point()).Y - ActualHeight - popupChild.ActualHeight - e.VerticalChange;
if (delta > 0)
{
scrollViewer.Height =
Math.Min(Math.Max(galleryPanel.GetItemSize().Height, scrollViewer.Height + e.VerticalChange),
MaxDropDownHeight);
}
else
{
delta = monitorBottom - this.PointToScreen(new Point()).Y - ActualHeight - popupChild.ActualHeight;
scrollViewer.Height =
Math.Min(Math.Max(galleryPanel.GetItemSize().Height, scrollViewer.Height + delta),
MaxDropDownHeight);
}
}
}