reworked start-size option
This commit is contained in:
@@ -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)
|
5.4.8.8 Beta (2021-05-09)
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
|
|||||||
@@ -217,11 +217,14 @@ Setting to remember the window height.
|
|||||||
**video**
|
**video**
|
||||||
Window size is set to video resolution.
|
Window size is set to video resolution.
|
||||||
|
|
||||||
**previous**
|
**previous-height**
|
||||||
Window size is remembered but only in the current session. Default
|
Height is remembered in the current session. Default
|
||||||
|
|
||||||
|
**always-height**
|
||||||
|
Height is always remembered.
|
||||||
|
|
||||||
**always**
|
**always**
|
||||||
Window size is always remembered.
|
Size is always remembered.
|
||||||
|
|
||||||
|
|
||||||
#### --start-threshold=\<milliseconds\>
|
#### --start-threshold=\<milliseconds\>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace mpvnet
|
|||||||
public static string DarkMode { get; set; } = "always";
|
public static string DarkMode { get; set; } = "always";
|
||||||
public static string DarkTheme { get; set; } = "dark";
|
public static string DarkTheme { get; set; } = "dark";
|
||||||
public static string LightTheme { get; set; } = "light";
|
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 RememberPosition { get; set; }
|
||||||
public static bool DebugMode { get; set; }
|
public static bool DebugMode { get; set; }
|
||||||
@@ -135,8 +135,8 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
if (RememberVolume)
|
if (RememberVolume)
|
||||||
{
|
{
|
||||||
core.set_property_int("volume", RegistryHelp.GetInt(RegPath, "Volume", 70));
|
core.set_property_int("volume", RegistryHelp.GetInt("Volume", 70));
|
||||||
core.set_property_string("mute", RegistryHelp.GetString(RegPath, "Mute", "no"));
|
core.set_property_string("mute", RegistryHelp.GetString("Mute", "no"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void ShowSetup()
|
public static void ShowSetup()
|
||||||
{
|
{
|
||||||
int value = RegistryHelp.GetInt(RegistryHelp.ApplicationKey, Folder.Startup);
|
int value = RegistryHelp.GetInt(Folder.Startup);
|
||||||
|
|
||||||
if (value != 1)
|
if (value != 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ namespace mpvnet
|
|||||||
public static void ExecuteMpvCommand() // deprecated 2019
|
public static void ExecuteMpvCommand() // deprecated 2019
|
||||||
{
|
{
|
||||||
InvokeOnMainThread(new Action(() => {
|
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))
|
if (string.IsNullOrEmpty(command))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -173,15 +173,15 @@ namespace mpvnet
|
|||||||
regKey.SetValue(name, value);
|
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();
|
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;
|
return !(value is int) ? defaultValue : (int)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,22 +193,18 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void RemoveKey(string path)
|
public static void RemoveKey(string path)
|
||||||
{
|
{
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
|
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
|
||||||
}
|
} catch { }
|
||||||
catch { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RemoveValue(string path, string name)
|
public static void RemoveValue(string path, string name)
|
||||||
{
|
{
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5), true))
|
using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5), true))
|
||||||
if (regKey != null)
|
if (regKey != null)
|
||||||
regKey.DeleteValue(name, false);
|
regKey.DeleteValue(name, false);
|
||||||
}
|
} catch { }
|
||||||
catch { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegistryKey GetRootKey(string path)
|
static RegistryKey GetRootKey(string path)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
public static void DailyCheck()
|
public static void DailyCheck()
|
||||||
{
|
{
|
||||||
if (App.UpdateCheck && RegistryHelp.GetInt(RegistryHelp.ApplicationKey, "UpdateCheckLast")
|
if (App.UpdateCheck && RegistryHelp.GetInt("UpdateCheckLast")
|
||||||
!= DateTime.Now.DayOfYear)
|
!= DateTime.Now.DayOfYear)
|
||||||
|
|
||||||
CheckOnline();
|
CheckOnline();
|
||||||
@@ -44,7 +44,7 @@ namespace mpvnet
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((RegistryHelp.GetString(RegistryHelp.ApplicationKey, "UpdateCheckVersion")
|
if ((RegistryHelp.GetString("UpdateCheckVersion")
|
||||||
!= onlineVersion.ToString() || showUpToDateMessage) && Msg.ShowQuestion(
|
!= onlineVersion.ToString() || showUpToDateMessage) && Msg.ShowQuestion(
|
||||||
$"New version {onlineVersion} is available, update now?") == MsgResult.OK)
|
$"New version {onlineVersion} is available, update now?") == MsgResult.OK)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -339,12 +339,13 @@ help = "<int> Maximum window height in percent. Default: 80"
|
|||||||
[[settings]]
|
[[settings]]
|
||||||
name = "start-size"
|
name = "start-size"
|
||||||
file = "mpvnet"
|
file = "mpvnet"
|
||||||
default = "previous"
|
default = "previous-height"
|
||||||
filter = "Screen"
|
filter = "Screen"
|
||||||
help = "Setting to remember the window height. (mpv.net specific setting)"
|
help = "Setting to remember the window size. (mpv.net specific setting)"
|
||||||
options = [{ name = "video", help = "Window size is set to video resolution" },
|
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 = "previous-height", help = "Height is remembered in the current session" },
|
||||||
{ name = "always", help = "Window size is always remembered"}]
|
{ name = "always-height", help = "Height is always remembered" },
|
||||||
|
{ name = "always", help = "Size is always remembered" }]
|
||||||
|
|
||||||
[[settings]]
|
[[settings]]
|
||||||
name = "start-threshold"
|
name = "start-threshold"
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace mpvnet
|
|||||||
LoadConf(App.ConfPath);
|
LoadConf(App.ConfPath);
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
InitialContent = GetCompareString();
|
InitialContent = GetCompareString();
|
||||||
SearchControl.Text = RegistryHelp.GetString(App.RegPath, "ConfigEditorSearch");
|
SearchControl.Text = RegistryHelp.GetString("ConfigEditorSearch");
|
||||||
FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':');
|
FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ namespace mpvnet
|
|||||||
if (!core.Border)
|
if (!core.Border)
|
||||||
FormBorderStyle = FormBorderStyle.None;
|
FormBorderStyle = FormBorderStyle.None;
|
||||||
|
|
||||||
int posX = RegistryHelp.GetInt(App.RegPath, "PosX");
|
int posX = RegistryHelp.GetInt("PosX");
|
||||||
int posY = RegistryHelp.GetInt(App.RegPath, "PosY");
|
int posY = RegistryHelp.GetInt("PosY");
|
||||||
|
|
||||||
if (posX != 0 && posY != 0 && App.RememberPosition)
|
if (posX != 0 && posY != 0 && App.RememberPosition)
|
||||||
{
|
{
|
||||||
@@ -320,7 +320,8 @@ namespace mpvnet
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetFormPosAndSize(double scale = 1,
|
void SetFormPosAndSize(
|
||||||
|
double scale = 1,
|
||||||
bool force = false,
|
bool force = false,
|
||||||
bool checkAutofitSmaller = true,
|
bool checkAutofitSmaller = true,
|
||||||
bool checkAutofitLarger = true)
|
bool checkAutofitLarger = true)
|
||||||
@@ -346,36 +347,66 @@ namespace mpvnet
|
|||||||
core.VideoSize = new Size((int)(autoFitHeight * (16 / 9f)), autoFitHeight);
|
core.VideoSize = new Size((int)(autoFitHeight * (16 / 9f)), autoFitHeight);
|
||||||
|
|
||||||
Size videoSize = core.VideoSize;
|
Size videoSize = core.VideoSize;
|
||||||
|
|
||||||
int height = videoSize.Height;
|
int height = videoSize.Height;
|
||||||
|
int width = videoSize.Width;
|
||||||
|
|
||||||
|
if (App.StartSize == "previous")
|
||||||
|
App.StartSize = "previous-height";
|
||||||
|
|
||||||
if (core.WasInitialSizeSet || scale != 1)
|
if (core.WasInitialSizeSet || scale != 1)
|
||||||
|
{
|
||||||
|
if (App.StartSize == "always")
|
||||||
|
{
|
||||||
|
width = ClientSize.Width;
|
||||||
height = ClientSize.Height;
|
height = ClientSize.Height;
|
||||||
|
}
|
||||||
|
else if (App.StartSize == "always-height" || App.StartSize == "previous-height")
|
||||||
|
{
|
||||||
|
height = ClientSize.Height;
|
||||||
|
width = height * videoSize.Width / videoSize.Height;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
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;
|
height = savedHeight;
|
||||||
else
|
width = height * videoSize.Width / videoSize.Height;
|
||||||
if (App.StartSize != "video")
|
}
|
||||||
|
else if (App.StartSize == "always" && savedHeight != 0)
|
||||||
|
{
|
||||||
|
height = savedHeight;
|
||||||
|
width = savedWidth;
|
||||||
|
}
|
||||||
|
else if (App.StartSize == "previous-height")
|
||||||
|
{
|
||||||
height = autoFitHeight;
|
height = autoFitHeight;
|
||||||
|
width = height * videoSize.Width / videoSize.Height;
|
||||||
|
}
|
||||||
|
|
||||||
core.WasInitialSizeSet = true;
|
core.WasInitialSizeSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
height = Convert.ToInt32(height * scale);
|
height = Convert.ToInt32(height * scale);
|
||||||
SetSize(new Size(height * videoSize.Width / videoSize.Height, height),
|
width = Convert.ToInt32(width * scale);
|
||||||
videoSize, screen, checkAutofitSmaller, checkAutofitLarger);
|
|
||||||
|
SetSize(new Size(width, height), videoSize, screen, checkAutofitSmaller, checkAutofitLarger);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSize(Size size,
|
void SetSize(
|
||||||
|
Size size,
|
||||||
Size videoSize,
|
Size videoSize,
|
||||||
Screen screen,
|
Screen screen,
|
||||||
bool checkAutofitSmaller = true,
|
bool checkAutofitSmaller = true,
|
||||||
bool checkAutofitLarger = true)
|
bool checkAutofitLarger = true)
|
||||||
{
|
{
|
||||||
int height = size.Height;
|
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 maxHeight = screen.WorkingArea.Height - (Height - ClientSize.Height);
|
||||||
int maxWidth = screen.WorkingArea.Width - (Width - ClientSize.Width);
|
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, "PosX", Left + Width / 2);
|
||||||
RegistryHelp.SetValue(App.RegPath, "PosY", Top + Height / 2);
|
RegistryHelp.SetValue(App.RegPath, "PosY", Top + Height / 2);
|
||||||
|
RegistryHelp.SetValue(App.RegPath, "Width", ClientSize.Width);
|
||||||
RegistryHelp.SetValue(App.RegPath, "Height", ClientSize.Height);
|
RegistryHelp.SetValue(App.RegPath, "Height", ClientSize.Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ namespace mpvnet
|
|||||||
_ConfigFolder = portableFolder;
|
_ConfigFolder = portableFolder;
|
||||||
|
|
||||||
if (!Directory.Exists(_ConfigFolder))
|
if (!Directory.Exists(_ConfigFolder))
|
||||||
_ConfigFolder = RegistryHelp.GetString(App.RegPath, "ConfigFolder");
|
_ConfigFolder = RegistryHelp.GetString("ConfigFolder");
|
||||||
|
|
||||||
if (!Directory.Exists(_ConfigFolder))
|
if (!Directory.Exists(_ConfigFolder))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user