design improvement
This commit is contained in:
11
Clean.ps1
Normal file
11
Clean.ps1
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
function Remove($path) {
|
||||||
|
if (Test-Path $path) {
|
||||||
|
Remove-Item $path -Recurse -Force
|
||||||
|
} else {
|
||||||
|
Write-Host "Path don't exist: $path"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Remove("obj")
|
||||||
|
Remove(".vs")
|
||||||
|
Remove("*.csproj.user")
|
||||||
20
mpv.net.sln
20
mpv.net.sln
@@ -11,40 +11,32 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptingExtension", "exten
|
|||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
Debug|x86 = Debug|x86
|
Debug|x86 = Debug|x86
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
Release|x64 = Release|x64
|
Release|x64 = Release|x64
|
||||||
Release|x86 = Release|x86
|
Release|x86 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|Any CPU.ActiveCfg = Debug|x86
|
|
||||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x64.ActiveCfg = Debug|x64
|
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x64.Build.0 = Debug|x64
|
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x64.Build.0 = Debug|x64
|
||||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x86.ActiveCfg = Debug|x86
|
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x86.Build.0 = Debug|x86
|
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x86.Build.0 = Debug|x64
|
||||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x64.ActiveCfg = Release|x64
|
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x64.ActiveCfg = Release|x64
|
||||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x64.Build.0 = Release|x64
|
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x64.Build.0 = Release|x64
|
||||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x86.ActiveCfg = Release|x86
|
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x86.ActiveCfg = Release|x86
|
||||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x86.Build.0 = Release|x86
|
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x86.Build.0 = Release|x86
|
||||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|Any CPU.ActiveCfg = Debug|x86
|
|
||||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.ActiveCfg = Debug|x64
|
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.Build.0 = Debug|x64
|
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.Build.0 = Debug|x64
|
||||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.ActiveCfg = Debug|x86
|
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.Build.0 = Debug|x86
|
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.Build.0 = Debug|x64
|
||||||
{55C88710-539D-4402-84C8-31694841C731}.Release|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.ActiveCfg = Release|x64
|
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.ActiveCfg = Release|x64
|
||||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.Build.0 = Release|x64
|
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.Build.0 = Release|x64
|
||||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.ActiveCfg = Release|x86
|
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.ActiveCfg = Release|x86
|
||||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.Build.0 = Release|x86
|
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.Build.0 = Release|x86
|
||||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|Any CPU.ActiveCfg = Debug|x86
|
|
||||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x64.ActiveCfg = Debug|x64
|
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x64.Build.0 = Debug|x64
|
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x64.Build.0 = Debug|x64
|
||||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x86.ActiveCfg = Debug|x86
|
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x86.Build.0 = Debug|x86
|
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x86.Build.0 = Debug|x64
|
||||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x64.ActiveCfg = Release|x64
|
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x64.ActiveCfg = Release|x64
|
||||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x64.Build.0 = Release|x64
|
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x64.Build.0 = Release|x64
|
||||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x86.ActiveCfg = Release|x86
|
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
|||||||
@@ -100,8 +100,6 @@ namespace mpvnet
|
|||||||
return string.Join("", SettingsDefinitions.Select(item => item.Name + item.Value).ToArray());
|
return string.Join("", SettingsDefinitions.Select(item => item.Name + item.Value).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, string> SectionComment = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
void LoadConf(string file)
|
void LoadConf(string file)
|
||||||
{
|
{
|
||||||
if (!File.Exists(file))
|
if (!File.Exists(file))
|
||||||
@@ -109,7 +107,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
string comment = "";
|
string comment = "";
|
||||||
string section = "";
|
string section = "";
|
||||||
bool isSectionItem = false; ;
|
bool isSectionItem = false;
|
||||||
|
|
||||||
foreach (string currentLine in File.ReadAllLines(file))
|
foreach (string currentLine in File.ReadAllLines(file))
|
||||||
{
|
{
|
||||||
@@ -125,11 +123,11 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
else if (line.StartsWith("[") && line.Contains("]"))
|
else if (line.StartsWith("[") && line.Contains("]"))
|
||||||
{
|
{
|
||||||
|
if (!isSectionItem && comment != "" && comment != "\r\n")
|
||||||
|
ConfItems.Add(new ConfItem() {
|
||||||
|
Comment = comment, File = Path.GetFileNameWithoutExtension(file)});
|
||||||
|
|
||||||
section = line.Substring(0, line.IndexOf("]") + 1);
|
section = line.Substring(0, line.IndexOf("]") + 1);
|
||||||
|
|
||||||
if (!SectionComment.ContainsKey(file))
|
|
||||||
SectionComment[file] = comment;
|
|
||||||
|
|
||||||
comment = "";
|
comment = "";
|
||||||
isSectionItem = true;
|
isSectionItem = true;
|
||||||
}
|
}
|
||||||
@@ -166,14 +164,14 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetContent(string name)
|
string GetContent(string filename)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
List<string> namesWritten = new List<string>();
|
List<string> namesWritten = new List<string>();
|
||||||
|
|
||||||
foreach (ConfItem item in ConfItems)
|
foreach (ConfItem item in ConfItems)
|
||||||
{
|
{
|
||||||
if (name != item.File || item.Section != "" || item.IsSectionItem)
|
if (filename != item.File || item.Section != "" || item.IsSectionItem)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (item.Comment != "")
|
if (item.Comment != "")
|
||||||
@@ -181,13 +179,16 @@ namespace mpvnet
|
|||||||
|
|
||||||
if (item.SettingBase == null)
|
if (item.SettingBase == null)
|
||||||
{
|
{
|
||||||
sb.Append(item.Name + " = " + item.Value);
|
if (item.Name != "")
|
||||||
|
{
|
||||||
|
sb.Append(item.Name + " = " + item.Value);
|
||||||
|
|
||||||
if (item.LineComment != "")
|
if (item.LineComment != "")
|
||||||
sb.Append(" " + item.LineComment);
|
sb.Append(" " + item.LineComment);
|
||||||
|
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
namesWritten.Add(item.Name);
|
namesWritten.Add(item.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ((item.SettingBase.Value ?? "") != item.SettingBase.Default)
|
else if ((item.SettingBase.Value ?? "") != item.SettingBase.Default)
|
||||||
{
|
{
|
||||||
@@ -211,15 +212,12 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SectionComment.ContainsKey(name) && SectionComment[name] != "\r\n")
|
|
||||||
sb.Append(SectionComment[name]);
|
|
||||||
|
|
||||||
if (!sb.ToString().Contains("# Editor"))
|
if (!sb.ToString().Contains("# Editor"))
|
||||||
sb.AppendLine("# Editor");
|
sb.AppendLine("# Editor");
|
||||||
|
|
||||||
foreach (SettingBase setting in SettingsDefinitions)
|
foreach (SettingBase setting in SettingsDefinitions)
|
||||||
{
|
{
|
||||||
if (name != setting.File || namesWritten.Contains(setting.Name))
|
if (filename != setting.File || namesWritten.Contains(setting.Name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((setting.Value ?? "") != setting.Default)
|
if ((setting.Value ?? "") != setting.Default)
|
||||||
@@ -240,7 +238,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
foreach (ConfItem item in ConfItems)
|
foreach (ConfItem item in ConfItems)
|
||||||
{
|
{
|
||||||
if (name != item.File || (item.Section == "" && !item.IsSectionItem))
|
if (filename != item.File || (item.Section == "" && !item.IsSectionItem))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (item.Section != "")
|
if (item.Section != "")
|
||||||
|
|||||||
Reference in New Issue
Block a user