1
我知道這是一個非常常見的話題,我一直在尋找解決方案。我再次在CHIP8模擬器上工作,並試圖創建一個單獨的窗體來處理圖形。以另一種形式調用方法C#
我現在有兩種形式,Form1和圖形。我想要做的是從Form1的圖形中調用「繪製」方法。在Form1中我有以下代碼...
這是我得到的錯誤: 錯誤4'System.Windows.Forms.Form'不包含'Draw'的定義並且沒有擴展方法'Draw 「接受一個類型的第一個參數‘System.Windows.Forms.Form中’可以找到(是否缺少using指令或程序集引用?)
Form graphicsTest = new graphics(); // This is in the initial declaration of Form1
graphicsTest.Draw(screen); // Screen is a [64,32] boolean array representing pixel states
以下是我對‘圖形’..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class graphics : Form // The purpose of this form is to handle the graphics
{
Graphics dc;
Rectangle ee = new Rectangle(10, 10, 30, 30); // Size of each pixel
Pen WhitePen = new Pen(Color.White, 10); // Pen to draw the rectangle object
Pen BlackPen = new Pen(Color.Black, 10);
bool[] drawMe;
public graphics()
{
InitializeComponent();
dc = this.CreateGraphics();
}
private void Form2_Load(object sender, EventArgs e)
{
}
public void Draw(bool[] drawme) // This method recieves the array and draws the appropriate Sprites!
{
// This is where I will draw the appropriate pixels...
}
}
}
再次,我可能會錯過簡單的東西,這是所有如果我沒有發佈足夠的信息,我很抱歉。任何輸入是讚賞!變量來代替graphics
的Form
graphics graphicsTest = new graphics();
graphicsTest.Draw(screen);
謝謝!!!這太容易了! – Bubo
@VRKnight歡迎:)我們都是從這樣的錯誤開始的! –