Only listen to drag events when IsDragSelectionEnable is true
This commit is contained in:
1 parent
97cce473e8
commit
2601519e8b
2 files changed
+44
-20
No files matched your search
@@ -350,6 +350,7 @@ namespace mbts.ui.controls {
|
||||
|
||||
public event DIYGridSortingEventHandler Sorting;
|
||||
public event Action<bool> SupportGroupItemsChanged;
|
||||
public event Action<bool> IsDragAdornerEnabledChanged;
|
||||
public event Action<double> RowHeightChanged;
|
||||
public event Action<List<ColumnGeometry>> ColumnLayoutChanged;
|
||||
|
||||
@@ -404,6 +405,16 @@ namespace mbts.ui.controls {
|
||||
(FontStretch)GetValue(FontStretchProperty),
|
||||
(FontFamily)GetValue(FontFamilyProperty));
|
||||
|
||||
#region IsDragSelectionEnabled
|
||||
public static readonly DependencyProperty IsDragSelectionEnabledProperty = WPFHelper.create_dp<bool, DIYGrid>(
|
||||
nameof(IsDragSelectionEnabled), (o, v) => o.IsDragAdornerEnabledChanged?.Invoke(v), true);
|
||||
|
||||
public bool IsDragSelectionEnabled {
|
||||
get => (bool)GetValue(IsDragSelectionEnabledProperty);
|
||||
set => SetValue(IsDragSelectionEnabledProperty, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IsDragAdornerEnabled
|
||||
public static readonly DependencyProperty IsDragAdornerEnabledProperty = WPFHelper.create_dp<bool, DIYGrid>(
|
||||
nameof(IsDragAdornerEnabled), true);
|
||||
|
||||
@@ -77,26 +77,8 @@ namespace mbts.ui.controls {
|
||||
});
|
||||
_cell_hover_adorner.attach();
|
||||
|
||||
// drag
|
||||
_drag_hook = Disposable.Create(
|
||||
DragDropHelper.subscribe_drag_coordinates(this, init_element: _content_presenter, use_preview_events: true)
|
||||
.Subscribe(pt => {
|
||||
if (_drag_start.HasValue) {
|
||||
if (pt.HasValue) {
|
||||
_drag_stop = pt.Value;
|
||||
_refresh_drag_rect();
|
||||
} else {
|
||||
if (_drag_stop.HasValue) {
|
||||
_end_drag(_drag_stop.Value);
|
||||
}
|
||||
_drag_start = null;
|
||||
_drag_stop = null;
|
||||
}
|
||||
} else if (pt.HasValue) {
|
||||
_begin_drag_selection(pt.Value);
|
||||
}
|
||||
}),
|
||||
_scroll_viewer.SubscribeScrollChanged((s, _) => _refresh_drag_rect()));
|
||||
_grid.IsDragAdornerEnabledChanged += on_is_drag_adorner_enabled_changed;
|
||||
on_is_drag_adorner_enabled_changed(_grid.IsDragAdornerEnabled);
|
||||
}
|
||||
|
||||
void on_unloaded(object sender, RoutedEventArgs e) =>
|
||||
@@ -121,6 +103,37 @@ namespace mbts.ui.controls {
|
||||
|
||||
void on_row_height_changed(double v) => _row_height = v;
|
||||
void on_support_group_items_changed(bool v) => _support_group_items = v;
|
||||
|
||||
void on_is_drag_adorner_enabled_changed(bool value) {
|
||||
Disposable.dispose(ref _drag_hook);
|
||||
if (value) {
|
||||
_drag_hook = _subscribe_drag();
|
||||
}
|
||||
}
|
||||
|
||||
IDisposable _subscribe_drag() =>
|
||||
Disposable.Create(
|
||||
DragDropHelper.subscribe_drag_coordinates(this, init_element: _content_presenter, use_preview_events: true)
|
||||
.Subscribe(pt => {
|
||||
if (_drag_start.HasValue) {
|
||||
if (pt.HasValue) {
|
||||
_drag_stop = pt.Value;
|
||||
_refresh_drag_rect();
|
||||
} else {
|
||||
if (_drag_stop.HasValue) {
|
||||
_end_drag(_drag_stop.Value);
|
||||
}
|
||||
_drag_start = null;
|
||||
_drag_stop = null;
|
||||
}
|
||||
} else if (pt.HasValue) {
|
||||
if (_grid is not null && !_grid.IsDragSelectionEnabled) {
|
||||
return;
|
||||
}
|
||||
_begin_drag_selection(pt.Value);
|
||||
}
|
||||
}),
|
||||
_scroll_viewer.SubscribeScrollChanged((s, _) => _refresh_drag_rect()));
|
||||
}
|
||||
|
||||
public event GroupItemSelectionPivotEventHandler GroupItemSelectionPivot;
|
||||
|
||||
Reference in new issue
Block a user