Add plug-in support
This commit is contained in:
39
VAR.Toolbox.TestPlugin/FrmTestPlugin.Designer.cs
generated
Normal file
39
VAR.Toolbox.TestPlugin/FrmTestPlugin.Designer.cs
generated
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
namespace VAR.Toolbox.TestPlugin
|
||||||
|
{
|
||||||
|
partial class FrmTestPlugin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Text = "FrmTestPlugin";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
17
VAR.Toolbox.TestPlugin/FrmTestPlugin.cs
Normal file
17
VAR.Toolbox.TestPlugin/FrmTestPlugin.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Windows.Forms;
|
||||||
|
using VAR.Toolbox.UI;
|
||||||
|
|
||||||
|
namespace VAR.Toolbox.TestPlugin
|
||||||
|
{
|
||||||
|
public partial class FrmTestPlugin : Form, IToolForm
|
||||||
|
{
|
||||||
|
public FrmTestPlugin()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ToolName { get { return "Test"; } }
|
||||||
|
|
||||||
|
public bool HasIcon { get { return false; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
13
VAR.Toolbox.TestPlugin/Notes.md
Normal file
13
VAR.Toolbox.TestPlugin/Notes.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
## Preparation
|
||||||
|
|
||||||
|
* Build as class library.
|
||||||
|
* Add reference to ```VAR.Toolbox``` for interface declarations and utilities.
|
||||||
|
* Use the interfaces to extend functionality:
|
||||||
|
* ```IToolForm```: Tool window.
|
||||||
|
* ```IToolPanel```: Tool panels in the main window. Try to fit all on 200px width.
|
||||||
|
* ```ITextCoder```: Text codification clases.
|
||||||
|
* ```IProxyCmdExecutor```: Proxy command executors, mainly for remote executions.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Put the generated assembly near ```VAR.Toolbox.exe``` it will load as plug-ins any assembly that starts with ```VAR.Toolbox```
|
||||||
35
VAR.Toolbox.TestPlugin/Properties/AssemblyInfo.cs
Normal file
35
VAR.Toolbox.TestPlugin/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
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("VAR.Toolbox.TestPlugin")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("VAR.Toolbox.TestPlugin")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||||
|
[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("74fe172a-d63c-460e-b15f-debf4150bab1")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
64
VAR.Toolbox.TestPlugin/VAR.Toolbox.TestPlugin.csproj
Normal file
64
VAR.Toolbox.TestPlugin/VAR.Toolbox.TestPlugin.csproj
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?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>{74FE172A-D63C-460E-B15F-DEBF4150BAB1}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>VAR.Toolbox.TestPlugin</RootNamespace>
|
||||||
|
<AssemblyName>VAR.Toolbox.TestPlugin</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<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="FrmTestPlugin.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="FrmTestPlugin.Designer.cs">
|
||||||
|
<DependentUpon>FrmTestPlugin.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\VAR.Toolbox\VAR.Toolbox.csproj">
|
||||||
|
<Project>{e8dab98d-4fd0-4d40-b29a-62b4c2fca4d7}</Project>
|
||||||
|
<Name>VAR.Toolbox</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Notes.md" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 14.0.25420.1
|
VisualStudioVersion = 16.0.28917.181
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VAR.Toolbox", "VAR.Toolbox\VAR.Toolbox.csproj", "{E8DAB98D-4FD0-4D40-B29A-62B4C2FCA4D7}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VAR.Toolbox", "VAR.Toolbox\VAR.Toolbox.csproj", "{E8DAB98D-4FD0-4D40-B29A-62B4C2FCA4D7}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VAR.Toolbox.TestPlugin", "VAR.Toolbox.TestPlugin\VAR.Toolbox.TestPlugin.csproj", "{74FE172A-D63C-460E-B15F-DEBF4150BAB1}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -15,8 +17,15 @@ Global
|
|||||||
{E8DAB98D-4FD0-4D40-B29A-62B4C2FCA4D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E8DAB98D-4FD0-4D40-B29A-62B4C2FCA4D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E8DAB98D-4FD0-4D40-B29A-62B4C2FCA4D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E8DAB98D-4FD0-4D40-B29A-62B4C2FCA4D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E8DAB98D-4FD0-4D40-B29A-62B4C2FCA4D7}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E8DAB98D-4FD0-4D40-B29A-62B4C2FCA4D7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{74FE172A-D63C-460E-B15F-DEBF4150BAB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{74FE172A-D63C-460E-B15F-DEBF4150BAB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{74FE172A-D63C-460E-B15F-DEBF4150BAB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{74FE172A-D63C-460E-B15F-DEBF4150BAB1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {08F0DAFF-33C5-4164-9454-62623789F7EB}
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using VAR.Toolbox.Code;
|
using VAR.Toolbox.Code;
|
||||||
using VAR.Toolbox.UI;
|
using VAR.Toolbox.UI;
|
||||||
@@ -15,6 +19,13 @@ namespace VAR.Toolbox
|
|||||||
{
|
{
|
||||||
Application.ThreadException += Application_ThreadException;
|
Application.ThreadException += Application_ThreadException;
|
||||||
|
|
||||||
|
// Load plug-ins
|
||||||
|
string executingAssemblyPath = Assembly.GetExecutingAssembly().Location;
|
||||||
|
string dirName = Path.GetDirectoryName(executingAssemblyPath);
|
||||||
|
string execName = Path.GetFileNameWithoutExtension(executingAssemblyPath);
|
||||||
|
string[] assemblyPaths = Directory.GetFiles(dirName, string.Format("{0}*.dll", execName));
|
||||||
|
foreach (string assemblyPath in assemblyPaths) { AssemblyLoadFull(assemblyPath); }
|
||||||
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
try
|
try
|
||||||
@@ -33,5 +44,36 @@ namespace VAR.Toolbox
|
|||||||
Logger.Log(e.Exception);
|
Logger.Log(e.Exception);
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Assembly AssemblyLoadFull(string fullPath, List<string> allAssemblyNames = null)
|
||||||
|
{
|
||||||
|
if (allAssemblyNames == null)
|
||||||
|
{
|
||||||
|
allAssemblyNames = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name).ToList();
|
||||||
|
}
|
||||||
|
Assembly asm = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
asm = Assembly.LoadFrom(fullPath);
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
if (asm == null) { return null; }
|
||||||
|
allAssemblyNames.Add(asm.GetName().Name);
|
||||||
|
|
||||||
|
// Load dependencies
|
||||||
|
string dirPath = Path.GetDirectoryName(fullPath);
|
||||||
|
AssemblyName[] asmNames = asm.GetReferencedAssemblies();
|
||||||
|
foreach (AssemblyName asmName in asmNames)
|
||||||
|
{
|
||||||
|
if (allAssemblyNames.Contains(asmName.Name) == false)
|
||||||
|
{
|
||||||
|
string fullPathAux = string.Format("{0}/{1}.dll", dirPath, asmName.Name);
|
||||||
|
Assembly asmAux = AssemblyLoadFull(fullPathAux, allAssemblyNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return asm;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user