protected override void OnPaint(PaintEventArgs e) { if (Title.Length > 0) { Core.TextShadow ts = new TextShadow(); SizeF szf = e.Graphics.MeasureString(Title, TitleFont); float x = 0; float y = 0; switch (TitleHAlignment) { case StringAlignment.Far: x = this.Width - szf.Width - 10; break; case StringAlignment.Near: x = 0; break; case StringAlignment.Center: x = (this.Width - szf.Width) / 2; break; default: break; } switch (TitleVAlignment) { case StringAlignment.Far: y = this.Height - szf.Height - 10; break; case StringAlignment.Near: break; case StringAlignment.Center: y = (this.Height - szf.Height) / 2; break; default: break; } ts.Draw(e.Graphics, Title, TitleFont, new PointF(x, y)); e.Graphics.DrawString(Title, TitleFont, new SolidBrush(TitleForeColor), new PointF(x, y)); } Draw(e.Graphics); base.OnPaint(e); }
public override void DrawKey(KeyRendererEventArgs args) { tShadow.Radius = 1; tShadow.Distance = 2; tShadow.Alpha = 146; Graphics g = args.Graphics; g.SmoothingMode = SmoothingMode.HighQuality; g.TextRenderingHint = TextRenderingHint.AntiAlias; SolidBrush brush = new SolidBrush(Color.Black); SolidBrush brush2 = new SolidBrush(Color.White); //Rectangle keyBackBounds = args.Bounds; //Rectangle keyBackBounds = new Rectangle(args.Bounds.X, args.Bounds.Y, args.Bounds.Width + 4, args.Bounds.Height + 4); Rectangle keyBackBounds = (args.Key.Info != "{BACKSPACE}") ? new Rectangle(args.Bounds.X, args.Bounds.Y, args.Bounds.Width + 4, args.Bounds.Height + 4) : new Rectangle(args.Bounds.X, args.Bounds.Y, args.Bounds.Width + 4, args.Bounds.Height + 4); //keyBackBounds.Inflate(2, 2); Rectangle keyTextBounds = args.Bounds; keyTextBounds.Inflate(2, 2); keyTextBounds.Offset(-3, 0); if (args.Key.Info != "{BACKSPACE}") { if (args.IsDown || args.Key.Style == KeyStyle.Pressed || args.Key.Style == KeyStyle.Toggled) { g.DrawImage(Properties.Resources.back_keyboard_number_down, keyBackBounds, new Rectangle(0, 0, Properties.Resources.back_keyboard_number_down.Width, Properties.Resources.back_keyboard_number_down.Height), GraphicsUnit.Pixel); if (args.Key.Style == KeyStyle.Toggled) { tShadow.Draw(g, args.Key.Caption, _Font, keyTextBounds, _Format); g.DrawString(args.Key.Caption, _Font, brush2, keyTextBounds, _Format); } else { keyTextBounds.Offset(1, 1); tShadow.Draw(g, args.Key.Caption, _Font, keyTextBounds, _Format); g.DrawString(args.Key.Caption, _Font, brush2, keyTextBounds, _Format); } } else { g.DrawImage(Properties.Resources.back_keyboard_number, keyBackBounds, new Rectangle(0, 0, Properties.Resources.back_keyboard_number.Width, Properties.Resources.back_keyboard_number.Height), GraphicsUnit.Pixel); tShadow.Draw(g, args.Key.Caption, _Font, keyTextBounds, _Format); g.DrawString(args.Key.Caption, _Font, brush2, keyTextBounds, _Format); } } else { keyTextBounds.Offset(10, 0); if (args.IsDown || args.Key.Style == KeyStyle.Pressed || args.Key.Style == KeyStyle.Toggled) { g.DrawImage(Properties.Resources.back_keyboard_delate_down, keyBackBounds, new Rectangle(0, 0, Properties.Resources.back_keyboard_delate_down.Width, Properties.Resources.back_keyboard_delate_down.Height), GraphicsUnit.Pixel); if (args.Key.Style == KeyStyle.Toggled) { tShadow.Draw(g, args.Key.Caption, _Font, keyTextBounds, _Format); g.DrawString(args.Key.Caption, _Font, brush2, keyTextBounds, _Format); } else { keyTextBounds.Offset(1, 1); tShadow.Draw(g, args.Key.Caption, _Font, keyTextBounds, _Format); g.DrawString(args.Key.Caption, _Font, brush2, keyTextBounds, _Format); } } else { g.DrawImage(Properties.Resources.back_keyboard_delate, keyBackBounds, new Rectangle(0, 0, Properties.Resources.back_keyboard_delate.Width, Properties.Resources.back_keyboard_delate.Height), GraphicsUnit.Pixel); tShadow.Draw(g, args.Key.Caption, _Font, keyTextBounds, _Format); g.DrawString(args.Key.Caption, _Font, brush2, keyTextBounds, _Format); } } brush.Dispose(); brush2.Dispose(); }