私は目の動きをフォームに表示するために目のトラッカーを使用しています。動きがたくさんちらついているので、私は、目の動きが始まるときを除いて、全てがうまく動作するBufferedGraphicsを使うことができることを発見しました。元の色から黒にフォームを変えます。これがコードです。うまくいけば誰かが助けることができます!なぜ旋削の形が黒くなるのですか
private void button2_Click(object sender, EventArgs e)
{
var host = new Host();
var gazeStream = host.Streams.CreateGazePointDataStream();
gazeStream.GazePoint((x, y, ts)
=> drawCircle(new PointF((float)x, (float)y)));
}
delegate void SetCallback(PointF point);
private void drawCircle(PointF point)
{
float x = point.X;
float y = point.Y;
if (this.InvokeRequired)
{
SetCallback d = new SetCallback(drawCircle);
this.Invoke(d, new object[] { point });
}
else
{
SolidBrush semiTransBrush = new SolidBrush(Color.Coral);
Pen pen = new Pen(Color.Aquamarine, 2);
BufferedGraphicsContext currentContext;
BufferedGraphics myBuffer;
// Gets a reference to the current BufferedGraphicsContext
currentContext = BufferedGraphicsManager.Current;
// Creates a BufferedGraphics instance associated with Form1, and with
// dimensions the same size as the drawing surface of Form1.
myBuffer = currentContext.Allocate(this.CreateGraphics(),this.DisplayRectangle);
myBuffer.Graphics.DrawEllipse(pen, x, y, 100, 100);
myBuffer.Graphics.FillEllipse(semiTransBrush, x, y, 100, 100);
// Renders the contents of the buffer to the specified drawing surface.
myBuffer.Render(this.CreateGraphics());
myBuffer.Dispose();
}
あなたは円はフォームがなくなっているように思えるのコントロールの後ろに表示されていることを画像で見ることができますか?
は 'myBuffer.Graphics.Clear(this.BackColor)を試してみてください;'図形を描画する前に - それは、フォーム –
に何かを持っていない場合、私は、フォーム上のラジオボタンやラベルを持っています。コントロールはまだ表示されます。それはちょうど変化する色ではなくフォームの背景が削除されているように見えます – user8370201
質問のコードはどこですか?メソッドの詳細を表示する –