WIP: a step to migrate (working on saves)
This commit is contained in:
147
SavedFontsConverter/Form1.Designer.cs
generated
Normal file
147
SavedFontsConverter/Form1.Designer.cs
generated
Normal file
@@ -0,0 +1,147 @@
|
||||
namespace SavedFontsConverter
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <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() {
|
||||
dlgOpen = new OpenFileDialog();
|
||||
dlgSave = new SaveFileDialog();
|
||||
btnOpen = new Button();
|
||||
btnConvert = new Button();
|
||||
lblPathOriginal = new Label();
|
||||
tbPathNew = new TextBox();
|
||||
btnPath = new Button();
|
||||
tbInfo = new TextBox();
|
||||
lblInfo = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
dlgOpen.FileName = "font.mbf";
|
||||
//
|
||||
// btnOpen
|
||||
//
|
||||
btnOpen.Font = new Font("Segoe UI Semibold", 11.25F, FontStyle.Bold, GraphicsUnit.Point, 204);
|
||||
btnOpen.Location = new Point(10, 10);
|
||||
btnOpen.Name = "btnOpen";
|
||||
btnOpen.Size = new Size(100, 30);
|
||||
btnOpen.TabIndex = 0;
|
||||
btnOpen.Text = "Load File";
|
||||
btnOpen.UseVisualStyleBackColor = true;
|
||||
btnOpen.Click += btnOpen_Click;
|
||||
//
|
||||
// btnConvert
|
||||
//
|
||||
btnConvert.Font = new Font("Segoe UI Semibold", 11.25F, FontStyle.Bold, GraphicsUnit.Point, 204);
|
||||
btnConvert.Location = new Point(10, 132);
|
||||
btnConvert.Name = "btnConvert";
|
||||
btnConvert.Size = new Size(100, 30);
|
||||
btnConvert.TabIndex = 1;
|
||||
btnConvert.Text = "Convert!";
|
||||
btnConvert.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lblPathOriginal
|
||||
//
|
||||
lblPathOriginal.AutoSize = true;
|
||||
lblPathOriginal.Location = new Point(116, 19);
|
||||
lblPathOriginal.Name = "lblPathOriginal";
|
||||
lblPathOriginal.Size = new Size(32, 15);
|
||||
lblPathOriginal.TabIndex = 2;
|
||||
lblPathOriginal.Text = "<...>";
|
||||
//
|
||||
// tbPathNew
|
||||
//
|
||||
tbPathNew.Location = new Point(10, 168);
|
||||
tbPathNew.Name = "tbPathNew";
|
||||
tbPathNew.Size = new Size(439, 23);
|
||||
tbPathNew.TabIndex = 3;
|
||||
//
|
||||
// btnPath
|
||||
//
|
||||
btnPath.Location = new Point(455, 167);
|
||||
btnPath.Name = "btnPath";
|
||||
btnPath.Size = new Size(28, 23);
|
||||
btnPath.TabIndex = 4;
|
||||
btnPath.Text = "...";
|
||||
btnPath.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tbInfo
|
||||
//
|
||||
tbInfo.BorderStyle = BorderStyle.FixedSingle;
|
||||
tbInfo.Location = new Point(116, 43);
|
||||
tbInfo.Multiline = true;
|
||||
tbInfo.Name = "tbInfo";
|
||||
tbInfo.ReadOnly = true;
|
||||
tbInfo.Size = new Size(200, 82);
|
||||
tbInfo.TabIndex = 5;
|
||||
tbInfo.TabStop = false;
|
||||
tbInfo.Text = "Mospaced / Variable width\r\nFrames number / Single\r\nCodepage";
|
||||
//
|
||||
// lblInfo
|
||||
//
|
||||
lblInfo.AutoSize = true;
|
||||
lblInfo.Location = new Point(58, 43);
|
||||
lblInfo.Name = "lblInfo";
|
||||
lblInfo.Size = new Size(52, 15);
|
||||
lblInfo.TabIndex = 6;
|
||||
lblInfo.Text = "File Info:";
|
||||
lblInfo.TextAlign = ContentAlignment.TopRight;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(96F, 96F);
|
||||
AutoScaleMode = AutoScaleMode.Dpi;
|
||||
ClientSize = new Size(490, 207);
|
||||
Controls.Add(lblInfo);
|
||||
Controls.Add(tbInfo);
|
||||
Controls.Add(btnPath);
|
||||
Controls.Add(tbPathNew);
|
||||
Controls.Add(lblPathOriginal);
|
||||
Controls.Add(btnConvert);
|
||||
Controls.Add(btnOpen);
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "Form1";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "McBitFont: Saved Font Converter";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private OpenFileDialog dlgOpen;
|
||||
private SaveFileDialog dlgSave;
|
||||
private Button btnOpen;
|
||||
private Button btnConvert;
|
||||
private Label lblPathOriginal;
|
||||
private TextBox tbPathNew;
|
||||
private Button btnPath;
|
||||
private TextBox tbInfo;
|
||||
private Label lblInfo;
|
||||
}
|
||||
}
|
96
SavedFontsConverter/Form1.cs
Normal file
96
SavedFontsConverter/Form1.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
namespace SavedFontsConverter
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
|
||||
//sealed class PreMergeToMergedDeserializationBinder : SerializationBinder {
|
||||
// public override Type BindToType(string assemblyName, string typeName) {
|
||||
// Type typeToDeserialize = null;
|
||||
|
||||
// // For each assemblyName/typeName that you want to deserialize to
|
||||
// // a different type, set typeToDeserialize to the desired type.
|
||||
// //String exeAssembly = Assembly.GetExecutingAssembly().FullName;
|
||||
// String exeAssembly = "McBitFont, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null";
|
||||
// //MessageBox.Show(exeAssembly);
|
||||
|
||||
// // The following line of code returns the type.
|
||||
// typeToDeserialize = Type.GetType(String.Format("{0}, {1}", typeName, exeAssembly));
|
||||
|
||||
// return typeToDeserialize;
|
||||
// }
|
||||
//}
|
||||
|
||||
public class CustomSerializationBinder : SerializationBinder {
|
||||
public override Type BindToType(string assemblyName, string typeName) {
|
||||
Assembly.GetExecutingAssembly().GetType(typeName)
|
||||
return Assembly.GetExecutingAssembly().GetType(typeName);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct FrameMiniature
|
||||
{
|
||||
public FrameMiniature(int cc, int ww, int hh)
|
||||
{
|
||||
code = cc;
|
||||
width = ww;
|
||||
height = hh;
|
||||
data = new bool[ww, hh];
|
||||
}
|
||||
public int code;
|
||||
public int width;
|
||||
public int height;
|
||||
public bool[,] data;
|
||||
};
|
||||
|
||||
[Serializable]
|
||||
public struct SaveBlock
|
||||
{
|
||||
public bool monospaced;
|
||||
public int codepage;
|
||||
public int baseline;
|
||||
public List<FrameMiniature> frames;
|
||||
}
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private void oldLoad(string filename)
|
||||
{
|
||||
// Disable the warning.
|
||||
#pragma warning disable SYSLIB0011
|
||||
|
||||
SaveBlock sav;
|
||||
BinaryFormatter formatter = new BinaryFormatter();
|
||||
formatter.Binder = new CustomSerializationBinder();
|
||||
|
||||
using (FileStream fs = File.Open(filename, FileMode.Open)) {
|
||||
sav = (SaveBlock)formatter.Deserialize(fs);
|
||||
fs.Close();
|
||||
}
|
||||
tbInfo.Clear();
|
||||
tbInfo.AppendText("Monospaced: " + sav.monospaced.ToString() + "\n");
|
||||
tbInfo.AppendText("Codepage: " + sav.codepage.ToString() + "\n");
|
||||
tbInfo.AppendText("Frames: " + sav.frames.Count.ToString() + "\n");
|
||||
// Re-enable the warning.
|
||||
#pragma warning restore SYSLIB0011
|
||||
}
|
||||
|
||||
private void btnOpen_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dlgOpen.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
lblPathOriginal.Text = dlgOpen.FileName;
|
||||
oldLoad(dlgOpen.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
126
SavedFontsConverter/Form1.resx
Normal file
126
SavedFontsConverter/Form1.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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgSave.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>156, 17</value>
|
||||
</metadata>
|
||||
</root>
|
17
SavedFontsConverter/Program.cs
Normal file
17
SavedFontsConverter/Program.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace SavedFontsConverter
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
12
SavedFontsConverter/SavedFontsConverter.csproj
Normal file
12
SavedFontsConverter/SavedFontsConverter.csproj
Normal file
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0-windows7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
Reference in New Issue
Block a user