<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule" >
  <channel>
  <title>猫耳ロボットは夢を見るか的な(*´ω｀*)</title>
  <link>https://re1985.blog.shinobi.jp/</link>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="https://re1985.blog.shinobi.jp/RSS/" />
  <description>プログラムと政治とオカルトと戯れ言</description>
  <lastBuildDate>Sun, 11 Sep 2016 23:54:31 GMT</lastBuildDate>
  <language>ja</language>
  <copyright>© Ninja Tools Inc.</copyright>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />

    <item>
    <title>移転にゃ～</title>
    <description>
    <![CDATA[以下に移転しました。<br />
<br />
<a href="http://barus.hatenadiary.jp/" title="">http://barus.hatenadiary.jp/</a><br />
<br />
]]>
    </description>
    <category>未選択</category>
    <link>https://re1985.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/%E7%A7%BB%E8%BB%A2%E3%81%AB%E3%82%83%EF%BD%9E</link>
    <pubDate>Sun, 11 Sep 2016 23:54:31 GMT</pubDate>
    <guid isPermaLink="false">re1985.blog.shinobi.jp://entry/54</guid>
  </item>
    <item>
    <title>C#３D立方体ワイヤーフレーム　終(第４回) for VS2013 Express</title>
    <description>
    <![CDATA[C#３D立方体ワイヤーフレーム　終(第４回) for VS2013 Express<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/GIF.gif" alt="" width="201" height="232" /> <br />
<br />

<div>CThreeD.cs　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%20for%20vs2013%20express" title="">C#３D立方体ワイヤーフレーム　序(第１回) for VS2013 Express</a></div>
<div>CBond.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E5%BA%A7%E6%A8%99%E3%83%96%E3%83%83%E3%82%B3%E3%83%9F-%E7%AC%AC%EF%BC%92%E5%9B%9E" title="">C#３D立方体ワイヤーフレーム　座標ブッコミ(第２回) for VS2013 Express</a></div>
<div>CRubic.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E3%83%9E%E3%82%A6%E3%82%B9%E3%81%AE%E5%BA%A7%E6%A8%99%E6%B8%A1%E3%81%97-%E7%AC%AC" title="">C#３D立方体ワイヤーフレーム　マウスの座標渡し(第３回) for VS2013 Express</a><br />
Form1.cs &nbsp; &nbsp; &nbsp; &larr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E7%B5%82-%E7%AC%AC%EF%BC%94%E5%9B%9E-%20for" title="">今回</a><br />
<br />
今回は、作成したクラスを使用します。<br />
プロジェクト名は変更なしでそのままで<br />
ボタンと、picturebox1とtextbox1、textbox2を追加<br />
してペタペタ貼り付けて下さい。<br />

<div><br />
参考　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF%E3%80%80%E3%82%B3%E3%83%83%E3%83%9B%E6%9B%B2%E7%B7%9A%E3%80%80for%20vs2013" title="">C#グラフィック　コッホ曲線　for VS2013 Express<br />
</a></div>
<img src="//re1985.blog.shinobi.jp/File/cube-06.png" alt="" width="329" height="256" /> <br />
<br />
<br />
<br />

<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
<br />
Form1　クラス<br />
<hr /><br />

<div>using System;</div>
<div>using System.Collections.Generic;</div>
<div>using System.ComponentModel;</div>
<div>using System.Data;</div>
<div>using System.Drawing;</div>
<div>using System.Linq;</div>
<div>using System.Text;</div>
<div>using System.Threading.Tasks;</div>
<div>using System.Windows.Forms;</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div>namespace WindowsFormsApplication1</div>
<div>{</div>
<div>&nbsp; &nbsp; public partial class Form1 : Form</div>
<div>&nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; CRubic m_pRubic;// = new CRubic();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; bool nFlags = false;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public Form1()</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //int scale = int.Parse(textBox2.Text);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic = new CRubic(600);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InitializeComponent();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; private void button1_Click(object sender, EventArgs e)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ondraw();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; void ondraw()</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //描画先とするImageオブジェクトを作成する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bitmap canvas = new Bitmap(pictureBox1.Width, pictureBox1.Height);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //ImageオブジェクトのGraphicsオブジェクトを作成する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Graphics gra = Graphics.FromImage(canvas);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Penオブジェクトの作成(幅1の黒色)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //(この場合はPenを作成せずに、Pens.Blackを使っても良い)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Pen pen = new Pen(Color.Blue, 1);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //立方体</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int scale = int.Parse(textBox2.Text);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic.DrawRubic(gra, pen, scale);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pen.Dispose();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gra.Dispose();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //PictureBox1に表示する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pictureBox1.Image = canvas;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; private void pictureBox1_Click(object sender, EventArgs e)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; private void pictureBox1_MouseDown(object sender, MouseEventArgs e)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Point point = new Point();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.X = e.X;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.Y = e.Y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((e.Button &amp; MouseButtons.Left) == MouseButtons.Left)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nFlags = true;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic.SetClickPoint(point);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if ((e.Button &amp; MouseButtons.Right) == MouseButtons.Right)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nFlags = true;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic.SetClickPoint(point);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ondraw();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; private void pictureBox1_MouseUp(object sender, MouseEventArgs e)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Point point = new Point();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.X = e.X;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.Y = e.Y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((e.Button &amp; MouseButtons.Left) == MouseButtons.Left)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nFlags = false;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if ((e.Button &amp; MouseButtons.Right) == MouseButtons.Right)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nFlags = false;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ondraw();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; private void pictureBox1_MouseMove(object sender, MouseEventArgs e)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Point point = new Point();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.X = e.X;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.Y = e.Y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (nFlags &amp;&amp; (e.Button &amp; MouseButtons.Left) == MouseButtons.Left)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic.TurnViewPoint( point );</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ondraw();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (nFlags &amp;&amp; (e.Button &amp; MouseButtons.Right) == MouseButtons.Right)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic.MoveCubes(point);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ondraw();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; }</div>
<div></div>
<div></div>
<div>}</div>
<br />
<hr /><br />
<br />

<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff6600;">void ondraw()</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //描画先とするImageオブジェクトを作成する</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bitmap canvas = new Bitmap(pictureBox1.Width, pictureBox1.Height);</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //ImageオブジェクトのGraphicsオブジェクトを作成する</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Graphics gra = Graphics.FromImage(canvas);</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Penオブジェクトの作成(幅1の黒色)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //(この場合はPenを作成せずに、Pens.Blackを使っても良い)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Pen pen = new Pen(Color.Blue, 1);</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //立方体</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int scale = int.Parse(textBox2.Text);</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic.DrawRubic(gra, pen, scale);</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pen.Dispose();</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gra.Dispose();</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //PictureBox1に表示する</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pictureBox1.Image = canvas;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<br />

<div><br />
<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF%E3%80%80%E3%82%B3%E3%83%83%E3%83%9B%E6%9B%B2%E7%B7%9A%E3%80%80for%20vs2013" title="">C#グラフィック　コッホ曲線　for VS2013 Express</a></div>
<div><a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF%E3%80%80" title="">C#グラフィック　Tree曲線　for VS2013 Express</a></div>
<div><a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF%E3%80%80%E3%83%89%E3%83%A9%E3%82%B4%E3%83%B3%E6%9B%B2%E7%B7%9A%E3%80%80for%20vs2013" title="">C#グラフィック　ドラゴン曲線　for VS2013 Express</a></div>
<div></div>
で使用したのをそのまま使用。<br />
<br />

<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //立方体</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int scale = int.Parse(textBox2.Text);</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic.DrawRubic(gra, pen, scale);</span></div>
<br />
<br />
この部分だけを差し替えただけです。<br />
pictureBox1上でマウスがクリックされたとき以下の関数がよばれます。<br />
<br />
<span style="color: #ff6600;">pictureBox1_MouseDown　　　・・・マウスがクリックされたとき</span><br />
<span style="color: #ff6600;">pictureBox1_MouseUp　　　　・・・マウスがクリックから離されたとき</span><br />
<span style="color: #ff6600;">pictureBox1_MouseMove　　　・・・マウスをクリックしたまま動したとき</span><br />
<br />
<br />
イベントといいます。<br />
他にもいろいろイベントがありますが、ここではマウスのイベントを拾っています。<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/cube-07.png" alt="" width="336" height="383" /> <br />
<br />
<br />
エディタ上で、右クリックしてプロパティをクリックすると<br />
以下のような画面が表示されます。雷マークみたいをクリックします。<br />
これが、このpictureBox1で拾えるイベントとなります。<br />
<br />
<span style="color: #ff6600;">pictureBox1_MouseDown　　　・・・マウスがクリックされたとき</span><br />
<span style="color: #ff6600;">pictureBox1_MouseUp　　　　・・・マウスがクリックから離されたとき</span><br />
<span style="color: #ff6600;">pictureBox1_MouseMove　　　・・・マウスをクリックしたまま動したとき</span><br />
<br />
のそれぞれをWクリックすると、ソースに追加されます。<br />
それを編集することになります。<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/cube-08.png" alt="" /> <br />
<br />
<br />
<br />

<div><span style="color: #ff6600;">　　private void pictureBox1_MouseDown(object sender, MouseEventArgs e)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Point point = new Point();</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.X = e.X;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.Y = e.Y;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((e.Button &amp; MouseButtons.Left) == MouseButtons.Left)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nFlags = true;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic.SetClickPoint(point);</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if ((e.Button &amp; MouseButtons.Right) == MouseButtons.Right)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nFlags = true;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic.SetClickPoint(point);</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ondraw();</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; }</span><br />
<br />

<div>左マウスがクリックされた時、<span style="color: #ff6600;">m_pRubic.SetClickPoint( point );</span>が処理される。</div>
<div>左マウスが離された時、<span style="color: #ff6600;">nFlags&nbsp;</span>が<span style="color: #ff6600;">true;</span>になる。</div>
右マウスがクリックされた時、<span style="color: #ff6600;">m_pRubic.</span><span style="color: #ff6600;">SetClickPoint( point );</span>が処理される。</div>
<div>
<div>右マウスが離された時、<span style="color: #ff6600;">nFlags</span>&nbsp;が<span style="color: #ff6600;">true</span>になる。</div>
</div>
<br />
<br />

<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; private void pictureBox1_MouseUp(object sender, MouseEventArgs e)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Point point = new Point();</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.X = e.X;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.Y = e.Y;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((e.Button &amp; MouseButtons.Left) == MouseButtons.Left)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nFlags = false;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if ((e.Button &amp; MouseButtons.Right) == MouseButtons.Right)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nFlags = false;</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ondraw();</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<br />
<br />

<div>左マウスが離された時、<span style="color: #ff6600;">nFlags </span>が<span style="color: #ff6600;">false;</span>になる。</div>
<div>右マウスが離された時、<span style="color: #ff6600;">nFlags</span> が<span style="color: #ff6600;">false;</span>になる。</div>
<div></div>
<br />

<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; private void pictureBox1_MouseMove(object sender, MouseEventArgs e)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Point point = new Point();</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.X = e.X;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point.Y = e.Y;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (nFlags &amp;&amp; (e.Button &amp; MouseButtons.Left) == MouseButtons.Left)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic.TurnViewPoint( point );</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ondraw();</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (nFlags &amp;&amp; (e.Button &amp; MouseButtons.Right) == MouseButtons.Right)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pRubic.MoveCubes(point);</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ondraw();</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; }</span><br />
<br />
<br />
左マウスがクリックされた状態で動いた時、<span style="color: #ff6600;">m_pRubic.TurnViewPoint( point );</span>が処理される。</div>
右マウスがクリックされた状態で動いた時、<span style="color: #ff6600;">m_pRubic.</span><span style="color: #ff6600;">MoveCubes</span><span style="color: #ff6600;">( point );</span>が処理される。<br />
<br />
<br />
このイベントという概念は、C#だけのものではなく他の言語にもあります。<br />
Windowsだけでなく、Linuxにもあり、似たり寄ったりなので<br />
こういうもんだと思って頂ければよいかと思います。<br />
<br />
<br />
<br />
<br />
終わり。<br />
<br />
<br />

<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
</div>]]>
    </description>
    <category>グラフィック</category>
    <link>https://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E7%B5%82-%E7%AC%AC%EF%BC%94%E5%9B%9E-%20for</link>
    <pubDate>Sun, 11 Sep 2016 10:57:37 GMT</pubDate>
    <guid isPermaLink="false">re1985.blog.shinobi.jp://entry/53</guid>
  </item>
    <item>
    <title>C#３D立方体ワイヤーフレーム　マウスの座標渡し(第３回) for VS2013 Express</title>
    <description>
    <![CDATA[<br />
C#３D立方体ワイヤーフレーム　マウスの座標渡し(第３回) for VS2013 Express<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/GIF.gif" alt="" width="233" height="269" /> <br />
<br />

<div></div>
<div>
<div>CThreeD.cs　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%20for%20vs2013%20express" title="">C#３D立方体ワイヤーフレーム　序(第１回) for VS2013 Express</a></div>
<div>CBond.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E5%BA%A7%E6%A8%99%E3%83%96%E3%83%83%E3%82%B3%E3%83%9F-%E7%AC%AC%EF%BC%92%E5%9B%9E" title="">C#３D立方体ワイヤーフレーム　座標ブッコミ(第２回) for VS2013 Express</a></div>
<div>CRubic.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E3%83%9E%E3%82%A6%E3%82%B9%E3%81%AE%E5%BA%A7%E6%A8%99%E6%B8%A1%E3%81%97-%E7%AC%AC" title="">C#３D立方体ワイヤーフレーム　マウスの座標渡し(第３回) for VS2013 Express</a><br />
Form1.cs &nbsp; &nbsp; &nbsp; &rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E7%B5%82-%E7%AC%AC%EF%BC%94%E5%9B%9E-%20for" title="">C#３D立方体ワイヤーフレーム　終(第４回) for VS2013 Express</a></div>
</div>
<div><br />
CRubicクラス<br />
<hr /><br />

<div>using System;</div>
<div>using System.Collections.Generic;</div>
<div>using System.Linq;</div>
<div>using System.Text;</div>
<div>using System.Threading.Tasks;</div>
<div></div>
<div>using System.Windows.Forms;</div>
<div>using System.Drawing;</div>
<div></div>
<div>namespace WindowsFormsApplication1</div>
<div>{</div>
<div>&nbsp; &nbsp; public partial class Form1 : Form</div>
<div>&nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; class CRubic</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private Vertex m_ViewVertex;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private Polar m_ViewPolar = new Polar();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private CThreeD m_pThreeD;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private int m_scale;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Polar m_OldViewPolar = new Polar();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Point m_ClickPoint = new Point();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private CBond[] m_pBond = new CBond[3];</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;メモリＤＣに描画する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp;pDC : メモリデバイスコンテキストへのポインタ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void DrawRubic(Graphics gra, Pen pen, int scale)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i, j, k;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = 0; j = 0; k = 0;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_scale = scale;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_ViewPolar.r = m_scale;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pBond[0].DrawBond(gra, pen, m_ViewVertex);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;コンストラクタ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public CRubic(int scale)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i, j, k;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = 0; j = 0; k = 0;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pThreeD = new CThreeD();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_scale = scale;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pBond[0] = new CBond(i, j, k, ref &nbsp;m_pThreeD);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InitWorld();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TransferScreen();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;視点を初期化する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void InitWorld()</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_ViewPolar.r = m_scale;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_ViewPolar.p = 0;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_ViewPolar.q = 0;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pThreeD.PolarToVertex(m_ViewPolar, ref m_ViewVertex);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*========================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;ルービックキューブを投影変換をする</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ========================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void TransferScreen()</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i, j, k;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = 0; j = 0; k = 0;</div>
<div></div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pBond[0].TransferScreen(m_ViewPolar);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*========================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;マウスがクリックされた位置を覚えておく</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp;point : クリックされた位置</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ========================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void SetClickPoint(Point point)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetViewPolar();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_ClickPoint.X = point.X;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_ClickPoint.Y = point.Y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*========================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;視点を回転させる</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp;point : 現在のマウスの位置</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ========================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void TurnViewPoint(Point point)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double p, q;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p = m_ClickPoint.X - point.X;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q = m_ClickPoint.Y - point.Y;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pThreeD.TurnPolar(ref m_ViewPolar, m_OldViewPolar, p / 200, q / 200);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pThreeD.PolarToVertex(m_ViewPolar, ref m_ViewVertex);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TransferScreen();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void MoveCubes(Point point)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double p, q;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p = m_ClickPoint.X - point.X;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q = m_ClickPoint.Y - point.Y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pBond[0].m_Center.x = -(int)p;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pBond[0].m_Center.y = -(int)q;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TransferScreen();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*========================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;現在の視点を記憶する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ========================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void SetViewPolar()</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_OldViewPolar.r = m_ViewPolar.r;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_OldViewPolar.p = m_ViewPolar.p;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_OldViewPolar.q = m_ViewPolar.q;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div></div>
<hr /><br />
<br />

<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
<br />
<span style="color: #ff6600;">private CBond[] m_pBond = new CBond[3];</span><br />
<br />
<br />
CBondの座標情報郡を入れている。<br />
今回０番目しか使用していないが、増やすことで<br />
座標情報を一つの塊としてそれぞれ動かす事が出来る。<br />
<br />
<br />
<br />

<div><span style="color: #ff6600;">public void DrawRubic(Graphics gra, Pen pen, int scale)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i, j, k;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = 0; j = 0; k = 0;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_scale = scale;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_ViewPolar.r = m_scale;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pBond[0].DrawBond(gra, pen, m_ViewVertex);</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><br />
<br />
Form1クラスのGraphics,Penを渡して描画しているだけですね。<br />
<br />

<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff6600;">public void SetClickPoint(Point point)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetViewPolar();</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_ClickPoint.X = point.X;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_ClickPoint.Y = point.Y;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</div>
<br />
マウスがクリックされたときのX,Y座標を取得。<br />
<br />

<div><span style="color: #ff6600;">　　　　public void TurnViewPoint(Point point)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double p, q;</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p = m_ClickPoint.X - point.X;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q = m_ClickPoint.Y - point.Y;</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pThreeD.TurnPolar(ref m_ViewPolar, m_OldViewPolar, p / 200, q / 200);</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pThreeD.PolarToVertex(m_ViewPolar, ref m_ViewVertex);</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TransferScreen();</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void MoveCubes(Point point)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double p, q;</span></div>
<div></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p = m_ClickPoint.X - point.X;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q = m_ClickPoint.Y - point.Y;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pBond[0].m_Center.x = -(int)p;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pBond[0].m_Center.y = -(int)q;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TransferScreen();</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div></div>
<br />
マウスが動いたときに呼び出される。<br />
（<span style="color: #ff6600;">TurnViewPoint</span>）は左クリックしたまま動いた時。<br />
（<span style="color: #ff6600;">MoveCubes</span>）は左クリックしたまま動いた時。<br />
<br />
<br />
次回は第４回目、マウスのイベントを拾ってこのクラスに渡す処理。</div>
<div>終わり。<br />
<br />

<div>CThreeD.cs　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%20for%20vs2013%20express" title="">C#３D立方体ワイヤーフレーム　序(第１回) for VS2013 Express</a></div>
<div>CBond.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E5%BA%A7%E6%A8%99%E3%83%96%E3%83%83%E3%82%B3%E3%83%9F-%E7%AC%AC%EF%BC%92%E5%9B%9E" title="">C#３D立方体ワイヤーフレーム　座標ブッコミ(第２回) for VS2013 Express</a></div>
<div>CRubic.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E3%83%9E%E3%82%A6%E3%82%B9%E3%81%AE%E5%BA%A7%E6%A8%99%E6%B8%A1%E3%81%97-%E7%AC%AC" title="">C#３D立方体ワイヤーフレーム　マウスの座標渡し(第３回) for VS2013 Express</a><br />
Form1.cs &nbsp; &nbsp; &nbsp; &rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E7%B5%82-%E7%AC%AC%EF%BC%94%E5%9B%9E-%20for" title="">C#３D立方体ワイヤーフレーム　終(第４回) for VS2013 Express</a><a href="http://re1985.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E7%B5%82-%E7%AC%AC%EF%BC%94%E5%9B%9E-%20for" title=""><br />
<br />
<br />
</a></div>
<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
</div>]]>
    </description>
    <category>グラフィック</category>
    <link>https://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E3%83%9E%E3%82%A6%E3%82%B9%E3%81%AE%E5%BA%A7%E6%A8%99%E6%B8%A1%E3%81%97-%E7%AC%AC</link>
    <pubDate>Sun, 11 Sep 2016 10:20:45 GMT</pubDate>
    <guid isPermaLink="false">re1985.blog.shinobi.jp://entry/52</guid>
  </item>
    <item>
    <title>C#３D立方体ワイヤーフレーム　座標ブッコミ(第２回) for VS2013 Express</title>
    <description>
    <![CDATA[C#３D立方体ワイヤーフレーム　座標ブッコミ(第２回) for VS2013 Express<br />
<img src="//re1985.blog.shinobi.jp/File/GIF.gif" alt="" width="231" height="266" /> <br />
<br />
<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%20for%20vs2013%20express" title="">C#３D立方体ワイヤーフレーム　序(第１回) for VS2013 Express<br />
<br />
</a>に続き２回目、<br />
<br />

<div>
<div>CThreeD.cs　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%20for%20vs2013%20express" title="">C#３D立方体ワイヤーフレーム　序(第１回) for VS2013 Express</a></div>
<div>CBond.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E5%BA%A7%E6%A8%99%E3%83%96%E3%83%83%E3%82%B3%E3%83%9F-%E7%AC%AC%EF%BC%92%E5%9B%9E" title="">C#３D立方体ワイヤーフレーム　座標ブッコミ(第２回) for VS2013 Express</a></div>
<div>CRubic.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E3%83%9E%E3%82%A6%E3%82%B9%E3%81%AE%E5%BA%A7%E6%A8%99%E6%B8%A1%E3%81%97-%E7%AC%AC" title="">C#３D立方体ワイヤーフレーム　マウスの座標渡し(第３回) for VS2013 Express</a><br />
Form1.cs &nbsp; &nbsp; &nbsp; &rarr;　<a href="http://re1985.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E7%B5%82-%E7%AC%AC%EF%BC%94%E5%9B%9E-%20for" title="">C#３D立方体ワイヤーフレーム　終(第４回) for VS2013 Express<br />
</a></div>
</div>
<div>今回はCBondクラスを紹介する。<br />
他のクラスはほぼ、変化はないがこのクラスを差し替えることで、<br />
様々な立体情報を記述する事が出来る。<br />
<br />
<br />

<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
<br />

<div>CBondクラス</div>
<hr />
<div>using System;</div>
<div>using System.Collections.Generic;</div>
<div>using System.Linq;</div>
<div>using System.Text;</div>
<div>using System.Threading.Tasks;</div>
<div></div>
<div>using System.Windows.Forms;</div>
<div>using System.Drawing;</div>
<div></div>
<div>namespace WindowsFormsApplication1</div>
<div>{</div>
<div>&nbsp; &nbsp; public partial class Form1 : Form</div>
<div>&nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; class CBond</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public CThreeD m_pThreeD;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public Vertex m_Center = new Vertex(); &nbsp;//相対座標の中心</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List&lt;Vertex&gt; m_Vertex = new List&lt;Vertex&gt;();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int mGourp_num; &nbsp; &nbsp; &nbsp;//グループ名の個数</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public CBond(int x, int y, int z, ref CThreeD pThreeD)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InitBond(x, y, z);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pThreeD = pThreeD;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;初期化する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp;x, y, z :&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void InitBond(int x, int y, int z)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InitVertex(x - 1, y - 1, z - 1);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;頂点を初期化する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp;x, y, z : 立方体の番号（ -1 ～ 1 ）</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void InitVertex(int x, int y, int z)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int cx, cy, cz;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_Center.x = 0;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_Center.y = 0;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_Center.z = 0;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cx = 0; cy = 0; cz = 0;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mGourp_num = 0;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D[] A = new MyPoint3D[8];</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[0] = new MyPoint3D(cx + 100, cy + 100, cz + 100);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[1] = new MyPoint3D(cx - 100, cy + 100, cz + 100);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[2] = new MyPoint3D(cx - 100, cy - 100, cz + 100);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[3] = new MyPoint3D(cx + 100, cy - 100, cz + 100);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[4] = new MyPoint3D(cx + 100, cy + 100, cz - 100);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[5] = new MyPoint3D(cx - 100, cy + 100, cz - 100);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[6] = new MyPoint3D(cx - 100, cy - 100, cz - 100);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[7] = new MyPoint3D(cx + 100, cy - 100, cz - 100);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //コネクト情報</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[0].bond.Add(1);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[1].bond.Add(2);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[2].bond.Add(3);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[3].bond.Add(0);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[4].bond.Add(5);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[5].bond.Add(6);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[6].bond.Add(7);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[7].bond.Add(4);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[0].bond.Add(4);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[1].bond.Add(5);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[2].bond.Add(6);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[3].bond.Add(7);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List&lt;MyPoint3D&gt; result = new List&lt;MyPoint3D&gt;();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //格納</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; 8 &gt; i; i++)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result.Add(A[i]);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; result.Count &gt; i; i++)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetVertex(0, i, result[i].bond, result[i].x, result[i].y, result[i].z);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;頂点を決める</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp; &nbsp; group: グループ番号</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;n : 線の番号</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m : どこと繋がるか</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x, y, z : 端の座標</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void SetVertex(int group, int n, List&lt;int&gt; bond, int x, int y, int z)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vertex ver = new Vertex();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ver.group = group;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; bond.Count &gt; i; i++) ver.bond.Add(bond[i]);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ver.x = x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ver.y = y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ver.z = z;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_Vertex.Add(ver);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;２次元座標系に変換する（回転行列をつくる）</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp;ViewPolar : 視点の極座標</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void TransferScreen(Polar ViewPolar)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vertex ver = new Vertex();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; m_Vertex.Count; i++)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (m_Vertex[i] != null)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ver = m_Vertex[i];</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pThreeD.TransferScreen(ViewPolar, ref ver);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_Vertex[i] = ver;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;立方体を描画する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp;pDC &nbsp; &nbsp; &nbsp; &nbsp;: メモリデバイスコンテキストへのポインタ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ViewVertex : 視点の座標</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void DrawBond(Graphics gra, Pen pen, Vertex ViewVertex)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i,j;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Point[] point = new Point[2];</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = 0;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; m_Vertex.Count; i++)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (m_Vertex[i] != null)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (j = 0; j &lt; m_Vertex[i].bond.Count; j++)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int c = m_Vertex[i].bond[j]; //接続先</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[0].X = m_Center.x + m_Vertex[i].point.X;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[0].Y = m_Center.y + m_Vertex[i].point.Y;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[1].X = m_Center.x + m_Vertex[c].point.X;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[1].Y = m_Center.y + m_Vertex[c].point.Y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gra.DrawLine(pen, point[0], point[1]);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div></div>
<hr /><br />
<br />

<div>DrawBond　　　・・・描画</div>
<div>TransferScreen　・・・座標を２次元に投影。CThreeDクラスに投げる。</div>
<div>SetVertex　　　　・・・座標情報を格納</div>
<div>InitVertex　　　　・・・初期の座標情報を作成</div>
<div>CBond　　　　　・・・このプログラムの最初に呼び出される。</div>
<div><br />
<br />
立方体なので、サイコロを思い出して欲しいのですが<br />
頂点が８個あるので<br />
<br />
MyPoint3D[] A = new MyPoint3D[8];<br />
<br />
で、８個の座標を格納する　MyPoint3D型　を生成している。<br />
<br />
&nbsp;<br />
<br />

<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
<img src="//re1985.blog.shinobi.jp/File/cube-05.png" alt="" width="357" height="393" /><br />

<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[0] = new MyPoint3D(cx + 100, cy + 100, cz + 100);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[1] = new MyPoint3D(cx - 100, cy + 100, cz + 100);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[2] = new MyPoint3D(cx - 100, cy - 100, cz + 100);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[3] = new MyPoint3D(cx + 100, cy - 100, cz + 100);</span></div>
<div></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[4] = new MyPoint3D(cx + 100, cy + 100, cz - 100);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[5] = new MyPoint3D(cx - 100, cy + 100, cz - 100);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[6] = new MyPoint3D(cx - 100, cy - 100, cz - 100);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[7] = new MyPoint3D(cx + 100, cy - 100, cz - 100);</span></div>
<br />
A[０]から、A[７]には図に示す通り、立方体の頂点を格納した。<br />
cx,cy,czは、この塊を動かす際に用いる。</div>
<br />
<br />

<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //コネクト情報</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[0].bond.Add(1);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[1].bond.Add(2);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[2].bond.Add(3);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[3].bond.Add(0);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ：</span></div>
<br />
コネクト情報で、どの点と点を結ぶか情報を与えている。<br />
第一回でも述べたが、bondはList＜int＞なのでAddで追加可能だ。<br />
<br />
<br />

<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List&lt;MyPoint3D&gt; result = new List&lt;MyPoint3D&gt;();</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //格納</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; 8 &gt; i; i++)</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result.Add(A[i]);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; result.Count &gt; i; i++)</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetVertex(0, i, result[i].bond, result[i].x, result[i].y, result[i].z);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
resultに再度入れているが、ここは別に必要ないが<br />
List型に入れとくと便利なので使用。<br />
<br />

<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff9900;">&nbsp;List&lt;Vertex&gt; m_Vertex = new List&lt;Vertex&gt;();</span></div>
<div><span style="color: #ff9900;">&nbsp;</span></div>
SetVertex（）で、List&lt;Vertex&gt; の　m_Vertex　に座標を格納。</div>
<div>
<div></div>
<br />
<br />

<div>　　 <span style="color: #ff9900;">public void TransferScreen(Polar ViewPolar)</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i;</span></div>
<div></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vertex ver = new Vertex();</span></div>
<div></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; m_Vertex.Count; i++)</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (m_Vertex[i] != null)</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ver = m_Vertex[i];</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_pThreeD.TransferScreen(ViewPolar, ref ver);</span></div>
<div></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_Vertex[i] = ver;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<br />
<br />
TransferScreen（）関数でList&lt;Vertex&gt; の　m_Vertex　に格納した座標を<br />
マウスが上下に動かした分を、それぞれ角度に見立て、極座標を直行座標に変換し<br />
X軸固定回転、Y軸固定回転のマトリックスで座標変換。</div>
<div><br />
参照　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%20for%20vs2013%20express" title="">C#３D立方体ワイヤーフレーム　序(第１回) for VS2013 Express<br />
</a><br />
<br />
<br />

<div><span style="color: #ff9900;">　　　public void DrawBond(Graphics gra, Pen pen, Vertex ViewVertex)</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i,j;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Point[] point = new Point[2];</span></div>
<div></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = 0;</span></div>
<div></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; m_Vertex.Count; i++)</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (m_Vertex[i] != null)</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (j = 0; j &lt; m_Vertex[i].bond.Count; j++)</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int c = m_Vertex[i].bond[j]; //接続先</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[0].X = m_Center.x + m_Vertex[i].point.X;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[0].Y = m_Center.y + m_Vertex[i].point.Y;</span></div>
<div></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[1].X = m_Center.x + m_Vertex[c].point.X;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; point[1].Y = m_Center.y + m_Vertex[c].point.Y;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gra.DrawLine(pen, point[0], point[1]);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<br />
<br />
List&lt;Vertex&gt; の　m_Vertex　に格納した座標の要素分（<span style="color: #ff9900;">m_Vertex[i].bond.Count;</span>）<br />
のそれぞれの座標に接続するラインを<br />
<span style="color: #ff9900;"><br />
gra.DrawLine(pen, point[0], point[1]);</span><br />
<br />
で描画している。</div>
<div><br />
このクラスをいろいろいじると様々な立体を３D化出来るので<br />
一番楽しいところだ。<br />
<br />
次の第三回は　CRubic　クラス。<br />
<br />
<br />

<div>CThreeD.cs　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%20for%20vs2013%20express" title="">C#３D立方体ワイヤーフレーム　序(第１回) for VS2013 Express</a></div>
<div>CBond.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E5%BA%A7%E6%A8%99%E3%83%96%E3%83%83%E3%82%B3%E3%83%9F-%E7%AC%AC%EF%BC%92%E5%9B%9E" title="">C#３D立方体ワイヤーフレーム　座標ブッコミ(第２回) for VS2013 Express</a></div>
<div>CRubic.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E3%83%9E%E3%82%A6%E3%82%B9%E3%81%AE%E5%BA%A7%E6%A8%99%E6%B8%A1%E3%81%97-%E7%AC%AC" title="">C#３D立方体ワイヤーフレーム　マウスの座標渡し(第３回) for VS2013 Express</a><br />
Form1.cs &nbsp; &nbsp; &nbsp; &rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E7%B5%82-%E7%AC%AC%EF%BC%94%E5%9B%9E-%20for" title="">C#３D立方体ワイヤーフレーム　終(第４回) for VS2013 Express</a><a href="http://re1985.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E7%B5%82-%E7%AC%AC%EF%BC%94%E5%9B%9E-%20for" title=""><br />
</a></div>
<br />
終わり。<br />
<br />

<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
</div>]]>
    </description>
    <category>グラフィック</category>
    <link>https://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E5%BA%A7%E6%A8%99%E3%83%96%E3%83%83%E3%82%B3%E3%83%9F-%E7%AC%AC%EF%BC%92%E5%9B%9E</link>
    <pubDate>Sun, 11 Sep 2016 09:54:07 GMT</pubDate>
    <guid isPermaLink="false">re1985.blog.shinobi.jp://entry/51</guid>
  </item>
    <item>
    <title>C#３D立方体ワイヤーフレーム　序(第１回) for VS2013 Express</title>
    <description>
    <![CDATA[C#３D立方体 for VS2013 Express<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/GIF.gif" alt="" /> <br />
<br />
<br />
参考：<a href="http://www.geocities.co.jp/SiliconValley-Bay/4543/Rubic/index.html" title="">Visual C++ を使ってルービックキューブを作ってみよう</a><br />
<br />
参考URLを元にC＃用に３D立方体を作成した。<br />
投稿できる量に制限があるので４回に分けることにする。<br />
<br />
<br />

<div>CThreeD.cs　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%20for%20vs2013%20express" title="">C#３D立方体ワイヤーフレーム　序(第１回) for VS2013 Express</a></div>
<div>CBond.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E5%BA%A7%E6%A8%99%E3%83%96%E3%83%83%E3%82%B3%E3%83%9F-%E7%AC%AC%EF%BC%92%E5%9B%9E" title="">C#３D立方体ワイヤーフレーム　座標ブッコミ(第２回) for VS2013 Express</a></div>
<div>CRubic.cs　　&rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E3%83%9E%E3%82%A6%E3%82%B9%E3%81%AE%E5%BA%A7%E6%A8%99%E6%B8%A1%E3%81%97-%E7%AC%AC" title="">C#３D立方体ワイヤーフレーム　マウスの座標渡し(第３回) for VS2013 Express</a><br />
Form1.cs &nbsp; &nbsp; &nbsp; &rarr;　<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E7%B5%82-%E7%AC%AC%EF%BC%94%E5%9B%9E-%20for" title="">C#３D立方体ワイヤーフレーム　終(第４回) for VS2013 Express</a><a href="http://re1985.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%80%80%E7%B5%82-%E7%AC%AC%EF%BC%94%E5%9B%9E-%20for" title=""><br />
</a></div>
<br />
<br />
ソリューションエクスプローラー内で右クリックして、クラスを追加する。<br />
<img src="//re1985.blog.shinobi.jp/File/cube-01.png" alt="" width="295" height="256" /> <br />
<br />
全てをForm1.csのファイルにまとめていいのだが、<br />
さすがに煩雑になるので、クラス毎にファイルを分けることにした。<br />
C＃の機能で「public partial」で囲えば、一つのファイルとして扱ってくれる。みたいだ。<br />
<br />
public partial class Form1 : Form<br />
<br />
初期状態は以下のような感じなので赤い部分を追加する。<br />
<br />
<hr /><br />

<div>using System;</div>
<div>using System.Collections.Generic;</div>
<div>using System.Linq;</div>
<div>using System.Text;</div>
<div>using System.Threading.Tasks;</div>
<div>
<div></div>
<div></div>
<div><span style="color: #ff0000;" data-mce-mark="1">using System.Windows.Forms;</span></div>
<div><span style="color: #ff0000;" data-mce-mark="1">using System.Drawing;</span></div>
</div>
<div></div>
<div>namespace WindowsFormsApplication1</div>
<div>{<br />

<div></div>
<div>&nbsp; &nbsp; <span style="color: #ff0000;" data-mce-mark="1">public partial class Form1 : Form</span></div>
<div>&nbsp; &nbsp; {</div>
</div>
<div>&nbsp; &nbsp; 　class Class1</div>
<div>&nbsp; &nbsp; 　{</div>
<div>&nbsp; &nbsp; 　}<br />
　}</div>
<div>}<br />
<hr /></div>
<!-- 本 自動表示 -->
<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
<div><br />
<br />
CThreeDクラス<br />
<br />
＃CThreeD.cs<br />
<hr />
<div>using System;</div>
<div>using System.Collections.Generic;</div>
<div>using System.Linq;</div>
<div>using System.Text;</div>
<div>using System.Threading.Tasks;</div>
<div></div>
<div>using System.Windows.Forms;</div>
<div>using System.Drawing;</div>
<div></div>
<div>namespace WindowsFormsApplication1</div>
<div>{</div>
<div>&nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; public partial class Form1 : Form</div>
<div>&nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; //絶対座標の中心</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; static public int RUBIC_X = 300;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; static public int RUBIC_Y = 300;</div>
<div></div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public class MyPoint3D</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int z;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public List&lt;int&gt; bond = new List&lt;int&gt;();//接続先</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int num;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public MyPoint3D() { }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public MyPoint3D(int _x, int _y, int _z)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = _x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = _y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z = _z;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; //デカルト座標</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public class Vertex</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int group; &nbsp; &nbsp; //グループ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public List&lt;int&gt; bond = new List&lt;int&gt;();//接続先</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int x, y, z;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public Point point;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public Vertex() { }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; //極座標</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public class Polar</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int r;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public double p, q;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; //線の構造体</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public class Bond</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public Vertex[] vertex;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public Vertex center = new Vertex(); //相対座標</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; //面の構造体</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public class Face</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public Vertex[] vertex = new Vertex[4];</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public Vertex center = new Vertex();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; class CThreeD</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;２次元座標系に変換する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp;ViewPolar : 視点の極座標</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vertex &nbsp; &nbsp;: 変換したい座標</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TransferScreen(Polar ViewPolar, ref Vertex pVertex)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double a;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double[,] matrix = new double[3, 3];</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vertex vertex = new Vertex();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a = ViewPolar.r * Math.Cos(ViewPolar.q);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /****************************************************************</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 回転行列を作る</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ****************************************************************/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[0, 0] = -1 * Math.Sin(ViewPolar.p);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[0, 1] = Math.Cos(ViewPolar.p);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[0, 2] = 0;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[1, 0] = -1 * Math.Sin(ViewPolar.q) * Math.Cos(ViewPolar.p);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[1, 1] = -1 * Math.Sin(ViewPolar.q) * Math.Sin(ViewPolar.p);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[1, 2] = Math.Cos(ViewPolar.q);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[2, 0] = -1 * Math.Cos(ViewPolar.q) * Math.Cos(ViewPolar.p);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[2, 1] = -1 * Math.Cos(ViewPolar.q) * Math.Sin(ViewPolar.p);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[2, 2] = -1 * Math.Sin(ViewPolar.q);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;X軸とY軸</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-sin.p &nbsp; &nbsp; &nbsp; &nbsp; cos.p &nbsp; &nbsp; &nbsp; &nbsp; 0</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-sin.q*cps.p &nbsp;-sin.q*sin.p &nbsp; cos.q</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-cos.q*cos.p &nbsp;-cos.q*sin.p &nbsp;-sin.q</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TransferVertex(matrix, ViewPolar, ref pVertex);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;２次元座標系に変換する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp;matrix[][3] : 回転行列</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ViewVertex &nbsp;: 視点の座標</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void TransferVertex(double[,] matrix, Polar ViewPolar, ref Vertex pVertex)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double x, y, z;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vertex vertex = new Vertex();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PolarToVertex(ViewPolar, ref vertex);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = matrix[0, 0] * (pVertex.x - vertex.x)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + matrix[0, 1] * (pVertex.y - vertex.y)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + matrix[0, 2] * (pVertex.z - vertex.z);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = matrix[1, 0] * (pVertex.x - vertex.x)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + matrix[1, 1] * (pVertex.y - vertex.y)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + matrix[1, 2] * (pVertex.z - vertex.z);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z = matrix[2, 0] * (pVertex.x - vertex.x)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + matrix[2, 1] * (pVertex.y - vertex.y)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + matrix[2, 2] * (pVertex.z - vertex.z);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z = z / 300;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pVertex.point.X = (int)(RUBIC_X + x / z);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pVertex.point.Y = (int)(RUBIC_Y + y / z);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;極座標を直行座標に変換する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp;polar &nbsp; &nbsp;: 極座標の座標値</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pVertex &nbsp;: 直行座標へのポインタ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void PolarToVertex(Polar polar, ref Vertex pVertex)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pVertex = new Vertex();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pVertex.x = (int)(polar.r * Math.Cos(polar.q) * Math.Cos(polar.p));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pVertex.y = (int)(polar.r * Math.Cos(polar.q) * Math.Sin(polar.p));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pVertex.z = (int)(polar.r * Math.Sin(polar.q));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=============================================================================</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;機能 &nbsp;極座標を回転移動する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;引数 &nbsp;new_polar : 回転後の座標</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;old_polar : 回転させたい極座標の座標値</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rotateP &nbsp; : Ｚ軸を中心とした回転量</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rotateQ &nbsp; : 原点を中心としてＸＹ平面と垂直な回転量</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =============================================================================*/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void TurnPolar( ref Polar new_polar, Polar old_polar, double rotateP, double rotateQ )</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new_polar.p = old_polar.p += rotateP;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new_polar.q = old_polar.q += rotateQ;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; }</div>
<div></div>
<div></div>
<div>}</div>
<div></div>
<hr /><br />
<br />
<!-- 本 自動表示 -->
<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
CThreeD　クラスの説明<br />
このクラスは、デカルト座標情報をVertexに入れて<br />
&nbsp;TransferScreen()関数で、２次元座標に投影している。<br />
<br />
ここさえ押さえれば、後は様々な立体の３次元情報を<br />
このクラスに与えればいいだけにゃ～♪<br />
<br />
なので、ここが肝なので、ちょっと深入りしてみる。<br />
<br />
<br />
３次元空間の座標移動を、３次元アフィン変換っていうらしいにゃ。<br />
<a href="http://www.cg.info.hiroshima-cu.ac.jp/~miyazaki/knowledge/tech07.html" title="">参考URL</a><br />
<b style="font-family: 'MS PGothic'; font-size: medium;">ロール(&phi;)ピッチ(&theta;)ヨー(&psi;)で回転する場合<br />
</b><img src="//re1985.blog.shinobi.jp/File/eq07-08.gif" alt="" width="476" height="76" /> <br />
<br />
<br />
しかし、このプログラムでは、<br />
TransferVertex（）にて、PolarToVertex（）で極座標を<br />
直行座標に返還後、X軸回転、Y軸回転を行っている。</div>
<div><br />
マウスで、グリグリと動かす際、縦方向と横方向の<br />
どちらかをX軸固定、Y軸固定と見立ている仕組みですね。<br />
つまり、２つの情報しかインプットできないので、Z軸固定回転は使用していない。<br />
<br />
<br />
<br />
<br />
まずは、２次元の場合の座標移動について考えてみる。<br />
<br />
<br />
下記図の、座標P(x ,y)からQ(x', y')の2次元アフィン変換は<br />
<br />
x' = x *cos&theta; - y*sin&theta;<br />
y' = x *sin&theta; + y*cos&theta;<br />
<br />
となる。この式は、加法定理から求まる。<br />
<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/cube-02.png" alt="" width="329" height="458" /> <br />
<br />
<br />
<br />
加法定理<br />
<br />
三角形OPQを考える、<a href="http://w3e.kanazawa-it.ac.jp/math/category/sankakukansuu/kahouteiri/henkan-tex.cgi?target=/math/category/sankakukansuu/kahouteiri/kahouteiri-2.html" title="">余弦定理</a>より　<br />
PQ＾2　=　2 - 2cos(&alpha;ー&beta;)　・・・(1)<br />
線分PQを座標で表した長さは<br />
PQ^2=( cos&beta;　ー　cos&alpha;)^2 　＋　( sin&beta;　ー　sin&alpha;)^2&nbsp;　・・・(２)<br />
(１)（２）より<br />
cos(&alpha;ー&beta;)＝cos&alpha;＊cos&beta; ＋sin&alpha;＊ sin&beta;　・・・（３）<br />
となる。（３）を用いて、<br />
cos(&alpha;＋&beta;)＝cos(&alpha;ー（ー&beta;）)<br />
　　　　＝cos&alpha;＊cos（ー&beta;） ＋sin&alpha;＊ sin（ー&beta;）<br />
　　　　＝cos&alpha;＊cos&beta; ー　sin&alpha;＊ sin&beta;　・・・（４）<br />
が求まる。sin(&alpha;＋&beta;)の場合は（４）を用いて</div>
<div>sin(&alpha;＋&beta;)＝cos(９０－（&alpha;＋&beta;）)<br />
　　　　＝cos(（９０－&alpha;）ー&beta;)<br />
　　　　＝cos（９０－&alpha;）＊cos&beta; ＋sin（９０－&alpha;）＊ sin&beta;<br />
　　　　＝sin&alpha;＊cos&beta; ＋　cos&alpha;＊ sin&beta;　・・・（５）</div>
<div><br />
<img src="//re1985.blog.shinobi.jp/File/kahou.gif" alt="" /> <br />
<br />
<br />
<br />
いま、求めた　座標P(x ,y)からQ(x', y')の2次元アフィン変換は<br />
Z軸を固定して回転した場合である。<br />
<br />
x' = x *cos&theta; - y*sin&theta;<br />
y' = x *sin&theta; + y*cos&theta;<br />
<br />
X軸、Y軸を固定した場合の２次元アフィン変換については以下。<br />
<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/cube-04.png" alt="" width="267" height="359" /> <br />
<br />
<br />

<div>X軸固定とY軸固定の行列を掛けたのが以下(A)の行列となる。<br />
<br />

<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;cos.p &nbsp; &nbsp; &nbsp; &nbsp; 　　0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sin.p&nbsp;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp;sin.q*sin.p &nbsp;　 &nbsp;cos.q &nbsp; &nbsp;-cos.p*sin.q</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp;-cos.q*sin.p &nbsp; &nbsp; sin.q &nbsp;　 cos.q*cos.p</span></div>
<div></div>
<br />
で、実際のプログラムは以下の(B)の行列</div>
<div><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff9900;">&nbsp;-sin.p &nbsp; &nbsp; &nbsp; &nbsp; 　　cos.p &nbsp; &nbsp; &nbsp; &nbsp; 　　0</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp;-sin.q*cos.p &nbsp;　-sin.q*sin.p &nbsp; 　 cos.q</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp;-cos.q*cos.p &nbsp;　-cos.q*sin.p &nbsp;　-sin.q</span></div>
<div><br />
<br />
（A）と（B）が異なるのでなぜなんだろうと悩んだ。<br />
列を入れ替えても同じだから それはよしとしても、符号が異なる。<br />
試しに（A）の行列で実行してみた場合（以下）、<br />
<br />
<span style="color: #ff9900;">　　　　//テストしてみた行列</span><br />

<div><span style="color: #ff9900;">　　　　 matrix[0, 0] = 1 * Math.Sin(ViewPolar.p);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[0, 1] = Math.Cos(ViewPolar.p);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[0, 2] = 0;</span></div>
<div></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[1, 0] = -1 * Math.Sin(ViewPolar.q) * Math.Cos(ViewPolar.p);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[1, 1] = 1 * Math.Sin(ViewPolar.q) * Math.Sin(ViewPolar.p);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[1, 2] = Math.Cos(ViewPolar.q);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[2, 0] = &nbsp;1 * Math.Cos(ViewPolar.q) * Math.Cos(ViewPolar.p);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[2, 1] = -1 * Math.Cos(ViewPolar.q) * Math.Sin(ViewPolar.p);</span></div>
<div><span style="color: #ff9900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matrix[2, 2] = &nbsp;1 * Math.Sin(ViewPolar.q);</span></div>
<div></div>
<br />
ちゃんと投影されるわけだがなんだか、違和感のある変な動きとなる。<br />
なので（B）の行列を利用している。<br />
<br />
<br />
ちゃんと理由があるはずなんだろうが、<br />
頭が痛くなってきたので、これでよしとするかにゃ～(*&acute;&omega;｀*)。</div>
<div><br />
<br />
<br />
<br />
</div>
この（B）の行列をつかうことで、X軸、Y軸それぞれで固定した座標変換を行った後に<br />
次の<span style="color: #ff9900;">PolarToVertex()</span>関数で直行座標に変換している。</div>
<div><br />
<br />

<div>　　　<span style="color: #ff6600;">public void PolarToVertex(Polar polar, ref Vertex pVertex)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pVertex = new Vertex();</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pVertex.x = (int)(polar.r * Math.Cos(polar.q) * Math.Cos(polar.p));</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pVertex.y = (int)(polar.r * Math.Cos(polar.q) * Math.Sin(polar.p));</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pVertex.z = (int)(polar.r * Math.Sin(polar.q));</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<br />
<br />
この関数では、極座標から、直行座標への変換を行っている。<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/cube-03.png" alt="" width="384" height="533" />&nbsp;<br />
<br />
<br />
以上が、座標を２次元に投影する仕組みである。<br />
ざっくりと理解できたところで、<br />
<br />
<br />
<br />
どこに座標を保持しているかというと、一旦MyPoint3Dクラスに保持している。<br />
<br />
<br />

<div>&nbsp; &nbsp; <span style="color: #ff6600;">&nbsp; &nbsp; public class MyPoint3D</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int x;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int y;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int z;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public List&lt;int&gt; bond = new List&lt;int&gt;();//接続先</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int num;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public MyPoint3D() { }</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public MyPoint3D(int _x, int _y, int _z)</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = _x;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = _y;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z = _z;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<br />
List&lt;int&gt;型は、C++のVector&lt;int&gt;に相当する。<br />
ある座標の点が、どの座標の点と接続しているか分からなければ<br />
線を引けないので、情報をもたせることにした。<br />
<br />
<br />
格納の仕方は bond.Add()で格納する。<br />
取り出し方は、bond.Countで要素数が分かるので<br />
for(int i=0; bond.Count&gt;i; i++) boud[i]　～<br />
のようにする。<br />
<br />

<div>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff6600;">//デカルト座標</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; public class Vertex</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int group; &nbsp; &nbsp; //グループ</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public List&lt;int&gt; bond = new List&lt;int&gt;();//接続先</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int x, y, z;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public Point point;</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public Vertex() { }</span></div>
<div><span style="color: #ff6600;">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div></div>
いわゆる、XYZ座標で表現するのをデカルト座標という。<br />
MyPoint3Dでワンクッション置いて、Vertexに入れている。<br />
<br />
<br />
次回は、CBoundクラスで立方体の座標を決定する。<br />
<br />
<br />
終わり。<br />
<!-- 本 自動表示 -->
<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
</div>]]>
    </description>
    <category>グラフィック</category>
    <link>https://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%EF%BC%93d%E7%AB%8B%E6%96%B9%E4%BD%93%20for%20vs2013%20express</link>
    <pubDate>Sun, 11 Sep 2016 05:52:14 GMT</pubDate>
    <guid isPermaLink="false">re1985.blog.shinobi.jp://entry/50</guid>
  </item>
    <item>
    <title>C#グラフィック　ドラゴン曲線　for VS2013 Express</title>
    <description>
    <![CDATA[C#グラフィック　ドラゴン曲線　for VS2013 Express<br />
参考URL：<a href="https://codezine.jp/article/detail/73" title="">https://codezine.jp/article/detail/73</a><br />
<br />
<img src="//re1985.blog.shinobi.jp/File/dragon1.png" alt="" /> <br />
<br />
<br />
<!-- 本 自動表示 -->
<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
<br />
<hr />
<div>using System;</div>
<div>using System.Collections.Generic;</div>
<div>using System.ComponentModel;</div>
<div>using System.Data;</div>
<div>using System.Drawing;</div>
<div>using System.Linq;</div>
<div>using System.Text;</div>
<div>using System.Threading.Tasks;</div>
<div>using System.Windows.Forms;</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div>namespace WindowsFormsApplication1</div>
<div>{</div>
<div>&nbsp; &nbsp; public partial class Form1 : Form</div>
<div>&nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public class &nbsp;MyPoint3D</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int z;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public MyPoint3D() { }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public MyPoint3D(int _x, int _y, int _z)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = _x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = _y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z = _z;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public Form1()</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InitializeComponent();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; private void button1_Click(object sender, EventArgs e)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //描画先とするImageオブジェクトを作成する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bitmap canvas = new Bitmap(pictureBox1.Width, pictureBox1.Height);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //ImageオブジェクトのGraphicsオブジェクトを作成する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Graphics gra = Graphics.FromImage(canvas);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Penオブジェクトの作成(幅1の黒色)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //(この場合はPenを作成せずに、Pens.Blackを使っても良い)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Pen pen = new Pen(Color.Blue, 1);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //コッホ曲線描画</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //drwKoch_main(gra, pen);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //樹木曲線</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //drwTree_main(gra, pen);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;"> //ドラゴン曲線</span></div>
<div><span style="color: #ff0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawDragon_main(gra, pen);</span></div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pen.Dispose();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gra.Dispose();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //PictureBox1に表示する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pictureBox1.Image = canvas;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; //ドラゴン</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public void drawDragon_main(Graphics gra, Pen pen)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int kaisu = int.Parse(textBox1.Text);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //出発点となる一対の点を指定します</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D P = new MyPoint3D(170, 140, 0);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D Q = new MyPoint3D(400, 350, 0);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //対となる二点の間にドラゴン曲線を描きます</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawDragon(gra, pen, P, Q, kaisu);</div>
<div>&nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; //ドラゴン曲線を描くメソッド</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public void drawDragon(Graphics g, Pen pen, MyPoint3D a, MyPoint3D b, int n)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D c = new MyPoint3D();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int xx, yy;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xx = b.x - a.x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yy = -(b.y - a.y);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c.x = a.x + (xx + yy) / 2;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c.y = b.y + (xx + yy) / 2;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //最後なので、実際に線を引きます</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (n &lt;= 0)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.DrawLine(pen, a.x, a.y, c.x, c.y); &nbsp; //点Aから点Cへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.DrawLine(pen, b.x, b.y, c.x, c.y); &nbsp; //点Bから点Cへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //最後ではないので、さらにメソッドを呼び出します（再帰処理）</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawDragon(g, pen, a, c, n - 1); &nbsp; &nbsp;//点Aから点Cへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawDragon(g, pen, b, c, n - 1); &nbsp; &nbsp;//点Bから点Cへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div></div>
<div>&nbsp; &nbsp; }</div>
<div></div>
<div></div>
<div>}</div>
<div></div>
<hr /><br />
drawDragon_main()<br />
drawDragon()<br />
<br />
関数を追加。<br />
<br />
textBox1.Text　の数値を変えると回帰回数を指定出来る。<br />
プロパティの初期設定の仕方は、コッホ曲線参照してみてください。<br />
<br />
終わり。<br />
<br />
<!-- 本 自動表示 -->
<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>]]>
    </description>
    <category>グラフィック</category>
    <link>https://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF%E3%80%80%E3%83%89%E3%83%A9%E3%82%B4%E3%83%B3%E6%9B%B2%E7%B7%9A%E3%80%80for%20vs2013</link>
    <pubDate>Sun, 04 Sep 2016 13:44:30 GMT</pubDate>
    <guid isPermaLink="false">re1985.blog.shinobi.jp://entry/49</guid>
  </item>
    <item>
    <title>C#グラフィック　Tree曲線　for VS2013 Express</title>
    <description>
    <![CDATA[<div><br />
<a href="http://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF%E3%80%80%E3%82%B3%E3%83%83%E3%83%9B%E6%9B%B2%E7%B7%9A%E3%80%80for%20vs2013" title="">C#グラフィック　コッホ曲線　for VS2013 Express</a><br />
<br />
に引き続き、Tree曲線をC＃で描画してみる。<br />
参考URL　<a href="https://codezine.jp/article/detail/73" title="">https://codezine.jp/article/detail/73</a><br />
<br />
<img src="//re1985.blog.shinobi.jp/File/tree1.png" alt="" /> <br />
<br />
<!-- 本 自動表示 -->
<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
<br />
<br />
<hr /><br />
using System;</div>
<div>using System.Collections.Generic;</div>
<div>using System.ComponentModel;</div>
<div>using System.Data;</div>
<div>using System.Drawing;</div>
<div>using System.Linq;</div>
<div>using System.Text;</div>
<div>using System.Threading.Tasks;</div>
<div>using System.Windows.Forms;</div>
<div></div>
<div></div>
<div>namespace WindowsFormsApplication1</div>
<div>{</div>
<div>&nbsp; &nbsp; public partial class Form1 : Form</div>
<div>&nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public class &nbsp;MyPoint3D</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int z;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public MyPoint3D() { }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public MyPoint3D(int _x, int _y, int _z)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = _x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = _y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z = _z;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public Form1()</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InitializeComponent();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; private void button1_Click(object sender, EventArgs e)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //描画先とするImageオブジェクトを作成する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bitmap canvas = new Bitmap(pictureBox1.Width, pictureBox1.Height);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //ImageオブジェクトのGraphicsオブジェクトを作成する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Graphics gra = Graphics.FromImage(canvas);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Penオブジェクトの作成(幅1の黒色)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //(この場合はPenを作成せずに、Pens.Blackを使っても良い)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Pen pen = new Pen(Color.Blue, 1);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //コッホ曲線描画</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //drwKoch_main(gra, pen);</div>
<div><span style="color: #ff0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //樹木曲線</span></div>
<div><span style="color: #ff0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drwTree_main(gra, pen);</span></div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pen.Dispose();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gra.Dispose();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //PictureBox1に表示する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pictureBox1.Image = canvas;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; //樹木曲線</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public void drwTree_main(Graphics gra, Pen pen)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //３対の点を指定します</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D P = new MyPoint3D(100, 400, 0);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D Q = new MyPoint3D(100, 100, 0);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D R = new MyPoint3D(250, 400, 0);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D S = new MyPoint3D(250, 100, 0);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D T = new MyPoint3D(400, 400, 0);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D U = new MyPoint3D(400, 100, 0);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //それぞれの対をなす２点間に樹木曲線を描きます</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawTree(gra, pen, P, Q, 3);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawTree(gra, pen, R, S, 4);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawTree(gra, pen, T, U, 5);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; //樹木曲線を描くメソッド</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public void drawTree(Graphics g, Pen pen, MyPoint3D a, MyPoint3D b, int n)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double STEM_RATIO = 0.25, BRANCH_RATIO = 0.6;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D c = new MyPoint3D();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D d = new MyPoint3D();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D e = new MyPoint3D();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int sign;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int xx, yy;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double angle1, angle2, center_length, branch_length;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xx = b.x - a.x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yy = -(b.y - a.y);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; angle1 = Math.Atan((double)yy / xx) + Math.PI / 6;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; angle2 = Math.Atan((double)yy / xx) - Math.PI / 6;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; center_length = Math.Sqrt(xx * xx + yy * yy) * (1 - STEM_RATIO);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; branch_length = BRANCH_RATIO * center_length;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //元の直線が右下がりなら符号をマイナスにします</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sign = (xx &gt;= 0) ? 1 : -1;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c.x = (int)(a.x + STEM_RATIO * xx);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c.y = (int)(a.y - STEM_RATIO * yy);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d.x = c.x + sign * (int)(branch_length * Math.Cos(angle1));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d.y = c.y - sign * (int)(branch_length * Math.Sin(angle1));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.x = c.x + sign * (int)(branch_length * Math.Cos(angle2));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.y = c.y - sign * (int)(branch_length * Math.Sin(angle2));</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //幹の部分は再帰を行わないので、点Aから点Cへ実際に線を引きます</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.DrawLine(pen, a.x, a.y, c.x, c.y);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //最後なので、実際に線を引きます</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (n &lt;= 0)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.DrawLine(pen, c.x, c.y, b.x, b.y); &nbsp; //中央部（点Cから点Bへ）</div>
<div></div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.DrawLine(pen, c.x, c.y, d.x, d.y); &nbsp; //左の枝（点Cから点Dへ）</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.DrawLine(pen, c.x, c.y, e.x, e.y); &nbsp; //右の枝（点Cから点Eへ）</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //最後ではないので、更にメソッドを呼び出します（再帰処理）</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawTree(g, pen, c, b, n - 1); &nbsp; //中央部（点Cから点Bへ）</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawTree(g, pen, c, d, n - 1); &nbsp; //左の枝（点Cから点Dへ）</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawTree(g, pen, c, e, n - 1); &nbsp; //右の枝（点Cから点Eへ） &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp;</div>
<div>&nbsp; &nbsp; }</div>
<div></div>
<div></div>
<div>}<br />
<br />
<hr /></div>
<div><br />
コッホ曲線の代わりに、<br />
<br />
drwTree_main()<br />
drwTree()<br />
<br />
を追加した。<br />
<br />
後は、同じですね。<br />
<br />
終わり。</div>
<!-- 本 自動表示 -->
<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>]]>
    </description>
    <category>グラフィック</category>
    <link>https://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF%E3%80%80</link>
    <pubDate>Sun, 04 Sep 2016 13:30:44 GMT</pubDate>
    <guid isPermaLink="false">re1985.blog.shinobi.jp://entry/48</guid>
  </item>
    <item>
    <title>C#グラフィック　コッホ曲線　for VS2013 Express</title>
    <description>
    <![CDATA[<div>C#グラフィック　コッホ曲線　for VS2013 Express</div>
<div><img src="//re1985.blog.shinobi.jp/File/koho.png" alt="" /> <br />
<br />
<br />
参考 URL<br />

<div>C#でグラフィック<a href="http://dobon.net/vb/dotnet/graphics/drawrectangle.html" title=""><br />
http://dobon.net/vb/dotnet/graphics/drawrectangle.html</a></div>
<div>コッホ曲線</div>
<div><a href="https://codezine.jp/article/detail/73" title="">https://codezine.jp/article/detail/73</a></div>
<div></div>
<div></div>
<!-- 本 自動表示 -->
<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
<br />
<br />
<br />
参考ページを元にC#用に作った。<br />
<br />
<hr />
<div>using System;</div>
<div>using System.Collections.Generic;</div>
<div>using System.ComponentModel;</div>
<div>using System.Data;</div>
<div>using System.Drawing;</div>
<div>using System.Linq;</div>
<div>using System.Text;</div>
<div>using System.Threading.Tasks;</div>
<div>using System.Windows.Forms;</div>
<div><br />

<div></div>
<div>namespace WindowsFormsApplication1</div>
<div>{</div>
<div>&nbsp; &nbsp; public partial class Form1 : Form</div>
<div>&nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public class &nbsp;MyPoint3D</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public int z;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public MyPoint3D() { }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public MyPoint3D(int _x, int _y, int _z)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = _x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = _y;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z = _z;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public Form1()</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InitializeComponent();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; private void button1_Click(object sender, EventArgs e)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //描画先とするImageオブジェクトを作成する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bitmap canvas = new Bitmap(pictureBox1.Width, pictureBox1.Height);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //ImageオブジェクトのGraphicsオブジェクトを作成する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Graphics gra = Graphics.FromImage(canvas);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Penオブジェクトの作成(幅1の黒色)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //(この場合はPenを作成せずに、Pens.Blackを使っても良い)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Pen pen = new Pen(Color.Blue, 1);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //コッホ曲線描画</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">drwKoch_main(gra, pen);</span></div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pen.Dispose();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gra.Dispose();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //PictureBox1に表示する</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pictureBox1.Image = canvas;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public void drwKoch_main(Graphics gra, Pen pen)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int kaisu = int.Parse(textBox1.Text);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //始点を３つ指定</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D P = new MyPoint3D(100, 160, 0);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D Q = new MyPoint3D(400, 160, 0);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D R = new MyPoint3D(250, 420, 0);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //コッホ曲線描画</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawKoch(gra, pen, P, Q, kaisu);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawKoch(gra, pen, Q, R, kaisu);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawKoch(gra, pen, R, P, kaisu); &nbsp; &nbsp; &nbsp;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; //コッホ曲線を描くメソッド</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public void drawKoch(Graphics g, Pen pen, MyPoint3D a, MyPoint3D b, int n)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //メソッド内部で使用する３点を生成します</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D c = new MyPoint3D();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D d = new MyPoint3D();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPoint3D e = new MyPoint3D();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int xx, yy;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double angle1, angle2, distance;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c.x = (2 * a.x + b.x) / 3;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c.y = (2 * a.y + b.y) / 3;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d.x = (a.x + 2 * b.x) / 3;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d.y = (a.y + 2 * b.y) / 3;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xx = b.x - a.x;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yy = -(b.y - a.y);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; distance = Math.Sqrt(xx * xx + yy * yy) / Math.Sqrt(3);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (xx &gt;= 0)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp;//元になる直線が右上がりの場合</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; angle1 = Math.Atan((double)yy / xx) + Math.PI / 6;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.x = a.x + (int)(distance * Math.Cos(angle1));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.y = a.y - (int)(distance * Math.Sin(angle1));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; //元になる直線が右下がりの場合</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; angle2 = Math.Atan((double)yy / xx) - Math.PI / 6;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.x = b.x + (int)(distance * Math.Cos(angle2));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.y = b.y - (int)(distance * Math.Sin(angle2));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //最後なので、実際に線を引きます</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (n &lt;= 0)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.DrawLine(pen, a.x, a.y, c.x, c.y); &nbsp; &nbsp;//点Aから点Cへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.DrawLine(pen, c.x, c.y, e.x, e.y); &nbsp; &nbsp;//点Cから点Eへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.DrawLine(pen, e.x, e.y, d.x, d.y); &nbsp; &nbsp;//点Eから点Dへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.DrawLine(pen, d.x, d.y, b.x, b.y); &nbsp; &nbsp;//点Dから点Bへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //最後ではないので、更にメソッドを呼び出します（再帰処理）</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawKoch(g, pen, a, c, n - 1); &nbsp; &nbsp;//点Aから点Cへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawKoch(g, pen, c, e, n - 1); &nbsp; &nbsp;//点Cから点Eへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawKoch(g, pen, e, d, n - 1); &nbsp; &nbsp;//点Eから点Dへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawKoch(g, pen, d, b, n - 1); &nbsp; &nbsp;//点Dから点Bへ</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp;&nbsp;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div></div>
<div>&nbsp; &nbsp; }</div>
<div></div>
<div></div>
<div>}</div>
<br />
<hr /><br />
<br />
<br />
</div>
Point3D構造体を使用しようとしたが、<span style="font-family: 'Meiryo UI', Meiryo, 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 17.55px;">PresentationCore.dllがなかったので<br />
</span>MyPoint3Dクラスを作成。<br />
<br />
参考にした、drawKoch()関数は、Java言語で書かれているが<br />
メソッド名が、似ていて簡単にC＃に移動出来た。<br />
C＃の場合、PENを変数に教えてあげる必要がある。<br />
<br />
C＃の場合<br />
<span style="color: #ff0000;">g.DrawLine(pen, a.x, a.y, c.x, c.y); &nbsp; &nbsp;//点Aから点Cへ</span><br />
<br />
Javaの場合<br />
<span style="color: #ff0000;">g.drawLine(a.x,a.y,c.x,c.y); &nbsp; &nbsp;//点Aから点Cへ</span><br />
<br />
違いはこれくらいか。<br />
<br />
textBox1.Textは回帰回数を指定出来る。<br />
エディタ側で、textBox1.Text上で右クリックしてプロパティを選択し<br />
text値の値を３にして下さい。<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/koho-2.png" alt="" /> <br />
<br />
<br />
textBox1.Textのプロパティ値のtextを３にする。<br />
<img src="//re1985.blog.shinobi.jp/File/koho-3.png" alt="" /> <br />
<br />
これで、初期設定が３になっています。<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/koho-4.png" alt="" /> <br />
<br />
<br />
<br />
終わり。<br />
<!-- 本 自動表示 -->
<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
</div>]]>
    </description>
    <category>グラフィック</category>
    <link>https://re1985.blog.shinobi.jp/%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF/c-%E3%82%B0%E3%83%A9%E3%83%95%E3%82%A3%E3%83%83%E3%82%AF%E3%80%80%E3%82%B3%E3%83%83%E3%83%9B%E6%9B%B2%E7%B7%9A%E3%80%80for%20vs2013</link>
    <pubDate>Sun, 04 Sep 2016 12:48:03 GMT</pubDate>
    <guid isPermaLink="false">re1985.blog.shinobi.jp://entry/47</guid>
  </item>
    <item>
    <title>C#作成アプリからVC++作成のDLLを使用　for VS2015 Express for Desktop</title>
    <description>
    <![CDATA[さて、前回<br />
<a href="http://re1985.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%83%A9%E3%82%A4%E3%83%B3%E3%81%A7c-%E3%81%8B%E3%82%89vc--%E4%BD%9C%E6%88%90%E3%81%AEdll%E3%82%92%E4%BD%BF%E7%94%A8%E3%80%80" title="">コマンドラインでC#からVC++作成のDLLを使用　for VS21015 Express for Desktop C#とVC++<br />
</a>を紹介しました。この時のコードと<br />
<a href="http://re1985.blog.shinobi.jp/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0/windows%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92%E4%BD%9C%E6%88%90%E3%81%97%E3%81%A6%E3%81%BF%E3%82%88%E3%81%86%20for%20vs2" title="">Windowsアプリを作成してみよう for VS2015 Express for Desktop C#</a><br />
のコードをそのまま流用してC#作成のアプリケーションから<br />
VC++作成のDLL呼び出しをしてみたいと思います。<br />
概念は以下の感じですね。<br />
<br />
<span style="color: #ff0000; font-size: x-large;">[ &nbsp;GUI &nbsp;]　&hArr;　[ &nbsp;DLL &nbsp;]</span><br />
<span style="color: #ff0000;">　C#で作成　　　　　　VC++で作成　</span><br />
<br />
<br />
GUI(WIndowsアプリケーション)はC＃で作成し、DLLをVC++で作成します。<br />
<br />
ここからは、GUIについての編集はエディタを大人しく使うことにします。<br />
<br />
DLLを作成する際は、VS2015提供のエディタを使うとモッサリしているので<br />
私は桜エディタを使用しています。有名なところは、秀丸エディタとか<br />
他にも優秀なソフトがあるのでそちらを使うといいかもしれません。<br />
<br />
<br />
<iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe> <br />
<br />
フォルダ配置は適当でいいのですが・・<br />
<br />
前回作成のC#のプロジェクトのフォルダをそのままコピーして、<br />
フォルダ名を「C＃helloGUI2」としました。<br />
このフォルダに、VC++作成のmydllフォルダを作成しました。<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/w6.png" alt="" /> <br />
<br />
<br />
<br />
<br />
<br />
<span style="font-size: x-large;">VC＋＋側</span><br />
<a href="http://re1985.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%83%A9%E3%82%A4%E3%83%B3%E3%81%A7c-%E3%81%8B%E3%82%89vc--%E4%BD%9C%E6%88%90%E3%81%AEdll%E3%82%92%E4%BD%BF%E7%94%A8%E3%80%80" title="">コマンドラインでC#からVC++作成のDLLを使用　for VS21015 Express for Desktop C#とVC++<br />
</a>mydll.cpp<br />
<hr />
<div>#include &lt;string.h&gt;</div>
<div>#include &lt;iostream&gt;</div>
<div><br />
#ifdef __cplusplus</div>
<div>#define DLLEXPORT extern "C" __declspec(dllexport)</div>
<div>#else</div>
<div>#define DLLEXPORT __declspec(dllexport)</div>
<div>#endif</div>
<div><br />
using namespace std;&nbsp;</div>
<div><br />
//整数値を返す</div>
<div>DLLEXPORT int &nbsp;add(int a, int b) {</div>
<div>&nbsp; &nbsp; return a + b;</div>
<div>}</div>
<div><br />
//文字列の参照値渡し</div>
<div>DLLEXPORT void &nbsp;test_str(char *str)</div>
<div>{</div>
<div>sprintf(str, "%sだにゃん♪", str);</div>
<div>}</div>
<hr /><br />
「開発者コマンドプロントfor2015」起動して、コマンドラインでコンパイル<br />
<br />
<br />
&gt;cl mydll.cpp /LD /EHsc<br />
<br />
<br />
※コマンドラインでのコンパイルの仕方が分からない方は<br />
　<a href="http://re1985.blog.shinobi.jp/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0/windows%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92vs2015%20%E3%81%A7%E4%BD%9C%E3%82%8D%E3%81%86" title="">コマンドラインでHello World！ for VS2015　VC++</a>&nbsp;<br />
　を見て下さい。<br />
<br />
コンパイルの際、３２Bitマシンか６４Bitマシンに提供するか意識する必要があります。<br />
切り替えるバッチファイルはインストールのデフォで以下に有ります。<br />
<br />
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"<br />
<br />
６４ビット用にしたい場合<br />
vcvarsall amd64<br />
<br />
３２ビット用にしたい場合<br />

<div>vcvarsall amd64_x86</div>
<div><br />
でしたね。<br />
<br />
コマンドラインの場合でコンパイルした際６４ビットにしましたが<br />
今回は３２ビットにします。<br />
<br />
なぜならC＃の、VS2015のエディタを使うと３２ビット優先になっているからです。<br />
６４ビットのままだとエラーとなります。<br />
<br />
メニュウ＞プロパティ＞ビルド　で確認。<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/w1.png" alt="" /> <br />
<br />
<br />
なので、６４BitでDLL作った方は、３２Bitに切り替える必要があります。<br />
（もしくは、C#側を代える必要がありますが、今回DLL側を代えています。）<br />
<br />
３２Bitに切り替える。<br />
&gt;"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64_x86<br />
<br />
ソースの有りかに移動<br />
&gt;cd /d S:\plog\vs2015\C＃helloGUI2\mydll<br />
<br />
コンパイル<br />
&gt;cl mydll.cpp /LD /EHsc<br />
<br />
<hr />
<div><span style="color: #008000;">S:\plog\vs2015\C＃helloGUI2\mydll&gt;cl mydll.cpp /LD /EHsc</span></div>
<div><span style="color: #008000;">Microsoft(R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x86</span></div>
<div><span style="color: #008000;">Copyright (C) Microsoft Corporation. &nbsp;All rights reserved.</span></div>
<div></div>
<div><span style="color: #008000;">mydll.cpp</span></div>
<div><span style="color: #008000;">Microsoft (R) Incremental Linker Version 14.00.24213.1</span></div>
<div><span style="color: #008000;">Copyright (C) Microsoft Corporation. &nbsp;All rights reserved.</span></div>
<div></div>
<div><span style="color: #008000;">/out:mydll.dll</span></div>
<div><span style="color: #008000;">/dll</span></div>
<div><span style="color: #008000;">/implib:mydll.lib</span></div>
<div><span style="color: #008000;">mydll.obj</span></div>
<div><span style="color: #008000;">&nbsp; &nbsp;ライブラリ mydll.lib とオブジェクト mydll.exp を作成中</span><br />
<hr /><br />
これでOKです。<br />
ソースはいじっていません。<br />
<br />
作成したmydll.dllファイルを移動させる必要がありますが<br />
次にC＃側を先にみましょう。</div>
<br />
<br />
<br />
<span style="font-size: x-large;">C#側</span><br />
<a href="http://re1985.blog.shinobi.jp/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0/windows%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92%E4%BD%9C%E6%88%90%E3%81%97%E3%81%A6%E3%81%BF%E3%82%88%E3%81%86%20for%20vs2" title="">Windowsアプリを作成してみよう for VS2015 Express for Desktop C#</a><br />
にて作ったコードを流用し、以下のようにします。<br />
<br />
Form1.cs<br />

<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"></p>
<hr />
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">using</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> System;</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">using</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">System.Collections.Generic</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">;</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">using</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">System.ComponentModel</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">;</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">using</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">System.Data</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">;</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">using</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">System.Drawing</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">;</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">using</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">System.Linq</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">;</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">using</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">System.Text</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">;</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">using</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">System.Threading.Tasks</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">;</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">using</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">System.Windows.Forms</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">;<br />
<br />
</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">// </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">DllImport</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: ja; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">に必要</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">using</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">System.Runtime.InteropServices</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">;<br />
<br />
</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">namespace</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">C_helloGUI</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">{</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">public</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">partial</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">class</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">Form1</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> : </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">Form</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">{</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">//</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: ja; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">数値の値渡し</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">DllImport</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">(</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;">"mydll.dll"</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">, </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">CallingConvention</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> = </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">CallingConvention</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">.Cdecl</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">)]</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">private</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">extern</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">static</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">int</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> add(</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">int</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> a, </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">int</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> b);<br />
<br />
</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">//</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: ja; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">文字列の参照渡し</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">DllImport</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">(</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;">"mydll.dll"</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">, </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">CallingConvention</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> = </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">CallingConvention</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">.Cdecl</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">)]</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">private</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">extern</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">static</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">void</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">test_str</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">(</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">StringBuilder</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">str</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">);<br />
<br />
</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">public</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> Form1()</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">{</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">InitializeComponent</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">();</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">}<br />
<br />
</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">private</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">void</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> button1_Click(</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">object</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> sender, </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">EventArgs</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> e)</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">{</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">//textBox1.Text = "Hello</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: ja; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">　</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">World</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: ja; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">！</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">";</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">//</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: green; mso-font-kerning: 12.0pt; language: ja; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: green; mso-style-textfill-fill-alpha: 100.0%;">追記部分</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">int</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> result = add(10, 3);</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">Console</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">.WriteLine</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">(</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;">"</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;">dll</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;"> add = {0}"</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">, result);<br />
<br />
</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">StringBuilder</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> buff = </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: blue; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: blue; mso-style-textfill-fill-alpha: 100.0%;">new</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">StringBuilder</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">();</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">buff.Append</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">(</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;">"C#</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: ja; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;">からの文字列</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;">"</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">);</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">test_str</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">(buff);</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #2b91af; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #2B91AF; mso-style-textfill-fill-alpha: 100.0%;">Console</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">.WriteLine</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">(</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;">"</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;">dll</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;"> </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;">test_str</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック'; mso-ascii-font-family: 'ＭＳ ゴシック'; mso-fareast-font-family: 'ＭＳ ゴシック'; mso-bidi-font-family: +mn-cs; mso-bidi-theme-font: minor-bidi; color: #a31515; mso-font-kerning: 12.0pt; language: en-US; text-combine: letters; mso-style-textfill-type: solid; mso-style-textfill-fill-color: #A31515; mso-style-textfill-fill-alpha: 100.0%;"> = {0}"</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">, buff);</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; textBox1.Text = </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">buff.ToString</span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">();<br />
<br />
</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">}</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">}</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: 10.5pt; font-family: 'ＭＳ ゴシック';">}</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed; word-break: normal;"><span style="font-size: small; font-family: 'ＭＳ ゴシック';">&nbsp;</span></p>
<hr /><br />
これを、F5にてビルドしましょう。<br />
するとエラーとなります。当然ですね、DLLを移動させていませんから<br />
<br />
bin\Debug配下に、C＃helloGUI.exe が出来るのでここにVC++で作成したDLLを置きます。<br />
<br />
&nbsp;<br />
<img src="//re1985.blog.shinobi.jp/File/8657d817.png" alt="" /> <br />
<br />
<br />
mydll.dll と C＃helloGUI.exe　を同じフォルダに配置しましたら<br />
F5にてビルドしましょう。<br />
<br />
Button1を押すと、DLLに渡った文字列に「だにゃん♪」が付加されて<br />
TextBoxに表示されているのがわかると思います。</div>
<div><img src="//re1985.blog.shinobi.jp/File/w4.png" alt="" /><br />
<br />
<img src="//re1985.blog.shinobi.jp/File/w3.png" alt="" /> &nbsp;<br />
<br />
<br />
いかがですか？出来ましたでしょうか？<br />
こなれてくると、修正したDLLの移動が面倒になってきますよね。<br />
<br />
その際は、メモ帳を開いて　makedll.bat　の名前にして<br />
<br />
makedll.bat<br />
<hr />
<div>cl mydll.cpp /LD /EHsc</div>
<div></div>
<div>copy /y mydll.dll ..\C＃helloGUI\bin\Debug</div>
<div></div>
<hr /><br />
のような感じにして、同じVC++側のフォルダに置きます。<br />
copyコマンドについては、詳細はググってみてください。<br />
/yオプションは強制上書きします。<br />
<br />
コピー先はC#のDebugフォルダを指定して下さい。<br />
相対パスで失敗する場合は、フルパスしてみてください。<br />
<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/80ba425d.png" alt="" /> <br />
<br />
<br />
バッチファイルを利用すると、手間が省けますよね。<br />
<br />
<br />
終わり。<br />
<br />
<br />
<iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>]]>
    </description>
    <category>プログラム</category>
    <link>https://re1985.blog.shinobi.jp/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0/windows%E3%82%A2%E3%83%97%E3%83%AAc-%E3%81%8B%E3%82%89vc--%E4%BD%9C%E6%88%90%E3%81%AEdll%E3%82%92%E4%BD%BF</link>
    <pubDate>Sat, 27 Aug 2016 10:14:42 GMT</pubDate>
    <guid isPermaLink="false">re1985.blog.shinobi.jp://entry/46</guid>
  </item>
    <item>
    <title>ブログでアマゾンアフィリエイト(ウィジット広告)する方法にゃ～♪</title>
    <description>
    <![CDATA[<br />
アフィって聞いたことあるけど、なんかよくわからず<br />
知ったフリしていたんですにゃ。<br />
<br />
そもそも、老人騙してアコギな商売しているという某デポデポで、<br />
ショートカットにアマゾンのリンクを張って小遣い稼ぎ云々・・<br />
・・というニュースを聞いて。<br />
<br />
俺も<span style="text-decoration: line-through;">デポれるかな？ｗ<br />
</span>アフィって出来るかな？ってなよこしまな動機から始めた。<br />
<br />
で、結論からいうと俺にも出来た。<br />
<br />
こう言う風に<br />
<br />
<br />
&dArr;　　&dArr;　　&dArr;　　&dArr;　　&dArr;　　&dArr;　　&dArr;　　&dArr;　　&dArr;　　&dArr;<br />
<br />
<!-- 本 自動表示 -->
<div class="amazon-ad"><iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe></div>
<br />
<!-- 自動検索用リンク -->
<div class="amazon-ad">
<script charset="utf-8" type="text/javascript">amzn_assoc_ad_type = "responsive_search_widget";
amzn_assoc_tracking_id = "fxpower-22";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "JP";
amzn_assoc_placement = "";
amzn_assoc_search_type = "search_widget";
amzn_assoc_width = "auto";
amzn_assoc_height = "auto";
amzn_assoc_default_search_category = "";
amzn_assoc_default_search_key = "";
amzn_assoc_theme = "light";
amzn_assoc_bg_color = "FFFFFF";</script>
<script src="//z-fe.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;Operation=GetScript&amp;ID=OneJS&amp;WS=1&amp;MarketPlace=JP" type="text/javascript"></script>
</div>
<div>&uarr;　　&uarr;　　&uarr;　　&uarr;　　&uarr;　　&uarr;　　&uarr;　　&uarr;　　&uarr;　　&uarr;　　</div>
<div></div>
<br />
用意するもの<br />
<br />
①ブログやWEBサイト<br />
②アマゾンへの登録<br />
③銀行口座（アマゾンから広告収入として振り込まれる口座を用意）<br />
まず、ブログやWEBサイトを準備します。<br />
<br />
もし、ブログを持ってなければ、この際忍者ブログに登録しましょう。（笑）<br />
<br />
<br />
<br />
次に、アマゾンアフィリエイトに登録します。<br />
ここで銀行口座を登録します。<br />
<br />
審査に数日掛かるのかな？と思っていましたが<br />
機械的に終わりました。<br />
<br />
もしかしたら、アマゾンで購入しているアカウントをそのまま使ったから<br />
審査らしい審査がなかったのかもしれません。<br />
<br />
登録の最後に、電話による自動音声ガイダンスで<br />
番号を入力して本人確認があります。<br />
<br />
Amazonアソシエイト登録は全て無人で自動的に行われました。<br />
さっそく、自分のブログに張る、HTMLタグを取得する手順を以下に記します。<br />
<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/afi2.png" alt="" width="394" height="251" /> <br />
<br />
おっと。<br />
<br />
忘れてはならないのは、広告ブロックのアドイン入れている場合、<br />
表示テストするサイトのURLをブロックしないように解除しといてくださいね。<br />
じゃないと、広告が表示されているかどうかを確認できませんので。<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/afi3.png" alt="" /><br />
<br />
<br />
アマゾンアフィリエイトでログインしたら、「ウィジット」というタブを選択<br />
<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/afi4.png" alt="" width="431" height="277" /> <br />
<br />
<br />
この中のサーチボックスとAmazonライブリンクが<br />
よさげなので私はこの２つをチョイスしました。<br />
というのも、Amazonライブリンクは説明に書いてある通り<br />
自動的に商品を表示なので、毎回、アマゾンアフィリエイトにログインして<br />
リンク取得～ってやらないで済むからです。<br />
<br />
下は広告ではありませんよ。画像です。<br />
<img src="//re1985.blog.shinobi.jp/File/afi5.png" alt="" width="235" height="273" /> <br />
Amazonライブリンクのソースコードを取得する方法を示します。<br />
他も似たり寄ったりなので参考にしてくださいね。<br />
「Amazonライブリンク」の「あなたのWEBサイトに追加」ボタンを押します。<br />
<br />
<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/afi6.png" alt="" width="483" height="250" /><br />
<br />
<br />
すると、ストアを選択とでます。<br />
私は「本」を選択し、カテゴリー・ジャンルの「ベストセラー」を選択し<br />
次に進むをクリック。<br />
<br />
<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/afi7.png" alt="" width="477" height="466" /><br />
<br />
すると、いろいろなサイズのウィジットが選択できるので<br />
お好きなのを選択します。<br />
<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/afi8.png" alt="" width="482" height="286" /><br />
<br />
<br />
左側にリンク作成の中に、ソースコードが書かれているので、<br />
HTMLをハイライトにするを選択し、「Cntl+C」（キーボードのコントロールキー＋C）<br />
にてコピーします。別にマウスでコピーでも構いません。<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/afi13.png" alt="" /> <br />
<br />
<br />
メモ帳に保存しておくといいですね。<br />
忍者ブログの場合は、ソースコードタブにリンク作成したコードを貼り付けます。<br />
以下のような感じ。<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/afi14.png" alt="" width="532" height="411" /> <br />
<br />
<br />
これでうまくウィジット広告が表示されるはずです。<br />
もし、うまくいかない場合、広告ブロックのアドインが有効になっていないか<br />
チェックしてくださいね。<br />
<br />
<img src="//re1985.blog.shinobi.jp/File/afi3.png" alt="" /><br />
<br />
<br />
<br />
ではよいアフィ生活を。<br />
<br />
<br />
終わり。<br />
<br />
<!-- 本 自動表示 --> <iframe width="468" height="60" style="border: none;" src="https://rcm-fe.amazon-adsystem.com/e/cm?t=fxpower-22&amp;o=9&amp;p=13&amp;l=bn1&amp;mode=books-

jp&amp;browse=466298&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" marginwidth="0" marginheight="0" border="0" frameborder="0" scrolling="no"></iframe> <br />
<!-- 自動検索用リンク -->
<script charset="utf-8" type="text/javascript">amzn_assoc_ad_type = "responsive_search_widget";
amzn_assoc_tracking_id = "fxpower-22";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "JP";
amzn_assoc_placement = "";
amzn_assoc_search_type = "search_widget";
amzn_assoc_width = "auto";
amzn_assoc_height = "auto";
amzn_assoc_default_search_category = "";
amzn_assoc_default_search_key = "";
amzn_assoc_theme = "light";
amzn_assoc_bg_color = "FFFFFF";</script>
<script src="//z-fe.amazon-adsystem.com/widgets/q?

ServiceVersion=20070822&amp;Operation=GetScript&amp;ID=OneJS&amp;WS=1&amp;MarketPlace=JP" type="text/javascript"></script>]]>
    </description>
    <category>未選択</category>
    <link>https://re1985.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/%E3%83%96%E3%83%AD%E3%82%B0%E3%82%84web%E3%82%B5%E3%82%A4%E3%83%88%E3%81%A7%E3%82%A2%E3%83%9E%E3%82%BE%E3%83%B3%E3%82%A2%E3%83%95%E3%82%A3%E3%83%AA%E3%82%A8%E3%82%A4%E3%83%88-%E3%82%A6%E3%82%A3%E3%82%B8</link>
    <pubDate>Sat, 27 Aug 2016 01:38:07 GMT</pubDate>
    <guid isPermaLink="false">re1985.blog.shinobi.jp://entry/45</guid>
  </item>

    </channel>
</rss>