1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-22 00:15:48 +02:00

Fix video player's minimum size

This commit is contained in:
chylex 2018-11-20 17:33:09 +01:00
parent 4ac05b38d3
commit 7d737eefb6
2 changed files with 14 additions and 6 deletions

View File

@ -191,7 +191,6 @@ private void InitializeComponent() {
this.Location = new System.Drawing.Point(-32000, -32000);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(400, 120);
this.Name = "FormPlayer";
this.ShowIcon = false;
this.ShowInTaskbar = false;

View File

@ -115,16 +115,25 @@ private void player_MediaError(object pMediaObject){
[HandleProcessCorruptedStateExceptions]
private void timerSync_Tick(object sender, EventArgs e){
if (NativeMethods.GetWindowRect(ownerHandle, out NativeMethods.RECT rect)){
int width = rect.Right-rect.Left+1;
int height = rect.Bottom-rect.Top+1;
IWMPMedia media = Player.currentMedia;
IWMPControls controls = Player.controls;
int ownerLeft = rect.Left;
int ownerTop = rect.Top;
int ownerWidth = rect.Right-rect.Left+1;
int ownerHeight = rect.Bottom-rect.Top+1;
// roughly matches MinimumSize for client bounds
const int minWidth = 334;
const int minHeight = 388;
int maxWidth = Math.Min(media.imageSourceWidth, ownerWidth*3/4);
int maxHeight = Math.Min(media.imageSourceHeight, ownerHeight*3/4);
bool isCursorInside = ClientRectangle.Contains(PointToClient(Cursor.Position));
ClientSize = new Size(Math.Max(MinimumSize.Width, Math.Min(media.imageSourceWidth, width*3/4)), Math.Max(MinimumSize.Height, Math.Min(media.imageSourceHeight, height*3/4)));
Location = new Point(rect.Left+(width-ClientSize.Width)/2, rect.Top+(height-ClientSize.Height+SystemInformation.CaptionHeight)/2);
ClientSize = new Size(Math.Max(minWidth, maxWidth), Math.Max(minHeight, maxHeight));
Location = new Point(ownerLeft+(ownerWidth-ClientSize.Width)/2, ownerTop+(ownerHeight-ClientSize.Height+SystemInformation.CaptionHeight)/2);
tablePanel.Visible = isCursorInside || isDragging;