reworked start-size option

This commit is contained in:
Frank Skare
2021-05-10 13:11:39 +02:00
parent 18c8f5783b
commit 6f7f127279
10 changed files with 87 additions and 49 deletions

View File

@@ -1,4 +1,10 @@
5.4.8.9 Beta (???)
=========================
- Reworked [start-size](Manual.md#--start-sizevalue) option.
5.4.8.8 Beta (2021-05-09)
=========================

View File

@@ -217,11 +217,14 @@ Setting to remember the window height.
**video**
Window size is set to video resolution.
**previous**
Window size is remembered but only in the current session. Default
**previous-height**
Height is remembered in the current session. Default
**always-height**
Height is always remembered.
**always**
Window size is always remembered.
Size is always remembered.
#### --start-threshold=\<milliseconds\>

View File

@@ -18,7 +18,7 @@ namespace mpvnet
public static string DarkMode { get; set; } = "always";
public static string DarkTheme { get; set; } = "dark";
public static string LightTheme { get; set; } = "light";
public static string StartSize { get; set; } = "previous";
public static string StartSize { get; set; } = "previous-height";
public static bool RememberPosition { get; set; }
public static bool DebugMode { get; set; }
@@ -135,8 +135,8 @@ namespace mpvnet
{
if (RememberVolume)
{
core.set_property_int("volume", RegistryHelp.GetInt(RegPath, "Volume", 70));
core.set_property_string("mute", RegistryHelp.GetString(RegPath, "Mute", "no"));
core.set_property_int("volume", RegistryHelp.GetInt("Volume", 70));
core.set_property_string("mute", RegistryHelp.GetString("Mute", "no"));
}
}
@@ -196,7 +196,7 @@ namespace mpvnet
public static void ShowSetup()
{
int value = RegistryHelp.GetInt(RegistryHelp.ApplicationKey, Folder.Startup);
int value = RegistryHelp.GetInt(Folder.Startup);
if (value != 1)
{

View File

@@ -234,7 +234,7 @@ namespace mpvnet
public static void ExecuteMpvCommand() // deprecated 2019
{
InvokeOnMainThread(new Action(() => {
string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegistryHelp.GetString(App.RegPath, "RecentExecutedCommand"));
string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegistryHelp.GetString("RecentExecutedCommand"));
if (string.IsNullOrEmpty(command))
return;

View File

@@ -173,15 +173,15 @@ namespace mpvnet
regKey.SetValue(name, value);
}
public static string GetString(string path, string name, string defaultValue = "")
public static string GetString(string name, string defaultValue = "")
{
object value = GetValue(path, name, defaultValue);
object value = GetValue(ApplicationKey, name, defaultValue);
return !(value is string) ? defaultValue : value.ToString();
}
public static int GetInt(string path, string name, int defaultValue = 0)
public static int GetInt(string name, int defaultValue = 0)
{
object value = GetValue(path, name, defaultValue);
object value = GetValue(ApplicationKey, name, defaultValue);
return !(value is int) ? defaultValue : (int)value;
}
@@ -193,22 +193,18 @@ namespace mpvnet
public static void RemoveKey(string path)
{
try
{
try {
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
}
catch { }
} catch { }
}
public static void RemoveValue(string path, string name)
{
try
{
try {
using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5), true))
if (regKey != null)
regKey.DeleteValue(name, false);
}
catch { }
} catch { }
}
static RegistryKey GetRootKey(string path)

View File

@@ -15,7 +15,7 @@ namespace mpvnet
{
public static void DailyCheck()
{
if (App.UpdateCheck && RegistryHelp.GetInt(RegistryHelp.ApplicationKey, "UpdateCheckLast")
if (App.UpdateCheck && RegistryHelp.GetInt("UpdateCheckLast")
!= DateTime.Now.DayOfYear)
CheckOnline();
@@ -44,7 +44,7 @@ namespace mpvnet
return;
}
if ((RegistryHelp.GetString(RegistryHelp.ApplicationKey, "UpdateCheckVersion")
if ((RegistryHelp.GetString("UpdateCheckVersion")
!= onlineVersion.ToString() || showUpToDateMessage) && Msg.ShowQuestion(
$"New version {onlineVersion} is available, update now?") == MsgResult.OK)
{

View File

@@ -339,12 +339,13 @@ help = "<int> Maximum window height in percent. Default: 80"
[[settings]]
name = "start-size"
file = "mpvnet"
default = "previous"
default = "previous-height"
filter = "Screen"
help = "Setting to remember the window height. (mpv.net specific setting)"
options = [{ name = "video", help = "Window size is set to video resolution" },
{ name = "previous", help = "Window size is remembered but only in the current session" },
{ name = "always", help = "Window size is always remembered"}]
help = "Setting to remember the window size. (mpv.net specific setting)"
options = [{ name = "video", help = "Window size is set to video resolution" },
{ name = "previous-height", help = "Height is remembered in the current session" },
{ name = "always-height", help = "Height is always remembered" },
{ name = "always", help = "Size is always remembered" }]
[[settings]]
name = "start-threshold"

View File

@@ -31,7 +31,7 @@ namespace mpvnet
LoadConf(App.ConfPath);
LoadSettings();
InitialContent = GetCompareString();
SearchControl.Text = RegistryHelp.GetString(App.RegPath, "ConfigEditorSearch");
SearchControl.Text = RegistryHelp.GetString("ConfigEditorSearch");
FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':');
}

View File

@@ -105,8 +105,8 @@ namespace mpvnet
if (!core.Border)
FormBorderStyle = FormBorderStyle.None;
int posX = RegistryHelp.GetInt(App.RegPath, "PosX");
int posY = RegistryHelp.GetInt(App.RegPath, "PosY");
int posX = RegistryHelp.GetInt("PosX");
int posY = RegistryHelp.GetInt("PosY");
if (posX != 0 && posY != 0 && App.RememberPosition)
{
@@ -320,10 +320,11 @@ namespace mpvnet
return null;
}
void SetFormPosAndSize(double scale = 1,
bool force = false,
bool checkAutofitSmaller = true,
bool checkAutofitLarger = true)
void SetFormPosAndSize(
double scale = 1,
bool force = false,
bool checkAutofitSmaller = true,
bool checkAutofitLarger = true)
{
if (!force)
{
@@ -346,36 +347,66 @@ namespace mpvnet
core.VideoSize = new Size((int)(autoFitHeight * (16 / 9f)), autoFitHeight);
Size videoSize = core.VideoSize;
int height = videoSize.Height;
int width = videoSize.Width;
if (App.StartSize == "previous")
App.StartSize = "previous-height";
if (core.WasInitialSizeSet || scale != 1)
height = ClientSize.Height;
{
if (App.StartSize == "always")
{
width = ClientSize.Width;
height = ClientSize.Height;
}
else if (App.StartSize == "always-height" || App.StartSize == "previous-height")
{
height = ClientSize.Height;
width = height * videoSize.Width / videoSize.Height;
}
}
else
{
int savedHeight = RegistryHelp.GetInt(App.RegPath, "Height");
int savedHeight = RegistryHelp.GetInt("Height");
int savedWidth = RegistryHelp.GetInt("Width");
if (App.StartSize == "always" && savedHeight != 0)
if (App.StartSize == "always-height" && savedHeight != 0)
{
height = savedHeight;
else
if (App.StartSize != "video")
height = autoFitHeight;
width = height * videoSize.Width / videoSize.Height;
}
else if (App.StartSize == "always" && savedHeight != 0)
{
height = savedHeight;
width = savedWidth;
}
else if (App.StartSize == "previous-height")
{
height = autoFitHeight;
width = height * videoSize.Width / videoSize.Height;
}
core.WasInitialSizeSet = true;
}
height = Convert.ToInt32(height * scale);
SetSize(new Size(height * videoSize.Width / videoSize.Height, height),
videoSize, screen, checkAutofitSmaller, checkAutofitLarger);
width = Convert.ToInt32(width * scale);
SetSize(new Size(width, height), videoSize, screen, checkAutofitSmaller, checkAutofitLarger);
}
void SetSize(Size size,
Size videoSize,
Screen screen,
bool checkAutofitSmaller = true,
bool checkAutofitLarger = true)
void SetSize(
Size size,
Size videoSize,
Screen screen,
bool checkAutofitSmaller = true,
bool checkAutofitLarger = true)
{
int height = size.Height;
int width = size.Height * videoSize.Width / videoSize.Height;
int width = size.Width;
int maxHeight = screen.WorkingArea.Height - (Height - ClientSize.Height);
int maxWidth = screen.WorkingArea.Width - (Width - ClientSize.Width);
@@ -538,6 +569,7 @@ namespace mpvnet
{
RegistryHelp.SetValue(App.RegPath, "PosX", Left + Width / 2);
RegistryHelp.SetValue(App.RegPath, "PosY", Top + Height / 2);
RegistryHelp.SetValue(App.RegPath, "Width", ClientSize.Width);
RegistryHelp.SetValue(App.RegPath, "Height", ClientSize.Height);
}
}

View File

@@ -193,7 +193,7 @@ namespace mpvnet
_ConfigFolder = portableFolder;
if (!Directory.Exists(_ConfigFolder))
_ConfigFolder = RegistryHelp.GetString(App.RegPath, "ConfigFolder");
_ConfigFolder = RegistryHelp.GetString("ConfigFolder");
if (!Directory.Exists(_ConfigFolder))
{