Esempio n. 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);
        }
Esempio n. 2
0
        public async Task InvokeAsync()
        {
            try {
                var sources = PlotClipboardData.FromClipboard().ToArray();
                if (sources.Length > 0)
                {
                    try {
                        if (VisualComponent.Device == null)
                        {
                            await InteractiveWorkflow.Plots.NewDeviceAsync(VisualComponent.InstanceId);
                        }

                        Debug.Assert(VisualComponent.Device != null);
                        foreach (var source in sources)
                        {
                            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 (sources[0].Cut)
                        {
                            Clipboard.Clear();
                        }
                    } catch (RPlotManagerException ex) {
                        InteractiveWorkflow.Shell.ShowErrorMessage(ex.Message);
                    } catch (OperationCanceledException) {
                    }
                }
            } catch (ExternalException ex) {
                InteractiveWorkflow.Shell.ShowErrorMessage(ex.Message);
            }
        }
Esempio n. 3
0
 public Task InvokeAsync()
 {
     try {
         PlotClipboardData.ToClipboard(VisualComponent.Device.DeviceId, VisualComponent.Device.ActivePlot.PlotId, _cut);
     } catch (ExternalException ex) {
         InteractiveWorkflow.Shell.ShowErrorMessage(ex.Message);
     }
     return(Task.CompletedTask);
 }
Esempio n. 4
0
 private void Image_MouseMove(object sender, MouseEventArgs e)
 {
     if (_dragSurface.IsMouseMoveStartingDrag(e))
     {
         var obj = PlotClipboardData.ToDataObject(Model.Device.DeviceId, Model.Device.ActivePlot.PlotId);
         DragDrop.DoDragDrop(this, obj, DragDropEffects.Copy | DragDropEffects.Move);
     }
     else
     {
         _dragSurface.MouseMove(e);
     }
 }
Esempio n. 5
0
        public Task <CommandResult> InvokeAsync()
        {
            try {
                var data = PlotClipboardData.Serialize(new PlotClipboardData(VisualComponent.Device.DeviceId, VisualComponent.Device.ActivePlot.PlotId, _cut));
                Clipboard.Clear();
                Clipboard.SetData(PlotClipboardData.Format, data);
            } catch (ExternalException ex) {
                InteractiveWorkflow.Shell.ShowErrorMessage(ex.Message);
            }

            return(Task.FromResult(CommandResult.Executed));
        }
Esempio n. 6
0
 private void Image_MouseMove(object sender, MouseEventArgs e)
 {
     if (_dragSurface.IsMouseMoveStartingDrag(e))
     {
         var data = PlotClipboardData.Serialize(new PlotClipboardData(Model.Device.DeviceId, Model.Device.ActivePlot.PlotId, false));
         var obj  = new DataObject(PlotClipboardData.Format, data);
         DragDrop.DoDragDrop(this, obj, DragDropEffects.Copy | DragDropEffects.Move);
     }
     else
     {
         _dragSurface.MouseMove(e);
     }
 }
        public override Task InvokeAsync()
        {
            var selection = VisualComponent.SelectedPlots.ToList();

            if (selection.Count > 0)
            {
                try {
                    PlotClipboardData.ToClipboard(selection);
                } catch (ExternalException ex) {
                    InteractiveWorkflow.Shell.ShowErrorMessage(ex.Message);
                }
            }
            return(Task.CompletedTask);
        }
Esempio n. 8
0
 private void HistoryListView_MouseMove(object sender, MouseEventArgs e)
 {
     if (_dragSurface.IsMouseMoveStartingDrag(e))
     {
         var plots = (DataContext as IRPlotHistoryViewModel)?.SelectedPlots?.Select(x => x.Plot).ToArray();
         if (plots != null && plots.Length > 0)
         {
             var obj = PlotClipboardData.ToDataObject(plots);
             DragDrop.DoDragDrop(HistoryListView, obj, DragDropEffects.Copy | DragDropEffects.Move);
             return;
         }
     }
     _dragSurface.MouseMove(e);
 }
Esempio n. 9
0
 private void HistoryListView_MouseMove(object sender, MouseEventArgs e)
 {
     if (_dragSurface.IsMouseMoveStartingDrag(e))
     {
         var entry = GetSourceListViewItem((DependencyObject)e.OriginalSource)?.DataContext as IRPlotHistoryEntryViewModel;
         if (entry != null)
         {
             var data = PlotClipboardData.Serialize(new PlotClipboardData(entry.Plot.ParentDevice.DeviceId, entry.Plot.PlotId, false));
             var obj  = new DataObject(PlotClipboardData.Format, data);
             DragDrop.DoDragDrop(HistoryListView, obj, DragDropEffects.Copy | DragDropEffects.Move);
             return;
         }
     }
     _dragSurface.MouseMove(e);
 }
Esempio n. 10
0
        public Task InvokeAsync()
        {
            var selection = VisualComponent.SelectedPlot;

            if (selection != null)
            {
                try {
                    var data = PlotClipboardData.Serialize(new PlotClipboardData(selection.ParentDevice.DeviceId, selection.PlotId, _cut));
                    Clipboard.Clear();
                    Clipboard.SetData(PlotClipboardData.Format, data);
                } catch (ExternalException ex) {
                    InteractiveWorkflow.Shell.ShowErrorMessage(ex.Message);
                }
            }
            return(Task.CompletedTask);
        }
Esempio n. 11
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;
            }
        }
Esempio n. 12
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;
        }
Esempio n. 13
0
        public override Task InvokeAsync()
        {
            var selection = VisualComponent.SelectedPlots.ToList();

            if (selection.Count > 0)
            {
                try {
                    var data = selection.Select(p => PlotClipboardData.Serialize(new PlotClipboardData(p.ParentDevice.DeviceId, p.PlotId, _cut))).ToArray();
                    Clipboard.Clear();
                    Clipboard.SetData(PlotClipboardData.Format, data);
                } catch (ExternalException ex) {
                    InteractiveWorkflow.Shell.ShowErrorMessage(ex.Message);
                }
            }
            return(Task.CompletedTask);
        }
Esempio n. 14
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;
            }
        }
Esempio n. 15
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;
        }