-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
48 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,58 @@ | ||
| ||
using System.Windows; | ||
|
||
using MpvNet.Windows.WPF; | ||
|
||
namespace MpvNet.Windows.Help; | ||
|
||
public class WinMpvHelp | ||
{ | ||
public static void AddToPath() | ||
public static void Setup() | ||
{ | ||
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!; | ||
string dir = RegistryHelp.GetString("PathEnvVarCheck"); // backward compatibility | ||
|
||
if (path.ToLower().Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar).ToLower())) | ||
if (dir == Folder.Startup) | ||
return; | ||
|
||
string dir = RegistryHelp.GetString("PathEnvVarCheck"); | ||
dir = RegistryHelp.GetString("Setup"); | ||
|
||
if (dir == Folder.Startup) | ||
return; | ||
|
||
var result = Msg.ShowQuestion("Would you like to add mpv.net to the Path environment variable?", | ||
MessageBoxButton.YesNo); | ||
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!; | ||
|
||
if (result == MessageBoxResult.Yes) | ||
if (!path.ToLower().Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar).ToLower())) | ||
{ | ||
Environment.SetEnvironmentVariable("Path", | ||
Folder.Startup.TrimEnd(Path.DirectorySeparatorChar) + ";" + path, | ||
EnvironmentVariableTarget.User); | ||
var result = Msg.ShowQuestion("Would you like to add mpv.net to the Path environment variable?" + BR2 + | ||
"This will allow using mpv.net in a console/terminal.", MessageBoxButton.YesNo); | ||
|
||
if (result == MessageBoxResult.Yes) | ||
{ | ||
Environment.SetEnvironmentVariable("Path", | ||
Folder.Startup.TrimEnd(Path.DirectorySeparatorChar) + ";" + path, | ||
EnvironmentVariableTarget.User); | ||
|
||
Msg.ShowInfo("mpv.net was added successfully to Path."); | ||
} | ||
else | ||
Msg.ShowInfo("If you want to add mpv.net to the Path environment variable later," + BR + | ||
"you can do so with the context menu (Settings/Setup)"); | ||
} | ||
|
||
var result2 = Msg.ShowQuestion("Would you like to register video file associations?", MessageBoxButton.YesNo); | ||
|
||
if (result2 == MessageBoxResult.Yes) | ||
{ | ||
Player.Command("script-message-to mpvnet reg-file-assoc video"); | ||
|
||
result2 = Msg.ShowQuestion("Would you like to register audio file associations?", MessageBoxButton.YesNo); | ||
|
||
Msg.ShowInfo("mpv.net was added successfully to Path."); | ||
if (result2 == MessageBoxResult.Yes) | ||
Player.Command("script-message-to mpvnet reg-file-assoc audio"); | ||
} | ||
else | ||
Msg.ShowInfo("If you want to register file associations later," + BR + | ||
"you can do so with the context menu (Settings/Setup)"); | ||
|
||
RegistryHelp.SetString("PathEnvVarCheck", Folder.Startup); | ||
RegistryHelp.SetString("Setup", Folder.Startup); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters