实施复制,剪切和粘贴 [英] Implementing copy, cut and paste
本文介绍了实施复制,剪切和粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的绘图程序中实现复制,剪切和粘贴(复制所选图像的一部分)
I want to implement copy, cut and paste in my drawing program (copy part of an image that is selected)
我不知道如何开始
有什么想法吗?
推荐答案
- 使用系统范围的剪贴板,以防万一用户在应用程序中的一个实例中复制并粘贴到另一个实例中,或者如果用户关闭窗口并重新打开它,则他可以粘贴数据。
- 从实现复制和复制的基类继承程序的所有形状。糊。
- 要复制(或剪切),请序列化对象并将其放置在系统剪贴板中。
- 要粘贴,请阅读系统剪贴板,然后尝试反序列化回形状对象(如果投射失败,则剪贴板内容不是对象)您的应用)
- 将粘贴形状的位置稍微向左和向左移动(以使用户知道图形中有一个新形状)
- Use the system-wide clipboard, just in case the user copy in one instance on your app and paste in another, or if the user close the window and re-open it, he can paste back the data.
- Inherit all the shapes of the program from a base class that implements the copy & paste.
- For copy (or cut), serialize the object and place it in the system clipboard.
- For paste, read the system clipboard and try to de-serialize back to a shape object (if the cast fails, the clipboard content was not an object of your app)
- Move the position of the pasted shape slightly to the left and bottom (to let the user know that there is a new shape in the drawing)
这篇关于实施复制,剪切和粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文