Hallo,
ich versuche gerade so etwas wie einen SpeedButton zu programmieren, der dasselbe Design wie ein ToolStripButton haben soll.
Die Dinger sind normalerweise transparent - bis auf den Glyph natürlich - und der Hintergrund (der TB-Gradient) scheint durch. Wenn man mit der Maus drüberfährt gibt es einen soliden Rand und eine halbtransparente Füllung. Beim MouseDown ne dunklere Füllung und Rand.
Die Färbungen sind alles kein Problem, so nach und nach kriegt man die raus, was ich nicht hinbekomme ist die Tranzparenz.
Wenn ich einfach garnüscht zeichne, dann bleibt der Hover-effekt nach dem MouseLeave logischerweise bestehen. Zeichne ich mit FillRectangle und Color.Transparent drüber, isses derselbe Effekt.
Ich müsste quasi das Parent Control an der Stelle drüberzeichnen lassen und dann mein Image draufbringen. Aber wie macht man das?
Code bisher:
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
| protected override void OnPaint(PaintEventArgs pevent) { if (mouseDown || mouseOver) { if (mouseDown) { baseBackground = new SolidBrush(SystemColors.ControlDark); } else { Color c = Color.FromArgb(128, SystemColors.Highlight.R, SystemColors.Highlight.G, SystemColors.Highlight.B); baseBackground = new SolidBrush(c); } pevent.Graphics.FillRectangle(baseBackground, ClientRectangle); pevent.Graphics.DrawRectangle(new Pen(SystemColors.Highlight), new Rectangle(0, 0, ClientSize.Width - 1, ClientSize.Height - 1)); } if (Image != null) { pevent.Graphics.DrawImage(Image, new Point(ClientSize.Width / 2 - Image.Size.Width / 2, ClientSize.Height / 2 - Image.Height / 2)); } pevent.Graphics.Flush(); } |
Vielen Dank für Hilfe
JayK