Explorar o código

Commit with files :-)

Michel %!s(int64=3) %!d(string=hai) anos
pai
achega
c5960380a1

+ 25 - 0
ZX-Keyboard.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.3.32811.315
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZX-Keyboard", "ZX-Keyboard\ZX-Keyboard.csproj", "{F3916341-8E50-4775-80DD-40E4E044630A}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{F3916341-8E50-4775-80DD-40E4E044630A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F3916341-8E50-4775-80DD-40E4E044630A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F3916341-8E50-4775-80DD-40E4E044630A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F3916341-8E50-4775-80DD-40E4E044630A}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {E838DE56-1B30-42C8-AB57-F0D761E213ED}
+	EndGlobalSection
+EndGlobal

+ 241 - 0
ZX-Keyboard/Logic/PdfContentsExtention.cs

@@ -0,0 +1,241 @@
+using Microsoft.VisualBasic;
+using PdfFileWriter;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Reflection.Metadata;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using static System.Windows.Forms.LinkLabel;
+
+namespace ZX_Keyboard.Logic
+{
+    static class PdfContentsExtention
+    {
+        public static void AddNumberGraphButton(this PdfContents contents,
+            PdfDocument document,
+            Double left,
+            Double bottom,
+            string key,
+            byte graph,
+            Color color,
+            string cShifted,
+            string eKeyword,
+            string eShifted)
+        {
+            contents.AddNumberButton(document, left, bottom, key, cShifted, eKeyword, eShifted);
+
+            // Draw graph
+            // Outline
+            PdfRectangle GraphRect = new PdfRectangle(left + 6.6, bottom + 6, left + 6.6 + 2, bottom + 6 + 2);
+            PdfDrawCtrl DrawGraphCtrl = new PdfDrawCtrl();
+            DrawGraphCtrl.Shape = DrawShape.Rectangle;
+            DrawGraphCtrl.Paint = DrawPaint.Border;
+            DrawGraphCtrl.BorderWidth = 0.1;
+            DrawGraphCtrl.BorderColor = color;
+            contents.DrawGraphics(DrawGraphCtrl, GraphRect);
+
+            // Top Left
+            if ((graph & 0b1000) != 0)
+            {
+                PdfRectangle innerRect = new PdfRectangle(left + 6.6, bottom + 7, left + 6.6 + 1, bottom + 7 + 1);
+                PdfDrawCtrl DrawInnerCtrl = new PdfDrawCtrl();
+                DrawInnerCtrl.Shape = DrawShape.Rectangle;
+                DrawInnerCtrl.Paint = DrawPaint.Fill;
+                DrawInnerCtrl.BackgroundTexture = color;
+                contents.DrawGraphics(DrawInnerCtrl, innerRect);
+            }
+
+            // Top Right
+            if ((graph & 0b0100) != 0)
+            {
+                PdfRectangle innerRect = new PdfRectangle(left + 7.6, bottom + 7, left + 7.6 + 1, bottom + 7 + 1);
+                PdfDrawCtrl DrawInnerCtrl = new PdfDrawCtrl();
+                DrawInnerCtrl.Shape = DrawShape.Rectangle;
+                DrawInnerCtrl.Paint = DrawPaint.Fill;
+                DrawInnerCtrl.BackgroundTexture = color;
+                contents.DrawGraphics(DrawInnerCtrl, innerRect);
+            }
+
+            // Bottom Right
+            if ((graph & 0b0010) != 0)
+            {
+                PdfRectangle innerRect = new PdfRectangle(left + 7.6, bottom + 6, left + 7.6 + 1, bottom + 6 + 1);
+                PdfDrawCtrl DrawInnerCtrl = new PdfDrawCtrl();
+                DrawInnerCtrl.Shape = DrawShape.Rectangle;
+                DrawInnerCtrl.Paint = DrawPaint.Fill;
+                DrawInnerCtrl.BackgroundTexture = color;
+                contents.DrawGraphics(DrawInnerCtrl, innerRect);
+            }
+
+            // Bottom Left
+            if ((graph & 0b0001) != 0)
+            {
+                PdfRectangle innerRect = new PdfRectangle(left + 6.6, bottom + 6, left + 6.6 + 1, bottom + 6 + 1);
+                PdfDrawCtrl DrawInnerCtrl = new PdfDrawCtrl();
+                DrawInnerCtrl.Shape = DrawShape.Rectangle;
+                DrawInnerCtrl.Paint = DrawPaint.Fill;
+                DrawInnerCtrl.BackgroundTexture = color;
+                contents.DrawGraphics(DrawInnerCtrl, innerRect);
+            }
+        }
+
+        public static void AddNumberButton(this PdfContents contents,
+            PdfDocument document,
+            Double left,
+            Double bottom,
+            string key,
+            string cShifted,
+            string eKeyword,
+            string eShifted)
+        {
+            KeyOutline(contents, left, bottom);
+            Key(contents, document, left, bottom, key);
+
+            PdfDrawTextCtrl cShiftedTextCtrl = new PdfDrawTextCtrl(document, "Verdana", FontStyle.Bold, 6);
+            cShiftedTextCtrl.TextColor = Color.Red;
+            cShiftedTextCtrl.Justify = TextJustify.Right;
+            contents.DrawText(cShiftedTextCtrl, left + 8, bottom + 4, cShifted);
+
+            PdfDrawTextCtrl eKeywordTextCtrl = new PdfDrawTextCtrl(document, "Verdana", FontStyle.Bold, 4);
+            if ("5678".Contains(key))
+            {
+                eKeywordTextCtrl = new PdfDrawTextCtrl(document, "Webdings", FontStyle.Bold, 8);
+            }
+            eKeywordTextCtrl.TextColor = Color.Black;
+            eKeywordTextCtrl.Justify = TextJustify.Center;
+            contents.DrawText(eKeywordTextCtrl, left + 5.5, bottom + 8.5, eKeyword);
+
+            PdfDrawTextCtrl eShiftedTextCtrl = new PdfDrawTextCtrl(document, "Verdana", FontStyle.Bold, 4);
+            eShiftedTextCtrl.TextColor = Color.Red;
+            eShiftedTextCtrl.Justify = TextJustify.Center;
+            contents.DrawText(eShiftedTextCtrl, left + 5.5, bottom + 1, eShifted);
+
+        }
+
+        public static void AddTextButton(this PdfContents contents,
+                PdfDocument document,
+                Double left,
+                Double bottom,
+                string line1,
+                string line2,
+                int textSize,
+                Color textColor,
+                Color backColor)
+        {
+            Double width = 11.6;
+            Double height = 11;
+            PdfRectangle Rect = new PdfRectangle(left, bottom, left + width, bottom + height);
+            PdfDrawCtrl DrawCtrl = new PdfDrawCtrl();
+            DrawCtrl.Shape = DrawShape.RoundedRect;
+            DrawCtrl.Paint = DrawPaint.BorderAndFill;
+            DrawCtrl.BorderWidth = 0.1;
+            DrawCtrl.BorderColor = Color.Black;
+            DrawCtrl.BackgroundTexture = backColor;
+            DrawCtrl.Radius = 1;
+            contents.DrawGraphics(DrawCtrl, Rect);
+
+            var line1vPos = bottom + 5;
+            if (!string.IsNullOrEmpty(line2))
+            {
+                line1vPos = bottom + 6;
+            }
+            PdfDrawTextCtrl keyLine1Ctrl = new PdfDrawTextCtrl(document, "Verdana", FontStyle.Bold, textSize);
+            keyLine1Ctrl.TextColor = textColor;
+            keyLine1Ctrl.Justify = TextJustify.Center;
+            contents.DrawText(keyLine1Ctrl, left + 5.8, line1vPos, line1);
+            contents.DrawText(keyLine1Ctrl, left + 5.8, line1vPos - 2.5, line2);
+        }
+
+        public static void AddButton(this PdfContents contents,
+                PdfDocument document,
+                Double left,
+                Double bottom,
+                string key,
+                string statement,
+                string sShifted,
+                string eKeyword,
+                string eShifted)
+        {
+            KeyOutline(contents, left, bottom);
+            Key(contents, document, left, bottom, key);
+            Statement(contents, document, left, bottom, statement);
+
+            PdfDrawTextCtrl sShiftedTextCtrl = new PdfDrawTextCtrl(document, "Verdana", FontStyle.Bold, 6);
+            sShiftedTextCtrl.TextColor = Color.Red;
+            sShiftedTextCtrl.Justify = TextJustify.Right;
+            contents.DrawText(sShiftedTextCtrl, left + 10.4, bottom + 6, sShifted);
+
+            PdfDrawTextCtrl eKeywordTextCtrl = new PdfDrawTextCtrl(document, "Verdana", FontStyle.Bold, 4);
+            eKeywordTextCtrl.TextColor = Color.Green;
+            eKeywordTextCtrl.Justify = TextJustify.Center;
+            contents.DrawText(eKeywordTextCtrl, left + 5.5, bottom + 8.5, eKeyword);
+
+            PdfDrawTextCtrl eShiftedTextCtrl = new PdfDrawTextCtrl(document, "Verdana", FontStyle.Bold, 4);
+            eShiftedTextCtrl.TextColor = Color.Red;
+            eShiftedTextCtrl.Justify = TextJustify.Center;
+            contents.DrawText(eShiftedTextCtrl, left + 5.5, bottom + 1, eShifted);
+        }
+
+        public static void AddColourLabel(this PdfContents contents,
+        PdfDocument document,
+        Double left,
+        Double bottom,
+        string text,
+        Color colour)
+        {
+            Double width = 11.6;
+            Double height = 5;
+            PdfRectangle Rect = new PdfRectangle(left, bottom, left + width, bottom + height);
+            PdfDrawCtrl DrawCtrl = new PdfDrawCtrl();
+            DrawCtrl.Shape = DrawShape.RoundedRect;
+            DrawCtrl.Paint = DrawPaint.Border;
+            DrawCtrl.BorderColor = Color.Black;
+            if (colour == Color.White)
+            {
+                DrawCtrl.Paint = DrawPaint.BorderAndFill;
+                DrawCtrl.BackgroundTexture = Color.Black;
+            }
+            DrawCtrl.BorderWidth = 0.1;
+            DrawCtrl.Radius = 1;
+            contents.DrawGraphics(DrawCtrl, Rect);
+
+            PdfDrawTextCtrl textCtrl = new PdfDrawTextCtrl(document, "Verdana", FontStyle.Bold, 4);
+            textCtrl.TextColor = colour;
+            textCtrl.Justify = TextJustify.Center;
+            contents.DrawText(textCtrl, left + 5.8, bottom + 2, text);
+
+        }
+
+        private static void KeyOutline(PdfContents contents, double left, double bottom)
+        {
+            Double width = 11.6;
+            Double height = 11;
+            PdfRectangle Rect = new PdfRectangle(left, bottom, left + width, bottom + height);
+            PdfDrawCtrl DrawCtrl = new PdfDrawCtrl();
+            DrawCtrl.Shape = DrawShape.RoundedRect;
+            DrawCtrl.Paint = DrawPaint.Border;
+            DrawCtrl.BorderWidth = 0.1;
+            DrawCtrl.BorderColor = Color.Black;
+            DrawCtrl.Radius = 1;
+            contents.DrawGraphics(DrawCtrl, Rect);
+        }
+
+        private static void Key(PdfContents contents, PdfDocument document, double left, double bottom, string key)
+        {
+            PdfDrawTextCtrl keyTextCtrl = new PdfDrawTextCtrl(document, "Verdana", FontStyle.Bold, 10);
+            keyTextCtrl.TextColor = Color.Black;
+            contents.DrawText(keyTextCtrl, left + 0.8, bottom + 4, key);
+        }
+
+        private static void Statement(PdfContents contents, PdfDocument document, double left, double bottom, string statement)
+        {
+            PdfDrawTextCtrl statementTextCtrl = new PdfDrawTextCtrl(document, "Verdana", FontStyle.Bold, 4);
+            statementTextCtrl.TextColor = Color.Black;
+            statementTextCtrl.Justify = TextJustify.Right;
+            contents.DrawText(statementTextCtrl, left + 10.4, bottom + 4, statement);
+        }
+    }
+}

+ 113 - 0
ZX-Keyboard/Logic/RenderPdf.cs

@@ -0,0 +1,113 @@
+using Microsoft.VisualBasic;
+using PdfFileWriter;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZX_Keyboard.Logic
+{
+    internal class RenderPdf
+    {
+        internal void CreateDocument()
+        {
+            var filename = "ZX-Keyboard.pdf";
+
+            // Create empty document
+            using (PdfDocument Document = new PdfDocument(PaperType.A4, false, UnitOfMeasure.mm, filename))
+            {
+                // Add new page
+                PdfPage Page = new PdfPage(Document);
+
+                // Add contents to page
+                PdfContents Contents = new PdfContents(Page);
+
+                // create font
+                PdfFont ArialNormal = PdfFont.CreatePdfFont(Document, "Arial", FontStyle.Regular, true);
+                PdfDrawTextCtrl TextCtrl = new PdfDrawTextCtrl(ArialNormal, 10.0);
+
+                // draw text
+                TextCtrl.Justify = TextJustify.Center;
+                Contents.DrawText(TextCtrl, 304, 830, "ZX-Keyboard Created by Badmuts");
+
+                // Row 1
+                Contents.AddNumberGraphButton(Document, 15, 275, "1", 0b0100, Color.Blue, "!", "EDIT", "DEF FN");
+                Contents.AddNumberGraphButton(Document, 28, 275, "2", 0b1000, Color.Red, "@", "CAPS LOCK", "FN");
+                Contents.AddNumberGraphButton(Document, 41, 275, "3", 0b1100, Color.Magenta, "#", "TRUE VIDEO", "Row");
+                Contents.AddNumberGraphButton(Document, 54, 275, "4", 0b0010, Color.Green, "$", "INV VIDEO", "OPEN");
+                Contents.AddNumberGraphButton(Document, 67, 275, "5", 0b0110, Color.Cyan, "%", "3", "CLOSE");
+                Contents.AddNumberGraphButton(Document, 80, 275, "6", 0b1010, Color.Yellow, "&", "6", "MOVE");
+                Contents.AddNumberGraphButton(Document, 93, 275, "7", 0b0001, Color.Black, "'", "5", "ERASE");
+                Contents.AddNumberGraphButton(Document, 106, 275, "8", 0b0000, Color.Black, "(", "4", "POINT");
+                Contents.AddNumberButton(Document, 119, 275, "9", ")", "GRAPHICS", "CAT");
+                Contents.AddNumberButton(Document, 132, 275, "0", "_", "DELETE", "FORMAT");
+
+                // Row 2
+                Contents.AddButton(Document, 145, 275, "Q", "PLOT", "<=", "SIN", "ASN");
+                Contents.AddButton(Document, 158, 275, "W", "DRAW", "<>", "COS", "ACS");
+                Contents.AddButton(Document, 171, 275, "E", "REM", ">=", "TAN", "ATN");
+                Contents.AddButton(Document, 184, 275, "R", "RUN", "<", "INT", "VERIFY");
+                Contents.AddButton(Document, 15, 262, "T", "RAND", ">", "RND", "MERGE");
+                Contents.AddButton(Document, 28, 262, "Y", "RETURN", "AND", "STR$", "[");
+                Contents.AddButton(Document, 41, 262, "U", "IF", "OR", "CHR$", "]");
+                Contents.AddButton(Document, 54, 262, "I", "INPUT", "AT", "CODE", "IN");
+                Contents.AddButton(Document, 67, 262, "O", "POKE", ";", "PEEK", "OUT");
+                Contents.AddButton(Document, 80, 262, "P", "PRINT", "\"", "TAB", "©");
+
+                // Row 3
+                Contents.AddButton(Document, 93, 262, "A", "NEW", "STOP", "READ", "~");
+                Contents.AddButton(Document, 106, 262, "S", "SAVE", "NOT", "RESTORE", "|");
+                Contents.AddButton(Document, 119, 262, "D", "DIM", "STEP", "DATA", "\\");
+                Contents.AddButton(Document, 132, 262, "F", "FOR", "TO", "SGN", "{");
+                Contents.AddButton(Document, 145, 262, "G", "GOTO", "THEN", "ABS", "}");
+                Contents.AddButton(Document, 158, 262, "H", "GOSUB", "↑", "SQR", "CIRCLE");
+                Contents.AddButton(Document, 171, 262, "J", "LOAD", "-", "VAL", "VAL$");
+                Contents.AddButton(Document, 184, 262, "K", "LIST", "+", "LEN", "SCREEN$");
+                Contents.AddButton(Document, 15, 249, "L", "LET", "=", "USR", "ATR");
+                Contents.AddTextButton(Document, 28, 249, "ENTER", "", 7, Color.Black, Color.Red);
+
+                // Row 4
+                Contents.AddTextButton(Document, 41, 249, "CAPS", "SHIFT", 5, Color.Black, Color.White);
+                Contents.AddButton(Document, 54, 249, "Z", "COPY", ":", "LN", "BEEP");
+                Contents.AddButton(Document, 67, 249, "X", "CLEAR", "£", "LN", "INK");
+                Contents.AddButton(Document, 80, 249, "C", "CONT", "?", "LN", "PAPER");
+                Contents.AddButton(Document, 93, 249, "V", "CLS", "/", "LN", "FLASH");
+                Contents.AddButton(Document, 106, 249, "B", "BORDER", "*", "LN", "BRIGHT");
+                Contents.AddButton(Document, 119, 249, "N", "NEXT", ",", "LN", "OVER");
+                Contents.AddButton(Document, 132, 249, "M", "PAUSE", ".", "LN", "INVERSE");
+                Contents.AddTextButton(Document, 145, 249, "SYMBOL", "SHIFT", 5, Color.Red, Color.White);
+                Contents.AddTextButton(Document, 158, 249, "BREAK", "SPACE", 5, Color.Black, Color.White);
+
+                // Extra for colour labels
+                Contents.AddNumberGraphButton(Document, 15, 236, "1", 0b0100, Color.Black, "!", "EDIT", "DEF FN");
+                Contents.AddNumberGraphButton(Document, 28, 236, "2", 0b1000, Color.Black, "@", "CAPS LOCK", "FN");
+                Contents.AddNumberGraphButton(Document, 41, 236, "3", 0b1100, Color.Black, "#", "TRUE VIDEO", "Row");
+                Contents.AddNumberGraphButton(Document, 54, 236, "4", 0b0010, Color.Black, "$", "INV VIDEO", "OPEN");
+                Contents.AddNumberGraphButton(Document, 67, 236, "5", 0b0110, Color.Black, "%", "3", "CLOSE");
+                Contents.AddNumberGraphButton(Document, 80, 236, "6", 0b1010, Color.Black, "&", "6", "MOVE");
+                Contents.AddNumberGraphButton(Document, 93, 236, "7", 0b1110, Color.Black, "'", "5", "ERASE");
+                Contents.AddNumberGraphButton(Document, 106, 236, "8", 0b0000, Color.Black, "(", "4", "POINT");
+
+                Contents.AddColourLabel(Document, 119, 242, "BLUE", Color.Blue);
+                Contents.AddColourLabel(Document, 119, 236, "RED", Color.Red);
+                Contents.AddColourLabel(Document, 132, 242, "MAGENTA", Color.Magenta);
+                Contents.AddColourLabel(Document, 132, 236, "GREEN", Color.Green);
+                Contents.AddColourLabel(Document, 145, 242, "CYAN", Color.Cyan);
+                Contents.AddColourLabel(Document, 145, 236, "YELLOW", Color.Yellow);
+                Contents.AddColourLabel(Document, 158, 242, "WHITE", Color.White);
+
+                // create pdf file
+                Document.CreateFile();
+
+                // start default PDF reader and display the file
+                Process Proc = new Process();
+                Proc.StartInfo = new ProcessStartInfo(filename) { UseShellExecute = true };
+                Proc.Start();
+
+            }
+        }
+    }
+}

+ 24 - 0
ZX-Keyboard/Program.cs

@@ -0,0 +1,24 @@
+using System.Configuration;
+using System.IO;
+using ZX_Keyboard.Logic;
+
+namespace ZX_Keyboard
+{
+    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 MainForm());
+            var renderPdf = new RenderPdf();
+            renderPdf.CreateDocument();
+
+        }
+    }
+}

+ 16 - 0
ZX-Keyboard/ZX-Keyboard.csproj

@@ -0,0 +1,16 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>WinExe</OutputType>
+    <TargetFramework>net6.0-windows</TargetFramework>
+    <RootNamespace>ZX_Keyboard</RootNamespace>
+    <Nullable>enable</Nullable>
+    <UseWindowsForms>true</UseWindowsForms>
+    <ImplicitUsings>enable</ImplicitUsings>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="PdfFileWriter" Version="2.0.1" />
+  </ItemGroup>
+
+</Project>