new folder structure and new C# script host

This commit is contained in:
Frank Skare
2021-05-06 15:23:28 +02:00
parent 642c36bacf
commit 3583aa11ed
101 changed files with 96 additions and 244 deletions

View File

@@ -1,5 +1,5 @@
![](https://raw.githubusercontent.com/stax76/mpv.net/master/img/mpvnet.png)
![](https://raw.githubusercontent.com/stax76/mpv.net/master/docs/img/mpvnet.png)
![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/stax76/mpv.net) ![GitHub closed issues](https://img.shields.io/github/issues-closed/stax76/mpv.net) ![GitHub All Releases](https://img.shields.io/github/downloads/stax76/mpv.net/total) ![GitHub tag (latest by date)](https://img.shields.io/github/tag-date/stax76/mpv.net) ![GitHub stars](https://img.shields.io/github/stars/stax76/mpv.net)
@@ -90,19 +90,19 @@ Features
- Update check and update routine
## [Support](Manual.md#support)
## [Support](docs/Manual.md#support)
[Support section of the manual.](Manual.md#support)
[Support section of the manual.](docs/Manual.md#support)
## [Download](Manual.md#download)
## [Download](docs/Manual.md#download)
[Download section of the manual.](Manual.md#download)
[Download section of the manual.](docs/Manual.md#download)
## [Manual](Manual.md)
## [Manual](docs/Manual.md)
[The mpv.net documentation.](Manual.md)
[The mpv.net documentation.](docs/Manual.md)
Screenshots
@@ -110,39 +110,39 @@ Screenshots
#### Main Window
![Main Window](https://raw.githubusercontent.com/stax76/mpv.net/master/img/Main.png)
![Main Window](docs/img/Main.png)
#### Context Menu
Context menu using dark mode.
![Context Menu](https://raw.githubusercontent.com/stax76/mpv.net/master/img/Menu.jpg)
![Context Menu](https://raw.githubusercontent.com/stax76/mpv.net/master/docs/img/Menu.jpg)
#### Config Editor
Searchable config editor as alternative to edit the conf file manually.
![](https://raw.githubusercontent.com/stax76/mpv.net/master/img/ConfEditor.png)
![](https://raw.githubusercontent.com/stax76/mpv.net/master/docs/img/ConfEditor.png)
#### Terminal
OSD console and status printed on the terminal.
![](https://raw.githubusercontent.com/stax76/mpv.net/master/img/Terminal.png)
![](https://raw.githubusercontent.com/stax76/mpv.net/master/docs/img/Terminal.png)
#### Input Editor
Searchable key and mouse binding editor.
![Input Editor](https://raw.githubusercontent.com/stax76/mpv.net/master/img/InputEditor.png)
![Input Editor](https://raw.githubusercontent.com/stax76/mpv.net/master/docs/img/InputEditor.png)
#### Command Palette
Command Palette to find commands and shortcut keys easily.
![Command Palette](https://raw.githubusercontent.com/stax76/mpv.net/master/img/CommandPalette.png)
![Command Palette](https://raw.githubusercontent.com/stax76/mpv.net/master/docs/img/CommandPalette.png)

View File

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 212 KiB

View File

Before

Width:  |  Height:  |  Size: 214 KiB

After

Width:  |  Height:  |  Size: 214 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 MiB

After

Width:  |  Height:  |  Size: 2.5 MiB

View File

Before

Width:  |  Height:  |  Size: 628 KiB

After

Width:  |  Height:  |  Size: 628 KiB

View File

Before

Width:  |  Height:  |  Size: 603 KiB

After

Width:  |  Height:  |  Size: 603 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 MiB

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RatingExtension")]
[assembly: AssemblyDescription("RatingExtension")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Frank Skare (stax76)")]
[assembly: AssemblyProduct("RatingExtension")]
[assembly: AssemblyCopyright("Copyright (C) 2017-2020 Frank Skare (stax76)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("55c88710-539d-4402-84c8-31694841c731")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,56 +0,0 @@
// This extension implements the C# scripting feature of mpv.net which
// is based on CS-Script (https://www.cs-script.net).
// I also use this extension to code scripts in order to have full
// code completion and debugger support, once the script code is
// finished I move it from the extension to a standalone script.
using System;
using System.ComponentModel.Composition;
using System.Collections.Generic;
using System.IO;
using mpvnet;
using CSScriptLibrary;
using static mpvnet.Core;
// the file name of extensions must end with 'Extension'
namespace ScriptingExtension
{
[Export(typeof(IExtension))]
public class ScriptingExtension : IExtension
{
//Script Script;
public ScriptingExtension()
{
//Script = new Script();
List<string> files = new List<string>();
if (Directory.Exists(core.ConfigFolder + "scripts-cs"))
files.AddRange(Directory.GetFiles(core.ConfigFolder + "scripts-cs", "*.cs"));
if (Directory.Exists(Folder.Startup + "scripts"))
foreach (string path in Directory.GetFiles(Folder.Startup + "scripts", "*.cs"))
files.AddRange(Directory.GetFiles(Folder.Startup + "scripts", "*.cs"));
if (files.Count == 0)
return;
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
foreach (string file in files)
{
try
{
CSScriptLibrary.CSScript.Evaluator.LoadCode(File.ReadAllText(file));
}
catch (Exception e)
{
App.ShowException(e);
}
}
}
}
}

View File

@@ -1,64 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{94255EF2-C823-4D82-9017-0E993CC0F5A1}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ScriptingExtension</RootNamespace>
<AssemblyName>ScriptingExtension</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\mpv.net\bin\Extensions\ScriptingExtension\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>..\..\mpv.net\bin\Extensions\ScriptingExtension\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="CSScriptLibrary">
<HintPath>.\CSScriptLibrary.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ScriptingExtension.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="script.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\mpv.net\mpv.net.csproj">
<Project>{1751f378-8edf-4b62-be6d-304c7c287089}</Project>
<Name>mpv.net</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1,31 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29123.88
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptingExtension", "ScriptingExtension.csproj", "{55C88710-539D-4402-84C8-31694841C731}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{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|x86.ActiveCfg = Debug|x86
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.Build.0 = Debug|x86
{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|x86.ActiveCfg = Release|x86
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C8A53BF6-B00A-4215-B9D7-801ADB9C8F60}
EndGlobalSection
EndGlobal

View File

@@ -1,19 +0,0 @@

using System.IO;
using mpvnet;
using static mpvnet.Core;
class Script
{
public Script()
{
core.Shutdown += Shutdown;
}
void Shutdown()
{
foreach (string file in Directory.GetFiles(@"C:\Users\frank\Desktop\aaa"))
File.Delete(file);
}
}

View File

@@ -0,0 +1,74 @@

using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using Microsoft.CSharp;
namespace mpvnet
{
class CSharpScriptHost
{
static List<object> References = new List<object>();
public static void ExecuteScriptsInFolder(string folder)
{
if (Directory.Exists(folder))
foreach (string file in Directory.GetFiles(folder, "*.cs"))
App.RunTask(() => Execute(file));
}
static void Execute(string file)
{
string code = File.ReadAllText(file);
string filename = Path.GetFileNameWithoutExtension(file) + " " + GetMD5(code) + ".dll";
string outputFile = Path.Combine(Path.GetTempPath(), filename);
if (!File.Exists(outputFile))
Compile(outputFile, file);
if (File.Exists(outputFile))
References.Add(Assembly.LoadFile(outputFile).CreateInstance("Script"));
}
public static void Compile(string outputFile, string file)
{
CSharpCodeProvider provider = new CSharpCodeProvider();
CompilerParameters parameters = new CompilerParameters();
string[] dependencies = {
"Microsoft.VisualBasic.dll",
"System.Core.dll", "System.Data.dll", "System.dll", "System.Drawing.dll", "System.Web.dll",
"System.Windows.Forms.dll", "System.Xaml.dll", "System.Xml.dll", "System.Xml.Linq.dll",
"WPF\\PresentationCore.dll", "WPF\\PresentationFramework.dll", "WPF\\WindowsBase.dll"
};
foreach (string i in dependencies)
parameters.ReferencedAssemblies.Add(i);
parameters.OutputAssembly = outputFile;
CompilerResults results = provider.CompileAssemblyFromFile(parameters, file);
var errors = results.Errors.Cast<CompilerError>().Select((i) => "Line Number " +
i.Line + "\r\n" + "Error Number: " + i.ErrorNumber + "\r\n" + i.ErrorText);
if (errors.Count() > 0)
ConsoleHelp.WriteError(string.Join("\r\n\r\n", errors), Path.GetFileName(file));
}
static string GetMD5(string code)
{
using (MD5 md5 = MD5.Create())
{
byte[] inputBuffer = Encoding.UTF8.GetBytes(code);
byte[] hashBuffer = md5.ComputeHash(inputBuffer);
return BitConverter.ToString(md5.ComputeHash(inputBuffer)).Replace("-", "");
}
}
}
}

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@@ -8,8 +8,6 @@ using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;
using static mpvnet.Core;
using static WinAPI;
@@ -851,7 +849,8 @@ namespace mpvnet
MinimumSize = new Size(FontHeight * 9, FontHeight * 9);
UpdateCheck.DailyCheck();
core.LoadScripts();
Task.Run(() => App.Extension = new Extension());
App.RunTask(() => App.Extension = new Extension());
CSharpScriptHost.ExecuteScriptsInFolder(core.ConfigFolder + "scripts-cs");
ShownTickCount = Environment.TickCount;
App.ShowSetup();
}

View File

@@ -15,7 +15,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\mpv.net\bin\Extensions\RatingExtension\</OutputPath>
<OutputPath>C:\Users\frank\OneDrive\Settings\mpv.net\extensions\RatingExtension\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -24,7 +24,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>..\..\mpv.net\bin\Extensions\RatingExtension\</OutputPath>
<OutputPath>C:\Users\frank\OneDrive\Settings\mpv.net\extensions\RatingExtension\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
@@ -50,7 +50,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\mpv.net\mpv.net.csproj">
<ProjectReference Include="..\..\mpv.net.csproj">
<Project>{1751f378-8edf-4b62-be6d-304c7c287089}</Project>
<Name>mpv.net</Name>
<Private>False</Private>

View File

@@ -76,11 +76,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Misc\App.cs" />
<Compile Include="Misc\CSharpScriptHost.cs" />
<Compile Include="Misc\Extension.cs" />
<Content Include="..\License.txt">
<Link>License.txt</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Resources\mpvnet-santa.png" />
<Content Include="Resources\theme.txt" />
<Page Include="WPF\SearchTextBoxUserControl.xaml">
@@ -180,12 +177,6 @@
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="..\Changelog.md">
<Link>Changelog.md</Link>
</None>
<None Include="..\Manual.md">
<Link>Manual.md</Link>
</None>
<None Include="..\README.md">
<Link>README.md</Link>
</None>

View File

@@ -3,12 +3,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28729.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mpv.net", "mpv.net\mpv.net.csproj", "{1751F378-8EDF-4B62-BE6D-304C7C287089}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mpv.net", "mpv.net.csproj", "{1751F378-8EDF-4B62-BE6D-304C7C287089}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatingExtension", "extensions\RatingExtension\RatingExtension.csproj", "{55C88710-539D-4402-84C8-31694841C731}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptingExtension", "extensions\ScriptingExtension\ScriptingExtension.csproj", "{94255EF2-C823-4D82-9017-0E993CC0F5A1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -23,10 +21,6 @@ Global
{55C88710-539D-4402-84C8-31694841C731}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55C88710-539D-4402-84C8-31694841C731}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55C88710-539D-4402-84C8-31694841C731}.Release|Any CPU.Build.0 = Release|Any CPU
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -1220,11 +1220,11 @@ namespace mpvnet
if (!File.Exists(ConfigFolder + "history.txt"))
return;
int totalMinutes = Convert.ToInt32((DateTime.Now - LastHistoryStartDateTime).TotalMinutes);
double totalMinutes = (DateTime.Now - LastHistoryStartDateTime).TotalMinutes;
if (LastHistoryPath != null && totalMinutes > 1 && !HistoryDiscard())
File.AppendAllText(ConfigFolder + "history.txt", DateTime.Now.ToString().Substring(0, 16) +
" " + totalMinutes.ToString().PadLeft(3) + " " + LastHistoryPath + "\r\n");
" " + Convert.ToInt32(totalMinutes).ToString().PadLeft(3) + " " + LastHistoryPath + "\r\n");
LastHistoryPath = path;
LastHistoryStartDateTime = DateTime.Now;

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Some files were not shown because too many files have changed in this diff Show More