mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-17 08:57:47 +01:00
Completely revamped output settings (quality settings WIP)
This commit is contained in:
@@ -10,6 +10,7 @@ using System.Windows.Forms;
|
||||
using Flowframes.Data;
|
||||
using System.Management.Automation;
|
||||
using System.Drawing;
|
||||
using Flowframes.MiscUtils;
|
||||
|
||||
namespace Flowframes
|
||||
{
|
||||
@@ -271,5 +272,99 @@ namespace Flowframes
|
||||
{
|
||||
return $"{(filePath.IsConcatFile() ? filePath.GetConcStr() : "")} -i {filePath.Wrap()}";
|
||||
}
|
||||
|
||||
public static string Get(this Dictionary<string, string> dict, string key, bool returnKeyInsteadOfEmptyString = false, bool ignoreCase = false)
|
||||
{
|
||||
if (key == null)
|
||||
key = "";
|
||||
|
||||
for (int i = 0; i < dict.Count; i++)
|
||||
{
|
||||
if (ignoreCase)
|
||||
{
|
||||
if (key.Lower() == dict.ElementAt(i).Key.Lower())
|
||||
return dict.ElementAt(i).Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key == dict.ElementAt(i).Key)
|
||||
return dict.ElementAt(i).Value;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnKeyInsteadOfEmptyString)
|
||||
return key;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void FillFromEnum<TEnum>(this ComboBox comboBox, Dictionary<string, string> stringMap = null, int defaultIndex = -1, List<TEnum> exclusionList = null) where TEnum : Enum
|
||||
{
|
||||
if (stringMap == null)
|
||||
stringMap = new Dictionary<string, string>();
|
||||
|
||||
if (exclusionList == null)
|
||||
exclusionList = new List<TEnum>();
|
||||
|
||||
comboBox.Items.Clear();
|
||||
var entriesToAdd = Enum.GetValues(typeof(TEnum)).Cast<TEnum>().Except(exclusionList);
|
||||
comboBox.Items.AddRange(entriesToAdd.Select(x => stringMap.Get(x.ToString(), true)).ToArray());
|
||||
|
||||
if (defaultIndex >= 0)
|
||||
comboBox.SelectedIndex = defaultIndex;
|
||||
}
|
||||
|
||||
public static void FillFromEnum<TEnum>(this ComboBox comboBox, IEnumerable<TEnum> entries, Dictionary<string, string> stringMap = null, int defaultIndex = -1) where TEnum : Enum
|
||||
{
|
||||
if (stringMap == null)
|
||||
stringMap = new Dictionary<string, string>();
|
||||
|
||||
comboBox.Items.Clear();
|
||||
comboBox.Items.AddRange(entries.Select(x => stringMap.Get(x.ToString(), true)).ToArray());
|
||||
|
||||
if (defaultIndex >= 0 && comboBox.Items.Count > 0)
|
||||
comboBox.SelectedIndex = defaultIndex;
|
||||
}
|
||||
|
||||
public static void SetIfTextMatches(this ComboBox comboBox, string str, bool ignoreCase = true, Dictionary<string, string> stringMap = null)
|
||||
{
|
||||
if (stringMap == null)
|
||||
stringMap = new Dictionary<string, string>();
|
||||
|
||||
str = stringMap.Get(str, true, true);
|
||||
|
||||
for (int i = 0; i < comboBox.Items.Count; i++)
|
||||
{
|
||||
if (ignoreCase)
|
||||
{
|
||||
if (comboBox.Items[i].ToString().Lower() == str.Lower())
|
||||
{
|
||||
comboBox.SelectedIndex = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (comboBox.Items[i].ToString() == str)
|
||||
{
|
||||
comboBox.SelectedIndex = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string Lower(this string s)
|
||||
{
|
||||
if (s == null)
|
||||
return s;
|
||||
|
||||
return s.ToLowerInvariant();
|
||||
}
|
||||
|
||||
public static EncoderInfoVideo GetInfo (this Enums.Encoding.Encoder enc)
|
||||
{
|
||||
return OutputUtils.GetEncoderInfoVideo(enc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user