我想提出一個Windows窗體在C#中的功課,接受一個多維數據集的長度應用。然後顯示立方體的表面積和體積。這很容易,但它也需要繪製立方體。在Windows窗體中繪製立方體的最簡單方法是什麼?
我想知道什麼是繪製立方體最簡單的方法。我必須通過Graphics
這個課程來做到這一點。
我如何做到這一點至今的想法:
paper = myPicBox.CreateGraphics();
myPen = new Pen(Color.Black);
myPen.Width = 3;
paper.DrawRectangle(myPen, xCoord, yCoord, width, height);
paper.DrawLine(myPen, pointOne, pointTwo); // Then repeat this line for the four lines on the Z-axis
paper.DrawRectangle(myPen, xCoord, yCoord, width, height); // Where xCoord and yCoord have been changed to be placed at the end of the lines I've drawn
這是非常龐大的,所以我在想,如果有一個容易和簡單的方式來達到同樣的事情?
你應該在`Paint`事件畫。調用`CreateGraphics`很少**是一個好主意。 – SLaks 2011-02-13 04:09:54
@SLaks:爲什麼呢?只有,`CreateGraphics`是我一直在uni教過的。 – 2011-02-13 04:11:59