Skip to content

Commit fc4384e

Browse files
committed
Fixing issue where combo box would revert back to classic mode on right monitor to the right of the primary screen.
Made Screen internal.
1 parent 436d585 commit fc4384e

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

MaterialDesignThemes.Wpf/ComboBoxPopup.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public enum ComboBoxPopupPlacement
1313
{
1414
Undefined,
1515
Down,
16-
Up,
16+
Up,
1717
Classic
1818
}
1919

@@ -114,7 +114,7 @@ public ComboBoxPopupPlacement PopupPlacement
114114
}
115115

116116
#endregion
117-
117+
118118
#region Background property
119119

120120
private static readonly DependencyPropertyKey BackgroundPropertyKey =
@@ -233,9 +233,9 @@ private CustomPopupPlacement[] ComboBoxCustomPopupPlacementCallback(
233233
SetupVisiblePlacementWidth(visualAncestry);
234234

235235
var data = GetPositioningData(visualAncestry, popupSize, targetSize, offset);
236-
var preferUpIfSafe = data.LocationY + data.PopupSize.Height > data.ScreenHeight;
236+
var preferUpIfSafe = data.LocationY + data.PopupSize.Height > data.ScreenHeight;
237237

238-
if (ClassicMode
238+
if (ClassicMode
239239
|| data.LocationX + data.PopupSize.Width - data.RealOffsetX > data.ScreenWidth
240240
|| data.LocationX - data.RealOffsetX < 0
241241
|| !preferUpIfSafe && data.LocationY - Math.Abs(data.NewDownY) < 0)
@@ -274,10 +274,10 @@ private PositioningData GetPositioningData(IEnumerable<DependencyObject> visualA
274274
var screen = Screen.FromPoint(locationFromScreen);
275275
var screenWidth = (int)DpiHelper.TransformToDeviceX(mainVisual, (int)screen.Bounds.Width);
276276
var screenHeight = (int)DpiHelper.TransformToDeviceY(mainVisual, (int)screen.Bounds.Height);
277-
277+
278278
//Adjust the location to be in terms of the current screen
279-
var locationX = (int)locationFromScreen.X % screenWidth - screen.Bounds.X;
280-
var locationY = (int)locationFromScreen.Y % screenHeight - screen.Bounds.Y;
279+
var locationX = (int)(locationFromScreen.X - screen.Bounds.X) % screenWidth;
280+
var locationY = (int)(locationFromScreen.Y - screen.Bounds.Y) % screenHeight;
281281

282282
var upVerticalOffsetIndepent = DpiHelper.TransformToDeviceY(mainVisual, UpVerticalOffset);
283283
var newUpY = upVerticalOffsetIndepent - popupSize.Height + targetSize.Height;
@@ -330,8 +330,8 @@ private void UpdateChildTemplate(ComboBoxPopupPlacement placement)
330330
case ComboBoxPopupPlacement.Up:
331331
SetChildTemplateIfNeed(UpContentTemplate);
332332
break;
333-
// default:
334-
// throw new NotImplementedException($"Unexpected value {placement} of the {nameof(PopupPlacement)} property inside the {nameof(ComboBoxPopup)} control.");
333+
// default:
334+
// throw new NotImplementedException($"Unexpected value {placement} of the {nameof(PopupPlacement)} property inside the {nameof(ComboBoxPopup)} control.");
335335
}
336336
}
337337

@@ -356,7 +356,7 @@ private static CustomPopupPlacement GetClassicPopupPlacement(ComboBoxPopup popup
356356
}
357357

358358
private static CustomPopupPlacement GetDownPopupPlacement(PositioningData data)
359-
{
359+
{
360360
return new CustomPopupPlacement(new Point(data.OffsetX, data.NewDownY), PopupPrimaryAxis.None);
361361
}
362362

MaterialDesignThemes.Wpf/Screen.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88

99
namespace MaterialDesignThemes.Wpf
1010
{
11-
1211
///<summary>
1312
/// Represents a display device or multiple display devices on a single system.
1413
/// Based on http://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Screen.cs
1514
/// </summary>
16-
public class Screen
15+
internal class Screen
1716
{
1817
private static class NativeMethods
1918
{

0 commit comments

Comments
 (0)