Exemple #1
0
        public async Task <CommandResult> InvokeAsync()
        {
            if (Clipboard.ContainsData(PlotClipboardData.Format))
            {
                var source = PlotClipboardData.Parse((string)Clipboard.GetData(PlotClipboardData.Format));
                if (source != null)
                {
                    try {
                        if (VisualComponent.Device == null)
                        {
                            await InteractiveWorkflow.Plots.NewDeviceAsync(VisualComponent.InstanceId);
                        }

                        Debug.Assert(VisualComponent.Device != null);
                        await InteractiveWorkflow.Plots.CopyOrMovePlotFromAsync(source.DeviceId, source.PlotId, VisualComponent.Device, source.Cut);

                        // If it's a move, clear the clipboard as we don't want
                        // the user to try to paste it again
                        if (source.Cut)
                        {
                            Clipboard.Clear();
                        }
                    } catch (RPlotManagerException ex) {
                        InteractiveWorkflow.Shell.ShowErrorMessage(ex.Message);
                    } catch (OperationCanceledException) {
                    }
                }
            }

            return(CommandResult.Executed);
        }
Exemple #2
0
        private void UserControl_Drop(object sender, DragEventArgs e)
        {
            var source = PlotClipboardData.Parse((string)e.Data.GetData(PlotClipboardData.Format));

            if (source != null)
            {
                bool isMove = (e.KeyStates & DragDropKeyStates.ShiftKey) != 0;
                try {
                    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;
            }
        }
Exemple #3
0
        private void UserControl_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(PlotClipboardData.Format))
            {
                var source = PlotClipboardData.Parse((string)e.Data.GetData(PlotClipboardData.Format));
                if (source != null)
                {
                    var targetDeviceId = Model?.Device?.DeviceId;
                    if (targetDeviceId != source.DeviceId)
                    {
                        bool isMove = (e.KeyStates & DragDropKeyStates.ShiftKey) != 0;
                        e.Effects = isMove ? DragDropEffects.Move : DragDropEffects.Copy;
                        e.Handled = true;
                        return;
                    }
                }
            }

            e.Effects = DragDropEffects.None;
            e.Handled = true;
        }