Store settings in settings.xml instead of registry.
This commit is contained in:
@@ -8,17 +8,19 @@
|
|||||||
- The CS-Script library was replaced with my own C# scripting implementation.
|
- The CS-Script library was replaced with my own C# scripting implementation.
|
||||||
- If a player window border is near to a screen border and the window size
|
- If a player window border is near to a screen border and the window size
|
||||||
changes, the player windows sticks to that near screen border location.
|
changes, the player windows sticks to that near screen border location.
|
||||||
Furthermore the `remember-position` option remembers a near screen border
|
Furthermore the `remember-window-position` option remembers a near screen
|
||||||
position instead of remembering the window center position.
|
border position instead of remembering the window center position.
|
||||||
- High DPI multi monitor fix.
|
- High DPI multi monitor fix.
|
||||||
- `start-size` option has new options, see config editor and manual.
|
- `start-size` option has new options, see config editor and manual.
|
||||||
- Improved `script-message mpv.net cycle-audio` OSD info.
|
- Improved `script-message mpv.net cycle-audio` OSD info.
|
||||||
- The logic for finding the config directory has changed, see manual.
|
- The logic for finding the config directory has changed, see manual.
|
||||||
- The native TaskDialog/MessageBox was replaced with the themed VB.NET
|
|
||||||
implementation of StaxRip.
|
|
||||||
- The dotnet script and extension host was redesigned, existing scripts
|
- The dotnet script and extension host was redesigned, existing scripts
|
||||||
and extensions must be fixed. All example scripts were updated and
|
and extensions must be fixed. All example scripts were updated and
|
||||||
a new script delete-current-file.cs was added.
|
a new script delete-current-file.cs was added.
|
||||||
|
- Fix console not working due to incorrect mpv.conf value generated
|
||||||
|
(script-opts=console-scale=0).
|
||||||
|
- Registry usage is not portable and also not popular, so settings
|
||||||
|
are stored in the file settings.xml now instead of the Registry.
|
||||||
|
|
||||||
|
|
||||||
5.4.8.8 Beta (2021-05-09)
|
5.4.8.8 Beta (2021-05-09)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ mpvnet.exe is platform agnostic, users that need x86 have to replace 4 native to
|
|||||||
|
|
||||||
#### File Associations
|
#### File Associations
|
||||||
|
|
||||||
File Associations can be created using the setup or with the context menu under 'Tools > Setup'.
|
File Associations can be created using the context menu under 'Tools > Setup'.
|
||||||
|
|
||||||
After the file associations were registered, go to the Windows settings under
|
After the file associations were registered, go to the Windows settings under
|
||||||
'Settings > Apps > Default apps' or shell execute `ms-settings:defaultapps` and choose
|
'Settings > Apps > Default apps' or shell execute `ms-settings:defaultapps` and choose
|
||||||
@@ -254,7 +254,7 @@ the window AR is set to 16/9. This avoids a square window for Music
|
|||||||
with cover art. Default: 1.2
|
with cover art. Default: 1.2
|
||||||
|
|
||||||
|
|
||||||
#### --remember-position=\<yes|no\>
|
#### --remember-window-position=\<yes|no\>
|
||||||
|
|
||||||
Save the window position on exit. Default: no
|
Save the window position on exit. Default: no
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace mpvnet
|
|||||||
public static string LightTheme { get; set; } = "light";
|
public static string LightTheme { get; set; } = "light";
|
||||||
public static string StartSize { get; set; } = "height-session";
|
public static string StartSize { get; set; } = "height-session";
|
||||||
|
|
||||||
public static bool RememberPosition { get; set; }
|
public static bool RememberWindowPosition { get; set; }
|
||||||
public static bool DebugMode { get; set; }
|
public static bool DebugMode { get; set; }
|
||||||
public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
|
public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
|
||||||
public static bool RememberVolume { get; set; } = true;
|
public static bool RememberVolume { get; set; } = true;
|
||||||
@@ -39,6 +39,17 @@ namespace mpvnet
|
|||||||
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static AppSettings _Settings;
|
||||||
|
|
||||||
|
public static AppSettings Settings {
|
||||||
|
get {
|
||||||
|
if (_Settings == null)
|
||||||
|
_Settings = SettingsManager.Load();
|
||||||
|
|
||||||
|
return _Settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
string dummy = Core.ConfigFolder;
|
string dummy = Core.ConfigFolder;
|
||||||
@@ -132,18 +143,17 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
if (RememberVolume)
|
if (RememberVolume)
|
||||||
{
|
{
|
||||||
Core.set_property_int("volume", RegistryHelp.GetInt("volume", 70));
|
Core.set_property_int("volume", Settings.Volume);
|
||||||
Core.set_property_string("mute", RegistryHelp.GetString("mute", "no"));
|
Core.set_property_string("mute", Settings.Mute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Shutdown()
|
static void Shutdown()
|
||||||
{
|
{
|
||||||
if (RememberVolume)
|
Settings.Volume = Core.get_property_int("volume");
|
||||||
{
|
Settings.Mute = Core.get_property_string("mute");
|
||||||
RegistryHelp.SetInt("volume", Core.get_property_int("volume"));
|
|
||||||
RegistryHelp.SetString("mute", Core.get_property_string("mute"));
|
SettingsManager.Save(Settings);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Dictionary<string, string> _Conf;
|
static Dictionary<string, string> _Conf;
|
||||||
@@ -167,7 +177,7 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case "remember-position": RememberPosition = value == "yes"; return true;
|
case "remember-window-position": RememberWindowPosition = value == "yes"; return true;
|
||||||
case "debug-mode": DebugMode = value == "yes"; return true;
|
case "debug-mode": DebugMode = value == "yes"; return true;
|
||||||
case "remember-volume": RememberVolume = value == "yes"; return true;
|
case "remember-volume": RememberVolume = value == "yes"; return true;
|
||||||
case "queue": Queue = value == "yes"; return true;
|
case "queue": Queue = value == "yes"; return true;
|
||||||
@@ -190,23 +200,5 @@ namespace mpvnet
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowSetup()
|
|
||||||
{
|
|
||||||
int value = RegistryHelp.GetInt("location: " + Folder.Startup);
|
|
||||||
|
|
||||||
if (value != 1)
|
|
||||||
{
|
|
||||||
if (Msg.ShowQuestion("Would you like to setup mpv.net?",
|
|
||||||
"The setup allows to create a start menu shortcut, file associations and " +
|
|
||||||
"adding mpv.net to the Path environment variable.") == DialogResult.OK)
|
|
||||||
|
|
||||||
Commands.Execute("show-setup-dialog");
|
|
||||||
else
|
|
||||||
Msg.ShowInfo("The setup dialog can be found at:\n\nContext Menu > Tools > Setup");
|
|
||||||
|
|
||||||
RegistryHelp.SetInt("location: " + Folder.Startup, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ using System.Collections.Generic;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
using static mpvnet.Global;
|
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
static class Program
|
static class Program
|
||||||
@@ -23,9 +21,6 @@ namespace mpvnet
|
|||||||
if (App.IsStartedFromTerminal)
|
if (App.IsStartedFromTerminal)
|
||||||
Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
|
Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
|
||||||
|
|
||||||
if (Core.ConfigFolder == "")
|
|
||||||
return;
|
|
||||||
|
|
||||||
string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
|
string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
|
||||||
|
|
||||||
if (args.Length >= 2 && args[0] == "--reg-file-assoc")
|
if (args.Length >= 2 && args[0] == "--reg-file-assoc")
|
||||||
|
|||||||
56
src/Misc/Settings.cs
Normal file
56
src/Misc/Settings.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
|
using static mpvnet.Global;
|
||||||
|
|
||||||
|
namespace mpvnet
|
||||||
|
{
|
||||||
|
[Serializable()]
|
||||||
|
public class AppSettings
|
||||||
|
{
|
||||||
|
public int LastUpdateCheck;
|
||||||
|
public int Volume = 70;
|
||||||
|
public List<string> RecentFiles = new List<string>();
|
||||||
|
public Point WindowLocation;
|
||||||
|
public Point WindowPosition;
|
||||||
|
public Size WindowSize;
|
||||||
|
public string ConfigEditorSearch = "";
|
||||||
|
public string Mute = "no";
|
||||||
|
public string UpdateCheckVersion = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
class SettingsManager
|
||||||
|
{
|
||||||
|
public static string SettingsFile {
|
||||||
|
get => Core.ConfigFolder + "settings.xml";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AppSettings Load()
|
||||||
|
{
|
||||||
|
if (!File.Exists(SettingsFile))
|
||||||
|
return new AppSettings();
|
||||||
|
|
||||||
|
XmlSerializer serializer = new XmlSerializer(typeof(AppSettings));
|
||||||
|
|
||||||
|
using (FileStream fs = new FileStream(SettingsFile, FileMode.Open))
|
||||||
|
return (AppSettings)serializer.Deserialize(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Save(object obj)
|
||||||
|
{
|
||||||
|
using (XmlTextWriter writer = new XmlTextWriter(SettingsFile, Encoding.UTF8))
|
||||||
|
{
|
||||||
|
writer.Formatting = Formatting.Indented;
|
||||||
|
writer.Indentation = 4;
|
||||||
|
XmlSerializer serializer = new XmlSerializer(obj.GetType());
|
||||||
|
serializer.Serialize(writer, obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,9 +15,7 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
public static void DailyCheck()
|
public static void DailyCheck()
|
||||||
{
|
{
|
||||||
if (App.UpdateCheck && RegistryHelp.GetInt("last-update-check")
|
if (App.UpdateCheck && App.Settings.LastUpdateCheck != DateTime.Now.DayOfYear)
|
||||||
!= DateTime.Now.DayOfYear)
|
|
||||||
|
|
||||||
CheckOnline();
|
CheckOnline();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +25,7 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
using (HttpClient client = new HttpClient())
|
using (HttpClient client = new HttpClient())
|
||||||
{
|
{
|
||||||
RegistryHelp.SetValue("last-update-check", DateTime.Now.DayOfYear);
|
App.Settings.LastUpdateCheck = DateTime.Now.DayOfYear;
|
||||||
client.DefaultRequestHeaders.Add("User-Agent", "mpv.net");
|
client.DefaultRequestHeaders.Add("User-Agent", "mpv.net");
|
||||||
var response = await client.GetAsync("https://api.github.com/repos/stax76/mpv.net/releases/latest");
|
var response = await client.GetAsync("https://api.github.com/repos/stax76/mpv.net/releases/latest");
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
@@ -51,8 +49,8 @@ namespace mpvnet
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((RegistryHelp.GetString("update-check-version")
|
if ((App.Settings.UpdateCheckVersion != onlineVersion.ToString() ||
|
||||||
!= onlineVersion.ToString() || showUpToDateMessage) && Msg.ShowQuestion(
|
showUpToDateMessage) && Msg.ShowQuestion(
|
||||||
$"New version {onlineVersion} is available, update now?") == DialogResult.OK)
|
$"New version {onlineVersion} is available, update now?") == DialogResult.OK)
|
||||||
{
|
{
|
||||||
string url = $"https://github.com/stax76/mpv.net/releases/download/{onlineVersion}/mpv.net-{onlineVersion}-portable.zip";
|
string url = $"https://github.com/stax76/mpv.net/releases/download/{onlineVersion}/mpv.net-{onlineVersion}-portable.zip";
|
||||||
@@ -73,7 +71,7 @@ namespace mpvnet
|
|||||||
Core.command("quit");
|
Core.command("quit");
|
||||||
}
|
}
|
||||||
|
|
||||||
RegistryHelp.SetValue("update-check-version", onlineVersion.ToString());
|
App.Settings.UpdateCheckVersion = onlineVersion.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ filter = "Screen"
|
|||||||
help = "<float> Minimum aspect ratio, if the AR is smaller than the defined value then the window AR is set to 16/9. This avoids a square window for Music with cover art. Default: 1.2 (mpv.net specific setting)"
|
help = "<float> Minimum aspect ratio, if the AR is smaller than the defined value then the window AR is set to 16/9. This avoids a square window for Music with cover art. Default: 1.2 (mpv.net specific setting)"
|
||||||
|
|
||||||
[[settings]]
|
[[settings]]
|
||||||
name = "remember-position"
|
name = "remember-window-position"
|
||||||
file = "mpvnet"
|
file = "mpvnet"
|
||||||
default = "no"
|
default = "no"
|
||||||
filter = "Screen"
|
filter = "Screen"
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace mpvnet
|
|||||||
LoadConf(App.ConfPath);
|
LoadConf(App.ConfPath);
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
InitialContent = GetCompareString();
|
InitialContent = GetCompareString();
|
||||||
SearchControl.Text = RegistryHelp.GetString("config-editor-search");
|
SearchControl.Text = App.Settings.ConfigEditorSearch;
|
||||||
FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':');
|
FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ namespace mpvnet
|
|||||||
protected override void OnClosed(EventArgs e)
|
protected override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
RegistryHelp.SetValue("config-editor-search", SearchControl.Text);
|
App.Settings.ConfigEditorSearch = SearchControl.Text;
|
||||||
|
|
||||||
if (InitialContent == GetCompareString())
|
if (InitialContent == GetCompareString())
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ namespace mpvnet
|
|||||||
int ShownTickCount;
|
int ShownTickCount;
|
||||||
|
|
||||||
Taskbar Taskbar;
|
Taskbar Taskbar;
|
||||||
List<string> RecentFiles;
|
|
||||||
bool WasMaximized;
|
bool WasMaximized;
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
@@ -38,9 +37,6 @@ namespace mpvnet
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
object recent = RegistryHelp.GetValue("recent");
|
|
||||||
RecentFiles = recent is string[] r ? new List<string>(r) : new List<string>();
|
|
||||||
|
|
||||||
Instance = this;
|
Instance = this;
|
||||||
Hwnd = Handle;
|
Hwnd = Handle;
|
||||||
Core.Init();
|
Core.Init();
|
||||||
@@ -100,21 +96,19 @@ namespace mpvnet
|
|||||||
if (!Core.Border)
|
if (!Core.Border)
|
||||||
FormBorderStyle = FormBorderStyle.None;
|
FormBorderStyle = FormBorderStyle.None;
|
||||||
|
|
||||||
int posX = RegistryHelp.GetInt("position-x");
|
Point pos = App.Settings.WindowPosition;
|
||||||
int posY = RegistryHelp.GetInt("position-y");
|
|
||||||
|
|
||||||
if ((posX != 0 || posY != 0) && App.RememberPosition)
|
if ((pos.X != 0 || pos.Y != 0) && App.RememberWindowPosition)
|
||||||
{
|
{
|
||||||
Left = posX - Width / 2;
|
Left = pos.X - Width / 2;
|
||||||
Top = posY - Height / 2;
|
Top = pos.Y - Height / 2;
|
||||||
|
|
||||||
int horizontal = RegistryHelp.GetInt("location-horizontal");
|
Point location = App.Settings.WindowLocation;
|
||||||
int vertical = RegistryHelp.GetInt("location-vertical");
|
|
||||||
|
|
||||||
if (horizontal == -1) Left = posX;
|
if (location.X == -1) Left = pos.X;
|
||||||
if (horizontal == 1) Left = posX - Width;
|
if (location.X == 1) Left = pos.X - Width;
|
||||||
if (vertical == -1) Top = posY;
|
if (location.Y == -1) Top = pos.Y;
|
||||||
if (vertical == 1) Top = posY - Height;
|
if (location.Y == 1) Top = pos.Y - Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Core.WindowMaximized)
|
if (Core.WindowMaximized)
|
||||||
@@ -273,12 +267,12 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
recent.DropDownItems.Clear();
|
recent.DropDownItems.Clear();
|
||||||
|
|
||||||
foreach (string path in RecentFiles)
|
foreach (string path in App.Settings.RecentFiles)
|
||||||
MenuItem.Add(recent.DropDownItems, path, () => Core.LoadFiles(new[] { path }, true, Control.ModifierKeys.HasFlag(Keys.Control)));
|
MenuItem.Add(recent.DropDownItems, path, () => Core.LoadFiles(new[] { path }, true, Control.ModifierKeys.HasFlag(Keys.Control)));
|
||||||
|
|
||||||
recent.DropDownItems.Add(new ToolStripSeparator());
|
recent.DropDownItems.Add(new ToolStripSeparator());
|
||||||
MenuItem mi = new MenuItem("Clear List");
|
MenuItem mi = new MenuItem("Clear List");
|
||||||
mi.Action = () => RecentFiles.Clear();
|
mi.Action = () => App.Settings.RecentFiles.Clear();
|
||||||
recent.DropDownItems.Add(mi);
|
recent.DropDownItems.Add(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,12 +371,11 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int savedHeight = RegistryHelp.GetInt("window-height");
|
Size windowSize = App.Settings.WindowSize;
|
||||||
int savedWidth = RegistryHelp.GetInt("window-width");
|
|
||||||
|
|
||||||
if (App.StartSize == "height-always" && savedHeight != 0)
|
if (App.StartSize == "height-always" && windowSize.Height != 0)
|
||||||
{
|
{
|
||||||
height = savedHeight;
|
height = windowSize.Height;
|
||||||
width = height * videoSize.Width / videoSize.Height;
|
width = height * videoSize.Width / videoSize.Height;
|
||||||
}
|
}
|
||||||
else if (App.StartSize == "height-session")
|
else if (App.StartSize == "height-session")
|
||||||
@@ -390,9 +383,9 @@ namespace mpvnet
|
|||||||
height = autoFitHeight;
|
height = autoFitHeight;
|
||||||
width = height * videoSize.Width / videoSize.Height;
|
width = height * videoSize.Width / videoSize.Height;
|
||||||
}
|
}
|
||||||
if (App.StartSize == "width-always" && savedHeight != 0)
|
if (App.StartSize == "width-always" && windowSize.Height != 0)
|
||||||
{
|
{
|
||||||
width = savedWidth;
|
width = windowSize.Width;
|
||||||
height = (int)Math.Ceiling(width * videoSize.Height / (double)videoSize.Width);
|
height = (int)Math.Ceiling(width * videoSize.Height / (double)videoSize.Width);
|
||||||
}
|
}
|
||||||
else if (App.StartSize == "width-session")
|
else if (App.StartSize == "width-session")
|
||||||
@@ -400,10 +393,10 @@ namespace mpvnet
|
|||||||
width = autoFitHeight / 9 * 16;
|
width = autoFitHeight / 9 * 16;
|
||||||
height = (int)Math.Ceiling(width * videoSize.Height / (double)videoSize.Width);
|
height = (int)Math.Ceiling(width * videoSize.Height / (double)videoSize.Width);
|
||||||
}
|
}
|
||||||
else if (App.StartSize == "always" && savedHeight != 0)
|
else if (App.StartSize == "always" && windowSize.Height != 0)
|
||||||
{
|
{
|
||||||
height = savedHeight;
|
height = windowSize.Height;
|
||||||
width = savedWidth;
|
width = windowSize.Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core.WasInitialSizeSet = true;
|
Core.WasInitialSizeSet = true;
|
||||||
@@ -495,7 +488,7 @@ namespace mpvnet
|
|||||||
Rectangle workingArea = screen.WorkingArea;
|
Rectangle workingArea = screen.WorkingArea;
|
||||||
Rectangle rect = new Rectangle(Left - workingArea.X, Top - workingArea.Y, Width, Height);
|
Rectangle rect = new Rectangle(Left - workingArea.X, Top - workingArea.Y, Width, Height);
|
||||||
|
|
||||||
if (workingArea.Width / (float)Width < 1.2)
|
if (workingArea.Width / (float)Width < 1.1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (rect.X * 3 < workingArea.Width - rect.Right)
|
if (rect.X * 3 < workingArea.Width - rect.Right)
|
||||||
@@ -512,7 +505,7 @@ namespace mpvnet
|
|||||||
Rectangle workingArea = screen.WorkingArea;
|
Rectangle workingArea = screen.WorkingArea;
|
||||||
Rectangle rect = new Rectangle(Left - workingArea.X, Top - workingArea.Y, Width, Height);
|
Rectangle rect = new Rectangle(Left - workingArea.X, Top - workingArea.Y, Width, Height);
|
||||||
|
|
||||||
if (workingArea.Height / (float)Height < 1.2)
|
if (workingArea.Height / (float)Height < 1.1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (rect.Y * 3 < workingArea.Height - rect.Bottom)
|
if (rect.Y * 3 < workingArea.Height - rect.Bottom)
|
||||||
@@ -619,13 +612,13 @@ namespace mpvnet
|
|||||||
UpdateProgressBar();
|
UpdateProgressBar();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (RecentFiles.Contains(path))
|
if (App.Settings.RecentFiles.Contains(path))
|
||||||
RecentFiles.Remove(path);
|
App.Settings.RecentFiles.Remove(path);
|
||||||
|
|
||||||
RecentFiles.Insert(0, path);
|
App.Settings.RecentFiles.Insert(0, path);
|
||||||
|
|
||||||
while (RecentFiles.Count > App.RecentCount)
|
while (App.Settings.RecentFiles.Count > App.RecentCount)
|
||||||
RecentFiles.RemoveAt(App.RecentCount);
|
App.Settings.RecentFiles.RemoveAt(App.RecentCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetTitle() => BeginInvoke(new Action(() => Text = Core.expand(Title)));
|
void SetTitle() => BeginInvoke(new Action(() => Text = Core.expand(Title)));
|
||||||
@@ -635,32 +628,25 @@ namespace mpvnet
|
|||||||
if (WindowState == FormWindowState.Normal)
|
if (WindowState == FormWindowState.Normal)
|
||||||
{
|
{
|
||||||
SavePosition();
|
SavePosition();
|
||||||
|
App.Settings.WindowSize = ClientSize;
|
||||||
RegistryHelp.SetInt("window-width", ClientSize.Width);
|
|
||||||
RegistryHelp.SetInt("window-height", ClientSize.Height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavePosition()
|
void SavePosition()
|
||||||
{
|
{
|
||||||
int posX = Left + Width / 2;
|
Point pos = new Point(Left + Width / 2, Top + Height / 2);
|
||||||
int posY = Top + Height / 2;
|
|
||||||
|
|
||||||
Screen screen = Screen.FromControl(this);
|
Screen screen = Screen.FromControl(this);
|
||||||
|
|
||||||
int x = GetHorizontalLocation(screen);
|
int x = GetHorizontalLocation(screen);
|
||||||
int y = GetVerticalLocation(screen);
|
int y = GetVerticalLocation(screen);
|
||||||
|
|
||||||
if (x == -1) posX = Left;
|
if (x == -1) pos.X = Left;
|
||||||
if (x == 1) posX = Left + Width;
|
if (x == 1) pos.X = Left + Width;
|
||||||
if (y == -1) posY = Top;
|
if (y == -1) pos.Y = Top;
|
||||||
if (y == 1) posY = Top + Height;
|
if (y == 1) pos.Y = Top + Height;
|
||||||
|
|
||||||
RegistryHelp.SetInt("position-x", posX);
|
App.Settings.WindowPosition = pos;
|
||||||
RegistryHelp.SetInt("position-y", posY);
|
App.Settings.WindowLocation = new Point(x, y);
|
||||||
|
|
||||||
RegistryHelp.SetInt("location-horizontal", x);
|
|
||||||
RegistryHelp.SetInt("location-vertical", y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override CreateParams CreateParams {
|
protected override CreateParams CreateParams {
|
||||||
@@ -952,7 +938,6 @@ namespace mpvnet
|
|||||||
App.RunTask(() => App.Extension = new Extension());
|
App.RunTask(() => App.Extension = new Extension());
|
||||||
CSharpScriptHost.ExecuteScriptsInFolder(Core.ConfigFolder + "scripts-cs");
|
CSharpScriptHost.ExecuteScriptsInFolder(Core.ConfigFolder + "scripts-cs");
|
||||||
ShownTickCount = Environment.TickCount;
|
ShownTickCount = Environment.TickCount;
|
||||||
App.ShowSetup();
|
|
||||||
|
|
||||||
//if (Debugger.IsAttached)
|
//if (Debugger.IsAttached)
|
||||||
//{
|
//{
|
||||||
@@ -1005,7 +990,6 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
base.OnFormClosing(e);
|
base.OnFormClosing(e);
|
||||||
SaveWindowProperties();
|
SaveWindowProperties();
|
||||||
RegistryHelp.SetValue("recent", RecentFiles.ToArray());
|
|
||||||
|
|
||||||
if (Core.IsQuitNeeded)
|
if (Core.IsQuitNeeded)
|
||||||
Core.commandv("quit");
|
Core.commandv("quit");
|
||||||
|
|||||||
@@ -189,6 +189,7 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
|||||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||||
rect = new Rectangle(rect.X + 2, rect.Y, rect.Width - 4, rect.Height - 1);
|
rect = new Rectangle(rect.X + 2, rect.Y, rect.Width - 4, rect.Height - 1);
|
||||||
rect.Inflate(-1, -1);
|
rect.Inflate(-1, -1);
|
||||||
|
|
||||||
using (SolidBrush b = new SolidBrush(SelectionColor))
|
using (SolidBrush b = new SolidBrush(SelectionColor))
|
||||||
e.Graphics.FillRectangle(b, rect);
|
e.Graphics.FillRectangle(b, rect);
|
||||||
}
|
}
|
||||||
@@ -205,12 +206,12 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
|||||||
float y3 = e.Item.Height * 0.75f;
|
float y3 = e.Item.Height * 0.75f;
|
||||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
|
|
||||||
using (Brush b = new SolidBrush(ForegroundColor))
|
using (Brush brush = new SolidBrush(ForegroundColor))
|
||||||
{
|
{
|
||||||
using (Pen p = new Pen(b, Control.DefaultFont.Height / 20f))
|
using (Pen pen = new Pen(brush, Control.DefaultFont.Height / 20f))
|
||||||
{
|
{
|
||||||
e.Graphics.DrawLine(p, x1, y1, x2, y2);
|
e.Graphics.DrawLine(pen, x1, y1, x2, y2);
|
||||||
e.Graphics.DrawLine(p, x2, y2, x3, y3);
|
e.Graphics.DrawLine(pen, x2, y2, x3, y3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,7 +222,6 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
MenuItem item = e.Item as MenuItem;
|
MenuItem item = e.Item as MenuItem;
|
||||||
|
|
||||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||||
|
|
||||||
if (!item.Checked)
|
if (!item.Checked)
|
||||||
@@ -250,6 +250,7 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
|||||||
int top = e.Item.Height / 2;
|
int top = e.Item.Height / 2;
|
||||||
top -= 1;
|
top -= 1;
|
||||||
int offset = Convert.ToInt32(e.Item.Font.Height * 0.7);
|
int offset = Convert.ToInt32(e.Item.Font.Height * 0.7);
|
||||||
|
|
||||||
using (Pen p = new Pen(BorderColor))
|
using (Pen p = new Pen(BorderColor))
|
||||||
e.Graphics.DrawLine(p,
|
e.Graphics.DrawLine(p,
|
||||||
new Point(offset, top),
|
new Point(offset, top),
|
||||||
@@ -298,6 +299,7 @@ public struct HSLColor
|
|||||||
value = 0;
|
value = 0;
|
||||||
else if (value > 1)
|
else if (value > 1)
|
||||||
value = 1;
|
value = 1;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,9 +390,9 @@ public struct HSLColor
|
|||||||
|
|
||||||
public void SetRGB(int red, int green, int blue)
|
public void SetRGB(int red, int green, int blue)
|
||||||
{
|
{
|
||||||
HSLColor hc = HSLColor.Convert(Color.FromArgb(red, green, blue));
|
HSLColor hc = Convert(Color.FromArgb(red, green, blue));
|
||||||
_Hue = hc._Hue;
|
_Hue = hc._Hue;
|
||||||
_Saturation = hc._Saturation;
|
_Saturation = hc._Saturation;
|
||||||
_Luminosity = hc._Luminosity;
|
_Luminosity = hc._Luminosity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,7 @@
|
|||||||
<Compile Include="Misc\Help.cs" />
|
<Compile Include="Misc\Help.cs" />
|
||||||
<Compile Include="Misc\GlobalHotkey.cs" />
|
<Compile Include="Misc\GlobalHotkey.cs" />
|
||||||
<Compile Include="Misc\Msg.cs" />
|
<Compile Include="Misc\Msg.cs" />
|
||||||
|
<Compile Include="Misc\Settings.cs" />
|
||||||
<Compile Include="Misc\Terminal.cs" />
|
<Compile Include="Misc\Terminal.cs" />
|
||||||
<Compile Include="Misc\UpdateCheck.cs" />
|
<Compile Include="Misc\UpdateCheck.cs" />
|
||||||
<Compile Include="Misc\Theme.cs" />
|
<Compile Include="Misc\Theme.cs" />
|
||||||
@@ -141,7 +142,7 @@
|
|||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="mpv\libmpv.cs" />
|
<Compile Include="Native\libmpv.cs" />
|
||||||
<Compile Include="WinForms\MainForm.cs">
|
<Compile Include="WinForms\MainForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -149,7 +150,7 @@
|
|||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Misc\Misc.cs" />
|
<Compile Include="Misc\Misc.cs" />
|
||||||
<Compile Include="mpv\CorePlayer.cs" />
|
<Compile Include="Misc\CorePlayer.cs" />
|
||||||
<Compile Include="Misc\Commands.cs" />
|
<Compile Include="Misc\Commands.cs" />
|
||||||
<Compile Include="Native\Native.cs" />
|
<Compile Include="Native\Native.cs" />
|
||||||
<Compile Include="Misc\Program.cs" />
|
<Compile Include="Misc\Program.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user