work in progess for work on graphics subsystem.
authorMichael Welch <michaelgwelch@gmail.com>
Sat, 10 Feb 2007 21:18:54 +0000 (21:18 +0000)
committerMichael Welch <michaelgwelch@gmail.com>
Sat, 10 Feb 2007 21:18:54 +0000 (21:18 +0000)
WindowsApplication1/CharacterBitmap.cs [new file with mode: 0644]
WindowsApplication1/Form1.Designer.cs [new file with mode: 0644]
WindowsApplication1/Form1.cs [new file with mode: 0644]
WindowsApplication1/Form1.resx [new file with mode: 0644]
WindowsApplication1/Program.cs
WindowsApplication1/Properties/Resources.Designer.cs
WindowsApplication1/Properties/Resources.resx
WindowsApplication1/Screen.cs
WindowsApplication1/TIColor.cs [new file with mode: 0644]
WindowsApplication1/WindowsApplication1.csproj

diff --git a/WindowsApplication1/CharacterBitmap.cs b/WindowsApplication1/CharacterBitmap.cs
new file mode 100644 (file)
index 0000000..238425b
--- /dev/null
@@ -0,0 +1,196 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using System.Globalization;
+using System.Collections;
+
+namespace WindowsApplication1
+{
+    class CharacterBitmap
+    {
+        private Dictionary<char, Bitmap> bitmaps = new Dictionary<char, Bitmap>();
+        private Dictionary<int, TIColor> foreColors = new Dictionary<int, TIColor>();
+        private Dictionary<int, TIColor> backColors = new Dictionary<int, TIColor>();
+        private Dictionary<char, string> codes = new Dictionary<char, string>();
+        public CharacterBitmap()
+        {
+            for (int i = 1; i <= 16; i++)
+            {
+                foreColors[i] = TIColor.Black;
+                backColors[i] = TIColor.Transparent;
+            }
+
+            for (char ch = char.MinValue; ch < 160; ch++) bitmaps[ch] = new Bitmap(8, 8);
+            // non defined chars
+            for (char ch = (char)128; ch < 160; ch++) ModifyBitmap(ch, "");
+             
+            // defined chars 32-127
+            ModifyBitmap(' ',"");
+            ModifyBitmap('!',"0010101010100010");
+            ModifyBitmap('"',"0028282800000000");
+            ModifyBitmap('#',"0028287C287C2828");
+            ModifyBitmap('$',"0038545038145438");
+            ModifyBitmap('%',"0060640810204C0C");
+            ModifyBitmap('&',"0020505020544834");
+            ModifyBitmap('\'', "0008081000000000");
+            ModifyBitmap('(',"0008102020201008");
+            ModifyBitmap(')',"0020100808081020");
+            ModifyBitmap('*',"000028107C102800");
+            ModifyBitmap('+',"000010107C101000");
+            ModifyBitmap(',',"0000000000301020");
+            ModifyBitmap('-',"000000007C000000");
+            ModifyBitmap('.',"0000000000003030");
+            ModifyBitmap('/',"0000040810204000");
+
+            ModifyBitmap('0',"0038444444444438");
+            ModifyBitmap('1',"0010301010101038");
+            ModifyBitmap('2',"003844040810207C");
+            ModifyBitmap('3',"0038440418044438");
+            ModifyBitmap('4',"00081828487C0808");
+            ModifyBitmap('5',"007C407804044438");
+            ModifyBitmap('6',"0018204078444438");
+            ModifyBitmap('7',"007C040810202020");
+            ModifyBitmap('8',"0038444438444438");
+            ModifyBitmap('9',"003844443C040830");
+            ModifyBitmap(':',"0000303000303000");
+            ModifyBitmap(';',"0000303000301020");
+            ModifyBitmap('<',"0008102040201008");
+            ModifyBitmap('=',"0000007C007C0000");
+            ModifyBitmap('>',"0020100804081020");
+            ModifyBitmap('?',"0038440408100010");
+            ModifyBitmap('@',"0038445C545C4038");
+
+            // upper case chars
+            ModifyBitmap('A',"003844447C444444");
+            ModifyBitmap('B',"0078242438242478");
+            ModifyBitmap('C',"0038444040404438");
+            ModifyBitmap('D',"0078242424242478");
+            ModifyBitmap('E',"007C40407840407C");
+            ModifyBitmap('F',"007C404078404040");
+            ModifyBitmap('G',"003C40405C444438");
+            ModifyBitmap('H',"004444447C444444");
+            ModifyBitmap('I',"0038101010101038");
+            ModifyBitmap('J',"0004040404044438");
+            ModifyBitmap('K',"0044485060504844");
+            ModifyBitmap('L',"004040404040407C");
+            ModifyBitmap('M',"00446C5454444444");
+            ModifyBitmap('N',"00446464544C4C44");
+            ModifyBitmap('O',"007C44444444447C");
+            ModifyBitmap('P',"0078444478404040");
+            ModifyBitmap('Q',"0038444444544834");
+            ModifyBitmap('R',"0078444478504844");
+            ModifyBitmap('S',"0038444038044438");
+            ModifyBitmap('T',"007C101010101010");
+            ModifyBitmap('U',"0044444444444438");
+            ModifyBitmap('V',"0044444428281010");
+            ModifyBitmap('W',"0044444454545428");
+            ModifyBitmap('X',"0044442810284444");
+            ModifyBitmap('Y',"0044442810101010");
+            ModifyBitmap('Z',"007C04081020407C");
+
+
+            ModifyBitmap('[',"0038202020202038");
+            ModifyBitmap('\\', "0000402010080400");
+            ModifyBitmap(']',"0038080808080838");
+            ModifyBitmap('^',"0000102844000000");
+            ModifyBitmap('_',"000000000000007C");
+            ModifyBitmap((char)96, "");
+
+            //lowercase chars
+            ModifyBitmap('a',"00000038447C4444");
+            ModifyBitmap('b',"0000007824382478");
+            ModifyBitmap('c',"0000003C4040403C");
+            ModifyBitmap('d',"0000007824242478");
+            ModifyBitmap('e',"0000007C4078407C");
+            ModifyBitmap('f',"0000007C40784040");
+            ModifyBitmap('g',"0000003C405C4438");
+            ModifyBitmap('h',"00000044447C4444");
+            ModifyBitmap('i',"0000003810101038");
+            ModifyBitmap('j',"0000000808084830");
+            ModifyBitmap('k',"0000002428302824");
+            ModifyBitmap('l',"000000404040407C");
+            ModifyBitmap('m',"000000446C544444");
+            ModifyBitmap('n',"0000004464544C44");
+            ModifyBitmap('o',"0000007C4444447C");
+            ModifyBitmap('p',"0000007844784040");
+            ModifyBitmap('q',"0000003844544834");
+            ModifyBitmap('r',"0000007844784844");
+            ModifyBitmap('s',"0000003C40380478");
+            ModifyBitmap('t',"0000007C10101010");
+            ModifyBitmap('u',"0000004444444438");
+            ModifyBitmap('v',"0000004444282810");
+            ModifyBitmap('w',"0000004444545428");
+            ModifyBitmap('x',"0000004428102844");
+            ModifyBitmap('y',"0000004428101010");
+            ModifyBitmap('z',"0000007C0810207C");
+
+            ModifyBitmap('{',"0018202040202018");
+            ModifyBitmap('|',"0010101000101010");
+            ModifyBitmap('}',"0030080804080830");
+            ModifyBitmap('~',"0000205408000000");
+            ModifyBitmap((char)127, "");
+        }
+
+        public Bitmap this[char c]
+        {
+            get { return Get(c); }
+        }
+
+        public Bitmap Get(char c)
+        {
+            if (c < 32 || c > 159) throw new ArgumentOutOfRangeException("c");
+            return bitmaps[c];
+        }
+
+        public void Color(int charSet, TIColor foreColor, TIColor backColor)
+        {
+            foreColors[charSet] = foreColor;
+            backColors[charSet] = backColor;
+            for (int i = 0; i < 8; i++)
+            {
+                char ch = CalculateCharacter(charSet, i);
+                ModifyBitmap(ch, codes[ch]);
+            }
+        }
+        private static char CalculateCharacter(int charSet, int offset)
+        {
+            return (char)(32 + offset + (charSet - 1) * 8);
+        }
+
+        private static int GetCharacterSet(char c)
+        {
+            return ((c - 32) / 8) + 1;
+        }
+
+        public void ModifyBitmap(char c, string hexCode)
+        {
+            int charSet = GetCharacterSet(c);
+            TIColor foreColor = foreColors[charSet];
+            TIColor backColor = backColors[charSet];
+            Bitmap m = bitmaps[c];
+            string padding = new string('0', 16 - hexCode.Length);
+            hexCode = hexCode + padding;
+            codes[c] = hexCode;
+            for (int j = 0; j < 8; j++)
+            {
+                String hexNumber = hexCode.Substring(j * 2, 2);
+                byte b = Byte.Parse(hexNumber, NumberStyles.AllowHexSpecifier | NumberStyles.HexNumber);
+                BitArray ba = new BitArray(new byte[] { b });
+                for (int i = 0; i < 8; i++)
+                {
+                    if (ba[7 - i]) m.SetPixel(i, j, foreColor);
+                    else m.SetPixel(i, j, backColor);
+                }
+            }
+        }
+
+        public Bitmap Space
+        {
+            get
+            {
+                return Get(' ');
+            }
+        }
+    }
+}
diff --git a/WindowsApplication1/Form1.Designer.cs b/WindowsApplication1/Form1.Designer.cs
new file mode 100644 (file)
index 0000000..55e1783
--- /dev/null
@@ -0,0 +1,65 @@
+namespace WindowsApplication1
+{
+    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()
+        {
+            this.screen1 = new WindowsApplication1.Screen();
+            this.SuspendLayout();
+            // 
+            // screen1
+            // 
+            this.screen1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(204)))), ((int)(((byte)(255)))));
+            this.screen1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.screen1.Location = new System.Drawing.Point(0, 0);
+            this.screen1.Name = "screen1";
+            this.screen1.Size = new System.Drawing.Size(765, 472);
+            this.screen1.TabIndex = 1;
+            this.screen1.Text = "screen1";
+            // 
+            // Form1
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(204)))), ((int)(((byte)(255)))));
+            this.ClientSize = new System.Drawing.Size(765, 472);
+            this.Controls.Add(this.screen1);
+            this.DoubleBuffered = true;
+            this.Name = "Form1";
+            this.Text = "Form1";
+            this.Load += new System.EventHandler(this.Form1_Load);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private Screen screen1;
+
+    }
+}
+
diff --git a/WindowsApplication1/Form1.cs b/WindowsApplication1/Form1.cs
new file mode 100644 (file)
index 0000000..eb4facb
--- /dev/null
@@ -0,0 +1,313 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using System.Collections;
+using System.Globalization;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+namespace WindowsApplication1
+{
+    public partial class Form1 : Form
+    {
+        public delegate void PrintCallback(string message);
+
+        public Form1()
+        {
+            InitializeComponent();
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            //Bitmap bmp = new Bitmap(8, 8);
+            
+            //bmp.SetPixel(1, 1, Color.Red);
+            //bmp.SetPixel(2, 2, Color.Red);
+            //bmp.SetPixel(3, 3, Color.Red);
+            //bmp.SetPixel(4, 4, Color.Red);
+
+            
+            
+            //Graphics g = CreateGraphics();
+            //g.DrawImage(bmp, 50, 100);
+            
+            //if (i == 0)
+            //{
+            //    g.DrawLine(new Pen(Color.Red), new Point(0, 0), new Point(100, 100));
+            //}
+            //else
+            //{
+            //    g.DrawLine(new Pen(Color.Black), new Point(0, 0), new Point(200, 200));
+            //}
+            //i++;
+
+
+            //g.DrawImage(dimg, new Point(82, 200));
+
+
+            //PutChar(aimg, 1, 1);
+            //PutChar(bimg, 1, 2);
+            //PutChar(cimg, 1, 3);
+            //PutChar(dimg, 1, 4);
+            //PutChar(eimg, 1, 5);
+            //PutChar(fimg, 1, 6);
+            //PutChar(gimg, 1, 7);
+            //PutChar(himg, 1, 8);
+            //PutChar(iimg, 1, 9);
+            //PutChar(jimg, 1, 10);
+            //PutChar(kimg, 1, 11);
+            //PutChar(limg, 1, 12);
+            //PutChar(mimg, 1, 13);
+            //PutChar(nimg, 1, 14);
+            //PutChar(oimg, 1, 15);
+            //PutChar(pimg, 1, 16);
+            //PutChar(qimg, 1, 17);
+            //PutChar(rimg, 1, 18);
+            //PutChar(simg, 1, 19);
+            //PutChar(timg, 1, 20);
+            //PutChar(uimg, 1, 21);
+            //PutChar(vimg, 1, 22);
+            //PutChar(wimg, 1, 23);
+            //PutChar(ximg, 1, 24);
+            //PutChar(yimg, 1, 25);
+            //PutChar(zimg, 1, 26);
+
+            //Bitmap aaimg = new Bitmap(@"C:\Documents and Settings\Michael Welch\Desktop\ti chars\A.PNG");
+            //Bitmap bbimg = new Bitmap(@"C:\Documents and Settings\Michael Welch\Desktop\ti chars\B.PNG");
+            //aaimg.MakeTransparent();
+            //bbimg.MakeTransparent();
+            //PutChar(aaimg, 2, 1);
+            //PutChar(bbimg, 2, 2);
+        }
+
+        CharacterBitmap characters = new CharacterBitmap();
+        private void PutChar(char c, int row, int col)
+        {
+            PutChar(characters[c], row, col);
+        }
+        private void PutChar(Image img, int row, int col)
+        {
+            using (Graphics g = CreateGraphics())
+            {
+                g.ScaleTransform(2f, 2f);
+                g.InterpolationMode = InterpolationMode.NearestNeighbor;
+                g.SmoothingMode = SmoothingMode.None;
+
+                g.DrawImage(img, new Point((col - 1) * 8, (row - 1) * 8));
+            }
+        }
+
+        public void Print(string msg)
+        {
+            for (int i = 0; i < msg.Length; i++ )
+            {
+                char c = msg[i];
+                int col = i + 3;
+                PutChar(c, 24, col);
+            }
+        }
+
+        private static Bitmap FromString(string hexCode)
+        {
+            Bitmap m = new Bitmap(8, 8);
+            m.MakeTransparent();
+
+            string padding = new string('0', 16 - hexCode.Length);
+            hexCode = hexCode + padding;
+
+            for (int j = 0; j < 8; j++)
+            {
+                String hexNumber = hexCode.Substring(j * 2, 2);
+                byte b = Byte.Parse(hexNumber, NumberStyles.AllowHexSpecifier | NumberStyles.HexNumber);
+                BitArray ba = new BitArray(new byte[] { b });
+                for (int i = 0; i < 8; i++)
+                {
+                    if (ba[7-i]) m.SetPixel(i, j, Color.Black);
+                }
+            }
+            return m;
+        }
+
+        private Dictionary<char, Bitmap> bitmaps = new Dictionary<char, Bitmap>();
+
+        private void Form1_Load(object sender, EventArgs e)
+        {
+            //bool a = this.GetStyle(ControlStyles.OptimizedDoubleBuffer);
+            //bool b = this.GetStyle(ControlStyles.AllPaintingInWmPaint);
+            //this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
+            //this.Width = 256 * 2;
+            //this.Height = 30 * 8 * 2;
+            //Bitmap aimg = FromString("003844447C444444");
+            //Bitmap bimg = FromString("0078242438242478");
+            //Bitmap cimg = FromString("0038444040404438");
+            //Bitmap dimg = FromString("0078242424242478");
+            //Bitmap eimg = FromString("007C40407840407C");
+            //Bitmap fimg = FromString("007C404078404040");
+            //Bitmap gimg = FromString("003C40405C444438");
+            //Bitmap himg = FromString("004444447C444444");
+            //Bitmap iimg = FromString("0038101010101038");
+            //Bitmap jimg = FromString("0004040404044438");
+            //Bitmap kimg = FromString("0044485060504844");
+            //Bitmap limg = FromString("004040404040407C");
+            //Bitmap mimg = FromString("00446C5454444444");
+            //Bitmap nimg = FromString("00446464544C4C44");
+            //Bitmap oimg = FromString("007C44444444447C");
+            //Bitmap pimg = FromString("0078444478404040");
+            //Bitmap qimg = FromString("0038444444544834");
+            //Bitmap rimg = FromString("0078444478504844");
+            //Bitmap simg = FromString("0038444038044438");
+            //Bitmap timg = FromString("007C101010101010");
+            //Bitmap uimg = FromString("0044444444444438");
+            //Bitmap vimg = FromString("0044444428281010");
+            //Bitmap wimg = FromString("0044444454545428");
+            //Bitmap ximg = FromString("0044442810284444");
+            //Bitmap yimg = FromString("0044442810101010");
+            //Bitmap zimg = FromString("007C04081020407C");
+            //Bitmap spaceimg = FromString("0000000000000000");
+
+            //Bitmap[] bmaps = new Bitmap[] {
+            //    aimg, bimg, cimg, dimg, eimg, fimg,
+            //    gimg, himg, iimg, jimg, kimg, limg,
+            //    mimg, nimg, oimg, pimg, qimg, rimg,
+            //    simg, timg, uimg, vimg, wimg, ximg,
+            //    yimg, zimg };
+            //for (char c = 'A'; c < 'Z' + 1; c++) bitmaps[c] = bmaps[c-65];
+            //bitmaps[' '] = spaceimg;
+            //bitmaps['!'] = FromString("0010101010100010");
+            //bitmaps['"'] = FromString("0028282800000000");
+            //bitmaps['#'] = FromString("0028287C287C2828");
+            //bitmaps['$'] = FromString("0038545038145438");
+            //bitmaps['%'] = FromString("0060640810204C0C");
+            //bitmaps['&'] = FromString("0020505020544834");
+            //bitmaps['\''] = FromString("0008081000000000");
+            //bitmaps['('] = FromString("0008102020201008");
+            //bitmaps[')'] = FromString("0020100808081020");
+            //bitmaps['*'] = FromString("000028107C102800");
+            //bitmaps['+'] = FromString("000010107C101000");
+            //bitmaps[','] = FromString("0000000000301020");
+            //bitmaps['-'] = FromString("000000007C000000");
+            //bitmaps['.'] = FromString("0000000000003030");
+            //bitmaps['/'] = FromString("0000040810204000");
+
+            //bitmaps['0'] = FromString("0038444444444438");
+            //bitmaps['1'] = FromString("0010301010101038");
+            //bitmaps['2'] = FromString("003844040810207C");
+            //bitmaps['3'] = FromString("0038440418044438");
+            //bitmaps['4'] = FromString("00081828487C0808");
+            //bitmaps['5'] = FromString("007C407804044438");
+            //bitmaps['6'] = FromString("0018204078444438");
+            //bitmaps['7'] = FromString("007C040810202020");
+            //bitmaps['8'] = FromString("0038444438444438");
+            //bitmaps['9'] = FromString("003844443C040830");
+            //bitmaps[':'] = FromString("0000303000303000");
+            //bitmaps[';'] = FromString("0000303000301020");
+            //bitmaps['<'] = FromString("0008102040201008");
+            //bitmaps['='] = FromString("0000007C007C0000");
+            //bitmaps['>'] = FromString("0020100804081020");
+            //bitmaps['?'] = FromString("0038440408100010");
+            //bitmaps['@'] = FromString("0038445C545C4038");
+
+            //bitmaps['['] = FromString("0038202020202038");
+            //bitmaps['\\'] = FromString("0000402010080400");
+            //bitmaps[']'] = FromString("0038080808080838");
+            //bitmaps['^'] = FromString("0000102844000000");
+            //bitmaps['_'] = FromString("000000000000007C");
+            //bitmaps[(char)96] = spaceimg;
+            
+            ////lowercase chars
+            //bitmaps['a'] = FromString("00000038447C4444");
+            //bitmaps['b'] = FromString("0000007824382478");
+            //bitmaps['c'] = FromString("0000003C4040403C");
+            //bitmaps['d'] = FromString("0000007824242478");
+            //bitmaps['e'] = FromString("0000007C4078407C");
+            //bitmaps['f'] = FromString("0000007C40784040");
+            //bitmaps['g'] = FromString("0000003C405C4438");
+            //bitmaps['h'] = FromString("00000044447C4444");
+            //bitmaps['i'] = FromString("0000003810101038");
+            //bitmaps['j'] = FromString("0000000808084830");
+            //bitmaps['k'] = FromString("0000002428302824");
+            //bitmaps['l'] = FromString("000000404040407C");
+            //bitmaps['m'] = FromString("000000446C544444");
+            //bitmaps['n'] = FromString("0000004464544C44");
+            //bitmaps['o'] = FromString("0000007C4444447C");
+            //bitmaps['p'] = FromString("0000007844784040");
+            //bitmaps['q'] = FromString("0000003844544834");
+            //bitmaps['r'] = FromString("0000007844784844");
+            //bitmaps['s'] = FromString("0000003C40380478");
+            //bitmaps['t'] = FromString("0000007C10101010");
+            //bitmaps['u'] = FromString("0000004444444438");
+            //bitmaps['v'] = FromString("0000004444282810");
+            //bitmaps['w'] = FromString("0000004444545428");
+            //bitmaps['x'] = FromString("0000004428102844");
+            //bitmaps['y'] = FromString("0000004428101010");
+            //bitmaps['z'] = FromString("0000007C0810207C");
+
+            //bitmaps['{'] = FromString("0018202040202018");
+            //bitmaps['|'] = FromString("0010101000101010");
+            //bitmaps['}'] = FromString("0030080804080830");
+            //bitmaps['~'] = FromString("0000205408000000");
+            //bitmaps[(char)127] = spaceimg;
+
+            screen1.Print("Hello, World!");
+            screen1.Print("I'm a TI Basic Look alike");
+
+            screen1.Char((char)128, "1898FF3D3C3CE404");
+            screen1.Char((char)129, "1819FFBC3C3C2720");
+            timer.Interval = 500;
+            screen1.Color(13, TIColor.DarkRed, TIColor.White);
+            timer.Tick += timer_Tick;
+            timer.Start();
+
+            screen1.BackColor = TIColor.DarkGreen;
+        }
+
+        bool image1 = false;
+        void timer_Tick(object sender, EventArgs e)
+        {
+            if (image1) screen1.VChar(12, 16, (char)128);
+            else screen1.VChar(12, 16, (char)129);
+            image1 = !image1;
+
+
+        }
+        Timer timer = new Timer();
+        int clickNum;
+        private void button1_Click_1(object sender, EventArgs e)
+        {
+            /*
+            using (Graphics g = CreateGraphics())
+            {
+                g.Clear(this.BackColor);
+            }*/
+            
+            switch (clickNum)
+            {
+                case 0:
+                    screen1.Print(" !\"#$%&'()*+,-./");
+                    break;
+                case 1:
+                    screen1.Print("0123456789:;<=>?@");
+                    break;
+                case 2:
+                    screen1.Print("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+                    break;
+                case 3:
+                    screen1.Print("[\\]^_" + (char)96);
+                    break;
+                case 4:
+                    screen1.Print("abcdefghijklmnopqrstuvwxyz");
+                    break;
+                case 5:
+                    screen1.Print("{|}~" + (char)127);
+                    break;
+            }
+            clickNum++;
+        }
+
+
+    }
+}
\ No newline at end of file
diff --git a/WindowsApplication1/Form1.resx b/WindowsApplication1/Form1.resx
new file mode 100644 (file)
index 0000000..ff31a6d
--- /dev/null
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+</root>
\ No newline at end of file
index 9cd959f..566af3b 100644 (file)
@@ -14,7 +14,7 @@ namespace WindowsApplication1
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
-            Application.Run(new Screen());
+            Application.Run(new Form1());
 
         }
     }
index c415d50..934185a 100644 (file)
@@ -66,12 +66,5 @@ namespace WindowsApplication1.Properties {
                 return ((System.Drawing.Bitmap)(obj));
             }
         }
-        
-        internal static System.Drawing.Bitmap B {
-            get {
-                object obj = ResourceManager.GetObject("B", resourceCulture);
-                return ((System.Drawing.Bitmap)(obj));
-            }
-        }
     }
 }
index 6249ece..9f5e316 100644 (file)
   <data name="A" type="System.Resources.ResXFileRef, System.Windows.Forms">\r
     <value>..\Resources\A.PNG;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>\r
   </data>\r
-  <data name="B" type="System.Resources.ResXFileRef, System.Windows.Forms">\r
-    <value>..\Resources\B.PNG;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>\r
-  </data>\r
 </root>
\ No newline at end of file
index 78ba42b..6efbcbe 100644 (file)
 using System;
 using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
 using System.Text;
 using System.Windows.Forms;
-using System.Collections;
-using System.Globalization;
+using System.Drawing;
 using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
 
 namespace WindowsApplication1
 {
-    public partial class Screen : Form
+    class Screen : Control
     {
-        public delegate void PrintCallback(string message);
+        private const int xScaleFactor = 2;
+        private const int yScaleFactor = 2;
+        private const int numCols = 32;
+        private const int numRows = 24;
+        private const int firstPrintCol = 2;
+
+        // circular buffer.
+        private CharacterBitmap characters;
+        private Bitmap[][] cells;
+        private int bottomRow;
 
         public Screen()
         {
-            InitializeComponent();
+            characters = new CharacterBitmap();
+            Height = 24 * 8 * yScaleFactor; // 24 rows * 8 pixels/row * scaling factor of 2
+            Width = 32 * 8 * xScaleFactor;  // 32 cols * 8 pixels/col * scaling factor of 2
+            SetStyle(ControlStyles.UserPaint |
+                  ControlStyles.OptimizedDoubleBuffer |
+                  ControlStyles.AllPaintingInWmPaint, true);
+            BackColor = TIColor.Cyan;
+
+            // cells is an array of 24 rows.
+            // each element is an array of bitmaps.
+            cells = new Bitmap[numRows][];
+
+            for (int row = 0; row < numRows; row++)
+            {
+                cells[row] = new Bitmap[numCols];
+                for (int col = 0; col < numCols; col++)
+                {
+                    cells[row][col] = characters.Space;
+                }
+            }
+
+        }
+
+        public void Color(int characterSet, TIColor foreColor, TIColor backColor)
+        {
+
+            characters.Color(characterSet, foreColor, backColor);
+            Invalidate();
         }
 
-        private void button1_Click(object sender, EventArgs e)
+        protected override void OnBackColorChanged(EventArgs e)
         {
-            //Bitmap bmp = new Bitmap(8, 8);
-            
-            //bmp.SetPixel(1, 1, Color.Red);
-            //bmp.SetPixel(2, 2, Color.Red);
-            //bmp.SetPixel(3, 3, Color.Red);
-            //bmp.SetPixel(4, 4, Color.Red);
-
-            
-            
-            //Graphics g = CreateGraphics();
-            //g.DrawImage(bmp, 50, 100);
-            
-            //if (i == 0)
-            //{
-            //    g.DrawLine(new Pen(Color.Red), new Point(0, 0), new Point(100, 100));
-            //}
-            //else
-            //{
-            //    g.DrawLine(new Pen(Color.Black), new Point(0, 0), new Point(200, 200));
-            //}
-            //i++;
-
-
-            //g.DrawImage(dimg, new Point(82, 200));
-
-
-            //PutChar(aimg, 1, 1);
-            //PutChar(bimg, 1, 2);
-            //PutChar(cimg, 1, 3);
-            //PutChar(dimg, 1, 4);
-            //PutChar(eimg, 1, 5);
-            //PutChar(fimg, 1, 6);
-            //PutChar(gimg, 1, 7);
-            //PutChar(himg, 1, 8);
-            //PutChar(iimg, 1, 9);
-            //PutChar(jimg, 1, 10);
-            //PutChar(kimg, 1, 11);
-            //PutChar(limg, 1, 12);
-            //PutChar(mimg, 1, 13);
-            //PutChar(nimg, 1, 14);
-            //PutChar(oimg, 1, 15);
-            //PutChar(pimg, 1, 16);
-            //PutChar(qimg, 1, 17);
-            //PutChar(rimg, 1, 18);
-            //PutChar(simg, 1, 19);
-            //PutChar(timg, 1, 20);
-            //PutChar(uimg, 1, 21);
-            //PutChar(vimg, 1, 22);
-            //PutChar(wimg, 1, 23);
-            //PutChar(ximg, 1, 24);
-            //PutChar(yimg, 1, 25);
-            //PutChar(zimg, 1, 26);
-
-            //Bitmap aaimg = new Bitmap(@"C:\Documents and Settings\Michael Welch\Desktop\ti chars\A.PNG");
-            //Bitmap bbimg = new Bitmap(@"C:\Documents and Settings\Michael Welch\Desktop\ti chars\B.PNG");
-            //aaimg.MakeTransparent();
-            //bbimg.MakeTransparent();
-            //PutChar(aaimg, 2, 1);
-            //PutChar(bbimg, 2, 2);
+            base.OnBackColorChanged(e);
+            Invalidate();
         }
 
-        private void PutChar(char c, int row, int col)
+        protected override void OnForeColorChanged(EventArgs e)
         {
-            PutChar(bitmaps[c], row, col);
+            base.OnForeColorChanged(e);
+            Invalidate();
         }
-        private void PutChar(Image img, int row, int col)
+
+        protected override void OnPaint(PaintEventArgs pe)
         {
-            using (Graphics g = CreateGraphics())
-            {
-                g.SmoothingMode = SmoothingMode.None;
-                g.ScaleTransform(2f, 2f);
+            base.OnPaint(pe);
+            Rectangle badArea = pe.ClipRectangle;
+            Graphics g = pe.Graphics;
+
+            g.Clear(BackColor);
+            g.ScaleTransform(xScaleFactor, yScaleFactor);
+            g.InterpolationMode = InterpolationMode.NearestNeighbor;
+            g.SmoothingMode = SmoothingMode.None;
 
-                g.DrawImage(img, new Point((col - 1) * 8, (row - 1) * 8));
+            for (int row = 0; row < numRows; row++)
+            {
+                int displayRow = CalculateDisplayRow(row);
+                for (int col = 0; col < numCols; col++)
+                {
+                    Bitmap bm = cells[row][col];
+                    if (bm == null) continue;
+                    g.DrawImage(bm, CalculateDisplayPosition(displayRow, col));
+                }
             }
         }
 
-        public void Print(string msg)
+        private static Point CalculateDisplayPosition(int row, int col)
         {
-            for (int i = 0; i < msg.Length; i++ )
+            return new Point(col * 8, row * 8);
+        }
+
+        private int CalculateDisplayRow(int cellRow)
+        {
+            return (numRows + cellRow - bottomRow - 1) % numRows;
+        }
+
+        public void Print(string value)
+        {
+            ShiftRowsUp();
+            for (int i = 0; i < value.Length; i++)
             {
-                char c = msg[i];
-                int col = i + 3;
-                PutChar(c, 24, col);
+                char ch = value[i];
+                cells[bottomRow][i+firstPrintCol] = characters[ch];
             }
+            Invalidate();
         }
 
-        private static Bitmap FromString(string hexCode)
+        public void HChar(int rowNum, int colNum, char ch)
         {
-            Bitmap m = new Bitmap(8, 8);
-            m.MakeTransparent();
-
-            string padding = new string('0', 16 - hexCode.Length);
-            hexCode = hexCode + padding;
+            HChar(rowNum, colNum, ch, 1);
+        }
 
-            for (int j = 0; j < 8; j++)
+        /// <summary>
+        /// 0 indexed
+        /// </summary>
+        /// <param name="rowNum"></param>
+        /// <param name="colNum"></param>
+        /// <param name="ch"></param>
+        /// <param name="repeat"></param>
+        public void HChar(int rowNum, int colNum, char ch, int repeat)
+        {
+            for (int i = 0; i < repeat; i++)
             {
-                String hexNumber = hexCode.Substring(j * 2, 2);
-                byte b = Byte.Parse(hexNumber, NumberStyles.AllowHexSpecifier | NumberStyles.HexNumber);
-                BitArray ba = new BitArray(new byte[] { b });
-                for (int i = 0; i < 8; i++)
+                colNum += i;
+                if (colNum > numCols)
                 {
-                    if (ba[7-i]) m.SetPixel(i, j, Color.Black);
+                    colNum = 0;
+                    rowNum = (rowNum + 1) % numRows;
                 }
+                cells[rowNum][colNum] = characters[ch];
             }
-            return m;
+            Invalidate();
         }
 
-        private Dictionary<char, Bitmap> bitmaps = new Dictionary<char, Bitmap>();
-
-        private void Form1_Load(object sender, EventArgs e)
+        public void VChar(int rowNum, int colNum, char ch)
         {
-            this.Width = 256 * 2;
-            this.Height = 30 * 8 * 2;
-            Bitmap aimg = FromString("003844447C444444");
-            Bitmap bimg = FromString("0078242438242478");
-            Bitmap cimg = FromString("0038444040404438");
-            Bitmap dimg = FromString("0078242424242478");
-            Bitmap eimg = FromString("007C40407840407C");
-            Bitmap fimg = FromString("007C404078404040");
-            Bitmap gimg = FromString("003C40405C444438");
-            Bitmap himg = FromString("004444447C444444");
-            Bitmap iimg = FromString("0038101010101038");
-            Bitmap jimg = FromString("0004040404044438");
-            Bitmap kimg = FromString("0044485060504844");
-            Bitmap limg = FromString("004040404040407C");
-            Bitmap mimg = FromString("00446C5454444444");
-            Bitmap nimg = FromString("00446464544C4C44");
-            Bitmap oimg = FromString("007C44444444447C");
-            Bitmap pimg = FromString("0078444478404040");
-            Bitmap qimg = FromString("0038444444544834");
-            Bitmap rimg = FromString("0078444478504844");
-            Bitmap simg = FromString("0038444038044438");
-            Bitmap timg = FromString("007C101010101010");
-            Bitmap uimg = FromString("0044444444444438");
-            Bitmap vimg = FromString("0044444428281010");
-            Bitmap wimg = FromString("0044444454545428");
-            Bitmap ximg = FromString("0044442810284444");
-            Bitmap yimg = FromString("0044442810101010");
-            Bitmap zimg = FromString("007C04081020407C");
-            Bitmap spaceimg = FromString("0000000000000000");
-
-            Bitmap[] bmaps = new Bitmap[] {
-                aimg, bimg, cimg, dimg, eimg, fimg,
-                gimg, himg, iimg, jimg, kimg, limg,
-                mimg, nimg, oimg, pimg, qimg, rimg,
-                simg, timg, uimg, vimg, wimg, ximg,
-                wimg, zimg };
-            for (char c = 'A'; c < 'Z' + 1; c++) bitmaps[c] = bmaps[c-65];
-            bitmaps[' '] = spaceimg;
-            
-
+            VChar(rowNum, colNum, ch, 1);
         }
 
-        private void button1_Click_1(object sender, EventArgs e)
+        public void VChar(int rowNum, int colNum, char ch, int repeat)
         {
-            
-            Print("HELLO THERE");
+            for (int i = 0; i < repeat; i++)
+            {
+                rowNum += i;
+                if (rowNum > numRows)
+                {
+                    rowNum = 0;
+                    colNum = (colNum + 1) % numCols;
+                }
+                cells[rowNum][colNum] = characters[ch];
+            }
+            Invalidate();
         }
 
+        public void Char(char ch, string hexCodes)
+        {
+            characters.ModifyBitmap(ch, hexCodes);
+        }
 
+        private void ShiftRowsUp()
+        {
+            bottomRow = (bottomRow+1) % 24;
+            for (int col = 0; col < numCols; col++)
+            {
+                cells[bottomRow][col] = characters.Space;
+            }
+        }
     }
-}
\ No newline at end of file
+}
diff --git a/WindowsApplication1/TIColor.cs b/WindowsApplication1/TIColor.cs
new file mode 100644 (file)
index 0000000..863fee6
--- /dev/null
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+
+namespace WindowsApplication1
+{
+    class TIColor
+    {
+        public readonly Color Color;
+        public readonly int TIColorCode;
+        private TIColor(Color color, int tiColorCode)
+        {
+            Color = color;
+            TIColorCode = tiColorCode;
+        }
+
+        public static implicit operator Color(TIColor tiColor)
+        {
+            return tiColor.Color;
+        }
+
+        public static readonly TIColor Transparent = new TIColor(Color.Transparent, 1);
+        public static readonly TIColor Black = new TIColor(Color.FromArgb(0, 0, 0), 2);
+        public static readonly TIColor MediumGreen = new TIColor(Color.FromArgb(72, 156, 8), 3);
+        public static readonly TIColor LightGreen = new TIColor(Color.FromArgb(112, 191, 136), 4);
+        public static readonly TIColor DarkBlue = new TIColor(Color.FromArgb(40, 60, 138), 5);
+        public static readonly TIColor LightBlue = new TIColor(Color.FromArgb(80, 108, 207), 6);
+        public static readonly TIColor DarkRed = new TIColor(Color.FromArgb(208, 72, 0), 7);
+        public static readonly TIColor Cyan = new TIColor(Color.FromArgb(0, 204, 255), 8);
+        public static readonly TIColor MediumRed = new TIColor(Color.FromArgb(208, 88, 40), 9);
+        public static readonly TIColor LightRed = new TIColor(Color.FromArgb(255, 160, 64), 10);
+        public static readonly TIColor DarkYellow = new TIColor(Color.FromArgb(252, 240, 80), 11);
+        public static readonly TIColor LightYellow = new TIColor(Color.FromArgb(255, 255, 128), 12);
+        public static readonly TIColor DarkGreen = new TIColor(Color.FromArgb(0, 128, 0), 13);
+        public static readonly TIColor Magenta = new TIColor(Color.FromArgb(205, 88, 205), 14);
+        public static readonly TIColor Gray = new TIColor(Color.FromArgb(224, 224, 224), 15);
+        public static readonly TIColor White = new TIColor(Color.FromArgb(255, 255, 255), 16);
+
+    }
+}
index 2230a44..9090eb9 100644 (file)
     <Reference Include="System.Xml" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <Compile Include="Screen.cs">\r
+    <Compile Include="CharacterBitmap.cs" />\r
+    <Compile Include="Form1.cs">\r
       <SubType>Form</SubType>\r
     </Compile>\r
-    <Compile Include="Screen.Designer.cs">\r
-      <DependentUpon>Screen.cs</DependentUpon>\r
+    <Compile Include="Form1.Designer.cs">\r
+      <DependentUpon>Form1.cs</DependentUpon>\r
     </Compile>\r
     <Compile Include="Program.cs" />\r
     <Compile Include="Properties\AssemblyInfo.cs" />\r
-    <EmbeddedResource Include="Screen.resx">\r
+    <EmbeddedResource Include="Form1.resx">\r
       <SubType>Designer</SubType>\r
-      <DependentUpon>Screen.cs</DependentUpon>\r
+      <DependentUpon>Form1.cs</DependentUpon>\r
     </EmbeddedResource>\r
     <EmbeddedResource Include="Properties\Resources.resx">\r
       <Generator>ResXFileCodeGenerator</Generator>\r
       <DependentUpon>Settings.settings</DependentUpon>\r
       <DesignTimeSharedInput>True</DesignTimeSharedInput>\r
     </Compile>\r
+    <Compile Include="Screen.cs">\r
+      <SubType>Component</SubType>\r
+    </Compile>\r
+    <Compile Include="TIColor.cs" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ProjectReference Include="..\..\vs0206dt\GaugeControlSolutionCSharp\WindowsControls\WindowsControls.csproj">\r