diff --git a/McBitFont.sln b/McBitFont.sln index 8cc0db1..0037dbe 100644 --- a/McBitFont.sln +++ b/McBitFont.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.5.33530.505 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McBitFont", "McBitFont\McBitFont.csproj", "{7C01529E-4414-405F-9B57-19FA4AF8ED60}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SavedFontsConverter", "SavedFontsConverter\SavedFontsConverter.csproj", "{3FBF35B9-8A24-422B-A825-8628FDD2EA86}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {7C01529E-4414-405F-9B57-19FA4AF8ED60}.Debug|Any CPU.Build.0 = Debug|Any CPU {7C01529E-4414-405F-9B57-19FA4AF8ED60}.Release|Any CPU.ActiveCfg = Release|Any CPU {7C01529E-4414-405F-9B57-19FA4AF8ED60}.Release|Any CPU.Build.0 = Release|Any CPU + {3FBF35B9-8A24-422B-A825-8628FDD2EA86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3FBF35B9-8A24-422B-A825-8628FDD2EA86}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3FBF35B9-8A24-422B-A825-8628FDD2EA86}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3FBF35B9-8A24-422B-A825-8628FDD2EA86}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/McBitFont/McBitFont.csproj b/McBitFont/McBitFont.csproj index bd0e30d..2369679 100644 --- a/McBitFont/McBitFont.csproj +++ b/McBitFont/McBitFont.csproj @@ -1,17 +1,7 @@ - - - + - Debug - AnyCPU - {7C01529E-4414-405F-9B57-19FA4AF8ED60} + net9.0-windows WinExe - McBitFont - McBitFont - v4.7.2 - 512 - true - true publish\ true Disk @@ -27,170 +17,15 @@ false false true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - + true + true icon_64.ico - - - - - - - - - - - - - - - - Form - - - About.cs - - - Form - - - Export.cs - - - Form - - - Form1.cs - - - Form - - - New.cs - - - - - About.cs - - - Export.cs - - - Form1.cs - - - New.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -204,5 +39,4 @@ false - \ No newline at end of file diff --git a/McBitFont/Properties/AssemblyInfo.cs b/McBitFont/Properties/AssemblyInfo.cs deleted file mode 100644 index 1c9ea79..0000000 --- a/McBitFont/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Общие сведения об этой сборке предоставляются следующим набором -// набора атрибутов. Измените значения этих атрибутов для изменения сведений, -// связанных со сборкой. -[assembly: AssemblyTitle("McBitFont")] -[assembly: AssemblyDescription("McFLY's Bit Font and Image Editor")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("McBitFont")] -[assembly: AssemblyCopyright("© Anton Mukhin, 2023")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми -// для компонентов COM. Если необходимо обратиться к типу в этой сборке через -// COM, следует установить атрибут ComVisible в TRUE для этого типа. -[assembly: ComVisible(false)] - -// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM -[assembly: Guid("7c01529e-4414-405f-9b57-19fa4af8ed60")] - -// Сведения о версии сборки состоят из указанных ниже четырех значений: -// -// Основной номер версии -// Дополнительный номер версии -// Номер сборки -// Редакция -// -// Можно задать все значения или принять номера сборки и редакции по умолчанию -// используя "*", как показано ниже: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.0.0")] -[assembly: AssemblyFileVersion("1.6.0.0")] diff --git a/SavedFontsConverter/Form1.Designer.cs b/SavedFontsConverter/Form1.Designer.cs new file mode 100644 index 0000000..dd45141 --- /dev/null +++ b/SavedFontsConverter/Form1.Designer.cs @@ -0,0 +1,147 @@ +namespace SavedFontsConverter +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} diff --git a/SavedFontsConverter/Form1.cs b/SavedFontsConverter/Form1.cs new file mode 100644 index 0000000..52454d2 --- /dev/null +++ b/SavedFontsConverter/Form1.cs @@ -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 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); + } + } + } +} diff --git a/SavedFontsConverter/Form1.resx b/SavedFontsConverter/Form1.resx new file mode 100644 index 0000000..b7747fe --- /dev/null +++ b/SavedFontsConverter/Form1.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 156, 17 + + \ No newline at end of file diff --git a/SavedFontsConverter/Program.cs b/SavedFontsConverter/Program.cs new file mode 100644 index 0000000..78c6e66 --- /dev/null +++ b/SavedFontsConverter/Program.cs @@ -0,0 +1,17 @@ +namespace SavedFontsConverter +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [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()); + } + } +} \ No newline at end of file diff --git a/SavedFontsConverter/SavedFontsConverter.csproj b/SavedFontsConverter/SavedFontsConverter.csproj new file mode 100644 index 0000000..d4c1124 --- /dev/null +++ b/SavedFontsConverter/SavedFontsConverter.csproj @@ -0,0 +1,12 @@ + + + + WinExe + net7.0-windows7.0 + enable + true + enable + true + + + \ No newline at end of file diff --git a/TODO.txt b/TODO.txt index 383408f..e86860b 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,5 +1,8 @@ Application: v Implement "Save" menu +- Migrate to .NET + - Migrate saves to MessagePack/protobuf-net + https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-migration-guide/choose-a-serializer Functionality: - Context menu in symbol navigator