でPanelに描画しWindows.Forms
ます。
このようにダブルバッファリングを使用すると、長方形の領域しか割り当てることができません。
そして、円や楕円を描くと、残りのスペースは黒い色で塗りつぶされます。
私が間違っていることや、この問題に対処する方法を理解するのを手伝ってください。
前もって感謝します!:)
this.DoubleBuffered = true
ちらつきを防ごうとしました。無駄です。
Var p
その上に何かを描くためのパネルです。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Dr(bool variant)
{
BufferedGraphicsContext currentContext;
BufferedGraphics myBuffer;
currentContext = BufferedGraphicsManager.Current;
myBuffer = currentContext.Allocate(panel1.CreateGraphics(), panel1.DisplayRectangle);
LinearGradientBrush lgb;
if (variant) lgb = new LinearGradientBrush(new Point(0, 0), new Point(500, 500), Color.Red, Color.DarkRed);
else lgb = new LinearGradientBrush(new Point(0, 0), new Point(500, 500), Color.DarkRed, Color.Red);
myBuffer.Graphics.FillEllipse(lgb, 0, 0, 300, 300);
myBuffer.Graphics.DrawString("Lorem ipsum", new Font("calibri", 40), Brushes.White, new PointF(50, 50));
myBuffer.Render();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Dr(true);
}
private void panel1_MouseEnter(object sender, EventArgs e)
{
Dr(false);
}
private void panel1_MouseLeave(object sender, EventArgs e)
{
Dr(true);
}
}