This repository has been archived by the owner on Apr 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Runtime patching of DDS structure, no more installer required.
- Loading branch information
1 parent
eaa4b74
commit 48cb983
Showing
5 changed files
with
179 additions
and
13 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
68 changes: 68 additions & 0 deletions
68
src/FileTypeDDS/FileTypeDDSEffect/FileTypeDDSEffect.csproj
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" 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>{ECCCB43B-AE85-4431-86DB-17C761976DEA}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>FileTypeDDSEffect</RootNamespace> | ||
<AssemblyName>FileTypeDDSEffect</AssemblyName> | ||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile /> | ||
</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="PaintDotNet.Base"> | ||
<HintPath>..\..\Dependencies\PaintDotNet.Base.dll</HintPath> | ||
</Reference> | ||
<Reference Include="PaintDotNet.Core"> | ||
<HintPath>..\..\Dependencies\PaintDotNet.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="PaintDotNet.Data"> | ||
<HintPath>..\..\Dependencies\PaintDotNet.Data.dll</HintPath> | ||
</Reference> | ||
<Reference Include="PaintDotNet.Effects"> | ||
<HintPath>..\..\Dependencies\PaintDotNet.Effects.dll</HintPath> | ||
</Reference> | ||
<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.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="PatcherEffect.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using PaintDotNet; | ||
using PaintDotNet.Effects; | ||
using PaintDotNet.PropertySystem; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FileTypeDDSEffect | ||
{ | ||
[EffectCategory(EffectCategory.DoNotDisplay), PluginSupportInfo(typeof(PluginSupportInfo), DisplayName = "FileTypeDDS")] | ||
public class PatcherEffect : PropertyBasedEffect | ||
{ | ||
public PatcherEffect() | ||
: base("FileTypeDDSPatcher", null, "", EffectFlags.None) | ||
{ | ||
try | ||
{ | ||
// Prepare to patch the built-in file type array | ||
var PaintAssembly = Assembly.GetEntryAssembly(); | ||
|
||
// Find the internal file type array | ||
var Type = PaintAssembly.GetType("PaintDotNet.Data.PdnFileTypes"); | ||
var Field = Type.GetField("fileTypes", BindingFlags.NonPublic | BindingFlags.Static); | ||
|
||
// Get it's value, then, replace with one that doesn't have the DDS | ||
var Result = (FileType[])Field.GetValue(null); | ||
var NewResult = Result.Where(x => !x.Name.ToLower().Contains("dds")).ToArray<FileType>(); | ||
|
||
// Patch it, we want full access... | ||
Field.SetValue(null, NewResult); | ||
} | ||
catch (Exception ex) | ||
{ | ||
System.Windows.Forms.MessageBox.Show("FileTypeDDS - Failed to patch the plugin (Report this on Github) [" + ex.Message + "]", "FileTypeDDS"); | ||
} | ||
} | ||
|
||
protected override void OnRender(Rectangle[] rois, int startIndex, int length) | ||
{ | ||
// Nothing... | ||
} | ||
|
||
protected override PropertyCollection OnCreatePropertyCollection() | ||
{ | ||
return new PropertyCollection(new List<Property>()); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/FileTypeDDS/FileTypeDDSEffect/Properties/AssemblyInfo.cs
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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("FileTypeDDSEffect")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("FileTypeDDSEffect")] | ||
[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("628e11f7-bf8d-4d22-8969-d38633450661")] | ||
|
||
// 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")] |