Merhaba Bir 0 #yöntemini geçersiz kıldığım bir C# usercontrol var. Benim OnPaint YöntemiC# DrawImage DoubleBuffered çalışmıyor
Aşağıdaki kod var:
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
Sonra png
görüntü gösterilmiyor: Bu benim yapıcı eklenen titremeyi önlemek için iyi ama işler
// Draw the new button.
protected override void OnPaint(PaintEventArgs e) {
Color btnColor = this.ButtonColor;
if (!this.ButtonEnabled) {
btnColor = Color.LightGray;
}
Bitmap GraphicsImage = new Bitmap(24, 24, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Graphics.FromImage(GraphicsImage).Clear(btnColor);
Graphics graphics = e.Graphics;
SolidBrush myBrush = new SolidBrush(btnColor);
Pen myPen = new Pen(btnColor);
// Draw the button in the form of a circle
graphics.DrawEllipse(myPen, 0, 0, 40, 40);
graphics.FillEllipse(myBrush, new Rectangle(0, 0, 40, 40));
if (!DesignMode) {
Image iconImg = null;
switch (this.ButtonImage) {
case CircleButtonImage.ArrowDown:
iconImg = POS.Framework.Utility.Common.GetResourceImage("arrowdown_16.png");
break;
case CircleButtonImage.ArrowUp:
iconImg = POS.Framework.Utility.Common.GetResourceImage("arrowup_16.png");
break;
case CircleButtonImage.Cross:
iconImg = POS.Framework.Utility.Common.GetResourceImage("close_16.png");
break;
case CircleButtonImage.Plus:
iconImg = POS.Framework.Utility.Common.GetResourceImage("plus_16.png");
break;
}
graphics = Graphics.FromImage(GraphicsImage);
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
graphics.DrawImage(iconImg, 5, 5);
this.CreateGraphics().DrawImageUnscaled(GraphicsImage, new Point(7, 6));
}
myBrush.Dispose();
myPen.Dispose();
}
daha fazla doublebufferd olmadan
:
doublebuffered olarak:
Bunu düzeltmek konusunda herhangi bir ipucu. Titremeyi önlemek istiyorum, ancak oluşturulacak görüntüye ihtiyacım var.
Bunun yerine 'e.Graphics' kullanmalısınız. –