
How to copy a plot in WindowsForms ?
This discussion was imported from CodePlex
buaashuai wrote at 2014-07-03 13:46:
Hi~~ I am using WindowsForms, and i need to copy a plot to clipboard after i press a button. In what way can i accomplish this? Thanks.
Slxe wrote at 2014-07-04 19:27:
Here's how I'm handling it:
I actually based this on some code that used to be in the PlotCommands, not sure why it was taken out.
PlotController.BindKeyDown(OxyKey.C, OxyModifierKeys.Control, new DelegatePlotCommand<OxyKeyEventArgs>( CopyChart_OnKeyDown)); private void CopyChart_OnKeyDown( IPlotView view, IController controller, OxyKeyEventArgs args) { var chartBitmap = new Bitmap(uiPlotView.Width, uiPlotView.Height); uiPlotView.DrawToBitmap(chartBitmap, new Rectangle(0, 0, uiPlotView.Width, uiPlotView.Height)); Clipboard.SetImage(chartBitmap); }
buaashuai wrote at 2014-07-06 10:01:
Thanks to you. you answer is right and my problem has solved.
buaashuai wrote at 2014-07-06 10:02:
Slxe wrote:
Here's how I'm handling it:Thanks to you. you answer is right and my problem has solved.
I actually based this on some code that used to be in the PlotCommands, not sure why it was taken out.PlotController.BindKeyDown(OxyKey.C, OxyModifierKeys.Control, new DelegatePlotCommand<OxyKeyEventArgs>( CopyChart_OnKeyDown)); private void CopyChart_OnKeyDown( IPlotView view, IController controller, OxyKeyEventArgs args) { var chartBitmap = new Bitmap(uiPlotView.Width, uiPlotView.Height); uiPlotView.DrawToBitmap(chartBitmap, new Rectangle(0, 0, uiPlotView.Width, uiPlotView.Height)); Clipboard.SetImage(chartBitmap); }
Customer support service by UserEcho