From 8a3b4ebd80f1c25780b9dcb5940b30305e1b82d8 Mon Sep 17 00:00:00 2001
From: N00MKRAD <61149547+n00mkrad@users.noreply.github.com>
Date: Sat, 28 Sep 2024 21:33:36 +0200
Subject: [PATCH] CLI mode (hide window)
---
CodeLegacy/Flowframes.csproj | 30 ++++++++++++++++++++-----
CodeLegacy/Flowframes.sln | 10 +++++++--
CodeLegacy/Forms/Main/Form1.cs | 30 ++++++++++++++++++++++---
CodeLegacy/Forms/SplashForm.Designer.cs | 7 +++++-
CodeLegacy/Forms/SplashForm.cs | 18 +++++++--------
CodeLegacy/Program.cs | 3 +++
CodeLegacy/Ui/GetWebInfo.cs | 4 ++--
7 files changed, 79 insertions(+), 23 deletions(-)
diff --git a/CodeLegacy/Flowframes.csproj b/CodeLegacy/Flowframes.csproj
index 1a7da75..c6466f9 100644
--- a/CodeLegacy/Flowframes.csproj
+++ b/CodeLegacy/Flowframes.csproj
@@ -3,11 +3,14 @@
+
+ WINDOWS_APP
+
Debug
AnyCPU
{389E42DD-A163-49D7-9E0A-AE41090A07B3}
- WinExe
+ Exe
Flowframes
Flowframes
v4.7.2
@@ -66,10 +69,11 @@
7.3
prompt
MinimumRecommendedRules.ruleset
- true
+ false
- bin\x64\Release\
+ bin\RelGui
+ WinExe
DEBUG;TRACE
false
pdbonly
@@ -77,8 +81,22 @@
7.3
prompt
MinimumRecommendedRules.ruleset
- true
- true
+ false
+ false
+ Off
+
+
+ bin\RelCmd
+ Exe
+ DEBUG;TRACE
+ false
+ pdbonly
+ x64
+ 7.3
+ prompt
+ MinimumRecommendedRules.ruleset
+ false
+ false
Off
@@ -645,7 +663,7 @@
-
+
$(MSBuildThisFileDirectory)bin\x64\Release
diff --git a/CodeLegacy/Flowframes.sln b/CodeLegacy/Flowframes.sln
index 163ede5..4a949f6 100644
--- a/CodeLegacy/Flowframes.sln
+++ b/CodeLegacy/Flowframes.sln
@@ -1,18 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.30413.136
+# Visual Studio Version 17
+VisualStudioVersion = 17.11.35303.130
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flowframes", "Flowframes.csproj", "{389E42DD-A163-49D7-9E0A-AE41090A07B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ ConsoleRelease|Any CPU = ConsoleRelease|Any CPU
+ ConsoleRelease|x64 = ConsoleRelease|x64
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {389E42DD-A163-49D7-9E0A-AE41090A07B3}.ConsoleRelease|Any CPU.ActiveCfg = ConsoleRelease|Any CPU
+ {389E42DD-A163-49D7-9E0A-AE41090A07B3}.ConsoleRelease|Any CPU.Build.0 = ConsoleRelease|Any CPU
+ {389E42DD-A163-49D7-9E0A-AE41090A07B3}.ConsoleRelease|x64.ActiveCfg = ConsoleRelease|x64
+ {389E42DD-A163-49D7-9E0A-AE41090A07B3}.ConsoleRelease|x64.Build.0 = ConsoleRelease|x64
{389E42DD-A163-49D7-9E0A-AE41090A07B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{389E42DD-A163-49D7-9E0A-AE41090A07B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{389E42DD-A163-49D7-9E0A-AE41090A07B3}.Debug|x64.ActiveCfg = Debug|x64
diff --git a/CodeLegacy/Forms/Main/Form1.cs b/CodeLegacy/Forms/Main/Form1.cs
index 76aff95..94325b4 100644
--- a/CodeLegacy/Forms/Main/Form1.cs
+++ b/CodeLegacy/Forms/Main/Form1.cs
@@ -34,9 +34,31 @@ namespace Flowframes.Forms.Main
public bool ShowModelDownloader = false;
+ protected override CreateParams CreateParams
+ {
+ get
+ {
+ CreateParams cp = base.CreateParams;
+ if (Program.CmdMode)
+ {
+ const int WS_EX_TOOLWINDOW = 0x80;
+ cp.ExStyle |= WS_EX_TOOLWINDOW; // Makes the window not appear in Alt-Tab
+ }
+ return cp;
+ }
+ }
+
public Form1()
{
InitializeComponent();
+
+ new SplashForm().Show();
+
+ if (Program.CmdMode)
+ {
+ ShowInTaskbar = false;
+ Opacity = 0;
+ }
}
private async void Form1_Load(object sender, EventArgs e)
@@ -47,7 +69,6 @@ namespace Flowframes.Forms.Main
private async void Form1_Shown(object sender, EventArgs e)
{
- new SplashForm().Show();
Refresh();
await Task.Delay(1);
@@ -439,7 +460,10 @@ namespace Flowframes.Forms.Main
public void Initialized()
{
Application.OpenForms.OfType().ToList().ForEach(f => f.Close());
- Opacity = 1.0f;
+
+ if (!Program.CmdMode)
+ Opacity = 1.0f;
+
_initialized = true;
runBtn.Enabled = true;
SetStatus("Ready");
@@ -852,7 +876,7 @@ namespace Flowframes.Forms.Main
float inFps = fpsInTbox.GetFloat();
float outFps = fpsOutTbox.GetFloat();
- if(inFps == 0 || outFps == 0)
+ if (inFps == 0 || outFps == 0)
return;
var targetFactorRounded = Math.Round((Decimal)(outFps / inFps), 3, MidpointRounding.AwayFromZero);
diff --git a/CodeLegacy/Forms/SplashForm.Designer.cs b/CodeLegacy/Forms/SplashForm.Designer.cs
index a38bb47..311d3a2 100644
--- a/CodeLegacy/Forms/SplashForm.Designer.cs
+++ b/CodeLegacy/Forms/SplashForm.Designer.cs
@@ -53,14 +53,19 @@
this.ClientSize = new System.Drawing.Size(480, 220);
this.Controls.Add(this.loadingTextLabel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(480, 220);
+ this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(480, 220);
this.Name = "SplashForm";
+ this.Opacity = 0D;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "SplashForm";
+ this.Text = "Flowframes";
+ this.TopMost = true;
this.UseWaitCursor = true;
+ this.Load += new System.EventHandler(this.SplashForm_Load);
this.ResumeLayout(false);
}
diff --git a/CodeLegacy/Forms/SplashForm.cs b/CodeLegacy/Forms/SplashForm.cs
index 454efdd..8b4be5b 100644
--- a/CodeLegacy/Forms/SplashForm.cs
+++ b/CodeLegacy/Forms/SplashForm.cs
@@ -1,12 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
+using System.Windows.Forms;
namespace Flowframes.Forms
{
@@ -16,5 +8,13 @@ namespace Flowframes.Forms
{
InitializeComponent();
}
+
+ private void SplashForm_Load(object sender, System.EventArgs e)
+ {
+ if (!Program.CmdMode)
+ {
+ Opacity = 1f;
+ }
+ }
}
}
diff --git a/CodeLegacy/Program.cs b/CodeLegacy/Program.cs
index 2fe08dc..8d71cc9 100644
--- a/CodeLegacy/Program.cs
+++ b/CodeLegacy/Program.cs
@@ -28,10 +28,13 @@ namespace Flowframes
public static bool lastInputPathIsSsd;
public static Queue batchQueue = new Queue();
+ public static bool CmdMode = false;
[STAThread]
static void Main()
{
+ CmdMode = new FileInfo(Paths.GetExe()).Name.Contains("Cmd");
+
// Force culture to en-US across entire application (to avoid number parsing issues etc)
var culture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = culture;
diff --git a/CodeLegacy/Ui/GetWebInfo.cs b/CodeLegacy/Ui/GetWebInfo.cs
index 397a9f5..ae4ad03 100644
--- a/CodeLegacy/Ui/GetWebInfo.cs
+++ b/CodeLegacy/Ui/GetWebInfo.cs
@@ -43,7 +43,7 @@ namespace Flowframes.Ui
{
try
{
- Logger.Log("Parsing Patrons from CSV...", true);
+ // Logger.Log("Parsing Patrons from CSV...", true);
List goldPatrons = new List();
List silverPatrons = new List();
string str = "Gold:\n";
@@ -68,7 +68,7 @@ namespace Flowframes.Ui
}
}
- Logger.Log($"Found {goldPatrons.Count} Gold Patrons, {silverPatrons.Count} Silver Patrons", true);
+ // Logger.Log($"Found {goldPatrons.Count} Gold Patrons, {silverPatrons.Count} Silver Patrons", true);
foreach (string pat in goldPatrons)
str += pat + "\n";