私はこれが非常に一般的なトピックであることを知っており、解決策を探していました。ここでも、CHIP8エミュレーターに取り組んでおり、グラフィックを処理するための別のフォームを作成しようとしています。
現在、Form1とグラフィックの2つのフォームがあります。私がやりたいのは、Form1からグラフィックスの「draw」メソッドを呼び出すことです。Form1には次のコードがあります...
これは私が得ているエラーです:エラー4'System.Windows.Forms.Form'には'Draw'の定義が含まれておらず、タイプ'System.Windows.Forms.Formの最初の引数を受け入れる拡張メソッド'Draw'がありません'が見つかりました(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...
}
}
}
繰り返しになりますが、私は単純なものを見逃している可能性があります。これはすべて私にとって比較的新しいことであり、十分な情報を投稿していない場合はお詫び申し上げます。どんな入力でも大歓迎です!