Option to only show relevant settings

This commit is contained in:
N00MKRAD
2024-11-26 11:45:21 +01:00
parent a09b290f9a
commit 6e4cc8d552
7 changed files with 107 additions and 58 deletions

View File

@@ -121,7 +121,6 @@ namespace Flowframes.Data
return NetworksAll[0];
}
// New: Use enums
public static AiInfo GetAi(Ai ai)
{
if (AiLookup.TryGetValue(ai, out AiInfo aiObj))

View File

@@ -62,6 +62,9 @@ namespace Flowframes
{
try
{
if (str.IsEmpty())
return false;
return bool.Parse(str);
}
catch

View File

@@ -8,12 +8,30 @@ namespace Flowframes.Forms
public class CustomForm : Form
{
public Control FocusedControl { get { return this.GetControls().Where(c => c.Focused).FirstOrDefault(); } }
public List<Control> AllControls => GetAllControls(this);
public bool AllowTextboxTab { get; set; } = true;
public bool AllowEscClose { get; set; } = true;
private List<Control> _tabOrderedControls;
private static List<Control> GetAllControls(Control parent)
{
var controls = new List<Control>();
foreach (Control ctrl in parent.Controls)
{
controls.Add(ctrl);
if (ctrl.HasChildren)
{
controls.AddRange(GetAllControls(ctrl));
}
}
return controls;
}
public void TabOrderInit(List<Control> tabOrderedControls, int defaultFocusIndex = 0)
{
_tabOrderedControls = tabOrderedControls;

View File

@@ -60,9 +60,9 @@ namespace Flowframes.Forms.Main
}
}
private async void Form1_Load(object sender, EventArgs e)
private void Form1_Load(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
CheckForIllegalCrossThreadCalls = Debugger.IsAttached;
AutoScaleMode = AutoScaleMode.None;
}

View File

@@ -126,9 +126,11 @@
this.panTitleAiFramework = new System.Windows.Forms.Panel();
this.label32 = new System.Windows.Forms.Label();
this.panTorchGpus = new System.Windows.Forms.Panel();
this.tooltipTorchGpu = new System.Windows.Forms.PictureBox();
this.label33 = new System.Windows.Forms.Label();
this.torchGpus = new System.Windows.Forms.ComboBox();
this.panNcnnGpus = new System.Windows.Forms.Panel();
this.tooltipNcnnGpu = new System.Windows.Forms.PictureBox();
this.label5 = new System.Windows.Forms.Label();
this.ncnnGpus = new System.Windows.Forms.ComboBox();
this.panNcnnThreads = new System.Windows.Forms.Panel();
@@ -183,8 +185,8 @@
this.titleLabel = new System.Windows.Forms.Label();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.resetBtn = new HTAlt.WinForms.HTButton();
this.tooltipTorchGpu = new System.Windows.Forms.PictureBox();
this.tooltipNcnnGpu = new System.Windows.Forms.PictureBox();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.onlyShowRelevantSettings = new System.Windows.Forms.CheckBox();
this.settingsTabList.SuspendLayout();
this.generalTab.SuspendLayout();
this.flowPanelApplication.SuspendLayout();
@@ -220,7 +222,9 @@
this.flowPanelAiOptions.SuspendLayout();
this.panTitleAiFramework.SuspendLayout();
this.panTorchGpus.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.tooltipTorchGpu)).BeginInit();
this.panNcnnGpus.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.tooltipNcnnGpu)).BeginInit();
this.panNcnnThreads.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.ncnnThreads)).BeginInit();
this.panTitleRife.SuspendLayout();
@@ -231,8 +235,7 @@
this.vidExportTab.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.minOutVidLength)).BeginInit();
this.debugTab.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.tooltipTorchGpu)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tooltipNcnnGpu)).BeginInit();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// settingsTabList
@@ -249,7 +252,7 @@
this.settingsTabList.ForeColor = System.Drawing.Color.DodgerBlue;
this.settingsTabList.Location = new System.Drawing.Point(12, 62);
this.settingsTabList.Name = "settingsTabList";
this.settingsTabList.Size = new System.Drawing.Size(920, 779);
this.settingsTabList.Size = new System.Drawing.Size(920, 427);
this.settingsTabList.TabIndex = 0;
this.settingsTabList.SelectedIndexChanged += new System.EventHandler(this.settingsTabList_SelectedIndexChanged);
//
@@ -1320,7 +1323,7 @@
this.aiOptsPage.Controls.Add(this.flowPanelAiOptions);
this.aiOptsPage.ForeColor = System.Drawing.Color.White;
this.aiOptsPage.Name = "aiOptsPage";
this.aiOptsPage.Size = new System.Drawing.Size(762, 771);
this.aiOptsPage.Size = new System.Drawing.Size(762, 419);
this.aiOptsPage.Text = "AI Specific Options";
//
// flowPanelAiOptions
@@ -1339,7 +1342,7 @@
this.flowPanelAiOptions.Location = new System.Drawing.Point(0, 0);
this.flowPanelAiOptions.Margin = new System.Windows.Forms.Padding(0);
this.flowPanelAiOptions.Name = "flowPanelAiOptions";
this.flowPanelAiOptions.Size = new System.Drawing.Size(762, 771);
this.flowPanelAiOptions.Size = new System.Drawing.Size(762, 419);
this.flowPanelAiOptions.TabIndex = 95;
//
// panTitleAiFramework
@@ -1373,6 +1376,16 @@
this.panTorchGpus.Size = new System.Drawing.Size(762, 30);
this.panTorchGpus.TabIndex = 5;
//
// tooltipTorchGpu
//
this.tooltipTorchGpu.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer;
this.tooltipTorchGpu.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.tooltipTorchGpu.Location = new System.Drawing.Point(536, 7);
this.tooltipTorchGpu.Name = "tooltipTorchGpu";
this.tooltipTorchGpu.Size = new System.Drawing.Size(29, 21);
this.tooltipTorchGpu.TabIndex = 91;
this.tooltipTorchGpu.TabStop = false;
//
// label33
//
this.label33.AutoSize = true;
@@ -1405,6 +1418,16 @@
this.panNcnnGpus.Size = new System.Drawing.Size(762, 30);
this.panNcnnGpus.TabIndex = 6;
//
// tooltipNcnnGpu
//
this.tooltipNcnnGpu.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer;
this.tooltipNcnnGpu.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.tooltipNcnnGpu.Location = new System.Drawing.Point(536, 7);
this.tooltipNcnnGpu.Name = "tooltipNcnnGpu";
this.tooltipNcnnGpu.Size = new System.Drawing.Size(29, 21);
this.tooltipNcnnGpu.TabIndex = 92;
this.tooltipNcnnGpu.TabStop = false;
//
// label5
//
this.label5.AutoSize = true;
@@ -1885,7 +1908,7 @@
this.debugTab.Controls.Add(this.cmdDebugMode);
this.debugTab.ForeColor = System.Drawing.Color.White;
this.debugTab.Name = "debugTab";
this.debugTab.Size = new System.Drawing.Size(762, 419);
this.debugTab.Size = new System.Drawing.Size(762, 771);
this.debugTab.Text = "Developer Options";
//
// label7
@@ -2057,32 +2080,35 @@
this.resetBtn.UseVisualStyleBackColor = false;
this.resetBtn.Click += new System.EventHandler(this.resetBtn_Click);
//
// tooltipTorchGpu
// flowLayoutPanel1
//
this.tooltipTorchGpu.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer;
this.tooltipTorchGpu.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.tooltipTorchGpu.Location = new System.Drawing.Point(536, 7);
this.tooltipTorchGpu.Name = "tooltipTorchGpu";
this.tooltipTorchGpu.Size = new System.Drawing.Size(29, 21);
this.tooltipTorchGpu.TabIndex = 91;
this.tooltipTorchGpu.TabStop = false;
this.flowLayoutPanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.flowLayoutPanel1.Controls.Add(this.onlyShowRelevantSettings);
this.flowLayoutPanel1.Location = new System.Drawing.Point(683, 12);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(200, 40);
this.flowLayoutPanel1.TabIndex = 41;
//
// tooltipNcnnGpu
// onlyShowRelevantSettings
//
this.tooltipNcnnGpu.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer;
this.tooltipNcnnGpu.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.tooltipNcnnGpu.Location = new System.Drawing.Point(536, 7);
this.tooltipNcnnGpu.Name = "tooltipNcnnGpu";
this.tooltipNcnnGpu.Size = new System.Drawing.Size(29, 21);
this.tooltipNcnnGpu.TabIndex = 92;
this.tooltipNcnnGpu.TabStop = false;
this.onlyShowRelevantSettings.Checked = true;
this.onlyShowRelevantSettings.CheckState = System.Windows.Forms.CheckState.Checked;
this.onlyShowRelevantSettings.ForeColor = System.Drawing.Color.White;
this.onlyShowRelevantSettings.Location = new System.Drawing.Point(9, 3);
this.onlyShowRelevantSettings.Margin = new System.Windows.Forms.Padding(9, 3, 3, 3);
this.onlyShowRelevantSettings.Name = "onlyShowRelevantSettings";
this.onlyShowRelevantSettings.Size = new System.Drawing.Size(179, 34);
this.onlyShowRelevantSettings.TabIndex = 0;
this.onlyShowRelevantSettings.Text = "Only show relevant settings";
this.onlyShowRelevantSettings.UseVisualStyleBackColor = true;
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32)))));
this.ClientSize = new System.Drawing.Size(944, 853);
this.ClientSize = new System.Drawing.Size(944, 501);
this.Controls.Add(this.flowLayoutPanel1);
this.Controls.Add(this.resetBtn);
this.Controls.Add(this.titleLabel);
this.Controls.Add(this.settingsTabList);
@@ -2151,8 +2177,10 @@
this.panTitleAiFramework.PerformLayout();
this.panTorchGpus.ResumeLayout(false);
this.panTorchGpus.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.tooltipTorchGpu)).EndInit();
this.panNcnnGpus.ResumeLayout(false);
this.panNcnnGpus.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.tooltipNcnnGpu)).EndInit();
this.panNcnnThreads.ResumeLayout(false);
this.panNcnnThreads.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.ncnnThreads)).EndInit();
@@ -2171,8 +2199,7 @@
((System.ComponentModel.ISupportInitialize)(this.minOutVidLength)).EndInit();
this.debugTab.ResumeLayout(false);
this.debugTab.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.tooltipTorchGpu)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tooltipNcnnGpu)).EndInit();
this.flowLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -2335,5 +2362,7 @@
public System.Windows.Forms.Panel panDainNcnnTileSize;
private System.Windows.Forms.PictureBox tooltipTorchGpu;
private System.Windows.Forms.PictureBox tooltipNcnnGpu;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.CheckBox onlyShowRelevantSettings;
}
}

View File

@@ -14,15 +14,18 @@ using System.Windows.Forms;
namespace Flowframes.Forms
{
public partial class SettingsForm : Form
public partial class SettingsForm : CustomForm
{
bool initialized = false;
private bool _initialized = false;
private AiInfo _currentAi = null;
public SettingsForm(int index = 0)
public SettingsForm(int tabIndex = 0, AiInfo currentAi = null)
{
AutoScaleMode = AutoScaleMode.None;
InitializeComponent();
settingsTabList.SelectedIndex = index;
_currentAi = currentAi == null ? Program.mainForm.GetAi() : currentAi;
settingsTabList.SelectedIndex = tabIndex;
}
private void SettingsForm_Load(object sender, EventArgs e)
@@ -30,12 +33,13 @@ namespace Flowframes.Forms
MinimumSize = new Size(Width, Height);
MaximumSize = new Size(Width, (Height * 1.5f).RoundToInt());
mpdecimateMode.FillFromEnum<Enums.Interpolation.MpDecimateSens>(useKeyNames: true);
onlyShowRelevantSettings.Click += (s, ea) => SetVisibility();
InitGpus();
InitServers();
LoadSettings();
AddTooltipClickFunction();
initialized = true;
_initialized = true;
Task.Run(() => CheckModelCacheSize());
}
@@ -105,6 +109,7 @@ namespace Flowframes.Forms
ncnnGpus.Text = ncnnGpus.Text.Replace(" ", "");
// General
ConfigParser.SaveGuiElement(onlyShowRelevantSettings);
ConfigParser.SaveComboxIndex(processingMode);
ConfigParser.SaveGuiElement(maxVidHeight, ConfigParser.StringMode.Int);
ConfigParser.SaveComboxIndex(tempFolderLoc);
@@ -150,6 +155,7 @@ namespace Flowframes.Forms
void LoadSettings()
{
ConfigParser.LoadGuiElement(onlyShowRelevantSettings);
// General
ConfigParser.LoadComboxIndex(processingMode);
ConfigParser.LoadGuiElement(maxVidHeight);
@@ -196,6 +202,8 @@ namespace Flowframes.Forms
private void SetVisibility()
{
bool onlyRelevant = onlyShowRelevantSettings.Checked;
// Dev options
List<Control> devOptions = new List<Control> { panKeepTempFolder, };
devOptions.ForEach(c => c.SetVisible(Program.Debug));
@@ -205,37 +213,27 @@ namespace Flowframes.Forms
legacyUntestedOptions.ForEach(c => c.SetVisible(Program.Debug));
// AutoEnc options
bool autoEncEnabled = autoEncMode.SelectedIndex != 0;
bool autoEncPossible = !_currentAi.Piped;
autoEncMode.Visible = !(onlyRelevant && !autoEncPossible);
bool autoEncEnabled = autoEncMode.Visible && autoEncMode.SelectedIndex != 0;
List<Control> autoEncOptions = new List<Control> { panAutoEncBackups, panAutoEncLowSpaceMode };
autoEncOptions.ForEach(c => c.SetVisible(autoEncEnabled));
panAutoEncInSbsMode.SetVisible(autoEncEnabled && panProcessingStyle.Visible);
var availAis = Implementations.NetworksAvailable;
panTorchGpus.SetVisible(NvApi.NvGpus.Count > 0 && Python.IsPytorchReady());
panNcnnGpus.SetVisible(VulkanUtils.VkDevices.Count > 0);
panRifeCudaHalfPrec.SetVisible(NvApi.NvGpus.Count > 0 && availAis.Contains(Implementations.rifeCuda));
}
private static List<Control> GetAllControls(Control parent)
{
var controls = new List<Control>();
foreach (Control ctrl in parent.Controls)
{
controls.Add(ctrl);
if (ctrl.HasChildren)
{
controls.AddRange(GetAllControls(ctrl));
}
}
return controls;
bool showTorchSettings = !(onlyRelevant && _currentAi.Backend != AiInfo.AiBackend.Pytorch);
panTorchGpus.SetVisible(showTorchSettings && NvApi.NvGpus.Count > 0 && Python.IsPytorchReady());
bool showNcnnSettings = !(onlyRelevant && _currentAi.Backend != AiInfo.AiBackend.Ncnn);
panNcnnGpus.SetVisible(showNcnnSettings && VulkanUtils.VkDevices.Count > 0);
bool showRifeCudaSettings = !(onlyRelevant && _currentAi != Implementations.rifeCuda);
panRifeCudaHalfPrec.SetVisible(showRifeCudaSettings && NvApi.NvGpus.Count > 0 && availAis.Contains(Implementations.rifeCuda));
bool showDainNcnnSettings = !(onlyRelevant && _currentAi != Implementations.dainNcnn);
new List<Control> { panTitleDainNcnn, panDainNcnnTileSize }.ForEach(c => c.SetVisible(showDainNcnnSettings && availAis.Contains(Implementations.dainNcnn)));
}
private void AddTooltipClickFunction()
{
foreach (Control control in GetAllControls(this))
foreach (Control control in AllControls)
{
if(!(control is PictureBox))
continue;
@@ -283,7 +281,7 @@ namespace Flowframes.Forms
private void cmdDebugMode_SelectedIndexChanged(object sender, EventArgs e)
{
if (initialized && cmdDebugMode.SelectedIndex == 2)
if (_initialized && cmdDebugMode.SelectedIndex == 2)
UiUtils.ShowMessageBox("If you enable this, you need to close the CMD window manually after the process has finished, otherwise processing will be paused!", UiUtils.MessageType.Warning);
}

View File

@@ -259,6 +259,7 @@ namespace Flowframes.IO
return WriteDefault(keyStr, "");
}
if (key == Key.onlyShowRelevantSettings) return WriteDefault(key, true);
if (key == Key.disablePreview) return WriteDefault(key, true);
if (key == Key.maxVidHeight) return WriteDefault(key, "2160");
if (key == Key.clearLogOnInput) return WriteDefault(key, true);
@@ -368,6 +369,7 @@ namespace Flowframes.IO
mpdecimateMode,
ncnnGpus,
ncnnThreads,
onlyShowRelevantSettings,
opusBitrate,
processingMode,
rifeCudaBufferSize,