mirror of
https://github.com/R-YaTian/TinkeDSi.git
synced 2025-06-18 16:45:43 -04:00
* Fixed problem saving the NFTR font files
* Add support to change the map char info (PMAC section) in NFTR font files * Fixed problem with some fonts * Improved NINOKUNI plugin to pack .N2D files * Added support for SUBARASHIKI game (The world end with you) -> Unpack [pack] files * Added option to search files by offset -> Offset: 00000000 * Improved hexadecimal editor
This commit is contained in:
parent
c9ce2e0ba8
commit
3c697b464c
70
Be.Windows.Forms.HexBox/AssemblyInfo.cs
Normal file
70
Be.Windows.Forms.HexBox/AssemblyInfo.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Permissions;
|
||||
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("Be.Windows.Forms.HexBox")]
|
||||
[assembly: AssemblyDescription("hex edit control (C# DOTNET)")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Be")]
|
||||
[assembly: AssemblyProduct("Be.Windows.Forms.HexBox")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// 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 Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.4.7.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
|
||||
//[assembly: AssemblyKeyFile("../../HexBox.snk")]
|
||||
//[assembly: AssemblyKeyName("")]
|
||||
|
||||
//[assembly:IsolatedStorageFilePermission(SecurityAction.RequestRefuse, UserQuota=1048576)]
|
||||
//[assembly:SecurityPermission(SecurityAction.RequestRefuse, UnmanagedCode=true)]
|
||||
//[assembly:FileIOPermission(SecurityAction.RequestOptional, Unrestricted=true)]
|
||||
|
||||
[assembly:CLSCompliant(true)]
|
||||
|
||||
[assembly:ComVisible(false)]
|
207
Be.Windows.Forms.HexBox/Be.Windows.Forms.HexBox.csproj
Normal file
207
Be.Windows.Forms.HexBox/Be.Windows.Forms.HexBox.csproj
Normal file
@ -0,0 +1,207 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{26C5F25F-B450-4CAF-AD8B-B8D11AE73457}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>Be.Windows.Forms.HexBox</AssemblyName>
|
||||
<AssemblyOriginatorKeyFile>HexBox.snk</AssemblyOriginatorKeyFile>
|
||||
<DefaultClientScript>JScript</DefaultClientScript>
|
||||
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
|
||||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||
<DelaySign>false</DelaySign>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Be.Windows.Forms</RootNamespace>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DocumentationFile>Be.Windows.Forms.HexBox.xml</DocumentationFile>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<NoStdLib>false</NoStdLib>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
<Optimize>false</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugType>full</DebugType>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<NoStdLib>false</NoStdLib>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
<Optimize>true</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugType>none</DebugType>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>BasicCorrectnessRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<Name>System</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Data">
|
||||
<Name>System.Data</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing.Design" />
|
||||
<Reference Include="System.Windows.Forms">
|
||||
<Name>System.Windows.Forms</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml">
|
||||
<Name>System.XML</Name>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BuiltInContextMenu.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ByteCollection.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BytePositionInfo.cs" />
|
||||
<Compile Include="DataBlock.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DataMap.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DynamicByteProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DynamicFileByteProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FileByteProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FileDataBlock.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="HexBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="HexCasing.cs" />
|
||||
<Compile Include="ByteCharConverters.cs" />
|
||||
<Compile Include="IByteProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MemoryDataBlock.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NativeMethods.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Util.cs" />
|
||||
<EmbeddedResource Include="HexBox.bmp" />
|
||||
<EmbeddedResource Include="HexBox.resx">
|
||||
<DependentUpon>HexBox.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="HexBox.snk" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
1616
Be.Windows.Forms.HexBox/Be.Windows.Forms.HexBox.xml
Normal file
1616
Be.Windows.Forms.HexBox/Be.Windows.Forms.HexBox.xml
Normal file
File diff suppressed because it is too large
Load Diff
220
Be.Windows.Forms.HexBox/BuiltInContextMenu.cs
Normal file
220
Be.Windows.Forms.HexBox/BuiltInContextMenu.cs
Normal file
@ -0,0 +1,220 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a build-in ContextMenuStrip manager for HexBox control to show Copy, Cut, Paste menu in contextmenu of the control.
|
||||
/// </summary>
|
||||
[TypeConverterAttribute(typeof(ExpandableObjectConverter))]
|
||||
public sealed class BuiltInContextMenu : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the HexBox control.
|
||||
/// </summary>
|
||||
HexBox _hexBox;
|
||||
/// <summary>
|
||||
/// Contains the ContextMenuStrip control.
|
||||
/// </summary>
|
||||
ContextMenuStrip _contextMenuStrip;
|
||||
/// <summary>
|
||||
/// Contains the "Cut"-ToolStripMenuItem object.
|
||||
/// </summary>
|
||||
ToolStripMenuItem _cutToolStripMenuItem;
|
||||
/// <summary>
|
||||
/// Contains the "Copy"-ToolStripMenuItem object.
|
||||
/// </summary>
|
||||
ToolStripMenuItem _copyToolStripMenuItem;
|
||||
/// <summary>
|
||||
/// Contains the "Paste"-ToolStripMenuItem object.
|
||||
/// </summary>
|
||||
ToolStripMenuItem _pasteToolStripMenuItem;
|
||||
/// <summary>
|
||||
/// Contains the "Select All"-ToolStripMenuItem object.
|
||||
/// </summary>
|
||||
ToolStripMenuItem _selectAllToolStripMenuItem;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of BuildInContextMenu class.
|
||||
/// </summary>
|
||||
/// <param name="hexBox">the HexBox control</param>
|
||||
internal BuiltInContextMenu(HexBox hexBox)
|
||||
{
|
||||
_hexBox = hexBox;
|
||||
_hexBox.ByteProviderChanged += new EventHandler(HexBox_ByteProviderChanged);
|
||||
}
|
||||
/// <summary>
|
||||
/// If ByteProvider
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void HexBox_ByteProviderChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckBuiltInContextMenu();
|
||||
}
|
||||
/// <summary>
|
||||
/// Assigns the ContextMenuStrip control to the HexBox control.
|
||||
/// </summary>
|
||||
void CheckBuiltInContextMenu()
|
||||
{
|
||||
if (Util.DesignMode)
|
||||
return;
|
||||
|
||||
if (this._contextMenuStrip == null)
|
||||
{
|
||||
ContextMenuStrip cms = new ContextMenuStrip();
|
||||
_cutToolStripMenuItem = new ToolStripMenuItem(CutMenuItemTextInternal, CutMenuItemImage, new EventHandler(CutMenuItem_Click));
|
||||
cms.Items.Add(_cutToolStripMenuItem);
|
||||
_copyToolStripMenuItem = new ToolStripMenuItem(CopyMenuItemTextInternal, CopyMenuItemImage, new EventHandler(CopyMenuItem_Click));
|
||||
cms.Items.Add(_copyToolStripMenuItem);
|
||||
_pasteToolStripMenuItem = new ToolStripMenuItem(PasteMenuItemTextInternal, PasteMenuItemImage, new EventHandler(PasteMenuItem_Click));
|
||||
cms.Items.Add(_pasteToolStripMenuItem);
|
||||
|
||||
cms.Items.Add(new ToolStripSeparator());
|
||||
|
||||
_selectAllToolStripMenuItem = new ToolStripMenuItem(SelectAllMenuItemTextInternal, SelectAllMenuItemImage, new EventHandler(SelectAllMenuItem_Click));
|
||||
cms.Items.Add(_selectAllToolStripMenuItem);
|
||||
cms.Opening += new CancelEventHandler(BuildInContextMenuStrip_Opening);
|
||||
|
||||
_contextMenuStrip = cms;
|
||||
}
|
||||
|
||||
if (this._hexBox.ByteProvider == null && this._hexBox.ContextMenuStrip != null)
|
||||
this._hexBox.ContextMenuStrip = null;
|
||||
else if (this._hexBox.ByteProvider != null && this._hexBox.ContextMenuStrip == null)
|
||||
this._hexBox.ContextMenuStrip = _contextMenuStrip;
|
||||
}
|
||||
/// <summary>
|
||||
/// Before opening the ContextMenuStrip, we manage the availability of the items.
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void BuildInContextMenuStrip_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
_cutToolStripMenuItem.Enabled = this._hexBox.CanCut();
|
||||
_copyToolStripMenuItem.Enabled = this._hexBox.CanCopy();
|
||||
_pasteToolStripMenuItem.Enabled = this._hexBox.CanPaste();
|
||||
_selectAllToolStripMenuItem.Enabled = this._hexBox.CanSelectAll();
|
||||
}
|
||||
/// <summary>
|
||||
/// The handler for the "Cut"-Click event
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void CutMenuItem_Click(object sender, EventArgs e) { this._hexBox.Cut(); }
|
||||
/// <summary>
|
||||
/// The handler for the "Copy"-Click event
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void CopyMenuItem_Click(object sender, EventArgs e) { this._hexBox.Copy(); }
|
||||
/// <summary>
|
||||
/// The handler for the "Paste"-Click event
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void PasteMenuItem_Click(object sender, EventArgs e) { this._hexBox.Paste(); }
|
||||
/// <summary>
|
||||
/// The handler for the "Select All"-Click event
|
||||
/// </summary>
|
||||
/// <param name="sender">the sender object</param>
|
||||
/// <param name="e">the event data</param>
|
||||
void SelectAllMenuItem_Click(object sender, EventArgs e) { this._hexBox.SelectAll(); }
|
||||
/// <summary>
|
||||
/// Gets or sets the custom text of the "Copy" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null), Localizable(true)]
|
||||
public string CopyMenuItemText
|
||||
{
|
||||
get { return _copyMenuItemText; }
|
||||
set { _copyMenuItemText = value; }
|
||||
} string _copyMenuItemText;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom text of the "Cut" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null), Localizable(true)]
|
||||
public string CutMenuItemText
|
||||
{
|
||||
get { return _cutMenuItemText; }
|
||||
set { _cutMenuItemText = value; }
|
||||
} string _cutMenuItemText;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom text of the "Paste" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null), Localizable(true)]
|
||||
public string PasteMenuItemText
|
||||
{
|
||||
get { return _pasteMenuItemText; }
|
||||
set { _pasteMenuItemText = value; }
|
||||
} string _pasteMenuItemText;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom text of the "Select All" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null), Localizable(true)]
|
||||
public string SelectAllMenuItemText
|
||||
{
|
||||
get { return _selectAllMenuItemText; }
|
||||
set { _selectAllMenuItemText = value; }
|
||||
} string _selectAllMenuItemText = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text of the "Cut" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
internal string CutMenuItemTextInternal { get { return !string.IsNullOrEmpty(CutMenuItemText) ? CutMenuItemText : "Cut"; } }
|
||||
/// <summary>
|
||||
/// Gets the text of the "Copy" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
internal string CopyMenuItemTextInternal { get { return !string.IsNullOrEmpty(CopyMenuItemText) ? CopyMenuItemText : "Copy"; } }
|
||||
/// <summary>
|
||||
/// Gets the text of the "Paste" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
internal string PasteMenuItemTextInternal { get { return !string.IsNullOrEmpty(PasteMenuItemText) ? PasteMenuItemText : "Paste"; } }
|
||||
/// <summary>
|
||||
/// Gets the text of the "Select All" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
internal string SelectAllMenuItemTextInternal { get { return !string.IsNullOrEmpty(SelectAllMenuItemText) ? SelectAllMenuItemText : "SelectAll"; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the image of the "Cut" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null)]
|
||||
public Image CutMenuItemImage
|
||||
{
|
||||
get { return _cutMenuItemImage; }
|
||||
set { _cutMenuItemImage = value; }
|
||||
} Image _cutMenuItemImage = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the image of the "Copy" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null)]
|
||||
public Image CopyMenuItemImage
|
||||
{
|
||||
get { return _copyMenuItemImage; }
|
||||
set { _copyMenuItemImage = value; }
|
||||
} Image _copyMenuItemImage = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the image of the "Paste" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null)]
|
||||
public Image PasteMenuItemImage
|
||||
{
|
||||
get { return _pasteMenuItemImage; }
|
||||
set { _pasteMenuItemImage = value; }
|
||||
} Image _pasteMenuItemImage = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the image of the "Select All" ContextMenuStrip item.
|
||||
/// </summary>
|
||||
[Category("BuiltIn-ContextMenu"), DefaultValue(null)]
|
||||
public Image SelectAllMenuItemImage
|
||||
{
|
||||
get { return _selectAllMenuItemImage; }
|
||||
set { _selectAllMenuItemImage = value; }
|
||||
} Image _selectAllMenuItemImage = null;
|
||||
}
|
||||
}
|
104
Be.Windows.Forms.HexBox/ByteCharConverters.cs
Normal file
104
Be.Windows.Forms.HexBox/ByteCharConverters.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// The interface for objects that can translate between characters and bytes.
|
||||
/// </summary>
|
||||
public interface IByteCharConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the character to display for the byte passed across.
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
char ToChar(byte b);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the byte to use when the character passed across is entered during editing.
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
/// <returns></returns>
|
||||
byte ToByte(char c);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default <see cref="IByteCharConverter"/> implementation.
|
||||
/// </summary>
|
||||
public class DefaultByteCharConverter : IByteCharConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the character to display for the byte passed across.
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
public virtual char ToChar(byte b)
|
||||
{
|
||||
return b > 0x1F && !(b > 0x7E && b < 0xA0) ? (char)b : '.';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the byte to use for the character passed across.
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
/// <returns></returns>
|
||||
public virtual byte ToByte(char c)
|
||||
{
|
||||
return (byte)c;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a description of the byte char provider.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "Default";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A byte char provider that can translate bytes encoded in codepage 500 EBCDIC
|
||||
/// </summary>
|
||||
public class EbcdicByteCharProvider : IByteCharConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// The IBM EBCDIC code page 500 encoding. Note that this is not always supported by .NET,
|
||||
/// the underlying platform has to provide support for it.
|
||||
/// </summary>
|
||||
private Encoding _ebcdicEncoding = Encoding.GetEncoding(500);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the EBCDIC character corresponding to the byte passed across.
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
public virtual char ToChar(byte b)
|
||||
{
|
||||
string encoded = _ebcdicEncoding.GetString(new byte[] { b });
|
||||
return encoded.Length > 0 ? encoded[0] : '.';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the byte corresponding to the EBCDIC character passed across.
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
/// <returns></returns>
|
||||
public virtual byte ToByte(char c)
|
||||
{
|
||||
byte[] decoded = _ebcdicEncoding.GetBytes(new char[] { c });
|
||||
return decoded.Length > 0 ? decoded[0] : (byte)0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a description of the byte char provider.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "EBCDIC (Code Page 500)";
|
||||
}
|
||||
}
|
||||
}
|
127
Be.Windows.Forms.HexBox/ByteCollection.cs
Normal file
127
Be.Windows.Forms.HexBox/ByteCollection.cs
Normal file
@ -0,0 +1,127 @@
|
||||
using System;
|
||||
|
||||
using System.Collections;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of bytes.
|
||||
/// </summary>
|
||||
public class ByteCollection : CollectionBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ByteCollection class.
|
||||
/// </summary>
|
||||
public ByteCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ByteCollection class.
|
||||
/// </summary>
|
||||
/// <param name="bs">an array of bytes to add to collection</param>
|
||||
public ByteCollection(byte[] bs)
|
||||
{ AddRange(bs); }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of a byte
|
||||
/// </summary>
|
||||
public byte this[int index]
|
||||
{
|
||||
get { return (byte)List[index]; }
|
||||
set { List[index] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a byte into the collection.
|
||||
/// </summary>
|
||||
/// <param name="b">the byte to add</param>
|
||||
public void Add(byte b)
|
||||
{ List.Add(b); }
|
||||
|
||||
/// <summary>
|
||||
/// Adds a range of bytes to the collection.
|
||||
/// </summary>
|
||||
/// <param name="bs">the bytes to add</param>
|
||||
public void AddRange(byte[] bs)
|
||||
{ InnerList.AddRange(bs); }
|
||||
|
||||
/// <summary>
|
||||
/// Removes a byte from the collection.
|
||||
/// </summary>
|
||||
/// <param name="b">the byte to remove</param>
|
||||
public void Remove(byte b)
|
||||
{ List.Remove(b); }
|
||||
|
||||
/// <summary>
|
||||
/// Removes a range of bytes from the collection.
|
||||
/// </summary>
|
||||
/// <param name="index">the index of the start byte</param>
|
||||
/// <param name="count">the count of the bytes to remove</param>
|
||||
public void RemoveRange(int index, int count)
|
||||
{ InnerList.RemoveRange(index, count); }
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a range of bytes to the collection.
|
||||
/// </summary>
|
||||
/// <param name="index">the index of start byte</param>
|
||||
/// <param name="bs">an array of bytes to insert</param>
|
||||
public void InsertRange(int index, byte[] bs)
|
||||
{ InnerList.InsertRange(index, bs); }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all bytes in the array
|
||||
/// </summary>
|
||||
/// <returns>an array of bytes.</returns>
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
byte[] bytes = new byte[Count];
|
||||
InnerList.CopyTo(0, bytes, 0, bytes.Length);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a byte to the collection.
|
||||
/// </summary>
|
||||
/// <param name="index">the index</param>
|
||||
/// <param name="b">a byte to insert</param>
|
||||
public void Insert(int index, byte b)
|
||||
{
|
||||
InnerList.Insert(index, b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the given byte.
|
||||
/// </summary>
|
||||
public int IndexOf(byte b)
|
||||
{
|
||||
return InnerList.IndexOf(b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if the byte exists in the collection.
|
||||
/// </summary>
|
||||
public bool Contains(byte b)
|
||||
{
|
||||
return InnerList.Contains(b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the content of the collection into the given array.
|
||||
/// </summary>
|
||||
public void CopyTo(byte[] bs, int index)
|
||||
{
|
||||
InnerList.CopyTo(bs, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the content of the collection into an array.
|
||||
/// </summary>
|
||||
/// <returns>the array containing all bytes.</returns>
|
||||
public byte[] ToArray()
|
||||
{
|
||||
byte[] data = new byte[this.Count];
|
||||
this.CopyTo(data, 0);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
28
Be.Windows.Forms.HexBox/BytePositionInfo.cs
Normal file
28
Be.Windows.Forms.HexBox/BytePositionInfo.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a position in the HexBox control
|
||||
/// </summary>
|
||||
struct BytePositionInfo
|
||||
{
|
||||
public BytePositionInfo(long index, int characterPosition)
|
||||
{
|
||||
_index = index;
|
||||
_characterPosition = characterPosition;
|
||||
}
|
||||
|
||||
public int CharacterPosition
|
||||
{
|
||||
get { return _characterPosition; }
|
||||
} int _characterPosition;
|
||||
|
||||
public long Index
|
||||
{
|
||||
get { return _index; }
|
||||
} long _index;
|
||||
}
|
||||
}
|
42
Be.Windows.Forms.HexBox/DataBlock.cs
Normal file
42
Be.Windows.Forms.HexBox/DataBlock.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
internal abstract class DataBlock
|
||||
{
|
||||
internal DataMap _map;
|
||||
internal DataBlock _nextBlock;
|
||||
internal DataBlock _previousBlock;
|
||||
|
||||
public abstract long Length
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public DataMap Map
|
||||
{
|
||||
get
|
||||
{
|
||||
return _map;
|
||||
}
|
||||
}
|
||||
|
||||
public DataBlock NextBlock
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nextBlock;
|
||||
}
|
||||
}
|
||||
|
||||
public DataBlock PreviousBlock
|
||||
{
|
||||
get
|
||||
{
|
||||
return _previousBlock;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void RemoveBytes(long position, long count);
|
||||
}
|
||||
}
|
318
Be.Windows.Forms.HexBox/DataMap.cs
Normal file
318
Be.Windows.Forms.HexBox/DataMap.cs
Normal file
@ -0,0 +1,318 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
internal class DataMap : ICollection, IEnumerable
|
||||
{
|
||||
readonly object _syncRoot = new object();
|
||||
internal int _count;
|
||||
internal DataBlock _firstBlock;
|
||||
internal int _version;
|
||||
|
||||
public DataMap()
|
||||
{
|
||||
}
|
||||
|
||||
public DataMap(IEnumerable collection)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw new ArgumentNullException("collection");
|
||||
}
|
||||
|
||||
foreach (DataBlock item in collection)
|
||||
{
|
||||
AddLast(item);
|
||||
}
|
||||
}
|
||||
|
||||
public DataBlock FirstBlock
|
||||
{
|
||||
get
|
||||
{
|
||||
return _firstBlock;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddAfter(DataBlock block, DataBlock newBlock)
|
||||
{
|
||||
AddAfterInternal(block, newBlock);
|
||||
}
|
||||
|
||||
public void AddBefore(DataBlock block, DataBlock newBlock)
|
||||
{
|
||||
AddBeforeInternal(block, newBlock);
|
||||
}
|
||||
|
||||
public void AddFirst(DataBlock block)
|
||||
{
|
||||
if (_firstBlock == null)
|
||||
{
|
||||
AddBlockToEmptyMap(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddBeforeInternal(_firstBlock, block);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddLast(DataBlock block)
|
||||
{
|
||||
if (_firstBlock == null)
|
||||
{
|
||||
AddBlockToEmptyMap(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddAfterInternal(GetLastBlock(), block);
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(DataBlock block)
|
||||
{
|
||||
RemoveInternal(block);
|
||||
}
|
||||
|
||||
public void RemoveFirst()
|
||||
{
|
||||
if (_firstBlock == null)
|
||||
{
|
||||
throw new InvalidOperationException("The collection is empty.");
|
||||
}
|
||||
RemoveInternal(_firstBlock);
|
||||
}
|
||||
|
||||
public void RemoveLast()
|
||||
{
|
||||
if (_firstBlock == null)
|
||||
{
|
||||
throw new InvalidOperationException("The collection is empty.");
|
||||
}
|
||||
RemoveInternal(GetLastBlock());
|
||||
}
|
||||
|
||||
public DataBlock Replace(DataBlock block, DataBlock newBlock)
|
||||
{
|
||||
AddAfterInternal(block, newBlock);
|
||||
RemoveInternal(block);
|
||||
return newBlock;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
DataBlock block = FirstBlock;
|
||||
while (block != null)
|
||||
{
|
||||
DataBlock nextBlock = block.NextBlock;
|
||||
InvalidateBlock(block);
|
||||
block = nextBlock;
|
||||
}
|
||||
_firstBlock = null;
|
||||
_count = 0;
|
||||
_version++;
|
||||
}
|
||||
|
||||
void AddAfterInternal(DataBlock block, DataBlock newBlock)
|
||||
{
|
||||
newBlock._previousBlock = block;
|
||||
newBlock._nextBlock = block._nextBlock;
|
||||
newBlock._map = this;
|
||||
|
||||
if (block._nextBlock != null)
|
||||
{
|
||||
block._nextBlock._previousBlock = newBlock;
|
||||
}
|
||||
block._nextBlock = newBlock;
|
||||
|
||||
this._version++;
|
||||
this._count++;
|
||||
}
|
||||
|
||||
void AddBeforeInternal(DataBlock block, DataBlock newBlock)
|
||||
{
|
||||
newBlock._nextBlock = block;
|
||||
newBlock._previousBlock = block._previousBlock;
|
||||
newBlock._map = this;
|
||||
|
||||
if (block._previousBlock != null)
|
||||
{
|
||||
block._previousBlock._nextBlock = newBlock;
|
||||
}
|
||||
block._previousBlock = newBlock;
|
||||
|
||||
if (_firstBlock == block)
|
||||
{
|
||||
_firstBlock = newBlock;
|
||||
}
|
||||
this._version++;
|
||||
this._count++;
|
||||
}
|
||||
|
||||
void RemoveInternal(DataBlock block)
|
||||
{
|
||||
DataBlock previousBlock = block._previousBlock;
|
||||
DataBlock nextBlock = block._nextBlock;
|
||||
|
||||
if (previousBlock != null)
|
||||
{
|
||||
previousBlock._nextBlock = nextBlock;
|
||||
}
|
||||
|
||||
if (nextBlock != null)
|
||||
{
|
||||
nextBlock._previousBlock = previousBlock;
|
||||
}
|
||||
|
||||
if (_firstBlock == block)
|
||||
{
|
||||
_firstBlock = nextBlock;
|
||||
}
|
||||
|
||||
InvalidateBlock(block);
|
||||
|
||||
_count--;
|
||||
_version++;
|
||||
}
|
||||
|
||||
DataBlock GetLastBlock()
|
||||
{
|
||||
DataBlock lastBlock = null;
|
||||
for (DataBlock block = FirstBlock; block != null; block = block.NextBlock)
|
||||
{
|
||||
lastBlock = block;
|
||||
}
|
||||
return lastBlock;
|
||||
}
|
||||
|
||||
void InvalidateBlock(DataBlock block)
|
||||
{
|
||||
block._map = null;
|
||||
block._nextBlock = null;
|
||||
block._previousBlock = null;
|
||||
}
|
||||
|
||||
void AddBlockToEmptyMap(DataBlock block)
|
||||
{
|
||||
block._map = this;
|
||||
block._nextBlock = null;
|
||||
block._previousBlock = null;
|
||||
|
||||
_firstBlock = block;
|
||||
_version++;
|
||||
_count++;
|
||||
}
|
||||
|
||||
#region ICollection Members
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
DataBlock[] blockArray = array as DataBlock[];
|
||||
for (DataBlock block = FirstBlock; block != null; block = block.NextBlock)
|
||||
{
|
||||
blockArray[index++] = block;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSynchronized
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public object SyncRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
return _syncRoot;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return new Enumerator(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Enumerator Nested Type
|
||||
internal class Enumerator : IEnumerator, IDisposable
|
||||
{
|
||||
DataMap _map;
|
||||
DataBlock _current;
|
||||
int _index;
|
||||
int _version;
|
||||
|
||||
internal Enumerator(DataMap map)
|
||||
{
|
||||
_map = map;
|
||||
_version = map._version;
|
||||
_current = null;
|
||||
_index = -1;
|
||||
}
|
||||
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_index < 0 || _index > _map.Count)
|
||||
{
|
||||
throw new InvalidOperationException("Enumerator is positioned before the first element or after the last element of the collection.");
|
||||
}
|
||||
return _current;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (this._version != _map._version)
|
||||
{
|
||||
throw new InvalidOperationException("Collection was modified after the enumerator was instantiated.");
|
||||
}
|
||||
|
||||
if (_index >= _map.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (++_index == 0)
|
||||
{
|
||||
_current = _map.FirstBlock;
|
||||
}
|
||||
else
|
||||
{
|
||||
_current = _current.NextBlock;
|
||||
}
|
||||
|
||||
return (_index < _map.Count);
|
||||
}
|
||||
|
||||
void IEnumerator.Reset()
|
||||
{
|
||||
if (this._version != this._map._version)
|
||||
{
|
||||
throw new InvalidOperationException("Collection was modified after the enumerator was instantiated.");
|
||||
}
|
||||
|
||||
this._index = -1;
|
||||
this._current = null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
177
Be.Windows.Forms.HexBox/DynamicByteProvider.cs
Normal file
177
Be.Windows.Forms.HexBox/DynamicByteProvider.cs
Normal file
@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Byte provider for a small amount of data.
|
||||
/// </summary>
|
||||
public class DynamicByteProvider : IByteProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information about changes.
|
||||
/// </summary>
|
||||
bool _hasChanges;
|
||||
/// <summary>
|
||||
/// Contains a byte collection.
|
||||
/// </summary>
|
||||
List<byte> _bytes;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DynamicByteProvider class.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public DynamicByteProvider(byte[] data) : this(new List<Byte>(data))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DynamicByteProvider class.
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
public DynamicByteProvider(List<Byte> bytes)
|
||||
{
|
||||
_bytes = bytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the Changed event.
|
||||
/// </summary>
|
||||
void OnChanged(EventArgs e)
|
||||
{
|
||||
_hasChanges = true;
|
||||
|
||||
if(Changed != null)
|
||||
Changed(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the LengthChanged event.
|
||||
/// </summary>
|
||||
void OnLengthChanged(EventArgs e)
|
||||
{
|
||||
if(LengthChanged != null)
|
||||
LengthChanged(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the byte collection.
|
||||
/// </summary>
|
||||
public List<Byte> Bytes
|
||||
{
|
||||
get { return _bytes; }
|
||||
}
|
||||
|
||||
#region IByteProvider Members
|
||||
/// <summary>
|
||||
/// True, when changes are done.
|
||||
/// </summary>
|
||||
public bool HasChanges()
|
||||
{
|
||||
return _hasChanges;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies changes.
|
||||
/// </summary>
|
||||
public void ApplyChanges()
|
||||
{
|
||||
_hasChanges = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs, when the write buffer contains new changes.
|
||||
/// </summary>
|
||||
public event EventHandler Changed;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs, when InsertBytes or DeleteBytes method is called.
|
||||
/// </summary>
|
||||
public event EventHandler LengthChanged;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reads a byte from the byte collection.
|
||||
/// </summary>
|
||||
/// <param name="index">the index of the byte to read</param>
|
||||
/// <returns>the byte</returns>
|
||||
public byte ReadByte(long index)
|
||||
{ return _bytes[(int)index]; }
|
||||
|
||||
/// <summary>
|
||||
/// Write a byte into the byte collection.
|
||||
/// </summary>
|
||||
/// <param name="index">the index of the byte to write.</param>
|
||||
/// <param name="value">the byte</param>
|
||||
public void WriteByte(long index, byte value)
|
||||
{
|
||||
_bytes[(int)index] = value;
|
||||
OnChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes bytes from the byte collection.
|
||||
/// </summary>
|
||||
/// <param name="index">the start index of the bytes to delete.</param>
|
||||
/// <param name="length">the length of bytes to delete.</param>
|
||||
public void DeleteBytes(long index, long length)
|
||||
{
|
||||
int internal_index = (int)Math.Max(0, index);
|
||||
int internal_length = (int)Math.Min((int)Length, length);
|
||||
_bytes.RemoveRange(internal_index, internal_length);
|
||||
|
||||
OnLengthChanged(EventArgs.Empty);
|
||||
OnChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts byte into the byte collection.
|
||||
/// </summary>
|
||||
/// <param name="index">the start index of the bytes in the byte collection</param>
|
||||
/// <param name="bs">the byte array to insert</param>
|
||||
public void InsertBytes(long index, byte[] bs)
|
||||
{
|
||||
_bytes.InsertRange((int)index, bs);
|
||||
|
||||
OnLengthChanged(EventArgs.Empty);
|
||||
OnChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the length of the bytes in the byte collection.
|
||||
/// </summary>
|
||||
public long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return _bytes.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true
|
||||
/// </summary>
|
||||
public bool SupportsWriteByte()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true
|
||||
/// </summary>
|
||||
public bool SupportsInsertBytes()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true
|
||||
/// </summary>
|
||||
public bool SupportsDeleteBytes()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
569
Be.Windows.Forms.HexBox/DynamicFileByteProvider.cs
Normal file
569
Be.Windows.Forms.HexBox/DynamicFileByteProvider.cs
Normal file
@ -0,0 +1,569 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements a fully editable byte provider for file data of any size.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only changes to the file are stored in memory with reads from the
|
||||
/// original data occurring as required.
|
||||
/// </remarks>
|
||||
public sealed class DynamicFileByteProvider : IByteProvider, IDisposable
|
||||
{
|
||||
const int COPY_BLOCK_SIZE = 4096;
|
||||
|
||||
string _fileName;
|
||||
Stream _stream;
|
||||
DataMap _dataMap;
|
||||
long _totalLength;
|
||||
bool _readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="DynamicFileByteProvider" /> instance.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file from which bytes should be provided.</param>
|
||||
public DynamicFileByteProvider(string fileName) : this(fileName, false) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="DynamicFileByteProvider" /> instance.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file from which bytes should be provided.</param>
|
||||
/// <param name="readOnly">True, opens the file in read-only mode.</param>
|
||||
public DynamicFileByteProvider(string fileName, bool readOnly)
|
||||
{
|
||||
_fileName = fileName;
|
||||
|
||||
if (!readOnly)
|
||||
{
|
||||
_stream = File.Open(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
|
||||
}
|
||||
else
|
||||
{
|
||||
_stream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
}
|
||||
|
||||
_readOnly = readOnly;
|
||||
|
||||
ReInitialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="DynamicFileByteProvider" /> instance.
|
||||
/// </summary>
|
||||
/// <param name="stream">the stream containing the data.</param>
|
||||
/// <remarks>
|
||||
/// The stream must supported seek operations.
|
||||
/// </remarks>
|
||||
public DynamicFileByteProvider(Stream stream)
|
||||
{
|
||||
if (stream == null)
|
||||
throw new ArgumentNullException("stream");
|
||||
if (!stream.CanSeek)
|
||||
throw new ArgumentException("stream must supported seek operations(CanSeek)");
|
||||
|
||||
_stream = stream;
|
||||
_readOnly = !stream.CanWrite;
|
||||
ReInitialize();
|
||||
}
|
||||
|
||||
#region IByteProvider Members
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.LengthChanged" /> for more information.
|
||||
/// </summary>
|
||||
public event EventHandler LengthChanged;
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.Changed" /> for more information.
|
||||
/// </summary>
|
||||
public event EventHandler Changed;
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.ReadByte" /> for more information.
|
||||
/// </summary>
|
||||
public byte ReadByte(long index)
|
||||
{
|
||||
long blockOffset;
|
||||
DataBlock block = GetDataBlock(index, out blockOffset);
|
||||
FileDataBlock fileBlock = block as FileDataBlock;
|
||||
if (fileBlock != null)
|
||||
{
|
||||
return ReadByteFromFile(fileBlock.FileOffset + index - blockOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
MemoryDataBlock memoryBlock = (MemoryDataBlock)block;
|
||||
return memoryBlock.Data[index - blockOffset];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.WriteByte" /> for more information.
|
||||
/// </summary>
|
||||
public void WriteByte(long index, byte value)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Find the block affected.
|
||||
long blockOffset;
|
||||
DataBlock block = GetDataBlock(index, out blockOffset);
|
||||
|
||||
// If the byte is already in a memory block, modify it.
|
||||
MemoryDataBlock memoryBlock = block as MemoryDataBlock;
|
||||
if (memoryBlock != null)
|
||||
{
|
||||
memoryBlock.Data[index - blockOffset] = value;
|
||||
return;
|
||||
}
|
||||
|
||||
FileDataBlock fileBlock = (FileDataBlock)block;
|
||||
|
||||
// If the byte changing is the first byte in the block and the previous block is a memory block, extend that.
|
||||
if (blockOffset == index && block.PreviousBlock != null)
|
||||
{
|
||||
MemoryDataBlock previousMemoryBlock = block.PreviousBlock as MemoryDataBlock;
|
||||
if (previousMemoryBlock != null)
|
||||
{
|
||||
previousMemoryBlock.AddByteToEnd(value);
|
||||
fileBlock.RemoveBytesFromStart(1);
|
||||
if (fileBlock.Length == 0)
|
||||
{
|
||||
_dataMap.Remove(fileBlock);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If the byte changing is the last byte in the block and the next block is a memory block, extend that.
|
||||
if (blockOffset + fileBlock.Length - 1 == index && block.NextBlock != null)
|
||||
{
|
||||
MemoryDataBlock nextMemoryBlock = block.NextBlock as MemoryDataBlock;
|
||||
if (nextMemoryBlock != null)
|
||||
{
|
||||
nextMemoryBlock.AddByteToStart(value);
|
||||
fileBlock.RemoveBytesFromEnd(1);
|
||||
if (fileBlock.Length == 0)
|
||||
{
|
||||
_dataMap.Remove(fileBlock);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Split the block into a prefix and a suffix and place a memory block in-between.
|
||||
FileDataBlock prefixBlock = null;
|
||||
if (index > blockOffset)
|
||||
{
|
||||
prefixBlock = new FileDataBlock(fileBlock.FileOffset, index - blockOffset);
|
||||
}
|
||||
|
||||
FileDataBlock suffixBlock = null;
|
||||
if (index < blockOffset + fileBlock.Length - 1)
|
||||
{
|
||||
suffixBlock = new FileDataBlock(
|
||||
fileBlock.FileOffset + index - blockOffset + 1,
|
||||
fileBlock.Length - (index - blockOffset + 1));
|
||||
}
|
||||
|
||||
block = _dataMap.Replace(block, new MemoryDataBlock(value));
|
||||
|
||||
if (prefixBlock != null)
|
||||
{
|
||||
_dataMap.AddBefore(block, prefixBlock);
|
||||
}
|
||||
|
||||
if (suffixBlock != null)
|
||||
{
|
||||
_dataMap.AddAfter(block, suffixBlock);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
OnChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.InsertBytes" /> for more information.
|
||||
/// </summary>
|
||||
public void InsertBytes(long index, byte[] bs)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Find the block affected.
|
||||
long blockOffset;
|
||||
DataBlock block = GetDataBlock(index, out blockOffset);
|
||||
|
||||
// If the insertion point is in a memory block, just insert it.
|
||||
MemoryDataBlock memoryBlock = block as MemoryDataBlock;
|
||||
if (memoryBlock != null)
|
||||
{
|
||||
memoryBlock.InsertBytes(index - blockOffset, bs);
|
||||
return;
|
||||
}
|
||||
|
||||
FileDataBlock fileBlock = (FileDataBlock)block;
|
||||
|
||||
// If the insertion point is at the start of a file block, and the previous block is a memory block, append it to that block.
|
||||
if (blockOffset == index && block.PreviousBlock != null)
|
||||
{
|
||||
MemoryDataBlock previousMemoryBlock = block.PreviousBlock as MemoryDataBlock;
|
||||
if (previousMemoryBlock != null)
|
||||
{
|
||||
previousMemoryBlock.InsertBytes(previousMemoryBlock.Length, bs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Split the block into a prefix and a suffix and place a memory block in-between.
|
||||
FileDataBlock prefixBlock = null;
|
||||
if (index > blockOffset)
|
||||
{
|
||||
prefixBlock = new FileDataBlock(fileBlock.FileOffset, index - blockOffset);
|
||||
}
|
||||
|
||||
FileDataBlock suffixBlock = null;
|
||||
if (index < blockOffset + fileBlock.Length)
|
||||
{
|
||||
suffixBlock = new FileDataBlock(
|
||||
fileBlock.FileOffset + index - blockOffset,
|
||||
fileBlock.Length - (index - blockOffset));
|
||||
}
|
||||
|
||||
block = _dataMap.Replace(block, new MemoryDataBlock(bs));
|
||||
|
||||
if (prefixBlock != null)
|
||||
{
|
||||
_dataMap.AddBefore(block, prefixBlock);
|
||||
}
|
||||
|
||||
if (suffixBlock != null)
|
||||
{
|
||||
_dataMap.AddAfter(block, suffixBlock);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_totalLength += bs.Length;
|
||||
OnLengthChanged(EventArgs.Empty);
|
||||
OnChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.DeleteBytes" /> for more information.
|
||||
/// </summary>
|
||||
public void DeleteBytes(long index, long length)
|
||||
{
|
||||
try
|
||||
{
|
||||
long bytesToDelete = length;
|
||||
|
||||
// Find the first block affected.
|
||||
long blockOffset;
|
||||
DataBlock block = GetDataBlock(index, out blockOffset);
|
||||
|
||||
// Truncate or remove each block as necessary.
|
||||
while ((bytesToDelete > 0) && (block != null))
|
||||
{
|
||||
long blockLength = block.Length;
|
||||
DataBlock nextBlock = block.NextBlock;
|
||||
|
||||
// Delete the appropriate section from the block (this may result in two blocks or a zero length block).
|
||||
long count = Math.Min(bytesToDelete, blockLength - (index - blockOffset));
|
||||
block.RemoveBytes(index - blockOffset, count);
|
||||
|
||||
if (block.Length == 0)
|
||||
{
|
||||
_dataMap.Remove(block);
|
||||
if (_dataMap.FirstBlock == null)
|
||||
{
|
||||
_dataMap.AddFirst(new MemoryDataBlock(new byte[0]));
|
||||
}
|
||||
}
|
||||
|
||||
bytesToDelete -= count;
|
||||
blockOffset += block.Length;
|
||||
block = (bytesToDelete > 0) ? nextBlock : null;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_totalLength -= length;
|
||||
OnLengthChanged(EventArgs.Empty);
|
||||
OnChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.Length" /> for more information.
|
||||
/// </summary>
|
||||
public long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return _totalLength;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.HasChanges" /> for more information.
|
||||
/// </summary>
|
||||
public bool HasChanges()
|
||||
{
|
||||
if (_readOnly)
|
||||
return false;
|
||||
|
||||
if (_totalLength != _stream.Length)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
long offset = 0;
|
||||
for (DataBlock block = _dataMap.FirstBlock; block != null; block = block.NextBlock)
|
||||
{
|
||||
FileDataBlock fileBlock = block as FileDataBlock;
|
||||
if (fileBlock == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fileBlock.FileOffset != offset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
offset += fileBlock.Length;
|
||||
}
|
||||
return (offset != _stream.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.ApplyChanges" /> for more information.
|
||||
/// </summary>
|
||||
public void ApplyChanges()
|
||||
{
|
||||
if (_readOnly)
|
||||
throw new OperationCanceledException("File is in read-only mode");
|
||||
|
||||
// This method is implemented to efficiently save the changes to the same file stream opened for reading.
|
||||
// Saving to a separate file would be a much simpler implementation.
|
||||
|
||||
// Firstly, extend the file length (if necessary) to ensure that there is enough disk space.
|
||||
if (_totalLength > _stream.Length)
|
||||
{
|
||||
_stream.SetLength(_totalLength);
|
||||
}
|
||||
|
||||
// Secondly, shift around any file sections that have moved.
|
||||
long dataOffset = 0;
|
||||
for (DataBlock block = _dataMap.FirstBlock; block != null; block = block.NextBlock)
|
||||
{
|
||||
FileDataBlock fileBlock = block as FileDataBlock;
|
||||
if (fileBlock != null && fileBlock.FileOffset != dataOffset)
|
||||
{
|
||||
MoveFileBlock(fileBlock, dataOffset);
|
||||
}
|
||||
dataOffset += block.Length;
|
||||
}
|
||||
|
||||
// Next, write in-memory changes.
|
||||
dataOffset = 0;
|
||||
for (DataBlock block = _dataMap.FirstBlock; block != null; block = block.NextBlock)
|
||||
{
|
||||
MemoryDataBlock memoryBlock = block as MemoryDataBlock;
|
||||
if (memoryBlock != null)
|
||||
{
|
||||
_stream.Position = dataOffset;
|
||||
for (int memoryOffset = 0; memoryOffset < memoryBlock.Length; memoryOffset += COPY_BLOCK_SIZE)
|
||||
{
|
||||
_stream.Write(memoryBlock.Data, memoryOffset, (int)Math.Min(COPY_BLOCK_SIZE, memoryBlock.Length - memoryOffset));
|
||||
}
|
||||
}
|
||||
dataOffset += block.Length;
|
||||
}
|
||||
|
||||
// Finally, if the file has shortened, truncate the stream.
|
||||
_stream.SetLength(_totalLength);
|
||||
ReInitialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.SupportsWriteByte" /> for more information.
|
||||
/// </summary>
|
||||
public bool SupportsWriteByte()
|
||||
{
|
||||
return !_readOnly;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.SupportsInsertBytes" /> for more information.
|
||||
/// </summary>
|
||||
public bool SupportsInsertBytes()
|
||||
{
|
||||
return !_readOnly;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IByteProvider.SupportsDeleteBytes" /> for more information.
|
||||
/// </summary>
|
||||
public bool SupportsDeleteBytes()
|
||||
{
|
||||
return !_readOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
/// <summary>
|
||||
/// See <see cref="Object.Finalize" /> for more information.
|
||||
/// </summary>
|
||||
~DynamicFileByteProvider()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="IDisposable.Dispose" /> for more information.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_stream != null)
|
||||
{
|
||||
_stream.Close();
|
||||
_stream = null;
|
||||
}
|
||||
_fileName = null;
|
||||
_dataMap = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value, if the file is opened in read-only mode.
|
||||
/// </summary>
|
||||
public bool ReadOnly
|
||||
{
|
||||
get { return _readOnly; }
|
||||
}
|
||||
|
||||
void OnLengthChanged(EventArgs e)
|
||||
{
|
||||
if (LengthChanged != null)
|
||||
LengthChanged(this, e);
|
||||
}
|
||||
|
||||
void OnChanged(EventArgs e)
|
||||
{
|
||||
if (Changed != null)
|
||||
{
|
||||
Changed(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
DataBlock GetDataBlock(long findOffset, out long blockOffset)
|
||||
{
|
||||
if (findOffset < 0 || findOffset > _totalLength)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("findOffset");
|
||||
}
|
||||
|
||||
// Iterate over the blocks until the block containing the required offset is encountered.
|
||||
blockOffset = 0;
|
||||
for (DataBlock block = _dataMap.FirstBlock; block != null; block = block.NextBlock)
|
||||
{
|
||||
if ((blockOffset <= findOffset && blockOffset + block.Length > findOffset) || block.NextBlock == null)
|
||||
{
|
||||
return block;
|
||||
}
|
||||
blockOffset += block.Length;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
FileDataBlock GetNextFileDataBlock(DataBlock block, long dataOffset, out long nextDataOffset)
|
||||
{
|
||||
// Iterate over the remaining blocks until a file block is encountered.
|
||||
nextDataOffset = dataOffset + block.Length;
|
||||
block = block.NextBlock;
|
||||
while (block != null)
|
||||
{
|
||||
FileDataBlock fileBlock = block as FileDataBlock;
|
||||
if (fileBlock != null)
|
||||
{
|
||||
return fileBlock;
|
||||
}
|
||||
nextDataOffset += block.Length;
|
||||
block = block.NextBlock;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
byte ReadByteFromFile(long fileOffset)
|
||||
{
|
||||
// Move to the correct position and read the byte.
|
||||
if (_stream.Position != fileOffset)
|
||||
{
|
||||
_stream.Position = fileOffset;
|
||||
}
|
||||
return (byte)_stream.ReadByte();
|
||||
}
|
||||
|
||||
void MoveFileBlock(FileDataBlock fileBlock, long dataOffset)
|
||||
{
|
||||
// First, determine whether the next file block needs to move before this one.
|
||||
long nextDataOffset;
|
||||
FileDataBlock nextFileBlock = GetNextFileDataBlock(fileBlock, dataOffset, out nextDataOffset);
|
||||
if (nextFileBlock != null && dataOffset + fileBlock.Length > nextFileBlock.FileOffset)
|
||||
{
|
||||
// The next block needs to move first, so do that now.
|
||||
MoveFileBlock(nextFileBlock, nextDataOffset);
|
||||
}
|
||||
|
||||
// Now, move the block.
|
||||
if (fileBlock.FileOffset > dataOffset)
|
||||
{
|
||||
// Move the section to earlier in the file stream (done in chunks starting at the beginning of the section).
|
||||
byte[] buffer = new byte[COPY_BLOCK_SIZE];
|
||||
for (long relativeOffset = 0; relativeOffset < fileBlock.Length; relativeOffset += buffer.Length)
|
||||
{
|
||||
long readOffset = fileBlock.FileOffset + relativeOffset;
|
||||
int bytesToRead = (int)Math.Min(buffer.Length, fileBlock.Length - relativeOffset);
|
||||
_stream.Position = readOffset;
|
||||
_stream.Read(buffer, 0, bytesToRead);
|
||||
|
||||
long writeOffset = dataOffset + relativeOffset;
|
||||
_stream.Position = writeOffset;
|
||||
_stream.Write(buffer, 0, bytesToRead);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Move the section to later in the file stream (done in chunks starting at the end of the section).
|
||||
byte[] buffer = new byte[COPY_BLOCK_SIZE];
|
||||
for (long relativeOffset = 0; relativeOffset < fileBlock.Length; relativeOffset += buffer.Length)
|
||||
{
|
||||
int bytesToRead = (int)Math.Min(buffer.Length, fileBlock.Length - relativeOffset);
|
||||
long readOffset = fileBlock.FileOffset + fileBlock.Length - relativeOffset - bytesToRead;
|
||||
_stream.Position = readOffset;
|
||||
_stream.Read(buffer, 0, bytesToRead);
|
||||
|
||||
long writeOffset = dataOffset + fileBlock.Length - relativeOffset - bytesToRead;
|
||||
_stream.Position = writeOffset;
|
||||
_stream.Write(buffer, 0, bytesToRead);
|
||||
}
|
||||
}
|
||||
|
||||
// This block now points to a different position in the file.
|
||||
fileBlock.SetFileOffset(dataOffset);
|
||||
}
|
||||
|
||||
void ReInitialize()
|
||||
{
|
||||
_dataMap = new DataMap();
|
||||
_dataMap.AddFirst(new FileDataBlock(0, _stream.Length));
|
||||
_totalLength = _stream.Length;
|
||||
}
|
||||
}
|
||||
}
|
271
Be.Windows.Forms.HexBox/FileByteProvider.cs
Normal file
271
Be.Windows.Forms.HexBox/FileByteProvider.cs
Normal file
@ -0,0 +1,271 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Byte provider for (big) files.
|
||||
/// </summary>
|
||||
public class FileByteProvider : IByteProvider, IDisposable
|
||||
{
|
||||
#region WriteCollection class
|
||||
/// <summary>
|
||||
/// Represents the write buffer class
|
||||
/// </summary>
|
||||
class WriteCollection : DictionaryBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a byte in the collection
|
||||
/// </summary>
|
||||
public byte this[long index]
|
||||
{
|
||||
get { return (byte)this.Dictionary[index]; }
|
||||
set { Dictionary[index] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a byte into the collection
|
||||
/// </summary>
|
||||
/// <param name="index">the index of the byte</param>
|
||||
/// <param name="value">the value of the byte</param>
|
||||
public void Add(long index, byte value)
|
||||
{ Dictionary.Add(index, value); }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if a byte with the given index exists.
|
||||
/// </summary>
|
||||
/// <param name="index">the index of the byte</param>
|
||||
/// <returns>true, if the is in the collection</returns>
|
||||
public bool Contains(long index)
|
||||
{ return Dictionary.Contains(index); }
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Occurs, when the write buffer contains new changes.
|
||||
/// </summary>
|
||||
public event EventHandler Changed;
|
||||
|
||||
/// <summary>
|
||||
/// Contains all changes
|
||||
/// </summary>
|
||||
WriteCollection _writes = new WriteCollection();
|
||||
|
||||
/// <summary>
|
||||
/// Contains the file name.
|
||||
/// </summary>
|
||||
string _fileName;
|
||||
/// <summary>
|
||||
/// Contains the file stream.
|
||||
/// </summary>
|
||||
FileStream _fileStream;
|
||||
/// <summary>
|
||||
/// Read-only access.
|
||||
/// </summary>
|
||||
bool _readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the FileByteProvider class.
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
public FileByteProvider(string fileName)
|
||||
{
|
||||
_fileName = fileName;
|
||||
|
||||
try
|
||||
{
|
||||
// try to open in write mode
|
||||
_fileStream = File.Open(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// write mode failed, try to open in read-only and fileshare friendly mode.
|
||||
try
|
||||
{
|
||||
_fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
_readOnly = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Terminates the instance of the FileByteProvider class.
|
||||
/// </summary>
|
||||
~FileByteProvider()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the Changed event.
|
||||
/// </summary>
|
||||
/// <remarks>Never used.</remarks>
|
||||
void OnChanged(EventArgs e)
|
||||
{
|
||||
if(Changed != null)
|
||||
Changed(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the file the byte provider is using.
|
||||
/// </summary>
|
||||
public string FileName
|
||||
{
|
||||
get { return _fileName; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value if there are some changes.
|
||||
/// </summary>
|
||||
/// <returns>true, if there are some changes</returns>
|
||||
public bool HasChanges()
|
||||
{
|
||||
return (_writes.Count > 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the file with all changes the write buffer contains.
|
||||
/// </summary>
|
||||
public void ApplyChanges()
|
||||
{
|
||||
if (this._readOnly)
|
||||
{
|
||||
throw new Exception("File is in read-only mode.");
|
||||
}
|
||||
|
||||
if(!HasChanges())
|
||||
return;
|
||||
|
||||
IDictionaryEnumerator en = _writes.GetEnumerator();
|
||||
while(en.MoveNext())
|
||||
{
|
||||
long index = (long)en.Key;
|
||||
byte value = (byte)en.Value;
|
||||
if(_fileStream.Position != index)
|
||||
_fileStream.Position = index;
|
||||
_fileStream.Write(new byte[] { value }, 0, 1);
|
||||
}
|
||||
_writes.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the write buffer and reject all changes made.
|
||||
/// </summary>
|
||||
public void RejectChanges()
|
||||
{
|
||||
_writes.Clear();
|
||||
}
|
||||
|
||||
#region IByteProvider Members
|
||||
/// <summary>
|
||||
/// Never used.
|
||||
/// </summary>
|
||||
public event EventHandler LengthChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Reads a byte from the file.
|
||||
/// </summary>
|
||||
/// <param name="index">the index of the byte to read</param>
|
||||
/// <returns>the byte</returns>
|
||||
public byte ReadByte(long index)
|
||||
{
|
||||
if(_writes.Contains(index))
|
||||
return _writes[index];
|
||||
|
||||
if(_fileStream.Position != index)
|
||||
_fileStream.Position = index;
|
||||
|
||||
byte res = (byte)_fileStream.ReadByte();
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the length of the file.
|
||||
/// </summary>
|
||||
public long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fileStream.Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a byte into write buffer
|
||||
/// </summary>
|
||||
public void WriteByte(long index, byte value)
|
||||
{
|
||||
if(_writes.Contains(index))
|
||||
_writes[index] = value;
|
||||
else
|
||||
_writes.Add(index, value);
|
||||
|
||||
OnChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not supported
|
||||
/// </summary>
|
||||
public void DeleteBytes(long index, long length)
|
||||
{
|
||||
throw new NotSupportedException("FileByteProvider.DeleteBytes");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not supported
|
||||
/// </summary>
|
||||
public void InsertBytes(long index, byte[] bs)
|
||||
{
|
||||
throw new NotSupportedException("FileByteProvider.InsertBytes");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true
|
||||
/// </summary>
|
||||
public bool SupportsWriteByte()
|
||||
{
|
||||
return !_readOnly;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns false
|
||||
/// </summary>
|
||||
public bool SupportsInsertBytes()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns false
|
||||
/// </summary>
|
||||
public bool SupportsDeleteBytes()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
/// <summary>
|
||||
/// Releases the file handle used by the FileByteProvider.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if(_fileStream != null)
|
||||
{
|
||||
_fileName = null;
|
||||
|
||||
_fileStream.Close();
|
||||
_fileStream = null;
|
||||
}
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
96
Be.Windows.Forms.HexBox/FileDataBlock.cs
Normal file
96
Be.Windows.Forms.HexBox/FileDataBlock.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using System;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
internal sealed class FileDataBlock : DataBlock
|
||||
{
|
||||
long _length;
|
||||
long _fileOffset;
|
||||
|
||||
public FileDataBlock(long fileOffset, long length)
|
||||
{
|
||||
_fileOffset = fileOffset;
|
||||
_length = length;
|
||||
}
|
||||
|
||||
public long FileOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fileOffset;
|
||||
}
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return _length;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFileOffset(long value)
|
||||
{
|
||||
_fileOffset = value;
|
||||
}
|
||||
|
||||
public void RemoveBytesFromEnd(long count)
|
||||
{
|
||||
if (count > _length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
}
|
||||
|
||||
_length -= count;
|
||||
}
|
||||
|
||||
public void RemoveBytesFromStart(long count)
|
||||
{
|
||||
if (count > _length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
}
|
||||
|
||||
_fileOffset += count;
|
||||
_length -= count;
|
||||
}
|
||||
|
||||
public override void RemoveBytes(long position, long count)
|
||||
{
|
||||
if (position > _length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("position");
|
||||
}
|
||||
|
||||
if (position + count > _length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
}
|
||||
|
||||
long prefixLength = position;
|
||||
long prefixFileOffset = _fileOffset;
|
||||
|
||||
long suffixLength = _length - count - prefixLength;
|
||||
long suffixFileOffset = _fileOffset + position + count;
|
||||
|
||||
if (prefixLength > 0 && suffixLength > 0)
|
||||
{
|
||||
_fileOffset = prefixFileOffset;
|
||||
_length = prefixLength;
|
||||
_map.AddAfter(this, new FileDataBlock(suffixFileOffset, suffixLength));
|
||||
return;
|
||||
}
|
||||
|
||||
if (prefixLength > 0)
|
||||
{
|
||||
_fileOffset = prefixFileOffset;
|
||||
_length = prefixLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
_fileOffset = suffixFileOffset;
|
||||
_length = suffixLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
Be.Windows.Forms.HexBox/HexBox.bmp
Normal file
BIN
Be.Windows.Forms.HexBox/HexBox.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 246 B |
3701
Be.Windows.Forms.HexBox/HexBox.cs
Normal file
3701
Be.Windows.Forms.HexBox/HexBox.cs
Normal file
File diff suppressed because it is too large
Load Diff
126
Be.Windows.Forms.HexBox/HexBox.resx
Normal file
126
Be.Windows.Forms.HexBox/HexBox.resx
Normal file
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
</root>
|
BIN
Be.Windows.Forms.HexBox/HexBox.snk
Normal file
BIN
Be.Windows.Forms.HexBox/HexBox.snk
Normal file
Binary file not shown.
21
Be.Windows.Forms.HexBox/HexCasing.cs
Normal file
21
Be.Windows.Forms.HexBox/HexCasing.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the case of hex characters in the HexBox control
|
||||
/// </summary>
|
||||
public enum HexCasing
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts all characters to uppercase.
|
||||
/// </summary>
|
||||
Upper = 0,
|
||||
/// <summary>
|
||||
/// Converts all characters to lowercase.
|
||||
/// </summary>
|
||||
Lower = 1
|
||||
}
|
||||
}
|
75
Be.Windows.Forms.HexBox/IByteProvider.cs
Normal file
75
Be.Windows.Forms.HexBox/IByteProvider.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a byte provider for HexBox control
|
||||
/// </summary>
|
||||
public interface IByteProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads a byte from the provider
|
||||
/// </summary>
|
||||
/// <param name="index">the index of the byte to read</param>
|
||||
/// <returns>the byte to read</returns>
|
||||
byte ReadByte(long index);
|
||||
/// <summary>
|
||||
/// Writes a byte into the provider
|
||||
/// </summary>
|
||||
/// <param name="index">the index of the byte to write</param>
|
||||
/// <param name="value">the byte to write</param>
|
||||
void WriteByte(long index, byte value);
|
||||
/// <summary>
|
||||
/// Inserts bytes into the provider
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="bs"></param>
|
||||
/// <remarks>This method must raise the LengthChanged event.</remarks>
|
||||
void InsertBytes(long index, byte[] bs);
|
||||
/// <summary>
|
||||
/// Deletes bytes from the provider
|
||||
/// </summary>
|
||||
/// <param name="index">the start index of the bytes to delete</param>
|
||||
/// <param name="length">the length of the bytes to delete</param>
|
||||
/// <remarks>This method must raise the LengthChanged event.</remarks>
|
||||
void DeleteBytes(long index, long length);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the total length of bytes the byte provider is providing.
|
||||
/// </summary>
|
||||
long Length { get; }
|
||||
/// <summary>
|
||||
/// Occurs, when the Length property changed.
|
||||
/// </summary>
|
||||
event EventHandler LengthChanged;
|
||||
|
||||
/// <summary>
|
||||
/// True, when changes are done.
|
||||
/// </summary>
|
||||
bool HasChanges();
|
||||
/// <summary>
|
||||
/// Applies changes.
|
||||
/// </summary>
|
||||
void ApplyChanges();
|
||||
/// <summary>
|
||||
/// Occurs, when bytes are changed.
|
||||
/// </summary>
|
||||
event EventHandler Changed;
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value if the WriteByte methods is supported by the provider.
|
||||
/// </summary>
|
||||
/// <returns>True, when it´s supported.</returns>
|
||||
bool SupportsWriteByte();
|
||||
/// <summary>
|
||||
/// Returns a value if the InsertBytes methods is supported by the provider.
|
||||
/// </summary>
|
||||
/// <returns>True, when it´s supported.</returns>
|
||||
bool SupportsInsertBytes();
|
||||
/// <summary>
|
||||
/// Returns a value if the DeleteBytes methods is supported by the provider.
|
||||
/// </summary>
|
||||
/// <returns>True, when it´s supported.</returns>
|
||||
bool SupportsDeleteBytes();
|
||||
}
|
||||
}
|
87
Be.Windows.Forms.HexBox/MemoryDataBlock.cs
Normal file
87
Be.Windows.Forms.HexBox/MemoryDataBlock.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
internal sealed class MemoryDataBlock : DataBlock
|
||||
{
|
||||
byte[] _data;
|
||||
|
||||
public MemoryDataBlock(byte data)
|
||||
{
|
||||
_data = new byte[] { data };
|
||||
}
|
||||
|
||||
public MemoryDataBlock(byte[] data)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
|
||||
_data = (byte[])data.Clone();
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return _data.LongLength;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddByteToEnd(byte value)
|
||||
{
|
||||
byte[] newData = new byte[_data.LongLength + 1];
|
||||
_data.CopyTo(newData, 0);
|
||||
newData[newData.LongLength - 1] = value;
|
||||
_data = newData;
|
||||
}
|
||||
|
||||
public void AddByteToStart(byte value)
|
||||
{
|
||||
byte[] newData = new byte[_data.LongLength + 1];
|
||||
newData[0] = value;
|
||||
_data.CopyTo(newData, 1);
|
||||
_data = newData;
|
||||
}
|
||||
|
||||
public void InsertBytes(long position, byte[] data)
|
||||
{
|
||||
byte[] newData = new byte[_data.LongLength + data.LongLength];
|
||||
if (position > 0)
|
||||
{
|
||||
Array.Copy(_data, 0, newData, 0, position);
|
||||
}
|
||||
Array.Copy(data, 0, newData, position, data.LongLength);
|
||||
if (position < _data.LongLength)
|
||||
{
|
||||
Array.Copy(_data, position, newData, position + data.LongLength, _data.LongLength - position);
|
||||
}
|
||||
_data = newData;
|
||||
}
|
||||
|
||||
public override void RemoveBytes(long position, long count)
|
||||
{
|
||||
byte[] newData = new byte[_data.LongLength - count];
|
||||
|
||||
if (position > 0)
|
||||
{
|
||||
Array.Copy(_data, 0, newData, 0, position);
|
||||
}
|
||||
if (position + count < _data.LongLength)
|
||||
{
|
||||
Array.Copy(_data, position + count, newData, position, newData.LongLength - position);
|
||||
}
|
||||
|
||||
_data = newData;
|
||||
}
|
||||
}
|
||||
}
|
27
Be.Windows.Forms.HexBox/NativeMethods.cs
Normal file
27
Be.Windows.Forms.HexBox/NativeMethods.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
internal static class NativeMethods
|
||||
{
|
||||
// Caret definitions
|
||||
[DllImport("user32.dll", SetLastError=true)]
|
||||
public static extern bool CreateCaret(IntPtr hWnd, IntPtr hBitmap, int nWidth, int nHeight);
|
||||
|
||||
[DllImport("user32.dll", SetLastError=true)]
|
||||
public static extern bool ShowCaret(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll", SetLastError=true)]
|
||||
public static extern bool DestroyCaret();
|
||||
|
||||
[DllImport("user32.dll", SetLastError=true)]
|
||||
public static extern bool SetCaretPos(int X, int Y);
|
||||
|
||||
// Key definitions
|
||||
public const int WM_KEYDOWN = 0x100;
|
||||
public const int WM_KEYUP = 0x101;
|
||||
public const int WM_CHAR = 0x102;
|
||||
}
|
||||
}
|
63
Be.Windows.Forms.HexBox/Properties/Resources.Designer.cs
generated
Normal file
63
Be.Windows.Forms.HexBox/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.1
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Be.Windows.Forms.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Be.Windows.Forms.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Be.Windows.Forms.HexBox/Properties/Resources.resx
Normal file
120
Be.Windows.Forms.HexBox/Properties/Resources.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
38
Be.Windows.Forms.HexBox/Util.cs
Normal file
38
Be.Windows.Forms.HexBox/Util.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Be.Windows.Forms
|
||||
{
|
||||
static class Util
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains true, if we are in design mode of Visual Studio
|
||||
/// </summary>
|
||||
private static bool _designMode;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an instance of Util class
|
||||
/// </summary>
|
||||
static Util()
|
||||
{
|
||||
_designMode = (System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToLower() == "devenv");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets true, if we are in design mode of Visual Studio
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// In Visual Studio 2008 SP1 the designer is crashing sometimes on windows forms.
|
||||
/// The DesignMode property of Control class is buggy and cannot be used, so use our own implementation instead.
|
||||
/// </remarks>
|
||||
public static bool DesignMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _designMode;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -33,6 +33,8 @@ REM Compilaci
|
||||
%windir%\microsoft.net\framework\v4.0.30319\msbuild "Plugins\DBK ULTIMATE\DBK ULTIMATE.sln" /v:minimal /p:Configuration=%conf%;TarjetFrameworkVersion=v3.5 "/p:Platform=Any CPU" "/p:OutputPath=%CD%\build\Plugins\"
|
||||
%windir%\microsoft.net\framework\v4.0.30319\msbuild "Plugins\MAPLESTORYDS\MAPLESTORYDS.sln" /v:minimal /p:Configuration=%conf%;TarjetFrameworkVersion=v3.5 "/p:Platform=Any CPU" "/p:OutputPath=%CD%\build\Plugins\"
|
||||
%windir%\microsoft.net\framework\v4.0.30319\msbuild "Plugins\NINOKUNI\NINOKUNI.sln" /v:minimal /p:Configuration=%conf%;TarjetFrameworkVersion=v3.5 "/p:Platform=Any CPU" "/p:OutputPath=%CD%\build\Plugins\"
|
||||
%windir%\microsoft.net\framework\v4.0.30319\msbuild "Plugins\SUBARASHIKI\SUBARASHIKI.sln" /v:minimal /p:Configuration=%conf%;TarjetFrameworkVersion=v3.5 "/p:Platform=Any CPU" "/p:OutputPath=%CD%\build\Plugins\"
|
||||
|
||||
|
||||
REM Compilación de los plugins de formatos
|
||||
%windir%\microsoft.net\framework\v4.0.30319\msbuild Plugins\Pack\Pack.sln /v:minimal /p:Configuration=%conf%;TarjetFrameworkVersion=v3.5 "/p:Platform=Any CPU" "/p:OutputPath=%CD%\build\Plugins\"
|
||||
|
4
Plugins/Fonts/Fonts/CharControl.Designer.cs
generated
4
Plugins/Fonts/Fonts/CharControl.Designer.cs
generated
@ -176,9 +176,9 @@
|
||||
this.Controls.Add(this.numericLength);
|
||||
this.Controls.Add(this.numericWidth);
|
||||
this.Controls.Add(this.picFont);
|
||||
this.MinimumSize = new System.Drawing.Size(243, 311);
|
||||
this.MinimumSize = new System.Drawing.Size(243, 308);
|
||||
this.Name = "CharControl";
|
||||
this.Size = new System.Drawing.Size(243, 311);
|
||||
this.Size = new System.Drawing.Size(243, 308);
|
||||
((System.ComponentModel.ISupportInitialize)(this.picFont)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericWidth)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericLength)).EndInit();
|
||||
|
57
Plugins/Fonts/Fonts/FontControl.Designer.cs
generated
57
Plugins/Fonts/Fonts/FontControl.Designer.cs
generated
@ -31,14 +31,15 @@
|
||||
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
||||
this.txtBox = new System.Windows.Forms.TextBox();
|
||||
this.panelPicImage = new System.Windows.Forms.Panel();
|
||||
this.picFont = new System.Windows.Forms.PictureBox();
|
||||
this.btnApply = new System.Windows.Forms.Button();
|
||||
this.panelCharEdit = new System.Windows.Forms.Panel();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.comboEncoding = new System.Windows.Forms.ComboBox();
|
||||
this.btnPalette = new System.Windows.Forms.Button();
|
||||
this.btnSave = new System.Windows.Forms.Button();
|
||||
this.picFont = new System.Windows.Forms.PictureBox();
|
||||
this.picText = new System.Windows.Forms.PictureBox();
|
||||
this.btnChangeMap = new System.Windows.Forms.Button();
|
||||
this.panelPicImage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picFont)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picText)).BeginInit();
|
||||
@ -56,7 +57,7 @@
|
||||
//
|
||||
// txtBox
|
||||
//
|
||||
this.txtBox.Location = new System.Drawing.Point(4, 344);
|
||||
this.txtBox.Location = new System.Drawing.Point(7, 371);
|
||||
this.txtBox.Multiline = true;
|
||||
this.txtBox.Name = "txtBox";
|
||||
this.txtBox.Size = new System.Drawing.Size(505, 50);
|
||||
@ -68,14 +69,27 @@
|
||||
this.panelPicImage.AutoScroll = true;
|
||||
this.panelPicImage.Controls.Add(this.picFont);
|
||||
this.panelPicImage.Location = new System.Drawing.Point(2, 29);
|
||||
this.panelPicImage.MaximumSize = new System.Drawing.Size(263, 307);
|
||||
this.panelPicImage.MaximumSize = new System.Drawing.Size(263, 310);
|
||||
this.panelPicImage.Name = "panelPicImage";
|
||||
this.panelPicImage.Size = new System.Drawing.Size(263, 307);
|
||||
this.panelPicImage.Size = new System.Drawing.Size(263, 310);
|
||||
this.panelPicImage.TabIndex = 5;
|
||||
//
|
||||
// picFont
|
||||
//
|
||||
this.picFont.BackColor = System.Drawing.Color.Moccasin;
|
||||
this.picFont.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.picFont.Location = new System.Drawing.Point(0, 0);
|
||||
this.picFont.MaximumSize = new System.Drawing.Size(263, 512);
|
||||
this.picFont.Name = "picFont";
|
||||
this.picFont.Size = new System.Drawing.Size(263, 310);
|
||||
this.picFont.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.picFont.TabIndex = 0;
|
||||
this.picFont.TabStop = false;
|
||||
this.picFont.MouseClick += new System.Windows.Forms.MouseEventHandler(this.picFont_MouseClick);
|
||||
//
|
||||
// btnApply
|
||||
//
|
||||
this.btnApply.Location = new System.Drawing.Point(430, 289);
|
||||
this.btnApply.Location = new System.Drawing.Point(432, 290);
|
||||
this.btnApply.Name = "btnApply";
|
||||
this.btnApply.Size = new System.Drawing.Size(75, 46);
|
||||
this.btnApply.TabIndex = 1;
|
||||
@ -88,7 +102,7 @@
|
||||
this.panelCharEdit.AutoScroll = true;
|
||||
this.panelCharEdit.Location = new System.Drawing.Point(266, 29);
|
||||
this.panelCharEdit.Name = "panelCharEdit";
|
||||
this.panelCharEdit.Size = new System.Drawing.Size(243, 307);
|
||||
this.panelCharEdit.Size = new System.Drawing.Size(243, 310);
|
||||
this.panelCharEdit.TabIndex = 7;
|
||||
//
|
||||
// label1
|
||||
@ -138,38 +152,38 @@
|
||||
this.btnSave.UseVisualStyleBackColor = true;
|
||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||
//
|
||||
// picFont
|
||||
//
|
||||
this.picFont.BackColor = System.Drawing.Color.Moccasin;
|
||||
this.picFont.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.picFont.Location = new System.Drawing.Point(0, 0);
|
||||
this.picFont.MaximumSize = new System.Drawing.Size(263, 512);
|
||||
this.picFont.Name = "picFont";
|
||||
this.picFont.Size = new System.Drawing.Size(263, 307);
|
||||
this.picFont.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.picFont.TabIndex = 0;
|
||||
this.picFont.TabStop = false;
|
||||
this.picFont.MouseClick += new System.Windows.Forms.MouseEventHandler(this.picFont_MouseClick);
|
||||
//
|
||||
// picText
|
||||
//
|
||||
this.picText.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.picText.Location = new System.Drawing.Point(4, 400);
|
||||
this.picText.Location = new System.Drawing.Point(7, 427);
|
||||
this.picText.Name = "picText";
|
||||
this.picText.Size = new System.Drawing.Size(505, 50);
|
||||
this.picText.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.picText.TabIndex = 4;
|
||||
this.picText.TabStop = false;
|
||||
//
|
||||
// btnChangeMap
|
||||
//
|
||||
this.btnChangeMap.Image = global::Fonts.Properties.Resources.font_go;
|
||||
this.btnChangeMap.Location = new System.Drawing.Point(144, 483);
|
||||
this.btnChangeMap.Name = "btnChangeMap";
|
||||
this.btnChangeMap.Size = new System.Drawing.Size(121, 26);
|
||||
this.btnChangeMap.TabIndex = 12;
|
||||
this.btnChangeMap.Text = "Change Map char";
|
||||
this.btnChangeMap.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnChangeMap.UseVisualStyleBackColor = true;
|
||||
this.btnChangeMap.Click += new System.EventHandler(this.btnChangeMap_Click);
|
||||
//
|
||||
// FontControl
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.Controls.Add(this.btnApply);
|
||||
this.Controls.Add(this.btnChangeMap);
|
||||
this.Controls.Add(this.btnPalette);
|
||||
this.Controls.Add(this.comboEncoding);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.btnSave);
|
||||
this.Controls.Add(this.btnApply);
|
||||
this.Controls.Add(this.panelCharEdit);
|
||||
this.Controls.Add(this.panelPicImage);
|
||||
this.Controls.Add(this.picText);
|
||||
@ -199,5 +213,6 @@
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.ComboBox comboEncoding;
|
||||
private System.Windows.Forms.Button btnPalette;
|
||||
private System.Windows.Forms.Button btnChangeMap;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using PluginInterface;
|
||||
|
||||
@ -68,21 +67,24 @@ namespace Fonts
|
||||
int interval = font.pamc[p].last_char - font.pamc[p].first_char;
|
||||
|
||||
for (int j = 0; j <= interval; j++)
|
||||
charTile.Add(font.pamc[p].first_char + j, type0.fist_char_code + j);
|
||||
try { charTile.Add(font.pamc[p].first_char + j, (int)type0.fist_char_code + j); }
|
||||
catch { }
|
||||
}
|
||||
else if (font.pamc[p].info is sNFTR.PAMC.Type1)
|
||||
{
|
||||
sNFTR.PAMC.Type1 type1 = (sNFTR.PAMC.Type1)font.pamc[p].info;
|
||||
|
||||
for (int j = 0; j < type1.char_code.Length; j++)
|
||||
charTile.Add(font.pamc[p].first_char + j, type1.char_code[j]);
|
||||
try { charTile.Add(font.pamc[p].first_char + j, type1.char_code[j]); }
|
||||
catch { }
|
||||
}
|
||||
else if (font.pamc[p].info is sNFTR.PAMC.Type2)
|
||||
{
|
||||
sNFTR.PAMC.Type2 type2 = (sNFTR.PAMC.Type2)font.pamc[p].info;
|
||||
|
||||
for (int j = 0; j < type2.num_chars; j++)
|
||||
charTile.Add(type2.chars_code[j], type2.chars[j]);
|
||||
try { charTile.Add(type2.chars_code[j], type2.chars[j]); }
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -205,5 +207,17 @@ namespace Fonts
|
||||
return palette;
|
||||
}
|
||||
|
||||
private void btnChangeMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
MapChar map = new MapChar(font.pamc);
|
||||
map.ShowDialog();
|
||||
if (map.DialogResult == DialogResult.OK)
|
||||
{
|
||||
font.pamc = map.Maps;
|
||||
charTile.Clear();
|
||||
Fill_CharTile();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,12 @@
|
||||
<DependentUpon>FontControl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="MapChar.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MapChar.Designer.cs">
|
||||
<DependentUpon>MapChar.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="NFTR.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
@ -72,6 +78,9 @@
|
||||
<EmbeddedResource Include="FontControl.resx">
|
||||
<DependentUpon>FontControl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="MapChar.resx">
|
||||
<DependentUpon>MapChar.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
@ -84,6 +93,9 @@
|
||||
<Content Include="FontLang.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Resources\font_go.png" />
|
||||
<None Include="Resources\font_delete.png" />
|
||||
<None Include="Resources\font_add.png" />
|
||||
<None Include="Resources\palette.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
277
Plugins/Fonts/Fonts/MapChar.Designer.cs
generated
Normal file
277
Plugins/Fonts/Fonts/MapChar.Designer.cs
generated
Normal file
@ -0,0 +1,277 @@
|
||||
namespace Fonts
|
||||
{
|
||||
partial class MapChar
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MapChar));
|
||||
this.btnSave = new System.Windows.Forms.Button();
|
||||
this.numericSection = new System.Windows.Forms.NumericUpDown();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.dataGridMapInfo = new System.Windows.Forms.DataGridView();
|
||||
this.ColumnImage = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnCharCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.btnAddSect = new System.Windows.Forms.Button();
|
||||
this.btnRemoveSec = new System.Windows.Forms.Button();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.numericLastChar = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericFirstChar = new System.Windows.Forms.NumericUpDown();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.numericType = new System.Windows.Forms.NumericUpDown();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.lblTotalSec = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericSection)).BeginInit();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridMapInfo)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericLastChar)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericFirstChar)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericType)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
this.btnSave.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnSave.Location = new System.Drawing.Point(305, 7);
|
||||
this.btnSave.Name = "btnSave";
|
||||
this.btnSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnSave.TabIndex = 0;
|
||||
this.btnSave.Text = "Accept";
|
||||
this.btnSave.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnSave.UseVisualStyleBackColor = true;
|
||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||
//
|
||||
// numericSection
|
||||
//
|
||||
this.numericSection.Location = new System.Drawing.Point(64, 7);
|
||||
this.numericSection.Maximum = new decimal(new int[] {
|
||||
65535,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericSection.Name = "numericSection";
|
||||
this.numericSection.Size = new System.Drawing.Size(50, 20);
|
||||
this.numericSection.TabIndex = 1;
|
||||
this.numericSection.ValueChanged += new System.EventHandler(this.numericSection_ValueChanged);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.dataGridMapInfo);
|
||||
this.groupBox1.Controls.Add(this.btnAddSect);
|
||||
this.groupBox1.Controls.Add(this.btnRemoveSec);
|
||||
this.groupBox1.Controls.Add(this.label4);
|
||||
this.groupBox1.Controls.Add(this.numericLastChar);
|
||||
this.groupBox1.Controls.Add(this.numericFirstChar);
|
||||
this.groupBox1.Controls.Add(this.label3);
|
||||
this.groupBox1.Controls.Add(this.numericType);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.groupBox1.Location = new System.Drawing.Point(0, 36);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(380, 207);
|
||||
this.groupBox1.TabIndex = 2;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Map info";
|
||||
//
|
||||
// dataGridMapInfo
|
||||
//
|
||||
this.dataGridMapInfo.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.dataGridMapInfo.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridMapInfo.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ColumnImage,
|
||||
this.ColumnCharCode});
|
||||
this.dataGridMapInfo.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.dataGridMapInfo.Location = new System.Drawing.Point(3, 79);
|
||||
this.dataGridMapInfo.Name = "dataGridMapInfo";
|
||||
this.dataGridMapInfo.RowTemplate.DefaultCellStyle.Format = "N0";
|
||||
this.dataGridMapInfo.RowTemplate.DefaultCellStyle.NullValue = "0";
|
||||
this.dataGridMapInfo.Size = new System.Drawing.Size(374, 125);
|
||||
this.dataGridMapInfo.TabIndex = 11;
|
||||
this.dataGridMapInfo.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridMapInfo_CellEndEdit);
|
||||
//
|
||||
// ColumnImage
|
||||
//
|
||||
this.ColumnImage.HeaderText = "Number of image";
|
||||
this.ColumnImage.Name = "ColumnImage";
|
||||
//
|
||||
// ColumnCharCode
|
||||
//
|
||||
this.ColumnCharCode.HeaderText = "Char Code";
|
||||
this.ColumnCharCode.Name = "ColumnCharCode";
|
||||
//
|
||||
// btnAddSect
|
||||
//
|
||||
this.btnAddSect.Location = new System.Drawing.Point(202, 50);
|
||||
this.btnAddSect.Name = "btnAddSect";
|
||||
this.btnAddSect.Size = new System.Drawing.Size(80, 23);
|
||||
this.btnAddSect.TabIndex = 10;
|
||||
this.btnAddSect.Text = "Add section";
|
||||
this.btnAddSect.UseVisualStyleBackColor = true;
|
||||
this.btnAddSect.Click += new System.EventHandler(this.btnAddSect_Click);
|
||||
//
|
||||
// btnRemoveSec
|
||||
//
|
||||
this.btnRemoveSec.Location = new System.Drawing.Point(288, 50);
|
||||
this.btnRemoveSec.Name = "btnRemoveSec";
|
||||
this.btnRemoveSec.Size = new System.Drawing.Size(80, 23);
|
||||
this.btnRemoveSec.TabIndex = 9;
|
||||
this.btnRemoveSec.Text = "Del section";
|
||||
this.btnRemoveSec.UseVisualStyleBackColor = true;
|
||||
this.btnRemoveSec.Click += new System.EventHandler(this.btnRemoveSec_Click);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(246, 26);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(54, 13);
|
||||
this.label4.TabIndex = 5;
|
||||
this.label4.Text = "Last char:";
|
||||
//
|
||||
// numericLastChar
|
||||
//
|
||||
this.numericLastChar.Location = new System.Drawing.Point(305, 24);
|
||||
this.numericLastChar.Maximum = new decimal(new int[] {
|
||||
65535,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericLastChar.Name = "numericLastChar";
|
||||
this.numericLastChar.Size = new System.Drawing.Size(50, 20);
|
||||
this.numericLastChar.TabIndex = 4;
|
||||
this.numericLastChar.ValueChanged += new System.EventHandler(this.numericChar_ValueChanged);
|
||||
//
|
||||
// numericFirstChar
|
||||
//
|
||||
this.numericFirstChar.Location = new System.Drawing.Point(179, 24);
|
||||
this.numericFirstChar.Maximum = new decimal(new int[] {
|
||||
65535,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericFirstChar.Name = "numericFirstChar";
|
||||
this.numericFirstChar.Size = new System.Drawing.Size(50, 20);
|
||||
this.numericFirstChar.TabIndex = 3;
|
||||
this.numericFirstChar.ValueChanged += new System.EventHandler(this.numericChar_ValueChanged);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(120, 26);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(53, 13);
|
||||
this.label3.TabIndex = 2;
|
||||
this.label3.Text = "First char:";
|
||||
//
|
||||
// numericType
|
||||
//
|
||||
this.numericType.Location = new System.Drawing.Point(53, 24);
|
||||
this.numericType.Maximum = new decimal(new int[] {
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericType.Name = "numericType";
|
||||
this.numericType.ReadOnly = true;
|
||||
this.numericType.Size = new System.Drawing.Size(50, 20);
|
||||
this.numericType.TabIndex = 1;
|
||||
this.numericType.ValueChanged += new System.EventHandler(this.numericType_ValueChanged);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 26);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(34, 13);
|
||||
this.label2.TabIndex = 0;
|
||||
this.label2.Text = "Type:";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(43, 13);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "Section";
|
||||
//
|
||||
// lblTotalSec
|
||||
//
|
||||
this.lblTotalSec.AutoSize = true;
|
||||
this.lblTotalSec.Location = new System.Drawing.Point(120, 9);
|
||||
this.lblTotalSec.Name = "lblTotalSec";
|
||||
this.lblTotalSec.Size = new System.Drawing.Size(25, 13);
|
||||
this.lblTotalSec.TabIndex = 4;
|
||||
this.lblTotalSec.Text = "of 0";
|
||||
//
|
||||
// MapChar
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
||||
this.ClientSize = new System.Drawing.Size(380, 243);
|
||||
this.Controls.Add(this.lblTotalSec);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.numericSection);
|
||||
this.Controls.Add(this.btnSave);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "MapChar";
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Character map";
|
||||
this.Resize += new System.EventHandler(this.MapChar_Resize);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericSection)).EndInit();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridMapInfo)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericLastChar)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericFirstChar)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericType)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnSave;
|
||||
private System.Windows.Forms.NumericUpDown numericSection;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.NumericUpDown numericType;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label lblTotalSec;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.NumericUpDown numericLastChar;
|
||||
private System.Windows.Forms.NumericUpDown numericFirstChar;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button btnAddSect;
|
||||
private System.Windows.Forms.Button btnRemoveSec;
|
||||
private System.Windows.Forms.DataGridView dataGridMapInfo;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn ColumnImage;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn ColumnCharCode;
|
||||
}
|
||||
}
|
247
Plugins/Fonts/Fonts/MapChar.cs
Normal file
247
Plugins/Fonts/Fonts/MapChar.cs
Normal file
@ -0,0 +1,247 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Fonts
|
||||
{
|
||||
public partial class MapChar : Form
|
||||
{
|
||||
List<sNFTR.PAMC> maps;
|
||||
|
||||
|
||||
public MapChar(List<sNFTR.PAMC> maps)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.maps = maps;
|
||||
lblTotalSec.Text = "of " + (maps.Count - 1).ToString();
|
||||
numericSection.Maximum = maps.Count - 1;
|
||||
MapInfo();
|
||||
}
|
||||
|
||||
private void MapInfo()
|
||||
{
|
||||
sNFTR.PAMC map = maps[(int)numericSection.Value];
|
||||
|
||||
numericFirstChar.Value = map.first_char;
|
||||
numericLastChar.Value = map.last_char;
|
||||
numericType.Value = map.type_section;
|
||||
dataGridMapInfo.Rows.Clear();
|
||||
|
||||
switch (map.type_section)
|
||||
{
|
||||
case 0:
|
||||
sNFTR.PAMC.Type0 type0 = (sNFTR.PAMC.Type0)map.info;
|
||||
dataGridMapInfo.Rows.Add(type0.fist_char_code.ToString(), "0");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
sNFTR.PAMC.Type1 type1 = (sNFTR.PAMC.Type1)map.info;
|
||||
for (int i = 0; i < type1.char_code.Length; i++)
|
||||
dataGridMapInfo.Rows.Add(type1.char_code[i].ToString(), i.ToString());
|
||||
break;
|
||||
|
||||
case 2:
|
||||
sNFTR.PAMC.Type2 type2 = (sNFTR.PAMC.Type2)map.info;
|
||||
for (int i = 0; i < type2.num_chars; i++)
|
||||
dataGridMapInfo.Rows.Add(type2.chars[i].ToString(), type2.chars_code[i].ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public List<sNFTR.PAMC> Maps
|
||||
{
|
||||
get
|
||||
{
|
||||
Recalculate_Size();
|
||||
return maps;
|
||||
}
|
||||
}
|
||||
private void Recalculate_Size()
|
||||
{
|
||||
for (int i = 0; i < maps.Count; i++)
|
||||
{
|
||||
sNFTR.PAMC map = maps[i];
|
||||
uint size = 0x14;
|
||||
|
||||
switch (map.type_section)
|
||||
{
|
||||
case 0:
|
||||
size += 4;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
sNFTR.PAMC.Type1 type1 = (sNFTR.PAMC.Type1)map.info;
|
||||
size += (uint)type1.char_code.Length * 2;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
sNFTR.PAMC.Type2 type2 = (sNFTR.PAMC.Type2)map.info;
|
||||
size += 2;
|
||||
size += (uint)type2.chars_code.Length * 2;
|
||||
size += (uint)type2.chars.Length * 2;
|
||||
break;
|
||||
}
|
||||
|
||||
map.block_size = size;
|
||||
maps[i] = map;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapChar_Resize(object sender, EventArgs e)
|
||||
{
|
||||
groupBox1.Height = this.Height - 80;
|
||||
btnSave.Location = new Point(this.Width - 91, 7);
|
||||
dataGridMapInfo.Height = groupBox1.Height - 82;
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void numericSection_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
MapInfo();
|
||||
numericType.ReadOnly = true;
|
||||
}
|
||||
|
||||
private void btnRemoveSec_Click(object sender, EventArgs e)
|
||||
{
|
||||
maps.RemoveAt((int)numericSection.Value);
|
||||
numericSection.Maximum = maps.Count - 1;
|
||||
|
||||
if (maps.Count == 0)
|
||||
MessageBox.Show("There aren't more sections.");
|
||||
else
|
||||
numericSection.Value = 0;
|
||||
|
||||
lblTotalSec.Text = "of " + (maps.Count - 1).ToString();
|
||||
}
|
||||
private void btnAddSect_Click(object sender, EventArgs e)
|
||||
{
|
||||
sNFTR.PAMC map = new sNFTR.PAMC();
|
||||
map.type = new char[] { 'P', 'A', 'M', 'C' };
|
||||
map.first_char = 0x0000;
|
||||
map.last_char = 0xFFFF;
|
||||
map.type_section = 2;
|
||||
numericType.ReadOnly = false;
|
||||
sNFTR.PAMC.Type2 type2 = new sNFTR.PAMC.Type2();
|
||||
type2.num_chars = 0;
|
||||
type2.chars = new ushort[0];
|
||||
type2.chars_code = new ushort[0];
|
||||
map.info = type2;
|
||||
maps.Add(map);
|
||||
|
||||
lblTotalSec.Text = "of " + (maps.Count - 1).ToString();
|
||||
numericSection.Maximum = maps.Count - 1;
|
||||
numericSection.Value = maps.Count - 1;
|
||||
}
|
||||
|
||||
|
||||
private void numericChar_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
sNFTR.PAMC pamc = maps[(int)numericSection.Value];
|
||||
pamc.first_char = (ushort)numericFirstChar.Value;
|
||||
pamc.last_char = (ushort)numericLastChar.Value;
|
||||
maps[(int)numericSection.Value] = pamc;
|
||||
}
|
||||
|
||||
private void dataGridMapInfo_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
sNFTR.PAMC map = maps[(int)numericSection.Value];
|
||||
|
||||
if (map.type_section == 2)
|
||||
{
|
||||
sNFTR.PAMC.Type2 type2 = (sNFTR.PAMC.Type2)map.info;
|
||||
if (e.ColumnIndex == 0)
|
||||
{
|
||||
if ((e.RowIndex + 1) > type2.chars.Length)
|
||||
{
|
||||
List<ushort> values = new List<ushort>();
|
||||
|
||||
values.AddRange(type2.chars);
|
||||
values.Add(Convert.ToUInt16(dataGridMapInfo.Rows[e.RowIndex].Cells[0].Value));
|
||||
type2.chars = values.ToArray();
|
||||
|
||||
values.Clear();
|
||||
values.AddRange(type2.chars_code);
|
||||
values.Add(0);
|
||||
type2.chars_code = values.ToArray();
|
||||
|
||||
type2.num_chars++;
|
||||
}
|
||||
else
|
||||
type2.chars[e.RowIndex] = Convert.ToUInt16(dataGridMapInfo.Rows[e.RowIndex].Cells[0].Value);
|
||||
|
||||
}
|
||||
else if (e.ColumnIndex == 1)
|
||||
{
|
||||
if ((e.RowIndex + 1) > type2.chars_code.Length)
|
||||
{
|
||||
List<ushort> values = new List<ushort>();
|
||||
|
||||
values.AddRange(type2.chars_code);
|
||||
values.Add(Convert.ToUInt16(dataGridMapInfo.Rows[e.RowIndex].Cells[1].Value));
|
||||
type2.chars_code = values.ToArray();
|
||||
|
||||
values.Clear();
|
||||
values.AddRange(type2.chars);
|
||||
values.Add(0);
|
||||
type2.chars = values.ToArray();
|
||||
|
||||
type2.num_chars++;
|
||||
}
|
||||
else
|
||||
type2.chars_code[e.RowIndex] = Convert.ToUInt16(dataGridMapInfo.Rows[e.RowIndex].Cells[1].Value);
|
||||
}
|
||||
map.info = type2;
|
||||
}
|
||||
else if (map.type_section == 1)
|
||||
{
|
||||
sNFTR.PAMC.Type1 type1 = (sNFTR.PAMC.Type1)map.info;
|
||||
|
||||
if (e.ColumnIndex == 0)
|
||||
{
|
||||
if ((e.RowIndex + 1) > type1.char_code.Length)
|
||||
{
|
||||
List<ushort> values = new List<ushort>();
|
||||
values.AddRange(type1.char_code);
|
||||
values.Add(Convert.ToUInt16(dataGridMapInfo.Rows[e.RowIndex].Cells[0].Value));
|
||||
type1.char_code = values.ToArray();
|
||||
}
|
||||
else
|
||||
type1.char_code[e.RowIndex] = Convert.ToUInt16(dataGridMapInfo.Rows[e.RowIndex].Cells[0].Value);
|
||||
}
|
||||
|
||||
map.info = type1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sNFTR.PAMC.Type0 type0 = (sNFTR.PAMC.Type0)map.info;
|
||||
|
||||
if (e.ColumnIndex == 0 && e.RowIndex == 0)
|
||||
{
|
||||
type0.fist_char_code = Convert.ToUInt16(dataGridMapInfo.Rows[e.RowIndex].Cells[0].Value);
|
||||
}
|
||||
|
||||
map.info = type0;
|
||||
}
|
||||
|
||||
maps[(int)numericSection.Value] = map;
|
||||
}
|
||||
|
||||
private void numericType_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
sNFTR.PAMC map = maps[(int)numericSection.Value];
|
||||
map.type_section = (uint)numericType.Value;
|
||||
maps[(int)numericSection.Value] = map;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
151
Plugins/Fonts/Fonts/MapChar.resx
Normal file
151
Plugins/Fonts/Fonts/MapChar.resx
Normal file
@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ColumnImage.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCharCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
AAABAAEAEBAAAAAAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA
|
||||
AAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8AAH0h6wN7Hv8AeRUE////AP//
|
||||
/wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAGDK+tDoV//AHsfzAB5
|
||||
GQb///8A////AP///wD///8A////AP///wD///8A////ACGXUf0bkUn9FY9D/Q+LO/06n17/gMGW/0aj
|
||||
Yv8AfR/RAHkZB////wDOaDiu2o9d/tuQYP/Xg1DtxFArjb1CIxApm1v/kMqp/43Ipf+KxqH/iMWe/2q2
|
||||
hf+Cwpf/SKVm/wB9IdcAeRsJylwvCstfMEThpHX/2oxY7MZSLD3///8AMZ9j/5TNrf9vuo7/a7iJ/2a2
|
||||
hf9hs4D/Z7WC/4PCmP88oFz/AH8l+f///wDLXTAB03Q/m+KpfP/MZjeZ////ADeja/+WzrD/lM2t/5HL
|
||||
qv+Qy6j/dLyQ/4rHof9GpWj/B4c1+wGDLQH///8A////AMxjMhXbk17q4qd5/9iDStM9pW//OaJs/jWh
|
||||
Z/4ynWL/Va98/5HLqv9Pq3T/F49F+xGLPQH///8A////AP///wD///8Az2o2XN+daPbai1LRy18xTsdZ
|
||||
LirNZzeg4aZ6/z2dYv5as4H/KJhX/////wD///8A////AP///wD///8A////ANBqNQPXgEKq359q981m
|
||||
NGbJXS8KzGEziOGmef9BoGn7MZ9l/////wD///8A////AP///wD///8A////AP///wD///8A0XE4It6b
|
||||
Y+Lcll7fz2k1VM9pNYDiqXz/0Ww6pf///wD///8A////AP///wD///8A////AP///wD///8A////AP//
|
||||
/wDUeTx34qZw99qIR63WfkOg5K6C/89tOpn///8A////AP///wD///8A////AP///wD///8A////AP//
|
||||
/wD///8A1n07HN2WVrrjqXPy4ahz9eGkcffTdz6Yy18wCP///wD///8A////AP///wD///8A////AP//
|
||||
/wD///8A////ANeDPlPip2ze6byR/+e6j//nt4v/4qRx+9Z+QrbLXC8K////AP///wD///8A////AP//
|
||||
/wD///8A////AP///wDYh0BA2ItDhdqOSZTZiUOP2IRAkNiEQZrTczqKzGIyDclbLgH///8A////AP//
|
||||
/wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP//
|
||||
/wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP//
|
||||
/wD///8A/8cAAP/DAAD8AQAAAAAAAAQAAACEAAAAwAEAAOAHAADgDwAA8B8AAPgfAAD4DwAA+AcAAPgD
|
||||
AAD//wAA//8AAA==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
@ -35,6 +35,8 @@ namespace Fonts
|
||||
font.fnif.offset_pamc = br.ReadUInt32();
|
||||
if (font.fnif.block_size == 0x20)
|
||||
font.fnif.unknown3 = br.ReadUInt32();
|
||||
else
|
||||
font.fnif.unknown3 = 0xFFFF; // It doesn't exit
|
||||
|
||||
// Character Graphics LP
|
||||
br.BaseStream.Position = font.fnif.offset_plgc - 0x08;
|
||||
@ -100,7 +102,7 @@ namespace Fonts
|
||||
{
|
||||
case 0:
|
||||
sNFTR.PAMC.Type0 type0 = new sNFTR.PAMC.Type0();
|
||||
type0.fist_char_code = br.ReadUInt16();
|
||||
type0.fist_char_code = br.ReadUInt32();
|
||||
pamc.info = type0;
|
||||
break;
|
||||
case 1:
|
||||
@ -138,6 +140,23 @@ namespace Fonts
|
||||
}
|
||||
public static void Write(sNFTR font, string fileout)
|
||||
{
|
||||
// Calculate de size of each block
|
||||
font.fnif.block_size = 0x1C;
|
||||
if (font.fnif.unknown3 != 0xFFFF)
|
||||
font.fnif.block_size += 4;
|
||||
font.plgc.block_size = (uint)(0x10 + font.plgc.tiles.Length * font.plgc.tile_length);
|
||||
font.hdwc.block_size = (uint)(0x10 + font.hdwc.info.Count * 3) + 0x02;
|
||||
uint pacm_totalSize = 0x00;
|
||||
for (int i = 0; i < font.pamc.Count; i++)
|
||||
pacm_totalSize += font.pamc[i].block_size;
|
||||
font.header.file_size = font.header.block_size + font.fnif.block_size + font.plgc.block_size +
|
||||
font.hdwc.block_size + pacm_totalSize;
|
||||
|
||||
// Calculate the new offset
|
||||
font.fnif.offset_plgc = font.header.block_size + font.fnif.block_size + 0x08;
|
||||
font.fnif.offset_hdwc = (font.fnif.offset_plgc - 0x08) + font.plgc.block_size + 0x08;
|
||||
font.fnif.offset_pamc = (font.fnif.offset_hdwc - 0x08) + font.hdwc.block_size + 0x08;
|
||||
|
||||
BinaryWriter bw = new BinaryWriter(File.OpenWrite(fileout));
|
||||
|
||||
// Write the generic header
|
||||
@ -156,7 +175,7 @@ namespace Fonts
|
||||
bw.Write(font.fnif.offset_plgc);
|
||||
bw.Write(font.fnif.offset_hdwc);
|
||||
bw.Write(font.fnif.offset_pamc);
|
||||
if (font.fnif.block_size == 0x20)
|
||||
if (font.fnif.unknown3 != 0xFFFF)
|
||||
bw.Write(font.fnif.unknown3);
|
||||
|
||||
// Write the PLGC section
|
||||
@ -182,6 +201,7 @@ namespace Fonts
|
||||
bw.Write(font.hdwc.info[i].pixel_width);
|
||||
bw.Write(font.hdwc.info[i].pixel_length);
|
||||
}
|
||||
bw.Write((ushort)0x00);
|
||||
|
||||
// Write the PAMC section
|
||||
for (int i = 0; i < font.pamc.Count; i++)
|
||||
@ -218,10 +238,6 @@ namespace Fonts
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
int relleno = (int)(currPos + font.pamc[i].block_size - bw.BaseStream.Position);
|
||||
for (int r = 0; r < relleno; r++)
|
||||
bw.Write((byte)0x00);
|
||||
}
|
||||
|
||||
bw.Flush();
|
||||
@ -562,7 +578,7 @@ namespace Fonts
|
||||
|
||||
public struct Type0
|
||||
{
|
||||
public ushort fist_char_code;
|
||||
public uint fist_char_code;
|
||||
}
|
||||
public struct Type1
|
||||
{
|
||||
|
21
Plugins/Fonts/Fonts/Properties/Resources.Designer.cs
generated
21
Plugins/Fonts/Fonts/Properties/Resources.Designer.cs
generated
@ -67,6 +67,27 @@ namespace Fonts.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap font_add {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("font_add", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap font_delete {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("font_delete", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap font_go {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("font_go", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap palette {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("palette", resourceCulture);
|
||||
|
@ -118,11 +118,20 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="disk" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\disk.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="palette" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\palette.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="font_delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\font_delete.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="disk" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\disk.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="font_add" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\font_add.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="font_go" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\font_go.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
Plugins/Fonts/Fonts/Resources/font_add.png
Normal file
BIN
Plugins/Fonts/Fonts/Resources/font_add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 634 B |
BIN
Plugins/Fonts/Fonts/Resources/font_delete.png
Normal file
BIN
Plugins/Fonts/Fonts/Resources/font_delete.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 661 B |
BIN
Plugins/Fonts/Fonts/Resources/font_go.png
Normal file
BIN
Plugins/Fonts/Fonts/Resources/font_go.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 700 B |
@ -35,11 +35,14 @@ namespace NINOKUNI
|
||||
|
||||
public void Read(string file, int id)
|
||||
{
|
||||
NPCK.Unpack(file, pluginHost);
|
||||
NPCK.Unpack(file, pluginHost);
|
||||
}
|
||||
|
||||
public System.Windows.Forms.Control Show_Info(string file, int id)
|
||||
{
|
||||
if (file.ToUpper().EndsWith(".N2D"))
|
||||
return new PackControl(file, id, pluginHost);
|
||||
|
||||
return new System.Windows.Forms.Control();
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,11 @@
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="PackControl.resx">
|
||||
<DependentUpon>PackControl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</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.
|
||||
|
@ -20,10 +20,9 @@ namespace NINOKUNI
|
||||
|
||||
char[] type = br.ReadChars(4);
|
||||
uint header_size = br.ReadUInt32();
|
||||
uint unknown = br.ReadUInt32();
|
||||
uint num_files = br.ReadUInt32();
|
||||
|
||||
int i = 0;
|
||||
while (br.BaseStream.Position != header_size)
|
||||
for (int i = 0; i < num_files; i++)
|
||||
{
|
||||
uint offset = br.ReadUInt32();
|
||||
uint size = br.ReadUInt32();
|
||||
@ -33,7 +32,6 @@ namespace NINOKUNI
|
||||
|
||||
sFile newFile = new sFile();
|
||||
newFile.name = "File" + i.ToString() + ".bin";
|
||||
i++;
|
||||
newFile.offset = offset;
|
||||
newFile.size = size;
|
||||
newFile.path = packFile;
|
||||
@ -43,5 +41,69 @@ namespace NINOKUNI
|
||||
br.Close();
|
||||
pluginHost.Set_Files(unpack);
|
||||
}
|
||||
public static void Pack(string file, int id, IPluginHost pluginHost)
|
||||
{
|
||||
/* In N2D files there must be 9 offset in this order:
|
||||
*
|
||||
* 0 - Palette
|
||||
* 1 - 1º Tiles
|
||||
* 2 - 2º Tiles
|
||||
* 3 - 1º Cell
|
||||
* 4 - ??
|
||||
* 5 - 1º Animation
|
||||
* 6 - 1º Map
|
||||
* 8 - ??
|
||||
* 9 - ??
|
||||
*/
|
||||
|
||||
sFolder unpacked = pluginHost.Get_DecompressedFiles(id);
|
||||
BinaryWriter bw = new BinaryWriter(File.OpenWrite(file));
|
||||
uint offset = (uint)0x09 * 8 + 0xC;
|
||||
|
||||
bw.Write(new char[] { 'N', 'P', 'C', 'K' });
|
||||
bw.Write(offset);
|
||||
bw.Write((uint)0x09);
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
sFile currFile = Search_File("File" + i.ToString() + ".bin", unpacked);
|
||||
|
||||
if (currFile.name is String)
|
||||
{
|
||||
bw.Write(offset);
|
||||
bw.Write(currFile.size);
|
||||
offset += currFile.size;
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.Write((uint)0x00); // Null offset
|
||||
bw.Write((uint)0x00); // Null size
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
sFile currFile = Search_File("File" + i.ToString() + ".bin", unpacked);
|
||||
|
||||
if (currFile.name is String)
|
||||
{
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(currFile.path));
|
||||
br.BaseStream.Position = currFile.offset;
|
||||
bw.Write(br.ReadBytes((int)currFile.size));
|
||||
br.Close();
|
||||
}
|
||||
}
|
||||
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
}
|
||||
|
||||
public static sFile Search_File(string name, sFolder folder)
|
||||
{
|
||||
for (int i = 0; i < folder.files.Count; i++)
|
||||
if (folder.files[i].name == name)
|
||||
return folder.files[i];
|
||||
|
||||
return new sFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
24
Plugins/NINOKUNI/NINOKUNI/PackControl.Designer.cs
generated
24
Plugins/NINOKUNI/NINOKUNI/PackControl.Designer.cs
generated
@ -28,10 +28,32 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
this.btnPack = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnPack
|
||||
//
|
||||
this.btnPack.Location = new System.Drawing.Point(4, 4);
|
||||
this.btnPack.Name = "btnPack";
|
||||
this.btnPack.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnPack.TabIndex = 0;
|
||||
this.btnPack.Text = "Pack";
|
||||
this.btnPack.UseVisualStyleBackColor = true;
|
||||
this.btnPack.Click += new System.EventHandler(this.btnPack_Click);
|
||||
//
|
||||
// PackControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.Controls.Add(this.btnPack);
|
||||
this.Name = "PackControl";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnPack;
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,31 @@ using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using PluginInterface;
|
||||
|
||||
namespace NINOKUNI
|
||||
{
|
||||
public partial class PackControl : UserControl
|
||||
{
|
||||
public PackControl()
|
||||
String file;
|
||||
int id;
|
||||
IPluginHost pluginHost;
|
||||
|
||||
public PackControl(string file, int id, IPluginHost pluginHost)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.file = file;
|
||||
this.id = id;
|
||||
this.pluginHost = pluginHost;
|
||||
}
|
||||
|
||||
private void btnPack_Click(object sender, EventArgs e)
|
||||
{
|
||||
string fileOut = pluginHost.Get_TempFolder() + System.IO.Path.DirectorySeparatorChar +
|
||||
"pack_" + System.IO.Path.GetFileName(file);
|
||||
NPCK.Pack(fileOut, id, pluginHost);
|
||||
pluginHost.ChangeFile(id, fileOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
Plugins/NINOKUNI/NINOKUNI/PackControl.resx
Normal file
120
Plugins/NINOKUNI/NINOKUNI/PackControl.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
20
Plugins/SUBARASHIKI/SUBARASHIKI.sln
Normal file
20
Plugins/SUBARASHIKI/SUBARASHIKI.sln
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SUBARASHIKI", "SUBARASHIKI\SUBARASHIKI.csproj", "{0009AD96-B697-4AD7-B38A-B7FBCF2DBBDF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0009AD96-B697-4AD7-B38A-B7FBCF2DBBDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0009AD96-B697-4AD7-B38A-B7FBCF2DBBDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0009AD96-B697-4AD7-B38A-B7FBCF2DBBDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0009AD96-B697-4AD7-B38A-B7FBCF2DBBDF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
48
Plugins/SUBARASHIKI/SUBARASHIKI/Main.cs
Normal file
48
Plugins/SUBARASHIKI/SUBARASHIKI/Main.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using PluginInterface;
|
||||
|
||||
namespace SUBARASHIKI
|
||||
{
|
||||
public class Main : IGamePlugin
|
||||
{
|
||||
IPluginHost pluginHost;
|
||||
String gameCode;
|
||||
|
||||
|
||||
public void Initialize(IPluginHost pluginHost, string gameCode)
|
||||
{
|
||||
this.gameCode = gameCode;
|
||||
this.pluginHost = pluginHost;
|
||||
}
|
||||
public bool IsCompatible()
|
||||
{
|
||||
if (gameCode == "AWLJ")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Format Get_Format(string fileName, byte[] magic, int id)
|
||||
{
|
||||
String ext = new String(Encoding.ASCII.GetChars(magic));
|
||||
|
||||
if (ext == "pack")
|
||||
return Format.Pack;
|
||||
|
||||
return Format.Unknown;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Read(string file, int id)
|
||||
{
|
||||
Pack.Unpack(file, pluginHost);
|
||||
}
|
||||
public System.Windows.Forms.Control Show_Info(string file, int id)
|
||||
{
|
||||
return new System.Windows.Forms.Control();
|
||||
}
|
||||
}
|
||||
}
|
37
Plugins/SUBARASHIKI/SUBARASHIKI/PackControl.Designer.cs
generated
Normal file
37
Plugins/SUBARASHIKI/SUBARASHIKI/PackControl.Designer.cs
generated
Normal file
@ -0,0 +1,37 @@
|
||||
namespace SUBARASHIKI
|
||||
{
|
||||
partial class PackControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Variable del diseñador requerida.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Limpiar los recursos que se estén utilizando.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true si los recursos administrados se deben eliminar; false en caso contrario, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Código generado por el Diseñador de componentes
|
||||
|
||||
/// <summary>
|
||||
/// Método necesario para admitir el Diseñador. No se puede modificar
|
||||
/// el contenido del método con el editor de código.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
19
Plugins/SUBARASHIKI/SUBARASHIKI/PackControl.cs
Normal file
19
Plugins/SUBARASHIKI/SUBARASHIKI/PackControl.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SUBARASHIKI
|
||||
{
|
||||
public partial class PackControl : UserControl
|
||||
{
|
||||
public PackControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
36
Plugins/SUBARASHIKI/SUBARASHIKI/Properties/AssemblyInfo.cs
Normal file
36
Plugins/SUBARASHIKI/SUBARASHIKI/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// La información general sobre un ensamblado se controla mediante el siguiente
|
||||
// conjunto de atributos. Cambie estos atributos para modificar la información
|
||||
// asociada con un ensamblado.
|
||||
[assembly: AssemblyTitle("SUBARASHIKI")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Tinke")]
|
||||
[assembly: AssemblyCopyright("pleoNeX")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Si establece ComVisible como false, los tipos de este ensamblado no estarán visibles
|
||||
// para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde
|
||||
// COM, establezca el atributo ComVisible como true en este tipo.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// El siguiente GUID sirve como identificador de typelib si este proyecto se expone a COM
|
||||
[assembly: Guid("47961b44-7a6a-4656-ac89-5976058d8adc")]
|
||||
|
||||
// La información de versión de un ensamblado consta de los cuatro valores siguientes:
|
||||
//
|
||||
// Versión principal
|
||||
// Versión secundaria
|
||||
// Número de compilación
|
||||
// Revisión
|
||||
//
|
||||
// Puede especificar todos los valores o establecer como predeterminados los números de versión de compilación y de revisión
|
||||
// mediante el asterisco ('*'), como se muestra a continuación:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
64
Plugins/SUBARASHIKI/SUBARASHIKI/SUBARASHIKI.csproj
Normal file
64
Plugins/SUBARASHIKI/SUBARASHIKI/SUBARASHIKI.csproj
Normal file
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0009AD96-B697-4AD7-B38A-B7FBCF2DBBDF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SUBARASHIKI</RootNamespace>
|
||||
<AssemblyName>SUBARASHIKI</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\Tinke\bin\Debug\Plugins\</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="PluginInterface, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\PluginInterface\bin\Debug\PluginInterface.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="pack.cs" />
|
||||
<Compile Include="PackControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PackControl.Designer.cs">
|
||||
<DependentUpon>PackControl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<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>
|
47
Plugins/SUBARASHIKI/SUBARASHIKI/pack.cs
Normal file
47
Plugins/SUBARASHIKI/SUBARASHIKI/pack.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using PluginInterface;
|
||||
|
||||
namespace SUBARASHIKI
|
||||
{
|
||||
public static class Pack
|
||||
{
|
||||
|
||||
|
||||
public static void Unpack(string file, IPluginHost pluginHost)
|
||||
{
|
||||
// Copied from:
|
||||
// http://forum.xentax.com/viewtopic.php?f=18&t=3175&p=30296&hilit=pack+world+ends#p30296
|
||||
// Credits to McCuñao
|
||||
string packFile = pluginHost.Get_TempFolder() + Path.DirectorySeparatorChar + "pack_" + Path.GetFileName(file);
|
||||
File.Copy(file, packFile, true);
|
||||
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file));
|
||||
sFolder unpack = new sFolder();
|
||||
unpack.files = new List<sFile>();
|
||||
|
||||
char[] type = br.ReadChars(4);
|
||||
uint num_files = br.ReadUInt32();
|
||||
uint data_size = br.ReadUInt32();
|
||||
uint unknown = br.ReadUInt32(); // Unknown always 0x00
|
||||
br.ReadBytes(16); // Padding always 0x000
|
||||
|
||||
for (int i = 0; i < num_files; i++)
|
||||
{
|
||||
sFile newFile = new sFile();
|
||||
newFile.name = "File" + i.ToString() + ".bin";
|
||||
newFile.offset = br.ReadUInt32() + 0x20;
|
||||
newFile.size = br.ReadUInt32();
|
||||
newFile.path = packFile;
|
||||
|
||||
unpack.files.Add(newFile);
|
||||
}
|
||||
|
||||
br.Close();
|
||||
pluginHost.Set_Files(unpack);
|
||||
}
|
||||
}
|
||||
}
|
10
Tinke.sln
10
Tinke.sln
@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginInterface", "PluginIn
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DSDecmp", "Plugins\DSDecmp\DSDecmp\DSDecmp.csproj", "{E6F419F9-D6B5-4BE7-99BB-97C48C927FF3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Be.Windows.Forms.HexBox", "Be.Windows.Forms.HexBox\Be.Windows.Forms.HexBox.csproj", "{26C5F25F-B450-4CAF-AD8B-B8D11AE73457}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -45,6 +47,14 @@ Global
|
||||
{E6F419F9-D6B5-4BE7-99BB-97C48C927FF3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E6F419F9-D6B5-4BE7-99BB-97C48C927FF3}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{E6F419F9-D6B5-4BE7-99BB-97C48C927FF3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{26C5F25F-B450-4CAF-AD8B-B8D11AE73457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{26C5F25F-B450-4CAF-AD8B-B8D11AE73457}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{26C5F25F-B450-4CAF-AD8B-B8D11AE73457}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{26C5F25F-B450-4CAF-AD8B-B8D11AE73457}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{26C5F25F-B450-4CAF-AD8B-B8D11AE73457}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{26C5F25F-B450-4CAF-AD8B-B8D11AE73457}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{26C5F25F-B450-4CAF-AD8B-B8D11AE73457}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{26C5F25F-B450-4CAF-AD8B-B8D11AE73457}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -695,6 +695,13 @@ namespace Tinke
|
||||
Recursivo_Archivo(length, root, carpeta);
|
||||
return carpeta;
|
||||
}
|
||||
public sFolder Search_FileOffset(int offset)
|
||||
{
|
||||
sFolder carpeta = new sFolder();
|
||||
carpeta.files = new List<sFile>();
|
||||
Recursive_FileOffset(offset, root, carpeta);
|
||||
return carpeta;
|
||||
}
|
||||
public sFolder Search_Folder(string name)
|
||||
{
|
||||
return Recursivo_Carpeta(name, root);
|
||||
@ -775,6 +782,19 @@ namespace Tinke
|
||||
foreach (sFolder subFolder in currFolder.folders)
|
||||
Recursivo_Archivo(length, subFolder, carpeta);
|
||||
|
||||
}
|
||||
private void Recursive_FileOffset(int offset, sFolder currFolder, sFolder carpeta)
|
||||
{
|
||||
if (currFolder.files is List<sFile>)
|
||||
foreach (sFile archivo in currFolder.files)
|
||||
if (archivo.offset <= offset && archivo.offset + archivo.size >= offset)
|
||||
carpeta.files.Add(archivo);
|
||||
|
||||
|
||||
if (currFolder.folders is List<sFolder>)
|
||||
foreach (sFolder subFolder in currFolder.folders)
|
||||
Recursive_FileOffset(offset, subFolder, carpeta);
|
||||
|
||||
}
|
||||
private void Recursivo_Archivo(string name, sFolder currFolder, sFolder carpeta)
|
||||
{
|
||||
|
Binary file not shown.
@ -359,6 +359,7 @@ namespace Tinke
|
||||
newMap = Imagen_NSCR.Create_BasicMap((int)tile.rahc.nTiles, width, heigth);
|
||||
|
||||
newMap.id = map.id;
|
||||
newMap.section.padding = map.section.padding;
|
||||
map = newMap;
|
||||
|
||||
pluginHost.Set_NSCR(map);
|
||||
|
@ -1417,6 +1417,8 @@ namespace Tinke
|
||||
if (searchedFile.name is String)
|
||||
resul.files.Add(searchedFile);
|
||||
}
|
||||
else if (txtSearch.Text.StartsWith("Offset: ") && txtSearch.Text.Length > 8 && txtSearch.Text.Length < 17)
|
||||
resul = accion.Search_FileOffset(Convert.ToInt32(txtSearch.Text.Substring(8), 16));
|
||||
else
|
||||
resul = accion.Search_File(txtSearch.Text);
|
||||
|
||||
|
@ -127,9 +127,6 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Be.Windows.Forms.HexBox">
|
||||
<HintPath>.\Be.Windows.Forms.HexBox.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
@ -333,6 +330,10 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Be.Windows.Forms.HexBox\Be.Windows.Forms.HexBox.csproj">
|
||||
<Project>{26C5F25F-B450-4CAF-AD8B-B8D11AE73457}</Project>
|
||||
<Name>Be.Windows.Forms.HexBox</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\PluginInterface\PluginInterface.csproj">
|
||||
<Project>{736010D3-F72F-4C56-B8D2-2EDD1B8F3A87}</Project>
|
||||
<Name>PluginInterface</Name>
|
||||
|
275
Tinke/VisorHex.Designer.cs
generated
275
Tinke/VisorHex.Designer.cs
generated
@ -30,79 +30,241 @@
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VisorHex));
|
||||
this.hexBox1 = new Be.Windows.Forms.HexBox();
|
||||
this.numericOffset = new System.Windows.Forms.NumericUpDown();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.btnSave = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericOffset)).BeginInit();
|
||||
this.menuStripTop = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.gotoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.goToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.selectRangeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.startOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.startOffsetSelect = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.endOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.endOffsetSelect = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.relativeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.goToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.encodingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.encodingCombo = new System.Windows.Forms.ToolStripComboBox();
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStripSelect = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.searchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStripTop.SuspendLayout();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// hexBox1
|
||||
//
|
||||
this.hexBox1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.hexBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.hexBox1.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.hexBox1.LineInfoForeColor = System.Drawing.Color.Empty;
|
||||
this.hexBox1.LineInfoVisible = true;
|
||||
this.hexBox1.Location = new System.Drawing.Point(0, 38);
|
||||
this.hexBox1.Location = new System.Drawing.Point(0, 24);
|
||||
this.hexBox1.Name = "hexBox1";
|
||||
this.hexBox1.ShadowSelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(60)))), ((int)(((byte)(188)))), ((int)(((byte)(255)))));
|
||||
this.hexBox1.Size = new System.Drawing.Size(809, 234);
|
||||
this.hexBox1.Size = new System.Drawing.Size(809, 289);
|
||||
this.hexBox1.StringViewVisible = true;
|
||||
this.hexBox1.TabIndex = 0;
|
||||
this.hexBox1.UseFixedBytesPerLine = true;
|
||||
this.hexBox1.VScrollBarVisible = true;
|
||||
this.hexBox1.SelectionStartChanged += new System.EventHandler(this.hexBox1_SelectionLengthChanged);
|
||||
this.hexBox1.SelectionLengthChanged += new System.EventHandler(this.hexBox1_SelectionLengthChanged);
|
||||
//
|
||||
// numericOffset
|
||||
// menuStripTop
|
||||
//
|
||||
this.numericOffset.Hexadecimal = true;
|
||||
this.numericOffset.Location = new System.Drawing.Point(51, 11);
|
||||
this.numericOffset.Maximum = new decimal(new int[] {
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericOffset.Name = "numericOffset";
|
||||
this.numericOffset.Size = new System.Drawing.Size(120, 20);
|
||||
this.numericOffset.TabIndex = 1;
|
||||
this.numericOffset.ValueChanged += new System.EventHandler(this.numericOffset_ValueChanged);
|
||||
this.menuStripTop.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.toolsToolStripMenuItem,
|
||||
this.optionsToolStripMenuItem});
|
||||
this.menuStripTop.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStripTop.Name = "menuStripTop";
|
||||
this.menuStripTop.Size = new System.Drawing.Size(809, 24);
|
||||
this.menuStripTop.TabIndex = 1;
|
||||
this.menuStripTop.Text = "menuStrip1";
|
||||
//
|
||||
// label1
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 13);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(33, 13);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "Goto:";
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// btnSave
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
this.btnSave.Image = global::Tinke.Properties.Resources.disk;
|
||||
this.btnSave.Location = new System.Drawing.Point(696, 8);
|
||||
this.btnSave.Name = "btnSave";
|
||||
this.btnSave.Size = new System.Drawing.Size(101, 25);
|
||||
this.btnSave.TabIndex = 3;
|
||||
this.btnSave.Text = "Save";
|
||||
this.btnSave.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnSave.UseVisualStyleBackColor = true;
|
||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||
this.saveToolStripMenuItem.Image = global::Tinke.Properties.Resources.disk;
|
||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(98, 22);
|
||||
this.saveToolStripMenuItem.Text = "Save";
|
||||
this.saveToolStripMenuItem.Click += new System.EventHandler(this.btnSave_Click);
|
||||
//
|
||||
// toolsToolStripMenuItem
|
||||
//
|
||||
this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.gotoToolStripMenuItem,
|
||||
this.selectRangeToolStripMenuItem,
|
||||
this.searchToolStripMenuItem});
|
||||
this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem";
|
||||
this.toolsToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
|
||||
this.toolsToolStripMenuItem.Text = "Tools";
|
||||
//
|
||||
// gotoToolStripMenuItem
|
||||
//
|
||||
this.gotoToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripTextBox1,
|
||||
this.goToolStripMenuItem});
|
||||
this.gotoToolStripMenuItem.Name = "gotoToolStripMenuItem";
|
||||
this.gotoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G)));
|
||||
this.gotoToolStripMenuItem.Size = new System.Drawing.Size(179, 22);
|
||||
this.gotoToolStripMenuItem.Text = "Goto (0x)";
|
||||
//
|
||||
// toolStripTextBox1
|
||||
//
|
||||
this.toolStripTextBox1.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
|
||||
this.toolStripTextBox1.MaxLength = 8;
|
||||
this.toolStripTextBox1.Name = "toolStripTextBox1";
|
||||
this.toolStripTextBox1.Size = new System.Drawing.Size(100, 23);
|
||||
this.toolStripTextBox1.Text = "00000000";
|
||||
//
|
||||
// goToolStripMenuItem
|
||||
//
|
||||
this.goToolStripMenuItem.Image = global::Tinke.Properties.Resources.accept;
|
||||
this.goToolStripMenuItem.Name = "goToolStripMenuItem";
|
||||
this.goToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
|
||||
this.goToolStripMenuItem.Text = "Go";
|
||||
this.goToolStripMenuItem.Click += new System.EventHandler(this.numericOffset_ValueChanged);
|
||||
//
|
||||
// selectRangeToolStripMenuItem
|
||||
//
|
||||
this.selectRangeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.startOffsetToolStripMenuItem,
|
||||
this.endOffsetToolStripMenuItem,
|
||||
this.relativeToolStripMenuItem,
|
||||
this.goToolStripMenuItem1});
|
||||
this.selectRangeToolStripMenuItem.Name = "selectRangeToolStripMenuItem";
|
||||
this.selectRangeToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.R)));
|
||||
this.selectRangeToolStripMenuItem.Size = new System.Drawing.Size(179, 22);
|
||||
this.selectRangeToolStripMenuItem.Text = "Select range";
|
||||
//
|
||||
// startOffsetToolStripMenuItem
|
||||
//
|
||||
this.startOffsetToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.startOffsetSelect});
|
||||
this.startOffsetToolStripMenuItem.Name = "startOffsetToolStripMenuItem";
|
||||
this.startOffsetToolStripMenuItem.Size = new System.Drawing.Size(153, 22);
|
||||
this.startOffsetToolStripMenuItem.Text = "Start offset (0x)";
|
||||
//
|
||||
// startOffsetSelect
|
||||
//
|
||||
this.startOffsetSelect.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
|
||||
this.startOffsetSelect.MaxLength = 8;
|
||||
this.startOffsetSelect.Name = "startOffsetSelect";
|
||||
this.startOffsetSelect.Size = new System.Drawing.Size(100, 23);
|
||||
this.startOffsetSelect.Text = "00000000";
|
||||
//
|
||||
// endOffsetToolStripMenuItem
|
||||
//
|
||||
this.endOffsetToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.endOffsetSelect});
|
||||
this.endOffsetToolStripMenuItem.Name = "endOffsetToolStripMenuItem";
|
||||
this.endOffsetToolStripMenuItem.Size = new System.Drawing.Size(153, 22);
|
||||
this.endOffsetToolStripMenuItem.Text = "End offset (0x)";
|
||||
//
|
||||
// endOffsetSelect
|
||||
//
|
||||
this.endOffsetSelect.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
|
||||
this.endOffsetSelect.MaxLength = 8;
|
||||
this.endOffsetSelect.Name = "endOffsetSelect";
|
||||
this.endOffsetSelect.Size = new System.Drawing.Size(100, 23);
|
||||
this.endOffsetSelect.Text = "00000000";
|
||||
//
|
||||
// relativeToolStripMenuItem
|
||||
//
|
||||
this.relativeToolStripMenuItem.CheckOnClick = true;
|
||||
this.relativeToolStripMenuItem.Name = "relativeToolStripMenuItem";
|
||||
this.relativeToolStripMenuItem.Size = new System.Drawing.Size(153, 22);
|
||||
this.relativeToolStripMenuItem.Text = "Relative";
|
||||
//
|
||||
// goToolStripMenuItem1
|
||||
//
|
||||
this.goToolStripMenuItem1.Image = global::Tinke.Properties.Resources.accept;
|
||||
this.goToolStripMenuItem1.Name = "goToolStripMenuItem1";
|
||||
this.goToolStripMenuItem1.Size = new System.Drawing.Size(153, 22);
|
||||
this.goToolStripMenuItem1.Text = "Go";
|
||||
this.goToolStripMenuItem1.Click += new System.EventHandler(this.goToolStripMenuItem1_Click);
|
||||
//
|
||||
// optionsToolStripMenuItem
|
||||
//
|
||||
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.encodingToolStripMenuItem});
|
||||
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
|
||||
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
|
||||
this.optionsToolStripMenuItem.Text = "Options";
|
||||
//
|
||||
// encodingToolStripMenuItem
|
||||
//
|
||||
this.encodingToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.encodingCombo});
|
||||
this.encodingToolStripMenuItem.Name = "encodingToolStripMenuItem";
|
||||
this.encodingToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
|
||||
this.encodingToolStripMenuItem.Text = "Encoding";
|
||||
//
|
||||
// encodingCombo
|
||||
//
|
||||
this.encodingCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.encodingCombo.Items.AddRange(new object[] {
|
||||
"Default",
|
||||
"shift_jis",
|
||||
"utf-7",
|
||||
"utf-8",
|
||||
"ascii"});
|
||||
this.encodingCombo.Name = "encodingCombo";
|
||||
this.encodingCombo.Size = new System.Drawing.Size(121, 23);
|
||||
this.encodingCombo.SelectedIndexChanged += new System.EventHandler(this.comboBoxEncoding_SelectedIndexChanged);
|
||||
//
|
||||
// statusStrip1
|
||||
//
|
||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripSelect});
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 291);
|
||||
this.statusStrip1.Name = "statusStrip1";
|
||||
this.statusStrip1.Size = new System.Drawing.Size(809, 22);
|
||||
this.statusStrip1.TabIndex = 2;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
// toolStripSelect
|
||||
//
|
||||
this.toolStripSelect.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.toolStripSelect.Name = "toolStripSelect";
|
||||
this.toolStripSelect.Size = new System.Drawing.Size(57, 17);
|
||||
this.toolStripSelect.Text = "Selected: ";
|
||||
//
|
||||
// searchToolStripMenuItem
|
||||
//
|
||||
this.searchToolStripMenuItem.Name = "searchToolStripMenuItem";
|
||||
this.searchToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F)));
|
||||
this.searchToolStripMenuItem.Size = new System.Drawing.Size(179, 22);
|
||||
this.searchToolStripMenuItem.Text = "Search";
|
||||
this.searchToolStripMenuItem.Click += new System.EventHandler(this.searchToolStripMenuItem_Click);
|
||||
//
|
||||
// VisorHex
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
||||
this.ClientSize = new System.Drawing.Size(809, 272);
|
||||
this.Controls.Add(this.btnSave);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.numericOffset);
|
||||
this.ClientSize = new System.Drawing.Size(809, 313);
|
||||
this.Controls.Add(this.statusStrip1);
|
||||
this.Controls.Add(this.hexBox1);
|
||||
this.Controls.Add(this.menuStripTop);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MinimizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(825, 38);
|
||||
this.MainMenuStrip = this.menuStripTop;
|
||||
this.Name = "VisorHex";
|
||||
this.Text = "S41";
|
||||
this.Resize += new System.EventHandler(this.VisorHex_Resize);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericOffset)).EndInit();
|
||||
this.menuStripTop.ResumeLayout(false);
|
||||
this.menuStripTop.PerformLayout();
|
||||
this.statusStrip1.ResumeLayout(false);
|
||||
this.statusStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -111,9 +273,26 @@
|
||||
#endregion
|
||||
|
||||
private Be.Windows.Forms.HexBox hexBox1;
|
||||
private System.Windows.Forms.NumericUpDown numericOffset;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button btnSave;
|
||||
private System.Windows.Forms.MenuStrip menuStripTop;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem gotoToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripTextBox toolStripTextBox1;
|
||||
private System.Windows.Forms.ToolStripMenuItem goToolStripMenuItem;
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripSelect;
|
||||
private System.Windows.Forms.ToolStripMenuItem selectRangeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem startOffsetToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripTextBox startOffsetSelect;
|
||||
private System.Windows.Forms.ToolStripMenuItem endOffsetToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripTextBox endOffsetSelect;
|
||||
private System.Windows.Forms.ToolStripMenuItem relativeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem goToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem encodingToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripComboBox encodingCombo;
|
||||
private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem;
|
||||
|
||||
|
||||
|
||||
|
@ -16,18 +16,22 @@ namespace Tinke
|
||||
{
|
||||
sFile file;
|
||||
bool fileEdited;
|
||||
IByteCharConverter bcc;
|
||||
|
||||
public VisorHex(sFile file, bool edit)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Text = Tools.Helper.ObtenerTraduccion("Sistema", "S41");
|
||||
btnSave.Enabled = edit;
|
||||
saveToolStripMenuItem.Enabled = edit;
|
||||
|
||||
this.file = file;
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(file.path));
|
||||
br.BaseStream.Position = file.offset;
|
||||
hexBox1.ByteProvider = new DynamicByteProvider(br.ReadBytes((int)file.size));
|
||||
br.Close();
|
||||
|
||||
|
||||
encodingCombo.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
@ -57,33 +61,88 @@ namespace Tinke
|
||||
|
||||
private void comboBoxEncoding_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// Obviously it doesn't work with shift-jis and unicode
|
||||
//hexBox1.ByteCharConverter = new ByteCharConveter(comboBoxEncoding.Text);
|
||||
if (encodingCombo.SelectedIndex == 0)
|
||||
bcc = new DefaultByteCharConverter();
|
||||
else
|
||||
bcc = new ByteCharConveter(encodingCombo.Text);
|
||||
|
||||
hexBox1.ByteCharConverter = bcc;
|
||||
}
|
||||
|
||||
private void numericOffset_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
hexBox1.Select((long)numericOffset.Value, 1);
|
||||
hexBox1.Select(Convert.ToInt64(toolStripTextBox1.Text, 16), 1);
|
||||
}
|
||||
private void hexBox1_SelectionLengthChanged(object sender, EventArgs e)
|
||||
{
|
||||
toolStripSelect.Text = String.Format("Selected at 0x{0} with length 0x{1}",
|
||||
hexBox1.SelectionStart.ToString("x"), hexBox1.SelectionLength.ToString("x"));
|
||||
}
|
||||
private void goToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
long size = 0;
|
||||
long start = Convert.ToInt64(startOffsetSelect.Text, 16);
|
||||
if (relativeToolStripMenuItem.Checked)
|
||||
size = Convert.ToInt64(endOffsetSelect.Text, 16);
|
||||
else
|
||||
size = Convert.ToInt64(endOffsetSelect.Text, 16) - start;
|
||||
|
||||
hexBox1.Select(start, size);
|
||||
}
|
||||
|
||||
private void searchToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class ByteCharConveter : IByteCharConverter
|
||||
{
|
||||
string encoding;
|
||||
Encoding encoding;
|
||||
List<byte> requeridedChar;
|
||||
List<char> requeridedByte;
|
||||
|
||||
public ByteCharConveter(string encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
this.encoding = Encoding.GetEncoding(encoding);
|
||||
requeridedChar = new List<byte>();
|
||||
requeridedByte = new List<char>();
|
||||
}
|
||||
|
||||
public byte ToByte(char c)
|
||||
{
|
||||
return Encoding.GetEncoding(encoding).GetBytes(new Char[] { c })[0];
|
||||
}
|
||||
if (encoding.WebName == "shift-jis")
|
||||
return ToByteShiftJis(c);
|
||||
|
||||
return (byte)c;
|
||||
}
|
||||
public char ToChar(byte b)
|
||||
{
|
||||
return Encoding.GetEncoding(encoding).GetChars(new Byte[] { b })[0];
|
||||
if (encoding.WebName == "shift_jis")
|
||||
return ToCharShiftJis(b);
|
||||
|
||||
return encoding.GetChars(new byte[] { b })[0];
|
||||
}
|
||||
|
||||
public byte ToByteShiftJis(char c)
|
||||
{
|
||||
return (byte)c;
|
||||
}
|
||||
public char ToCharShiftJis(byte b)
|
||||
{
|
||||
if (requeridedChar.Count == 0 && b > 0x7F)
|
||||
{
|
||||
requeridedChar.Add(b);
|
||||
return '\x20';
|
||||
}
|
||||
|
||||
requeridedChar.Add(b);
|
||||
string c = new String(encoding.GetChars(requeridedChar.ToArray()));
|
||||
requeridedChar.Clear();
|
||||
return (c[0] > '\x1F' ? c[0] : '.');
|
||||
|
||||
}
|
||||
|
||||
// TODO: utf-16, unicodeFFFE, utf-32, utf-32BE
|
||||
}
|
||||
}
|
@ -117,6 +117,12 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStripTop.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>146, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
@ -8,10 +8,17 @@
|
||||
- Unpacker for file "RESOURCE.NXARC"
|
||||
** Game NINOKUNI (Ninokuni Shikkoku no Madoushi) supported
|
||||
- Unpacker for NPCK files
|
||||
- Packer for N2D files
|
||||
** Game SUBARASHIKI (The world end with you) supported
|
||||
** Improved Font plugin
|
||||
- Fixed problem with rotated Font
|
||||
- Fixed problem with char codes
|
||||
- Change info map char (PMAC section)
|
||||
- Fixed problems saving new fonts
|
||||
** Fixed problem reading NCER files
|
||||
* Fixed problem with rotated Font and some char codes
|
||||
* Fixed problem with textures with format 2
|
||||
* Added hotkeys (X for eXpand all nodes, C for Collapse all nodes)
|
||||
* Search by offset -> Offset: 00000000
|
||||
|
||||
0.8.1 (public release) rev100
|
||||
*** BTX0 textures supported (view only)
|
||||
|
Loading…
Reference in New Issue
Block a user