Article.htm
(开头部分) 13KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<!-- Start Article -->
<span id="ArticleContent">
<ul class="download">
<li><a href="DrawToolsRedux/DrawToolsRedux_demo.zip">Download demo - 54.19 KB</a> </li>
<li><a href="DrawToolsRedux/DrawToolsRedux-Source.zip">Download Source (VS 2008)- 912.44 KB </a></li>
</ul>
<h4>Updated 6/23/2010</h4>
<ul class="download">
<li><a href="DrawToolsRedux/DrawToolsRedux.zip">Download updated demo - 58 KB</a> </li>
<li><a href="DrawToolsRedux/DrawToolsRedux-Source.zip">Download (VS 2010) updated source - 880 KB</a> </li>
</ul>
<img width="465" height="303" alt="Draw Tools Redux Image" src="DrawToolsRedux/DrawToolsRedux.png" border="0" hspace="0" complete="true" complete="true" />
<h2>Introduction</h2>
<p>Alex Fr provided an excellent set of drawing tools in his <a href="http://www.codeproject.com/csharp/drawtools.asp">DrawTools</a> article and these tools serve as a basis for this article, which expands on the original toolset in the following ways: </p>
<ol>
<li>In addition to the basic Rectangle, Ellipse, Line and Scribble tools, this version adds PolyLine, Filled Ellipse, Filled Rectangle, Text and Image tools </li>
<li>Multiple drawing Layers </li>
<li>Zooming </li>
<li>Panning </li>
<li>Rotation </li>
</ol>
<p>In this article, I will describe how Layers were implemented, as well as the Text and Image tools. </p>
<h2>Background</h2>
<p>See the original DrawTools article for details on how the basic application is built, class structure, etc. </p>
<p>It is also assumed that the reader has a working understanding of GDI+ fundamentals, including Matrices. For an excellent introduction to GDI+, see <a href="http://www.bobpowell.net/">www.bobpowell.net</a>.</p>
<h2>Implementing Layers </h2>
<p>Adding Layers to the application involved adding two classes, <code>Layer</code> and <code>Layers</code>, where <code>Layer</code> defines a single Layer and <code>Layers</code> defines the collection of <code>Layers </code>in an <code>ArrayList</code>. </p>
<p>Each Layer exposes the following properties: </p>
<pre lang="cs"> private string _name;
private bool _isDirty;
private bool _visible;
private bool _active;
private GraphicsList _graphicsList;</pre>
<p>Note that the <code>Layer</code> contains the <code>GraphicsList</code> - this is the key to the whole thing - each <code>Layer</code> contains its own list of drawing objects instead of <code>DrawArea</code>. <code>DrawArea</code> is modified to declare a <code>Layers</code> collection instead of a <code>GraphicsList</code> collection: </p>
<pre lang="cs"> // Define the Layers collection
private Layers _layers; </pre>
<p>When <code>DrawArea </code>is initialized, the <code>Layers</code> are initialized by creating the first <code>Layer</code> and setting it <code>Active </code>and <code>Visible</code>:</p>
<pre lang="cs"> public DrawArea()
后面还有 200 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。