Skip to content

Commit

Permalink
Long-awaited changes
Browse files Browse the repository at this point in the history
Typo fixes
Fix for display bug causing offset footage
Code clean-up
  • Loading branch information
Jordy3D committed Sep 9, 2022
1 parent 70c1006 commit c2a5987
Showing 1 changed file with 40 additions and 45 deletions.
85 changes: 40 additions & 45 deletions CameraTest/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ private void Form1_Closed(object sender, EventArgs e)
}
captureDevice = null;
wave = null;
Environment.ExitCode = 1;
Application.Exit();
Environment.Exit(1);
}
#endregion

Expand Down Expand Up @@ -172,7 +171,7 @@ void GetDevicesLists(bool SetLast = false)
}
}

#region Vidoe
#region Video
private void VideoComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (VideoComboBox.SelectedIndex != -1)
Expand Down Expand Up @@ -355,6 +354,8 @@ private void RenderSizeComboBox_SelectedIndexChanged(object sender, EventArgs e)
showFPS = tempFPS;
SetSettings();
}

SizeObjectsScale();
}
}

Expand Down Expand Up @@ -443,39 +444,35 @@ void UpdateDisplayMode()

void SizeObjectsScale()
{
int displayIndex = DisplaySizeComboBox.SelectedIndex;

int clientWidth = ClientSize.Width;
int clientHeight = ClientSize.Height;
int playerWidth = videoSourcePlayer1.ClientSize.Width;
int playerHeight = videoSourcePlayer1.ClientSize.Height;
int index = DisplaySizeComboBox.SelectedIndex;

RACCheck = true;

switch (displayIndex)
switch (index)
{
case 0:

AutoSize = false;
videoSourcePlayer1.Location = new Point((clientWidth - playerWidth) / 2, (clientHeight - playerHeight) / 2);
videoSourcePlayer1.Location = new Point((ClientSize.Width - videoSourcePlayer1.ClientSize.Width) / 2,
(ClientSize.Height - videoSourcePlayer1.ClientSize.Height) / 2);
AutoSize = true;
break;
case 1:
break;
case 2: // Cases 2, 3, and 4 are functionally identical, just with different values.
case 3: // These values are stored in the ratios array that is used
case 4: // Riiight here ----v
Vector2 displayRatio = ratios[displayIndex];

int test = (int)((clientWidth / displayRatio.X) * displayRatio.Y);
if (test > clientHeight)
test = (int)((clientHeight / displayRatio.Y) * displayRatio.X);
Vector2 displayRatio = ratios[index];

videoSourcePlayer1.Size = test > clientHeight ? new Size(test, clientHeight) : new Size(clientWidth, test);
int test = (int)((ClientSize.Width / displayRatio.X) * displayRatio.Y);
if (test > ClientSize.Height)
test = (int)((ClientSize.Height / displayRatio.Y) * displayRatio.X);

playerWidth = videoSourcePlayer1.ClientSize.Width;
playerHeight = videoSourcePlayer1.ClientSize.Height;
videoSourcePlayer1.Size = test > ClientSize.Height ? new Size(test, ClientSize.Height) :
new Size(ClientSize.Width, test);

videoSourcePlayer1.Location = new Point((clientWidth - playerWidth) / 2, (clientHeight - playerHeight) / 2);
videoSourcePlayer1.Location = new Point((ClientSize.Width - videoSourcePlayer1.ClientSize.Width) / 2,
(ClientSize.Height - videoSourcePlayer1.ClientSize.Height) / 2);
break;
default:
break;
}

Expand Down Expand Up @@ -548,30 +545,28 @@ private void Wave_DataAvailable(object sender, WaveInEventArgs e)
#region HotKeys
void HotKeyGroup(Keys e)
{
if (e == Keys.Escape)
Close();

if (e == Keys.F)
{
ToggleFullscreen();
InvokeDisplayLabel("Toggled Fullscreen...");
}

if (e == Keys.C)
ToggleFPS();

if (e == Keys.R)
{
InitalizeCamera();
AudioCapture();
InvokeDisplayLabel("Reinitialsed Inputs...");
}

if(e == Keys.Q)
switch (e)
{
GetDevicesLists(true);
InvokeDisplayLabel("Refreshed Inputs...");
}
case Keys.Escape:
Close();
break;
case Keys.F:
ToggleFullscreen();
InvokeDisplayLabel("Toggled Fullscreen...");
break;
case Keys.C:
ToggleFPS();
break;
case Keys.R:
InitalizeCamera();
AudioCapture();
InvokeDisplayLabel("Reinitialised Inputs...");
break;
case Keys.Q:
GetDevicesLists(true);
InvokeDisplayLabel("Refreshed Input List...");
break;
}
}

void InvokeDisplayLabel(string Input)
Expand Down

0 comments on commit c2a5987

Please sign in to comment.