Пример #1
0
        private void UserControl_DragEnter(object sender, DragEventArgs e)
        {
            var plots          = PlotClipboardData.FromDataObject(e.Data);
            var targetDeviceId = Model?.Device?.DeviceId;

            if (targetDeviceId != null && plots.All(p => p.DeviceId == targetDeviceId))
            {
                var isMove = (e.KeyStates & DragDropKeyStates.ShiftKey) != 0;
                e.Effects = isMove ? DragDropEffects.Move : DragDropEffects.Copy;
                e.Handled = true;
                return;
            }

            e.Effects = DragDropEffects.None;
            e.Handled = true;
        }
Пример #2
0
        private void UserControl_Drop(object sender, DragEventArgs e)
        {
            var sources = PlotClipboardData.FromDataObject(e.Data).ToArray();

            if (sources.Length > 0)
            {
                var isMove = (e.KeyStates & DragDropKeyStates.ShiftKey) != 0;
                try {
                    foreach (var source in sources)
                    {
                        Model?.CopyPlotFromAsync(source.DeviceId, source.PlotId, isMove).DoNotWait();
                    }
                } catch (RPlotManagerException ex) {
                    MessageBox.Show(ex.Message, string.Empty, MessageBoxButton.OK, MessageBoxImage.Error);
                } catch (OperationCanceledException) {
                }
                e.Handled = true;
            }
        }