-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Labels
Description
As per title, copy to clipboard with the WPF default context menu does not copy the image to the clipboard. I've tested the WinForms context menu and that one will copy to the clipboard. The copy to clipboard functions are fairly different between the two.
ScottPlot/src/ScottPlot5/ScottPlot5 Controls/ScottPlot.WPF/WpfPlotMenu.cs
Lines 104 to 109 in 54c172f
| public static void CopyImageToClipboard(IPlotControl plotControl) | |
| { | |
| PixelSize lastRenderSize = plotControl.Plot.RenderManager.LastRender.FigureRect.Size; | |
| BitmapImage bmp = plotControl.Plot.GetBitmapImage((int)lastRenderSize.Width, (int)lastRenderSize.Height); | |
| Clipboard.SetImage(bmp); | |
| } |
ScottPlot/src/ScottPlot5/ScottPlot5 Controls/ScottPlot.WinForms/FormsPlotMenu.cs
Lines 42 to 47 in 54c172f
| public void CopyImageToClipboard(IPlotControl plotControl) | |
| { | |
| PixelSize lastRenderSize = plotControl.Plot.RenderManager.LastRender.FigureRect.Size; | |
| Bitmap bmp = plotControl.Plot.GetBitmap((int)lastRenderSize.Width, (int)lastRenderSize.Height); | |
| Clipboard.SetImage(bmp); | |
| } |
ScottPlot NuGet version: 5.0.16
I've tested this in a few applications and it fails in all of them. I threw together the basic scatter plot example FWIW and it fails with that one for example:
<Window x:Class="SPCopyToClipBoardTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ScottPlot="clr-namespace:ScottPlot.WPF;assembly=ScottPlot.WPF"
xmlns:local="clr-namespace:SPCopyToClipBoardTest"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<ScottPlot:WpfPlot x:Name="MyPlot" />
</Grid>
</Window>using ScottPlot;
using System.Windows;
namespace SPCopyToClipBoardTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Coordinates[] coordinates =
{
new(1, 1),
new(2, 4),
new(3, 9),
new(4, 16),
new(5, 25),
};
MyPlot.Plot.Add.Scatter(coordinates);
}
}
}Reactions are currently unavailable