|
@@ -20,7 +20,7 @@ public partial class MainForm : Form
|
|
|
private Dictionary<ChildProcessKind, ChildProcessControlGroup> childProcessControlGroups;
|
|
|
|
|
|
private readonly IEnumerator<string> txtAni = TextAnimation.LoadingTextSeq(8).GetEnumerator();
|
|
|
- private string mainControlStatusText = "摸鱼中";
|
|
|
+ private string mainControlStatusText = "摸鱼中,你可以按一键启动了";
|
|
|
private bool mainControlStatusTextAnimation = false;
|
|
|
|
|
|
private DateTime lastCheckSinMaiMainWinPos = DateTime.Now;
|
|
@@ -30,10 +30,13 @@ public partial class MainForm : Form
|
|
|
|
|
|
private CameraInterops.CameraCaptureWrap? cameraCapture;
|
|
|
private bool cameraMax = false;
|
|
|
+ private Rectangle cameraRestoreRect;
|
|
|
+ private Form cameraRestoreFloatPanel = new Form { FormBorderStyle = FormBorderStyle.None, Opacity = 0.005 };
|
|
|
|
|
|
public MainForm()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
+ cameraRestoreFloatPanel.Click += CameraRestoreFloatPanel_Click;
|
|
|
}
|
|
|
|
|
|
private WindowInterops.MoveWindowResult MoveSinMaiMainWindow()
|
|
@@ -62,6 +65,115 @@ public partial class MainForm : Form
|
|
|
ExplorerInterops.OpenWindow(holdingExplorerWindowPaths);
|
|
|
}
|
|
|
|
|
|
+ private void CameraAutoPlace()
|
|
|
+ {
|
|
|
+ cameraRestoreRect = new(Location, Size);
|
|
|
+
|
|
|
+ FormBorderStyle = FormBorderStyle.None;
|
|
|
+ picBoxCamera.Parent = this;
|
|
|
+ WindowInterops.Maximize(picBoxCamera.Handle);
|
|
|
+
|
|
|
+ Top = TargetTop;
|
|
|
+ Height = TargetHeight;
|
|
|
+
|
|
|
+ if (cboCameraFormats.SelectedItem is CameraInterops.CameraCaptureWrap.ICameraFormat fmt)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ var r = (double)fmt.Width / fmt.Height;
|
|
|
+ Width = (int)(Height * r);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (rdoCameraPlaceLeft.Checked)
|
|
|
+ {
|
|
|
+ Left = 0;
|
|
|
+ }
|
|
|
+ else if (rdoCameraPlaceRight.Checked)
|
|
|
+ {
|
|
|
+ Left = Screen.PrimaryScreen.Bounds.Right - Width;
|
|
|
+ }
|
|
|
+
|
|
|
+ cameraRestoreFloatPanel.Visible = true;
|
|
|
+ cameraRestoreFloatPanel.Width = Width;
|
|
|
+ cameraRestoreFloatPanel.Height = 200;
|
|
|
+ cameraRestoreFloatPanel.Left = Left;
|
|
|
+ cameraRestoreFloatPanel.Top = Top - cameraRestoreFloatPanel.Height;
|
|
|
+
|
|
|
+ cameraMax = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CameraRestore()
|
|
|
+ {
|
|
|
+ FormBorderStyle = FormBorderStyle.Sizable;
|
|
|
+ picBoxCamera.Parent = pnlCamera;
|
|
|
+ WindowInterops.Normal(picBoxCamera.Handle);
|
|
|
+ cameraMax = false;
|
|
|
+
|
|
|
+ cameraRestoreFloatPanel.Visible = false;
|
|
|
+ Location = cameraRestoreRect.Location;
|
|
|
+ Size = cameraRestoreRect.Size;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private Padding GetControlMarginsRelativeToForm(Control control)
|
|
|
+ {
|
|
|
+ var leftMargin = 0;
|
|
|
+ var topMargin = 0;
|
|
|
+ var rightMargin = 0;
|
|
|
+ var bottomMargin = 0;
|
|
|
+
|
|
|
+ var current = control;
|
|
|
+ while (current != null && current != this)
|
|
|
+ {
|
|
|
+
|
|
|
+ leftMargin += current.Left;
|
|
|
+ topMargin += current.Top;
|
|
|
+
|
|
|
+ if (current.Parent != null)
|
|
|
+ {
|
|
|
+ var parentPadding = current.Parent.Padding;
|
|
|
+ leftMargin += parentPadding.Left;
|
|
|
+ topMargin += parentPadding.Top;
|
|
|
+
|
|
|
+ rightMargin += (current.Parent.ClientSize.Width - current.Right) + parentPadding.Right;
|
|
|
+ bottomMargin += (current.Parent.ClientSize.Height - current.Bottom) + parentPadding.Bottom;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (current is TabPage && current.Parent is TabControl tabControl)
|
|
|
+ {
|
|
|
+
|
|
|
+ var displayRect = tabControl.DisplayRectangle;
|
|
|
+ var controlRect = tabControl.ClientRectangle;
|
|
|
+
|
|
|
+ switch (tabControl.Alignment)
|
|
|
+ {
|
|
|
+ case TabAlignment.Top:
|
|
|
+ topMargin += (controlRect.Height - displayRect.Height);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case TabAlignment.Bottom:
|
|
|
+ bottomMargin += (controlRect.Height - displayRect.Height);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case TabAlignment.Left:
|
|
|
+ leftMargin += (controlRect.Width - displayRect.Width);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case TabAlignment.Right:
|
|
|
+ rightMargin += (controlRect.Width - displayRect.Width);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ current = current.Parent;
|
|
|
+ }
|
|
|
+
|
|
|
+ return new Padding(leftMargin, topMargin, rightMargin, bottomMargin);
|
|
|
+ }
|
|
|
+
|
|
|
private async void MainForm_Shown(object sender, EventArgs e)
|
|
|
{
|
|
|
TopMost = false;
|
|
@@ -482,7 +594,7 @@ public partial class MainForm : Form
|
|
|
|
|
|
if (lastCheckSysVolume < DateTime.Now.AddSeconds(-1))
|
|
|
{
|
|
|
- lastCheckSinMaiMainWinPos = DateTime.Now;
|
|
|
+ lastCheckSysVolume = DateTime.Now;
|
|
|
var sv = SystemAudioVolumeInterop.GetVolume();
|
|
|
lblSysVolume.Text = sv.HasValue ? $"{sv:N2}%" : "-";
|
|
|
}
|
|
@@ -679,47 +791,45 @@ public partial class MainForm : Form
|
|
|
private void cboCameraFormats_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
if (cboCameraFormats.SelectedItem != null)
|
|
|
- cameraCapture?.ApplySelectedFormat((CameraInterops.CameraCaptureWrap.ICameraFormat)cboCameraFormats.SelectedItem);
|
|
|
+ {
|
|
|
+ var selectedItem = (CameraInterops.CameraCaptureWrap.ICameraFormat)cboCameraFormats.SelectedItem;
|
|
|
+ cameraCapture?.ApplySelectedFormat(selectedItem);
|
|
|
+
|
|
|
+ var pad = GetControlMarginsRelativeToForm(pnlCamera);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ var r = (double)selectedItem.Width / selectedItem.Height;
|
|
|
+ var h = TargetWidth / r;
|
|
|
+
|
|
|
+ Width = pad.Left + pad.Right + TargetWidth;
|
|
|
+ Height = pad.Top + pad.Bottom + (int)h;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CameraRestoreFloatPanel_Click(object? sender, EventArgs e)
|
|
|
+ {
|
|
|
+ CameraRestore();
|
|
|
}
|
|
|
|
|
|
private void picBoxCamera_CameraClick(object sender, EventArgs e)
|
|
|
{
|
|
|
if (cameraMax)
|
|
|
{
|
|
|
- FormBorderStyle = FormBorderStyle.Sizable;
|
|
|
- picBoxCamera.Parent = pnlCamera;
|
|
|
- WindowInterops.Normal(picBoxCamera.Handle);
|
|
|
- cameraMax = false;
|
|
|
+ CameraRestore();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- FormBorderStyle = FormBorderStyle.None;
|
|
|
- picBoxCamera.Parent = this;
|
|
|
- WindowInterops.Maximize(picBoxCamera.Handle);
|
|
|
-
|
|
|
- Top = TargetTop;
|
|
|
- Height = TargetHeight;
|
|
|
-
|
|
|
- if (cboCameraFormats.SelectedItem is CameraInterops.CameraCaptureWrap.ICameraFormat fmt)
|
|
|
- {
|
|
|
- var r = (double)fmt.Width / fmt.Height;
|
|
|
-
|
|
|
-
|
|
|
- Width = (int)(Height * r);
|
|
|
- }
|
|
|
-
|
|
|
- cameraMax = true;
|
|
|
+ CameraAutoPlace();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (rdoCameraPlaceLeft.Checked)
|
|
|
- {
|
|
|
- Left = 0;
|
|
|
- }
|
|
|
- else if (rdoCameraPlaceRight.Checked)
|
|
|
+ private void tcMain_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (tcMain.SelectedTab == tpConsoles)
|
|
|
{
|
|
|
- Left = Screen.PrimaryScreen.Bounds.Right - Width;
|
|
|
+ Height++;
|
|
|
+ Height--;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|