mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-24 12:19:27 +01:00
Save/load output settings, some refactoring
This commit is contained in:
@@ -380,6 +380,9 @@
|
||||
<Compile Include="Forms\DebugForm.Designer.cs">
|
||||
<DependentUpon>DebugForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Main\Form1.Properties.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\MessageForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -451,10 +454,10 @@
|
||||
<Compile Include="MiscUtils\ParseUtils.cs" />
|
||||
<Compile Include="Os\AiProcess.cs" />
|
||||
<Compile Include="Extensions\ExtensionMethods.cs" />
|
||||
<Compile Include="Form1.cs">
|
||||
<Compile Include="Forms\Main\Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<Compile Include="Forms\Main\Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Main\Interpolate.cs" />
|
||||
@@ -484,7 +487,7 @@
|
||||
<Compile Include="Ui\QuickSettingsTab.cs" />
|
||||
<Compile Include="Utilities\ColorDataUtils.cs" />
|
||||
<Compile Include="Utilities\NcnnUtils.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<EmbeddedResource Include="Forms\Main\Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Flowframes
|
||||
namespace Flowframes.Forms.Main
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
74
Code/Forms/Main/Form1.Properties.cs
Normal file
74
Code/Forms/Main/Form1.Properties.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using Flowframes.Data;
|
||||
using Flowframes.Main;
|
||||
using Flowframes.MiscUtils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flowframes.Forms.Main
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
Enums.Output.Format OutputFormat { get { return ParseUtils.GetEnum<Enums.Output.Format>(comboxOutputFormat.Text, true, Strings.OutputFormat); } }
|
||||
|
||||
Enums.Encoding.Encoder Encoder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (comboxOutputEncoder.Visible)
|
||||
return ParseUtils.GetEnum<Enums.Encoding.Encoder>(comboxOutputEncoder.Text, true, Strings.Encoder);
|
||||
else
|
||||
return (Enums.Encoding.Encoder)(-1);
|
||||
}
|
||||
}
|
||||
|
||||
Enums.Encoding.PixelFormat PixelFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
if (comboxOutputColors.Visible)
|
||||
return ParseUtils.GetEnum<Enums.Encoding.PixelFormat>(comboxOutputColors.Text, true, Strings.PixelFormat);
|
||||
else
|
||||
return (Enums.Encoding.PixelFormat)(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public ModelCollection.ModelInfo GetModel(AI currentAi)
|
||||
{
|
||||
try
|
||||
{
|
||||
return AiModels.GetModels(currentAi).Models[aiModel.SelectedIndex];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public AI GetAi()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (AI ai in Implementations.NetworksAll)
|
||||
{
|
||||
if (GetAiComboboxName(ai) == aiCombox.Text)
|
||||
return ai;
|
||||
}
|
||||
|
||||
return Implementations.NetworksAvailable[0];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public OutputSettings GetOutputSettings()
|
||||
{
|
||||
string custQ = textboxOutputQualityCust.Visible ? textboxOutputQualityCust.Text.Trim() : "";
|
||||
return new OutputSettings() { Encoder = Encoder, Format = OutputFormat, PixelFormat = PixelFormat, Quality = comboxOutputQuality.Text, CustomQuality = custQ };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable IDE1006
|
||||
|
||||
namespace Flowframes
|
||||
namespace Flowframes.Forms.Main
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
@@ -29,8 +29,9 @@ namespace Flowframes
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags); // PREVENT WINDOWS FROM GOING TO SLEEP
|
||||
|
||||
public bool initialized = false;
|
||||
public bool quickSettingsInitialized = false;
|
||||
private bool _initialized = false;
|
||||
private bool _mainTabInitialized = false;
|
||||
private bool _quickSettingsInitialized = false;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
@@ -337,9 +338,18 @@ namespace Flowframes
|
||||
return ai.FriendlyName + " - " + ai.Description;
|
||||
}
|
||||
|
||||
private void InitializeMainTab ()
|
||||
{
|
||||
if (_mainTabInitialized)
|
||||
return;
|
||||
|
||||
LoadOutputSettings();
|
||||
_mainTabInitialized = true;
|
||||
}
|
||||
|
||||
public void Initialized()
|
||||
{
|
||||
initialized = true;
|
||||
_initialized = true;
|
||||
runBtn.Enabled = true;
|
||||
}
|
||||
|
||||
@@ -378,7 +388,7 @@ namespace Flowframes
|
||||
Interpolate.currentSettings = GetCurrentSettings();
|
||||
|
||||
AiProcessSuspend.Reset();
|
||||
|
||||
SaveOutputSettings();
|
||||
|
||||
if (Interpolate.currentSettings.outSettings.Format == Enums.Output.Format.Realtime)
|
||||
{
|
||||
@@ -391,33 +401,27 @@ namespace Flowframes
|
||||
}
|
||||
}
|
||||
|
||||
public ModelCollection.ModelInfo GetModel(AI currentAi)
|
||||
private void SaveOutputSettings ()
|
||||
{
|
||||
try
|
||||
{
|
||||
return AiModels.GetModels(currentAi).Models[aiModel.SelectedIndex];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var strings = new List<string>();
|
||||
if (comboxOutputFormat.Visible) strings.Add(comboxOutputFormat.Text);
|
||||
if (comboxOutputEncoder.Visible) strings.Add(comboxOutputEncoder.Text);
|
||||
if (comboxOutputQuality.Visible) strings.Add(comboxOutputQuality.Text);
|
||||
if (comboxOutputColors.Visible) strings.Add(comboxOutputColors.Text);
|
||||
Config.Set(Config.Key.lastOutputSettings, string.Join(",", strings));
|
||||
}
|
||||
|
||||
Enums.Output.Format GetOutputFormat { get { return ParseUtils.GetEnum<Enums.Output.Format>(comboxOutputFormat.Text, true, Strings.OutputFormat); } }
|
||||
Enums.Encoding.Encoder GetEncoder { get { return ParseUtils.GetEnum<Enums.Encoding.Encoder>(comboxOutputEncoder.Text, true, Strings.Encoder); } }
|
||||
|
||||
private Enums.Encoding.PixelFormat GetPixelFormat()
|
||||
private void LoadOutputSettings()
|
||||
{
|
||||
if (!comboxOutputColors.Visible)
|
||||
return (Enums.Encoding.PixelFormat)(-1);
|
||||
string[] strings = Config.Get(Config.Key.lastOutputSettings).Split(',');
|
||||
|
||||
return ParseUtils.GetEnum<Enums.Encoding.PixelFormat>(comboxOutputColors.Text, true, Strings.PixelFormat);
|
||||
}
|
||||
if (strings.Length < 4)
|
||||
return;
|
||||
|
||||
public OutputSettings GetOutputSettings()
|
||||
{
|
||||
string custQ = textboxOutputQualityCust.Visible ? textboxOutputQualityCust.Text.Trim() : "";
|
||||
return new OutputSettings() { Encoder = GetEncoder, Format = GetOutputFormat, PixelFormat = GetPixelFormat(), Quality = comboxOutputQuality.Text, CustomQuality = custQ };
|
||||
if (comboxOutputFormat.Visible) comboxOutputFormat.Text = strings[0];
|
||||
if (comboxOutputEncoder.Visible) comboxOutputEncoder.Text = strings[1];
|
||||
if (comboxOutputQuality.Visible) comboxOutputQuality.Text = strings[2];
|
||||
if (comboxOutputColors.Visible) comboxOutputColors.Text = strings[3];
|
||||
}
|
||||
|
||||
public void SetFormat(Enums.Output.Format format)
|
||||
@@ -425,25 +429,6 @@ namespace Flowframes
|
||||
comboxOutputFormat.Text = Strings.OutputFormat.Get(format.ToString());
|
||||
}
|
||||
|
||||
public AI GetAi()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (AI ai in Implementations.NetworksAll)
|
||||
{
|
||||
if (GetAiComboboxName(ai) == aiCombox.Text)
|
||||
return ai;
|
||||
}
|
||||
|
||||
Logger.Log($"AI implementation lookup failed! This should not happen! Please tell the developer!");
|
||||
return Implementations.NetworksAvailable[0];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void inputTbox_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Copy; }
|
||||
|
||||
private void inputTbox_DragDrop(object sender, DragEventArgs e)
|
||||
@@ -530,7 +515,7 @@ namespace Flowframes
|
||||
|
||||
interpFactorCombox.SelectedIndex = 0;
|
||||
|
||||
if (initialized)
|
||||
if (_initialized)
|
||||
Config.Set(Config.Key.lastUsedAiName, GetAi().NameInternal);
|
||||
|
||||
interpFactorCombox_SelectedIndexChanged(null, null);
|
||||
@@ -690,8 +675,13 @@ namespace Flowframes
|
||||
|
||||
private void mainTabControl_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!initialized) return;
|
||||
aiCombox_SelectedIndexChanged(null, null);
|
||||
if (!_initialized) return;
|
||||
|
||||
if(mainTabControl.SelectedTab == interpOptsTab)
|
||||
{
|
||||
aiCombox_SelectedIndexChanged(null, null);
|
||||
InitializeMainTab();
|
||||
}
|
||||
}
|
||||
|
||||
private void trimCombox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
@@ -720,7 +710,7 @@ namespace Flowframes
|
||||
|
||||
public void SaveQuickSettings(object sender, EventArgs e)
|
||||
{
|
||||
if (!quickSettingsInitialized) return;
|
||||
if (!_quickSettingsInitialized) return;
|
||||
|
||||
if (Program.busy)
|
||||
LoadQuickSettings(); // Discard any changes if busy
|
||||
@@ -746,7 +736,7 @@ namespace Flowframes
|
||||
ConfigParser.LoadGuiElement(scnDetectValue);
|
||||
ConfigParser.LoadGuiElement(maxFps);
|
||||
|
||||
quickSettingsInitialized = true;
|
||||
_quickSettingsInitialized = true;
|
||||
}
|
||||
|
||||
private void dedupMode_SelectedIndexChanged(object sender, EventArgs e)
|
||||
@@ -360,7 +360,8 @@ namespace Flowframes.IO
|
||||
torchGpus,
|
||||
uhdThresh,
|
||||
vsRtShowOsd,
|
||||
vsUseLsmash
|
||||
vsUseLsmash,
|
||||
lastOutputSettings,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Flowframes.MiscUtils;
|
||||
using Flowframes.Forms.Main;
|
||||
using Flowframes.MiscUtils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Flowframes.Data;
|
||||
using Flowframes.Forms;
|
||||
using Flowframes.Forms.Main;
|
||||
using Flowframes.IO;
|
||||
using Flowframes.MiscUtils;
|
||||
using Flowframes.Os;
|
||||
|
||||
Reference in New Issue
Block a user