in the event of the termination of the selection of the area to increase:
Code: Select all
private void vlcControlMain_MouseUp(object sender, MouseEventArgs e)
{
isSelecting = false;
selectionEnd = e.Location;
if (selectionStart != selectionEnd)
{
int x = Math.Min(selectionStart.X, selectionEnd.X);
int y = Math.Min(selectionStart.Y, selectionEnd.Y);
int width = Math.Abs(selectionEnd.X - selectionStart.X);
int height = Math.Abs(selectionEnd.Y - selectionStart.Y);
if (width % 2 != 0)
{
width++;
}
if (height % 2 != 0)
{
height++;
}
if (width < 10 || width > vlcControlMain.Width || height < 10 || height > vlcControlMain.Height)
{
return;
}
double aspectRatio = Math.Round((double)width / (double)height, 2);
string aspectRatioString = string.Format("{0}:{1}", width, height);
if (x < 0 || y < 0 || x + width > vlcControlMain.Width || y + height > vlcControlMain.Height)
{
return;
}
vlcControlMain.MediaPlayer.CropGeometry = $"{width}x{height}+{x}+{y}";
vlcControlMain.MediaPlayer.AspectRatio = aspectRatioString;
int playerWidth = vlcControlMain.Width;
int playerHeight = vlcControlMain.Height;
Point playerLocation = vlcControlMain.Location;
string logText = $"Selection size: {width}x{height}, player size: {playerWidth}x{playerHeight}, player location: {playerLocation}, selection start: {selectionStart}, selection end: {selectionEnd}, crop: {vlcControlMain.MediaPlayer.CropGeometry}, aspect ratio: {aspectRatioString}";
}
else
{
vlcControlMain.MediaPlayer.CropGeometry = null;
vlcControlMain.MediaPlayer.AspectRatio = null;
vlcControlMain.Width = videoWidth;
vlcControlMain.Height = videoHeight;
vlcControlMain.Location = videoPosition;
}
}