2015-07-25 12:40:17 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using BizHawk.Client.Common;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
|
|
|
|
{
|
|
|
|
|
public partial class ScreenshotPopupControl : UserControl
|
|
|
|
|
{
|
2015-11-23 20:26:56 +00:00
|
|
|
|
public TasBranch Branch { get; set; }
|
|
|
|
|
public int DrawingHeight = 0;
|
|
|
|
|
public int UserPadding = 0;
|
|
|
|
|
public int UserFontSize = 10; // because why not?
|
|
|
|
|
public FontStyle UserFontStyle = FontStyle.Regular;
|
|
|
|
|
public string UserText;
|
|
|
|
|
private Font UserFont;
|
|
|
|
|
|
2015-07-25 12:40:17 +00:00
|
|
|
|
public ScreenshotPopupControl()
|
|
|
|
|
{
|
2015-12-02 17:15:12 +00:00
|
|
|
|
//SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
2015-11-22 19:31:08 +00:00
|
|
|
|
//SetStyle(ControlStyles.Opaque, true);
|
|
|
|
|
//this.BackColor = Color.Transparent;
|
2015-07-25 12:40:17 +00:00
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
|
|
|
{
|
2015-12-02 17:15:12 +00:00
|
|
|
|
Branch.OSDFrameBuffer.DiscardAlpha();
|
2015-07-25 15:08:23 +00:00
|
|
|
|
var bitmap = Branch.OSDFrameBuffer.ToSysdrawingBitmap();
|
2015-11-22 19:31:08 +00:00
|
|
|
|
e.Graphics.DrawImage(bitmap, new Rectangle(0, 0, Width, DrawingHeight));
|
|
|
|
|
if (UserPadding > 0)
|
|
|
|
|
{
|
|
|
|
|
e.Graphics.DrawRectangle(new Pen(Brushes.Black), new Rectangle(new Point(0, DrawingHeight), new Size(Width - 1, UserPadding - 1)));
|
2015-11-23 20:26:56 +00:00
|
|
|
|
e.Graphics.DrawString(UserText, UserFont, Brushes.Black, new Rectangle(2, DrawingHeight, Width - 2, Height));
|
2015-11-22 19:31:08 +00:00
|
|
|
|
}
|
2015-07-25 12:40:17 +00:00
|
|
|
|
base.OnPaint(e);
|
|
|
|
|
}
|
2015-11-22 16:54:21 +00:00
|
|
|
|
|
2015-11-23 20:26:56 +00:00
|
|
|
|
public void SetFontStyle(FontStyle style)
|
2015-11-22 16:54:21 +00:00
|
|
|
|
{
|
2015-11-23 20:26:56 +00:00
|
|
|
|
UserFontStyle = style;
|
2015-11-22 16:54:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-23 20:26:56 +00:00
|
|
|
|
public void SetFontSize(int size)
|
2015-11-22 16:54:21 +00:00
|
|
|
|
{
|
2015-11-23 20:26:56 +00:00
|
|
|
|
UserFontSize = size;
|
2015-11-22 16:54:21 +00:00
|
|
|
|
}
|
2015-11-22 19:31:08 +00:00
|
|
|
|
|
2015-11-23 20:26:56 +00:00
|
|
|
|
public void RecalculateHeight()
|
2015-11-22 19:31:08 +00:00
|
|
|
|
{
|
2015-11-23 20:26:56 +00:00
|
|
|
|
UserFont = new Font(FontFamily.GenericMonospace, UserFontSize, UserFontStyle);
|
|
|
|
|
UserText = Branch.UserText;
|
|
|
|
|
UserPadding = (int)Graphics.FromHwnd(this.Handle).MeasureString(UserText, UserFont, Width).Height;
|
2015-11-22 19:31:08 +00:00
|
|
|
|
if (UserPadding > 0)
|
|
|
|
|
UserPadding += 2;
|
|
|
|
|
Height = DrawingHeight + UserPadding;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-23 20:26:56 +00:00
|
|
|
|
private void ScreenshotPopupControl_MouseLeave(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ScreenshotPopupControl_MouseHover(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// todo: switch screenshots by hotkey
|
|
|
|
|
}
|
2015-11-22 19:31:08 +00:00
|
|
|
|
|
2015-11-23 20:26:56 +00:00
|
|
|
|
private void ScreenshotPopupControl_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2015-07-25 12:40:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|