保存在UserControl上绘制的对象 [英] Saving objects drawn on UserControl
问题描述
大家好我正在尝试保存在UserControl上绘制的2D图形形状.我的意思是,就像微软的绘画应用程序一样,用户可以创建不同的形状(如矩形,线条),然后将其保存到PC中的文件中.他们可以稍后访问该文件并打开它.
我目前正在UserControl中绘制这些形状,并希望将其保存,如上所述.我认为一种方法是序列化UserControl.但是有些查询表明我UserControls和WindowsForms不适合序列化.
有办法解决这个问题吗?如果您对这件事有经验,我会建议您提出任何想法.
在此先感谢您
Hi guys. I am trying to save 2D graphics shapes that were drawn on a UserControl. I mean, it is like Microsoft''s paint application where the user can create different shapes like rectangles, lines and then save it to a file in their PC. They can later come to that file and open it.
I am currently drawing these shapes in a UserControl and wanted to save it as I explained above. I thought one way would be to serialize the UserControl. But some googling showed me that UserControls and WindowsForms are not suitable for serialization.
Is there a way around this thing? I appreciate any ideas you might suggest if you have an experience on this thing.
Thanks in advance
推荐答案
我将截屏托管用户控件的窗口.您可以在此处找到执行此操作的示例代码:
屏幕截图C#示例
该页面以德语显示,但是代码很容易解释.
祝你好运!
I would take a screenshot of the the window which hosts your user control. A sample code to do this you can find here :
Screenshot C# Example
The page is in german, but the code is quite self-explainatory.
Good luck !
本文可能会给您一些想法. 绘图工具 [
This article might give you some ideas. Draw Tools[^]
这篇关于保存在UserControl上绘制的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!