fix (ui): Validate width/height before updating DragRectAdorner

This commit is contained in:
John Colvin committed 2022-08-06 23:54:15 -04:00
1 parent 181072f3e7
commit f3302dbac0
2 files changed
+15 -2

No files matched your search

@@ -302,8 +302,12 @@ namespace mbts.ui.controls {
return;
rect.Intersect(this.GetChildBounds(_drag_rect_adorner.AdornedElement));
_drag_rect_adorner.Child.Margin = new Thickness(rect.Left, rect.Top, 0, 0);
_drag_rect_adorner.Child.Width = rect.Width;
_drag_rect_adorner.Child.Height = rect.Height;
if (rect.Width.is_real_non_negative()) {
_drag_rect_adorner.Child.Width = rect.Width;
}
if (rect.Height.is_real_non_negative()) {
_drag_rect_adorner.Child.Height = rect.Height;
}
}
void _select_items_between(object inclusive_begin, object inclusive_end) {
@@ -477,6 +477,15 @@ namespace mbts.ui {
public static string join_binding_paths(params string[] paths) => string.Join(".", paths);
public static Rect? try_mk_rect(double left, double top, double right, double bottom) =>
left.is_real()
&& top.is_real()
&& right.is_real()
&& bottom.is_real()
&& left <= right
&& top <= bottom ?
new(left, top, right, bottom) : null;
public static class Hooks {
public static void exchange_is_keyboard_focused_within(FrameworkElement oldval, FrameworkElement newval, DependencyPropertyChangedEventHandler handler) {
if (oldval != null) oldval.IsKeyboardFocusWithinChanged -= handler;