diff options
-rw-r--r-- | neschr.sln | 22 | ||||
-rw-r--r-- | neschr/App.config | 6 | ||||
-rw-r--r-- | neschr/EditControl.Designer.cs | 36 | ||||
-rw-r--r-- | neschr/EditControl.cs | 873 | ||||
-rw-r--r-- | neschr/IIndexedPalette.cs | 17 | ||||
-rw-r--r-- | neschr/IndexedPalette.cs | 73 | ||||
-rw-r--r-- | neschr/MainForm.Designer.cs | 499 | ||||
-rw-r--r-- | neschr/MainForm.cs | 465 | ||||
-rw-r--r-- | neschr/MainForm.resx | 123 | ||||
-rw-r--r-- | neschr/NesPalette.Designer.cs | 59 | ||||
-rw-r--r-- | neschr/NesPalette.cs | 136 | ||||
-rw-r--r-- | neschr/NesPalette.resx | 120 | ||||
-rw-r--r-- | neschr/NesTileset.cs | 308 | ||||
-rw-r--r-- | neschr/PaletteControl.Designer.cs | 36 | ||||
-rw-r--r-- | neschr/PaletteControl.cs | 141 | ||||
-rw-r--r-- | neschr/Program.cs | 22 | ||||
-rw-r--r-- | neschr/Properties/AssemblyInfo.cs | 36 | ||||
-rw-r--r-- | neschr/Properties/Resources.Designer.cs | 71 | ||||
-rw-r--r-- | neschr/Properties/Resources.resx | 117 | ||||
-rw-r--r-- | neschr/Properties/Settings.Designer.cs | 30 | ||||
-rw-r--r-- | neschr/Properties/Settings.settings | 7 | ||||
-rw-r--r-- | neschr/neschr.csproj | 114 |
22 files changed, 3311 insertions, 0 deletions
diff --git a/neschr.sln b/neschr.sln new file mode 100644 index 0000000..f908868 --- /dev/null +++ b/neschr.sln @@ -0,0 +1,22 @@ +
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25123.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "neschr", "neschr\neschr.csproj", "{22E17FEA-C5B4-4544-940D-693AD98C8324}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {22E17FEA-C5B4-4544-940D-693AD98C8324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {22E17FEA-C5B4-4544-940D-693AD98C8324}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {22E17FEA-C5B4-4544-940D-693AD98C8324}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {22E17FEA-C5B4-4544-940D-693AD98C8324}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/neschr/App.config b/neschr/App.config new file mode 100644 index 0000000..d740e88 --- /dev/null +++ b/neschr/App.config @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
+ </startup>
+</configuration>
\ No newline at end of file diff --git a/neschr/EditControl.Designer.cs b/neschr/EditControl.Designer.cs new file mode 100644 index 0000000..d6b1ad1 --- /dev/null +++ b/neschr/EditControl.Designer.cs @@ -0,0 +1,36 @@ +namespace UCTest
+{
+ partial class EditControl
+ {
+ /// <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 Component 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()
+ {
+ components = new System.ComponentModel.Container();
+ }
+
+ #endregion
+ }
+}
diff --git a/neschr/EditControl.cs b/neschr/EditControl.cs new file mode 100644 index 0000000..566ac46 --- /dev/null +++ b/neschr/EditControl.cs @@ -0,0 +1,873 @@ +using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace UCTest
+{
+ public partial class EditControl : Control
+ {
+ public enum Mode
+ {
+ Plot,
+ Line,
+ Fill,
+ Rect,
+ FilledRect
+ }
+
+ private bool initialised = false;
+
+ private Control preview;
+
+ private int count;
+
+ private int[] width;
+ private int[] height;
+
+ private int grid_width;
+ private int grid_height;
+
+ private int[] cell_width;
+ private int[] cell_height;
+ private int[] adjust_size;
+
+ private Bitmap[] backing;
+ private Graphics[] g;
+ private Graphics[] cg;
+
+ private IIndexedPalette pal;
+ private Brush[] brush;
+
+ private int[,] grid;
+
+ private int[,] saved;
+
+ private Stack<int[,]> undo;
+ private Stack<int[,]> redo;
+
+ private bool drawStarted;
+ private int drawX;
+ private int drawY;
+ private bool drawFg;
+ private MouseButtons drawButton;
+
+ private int Bound(int i, int max)
+ {
+ while(i < 0)
+ {
+ i += max;
+ }
+
+ return i % max;
+ }
+
+ private void SaveUndo()
+ {
+ undo.Push((int[,])grid.Clone());
+ redo.Clear();
+ OnContentChanged(new EventArgs());
+ }
+
+ private void SaveCurrent()
+ {
+ saved = (int[,])grid.Clone();
+ }
+
+ private void RestoreCurrent()
+ {
+ grid = (int[,])saved.Clone();
+ }
+
+ private void CreateBacking()
+ {
+ count = 1;
+
+ if (preview != null)
+ {
+ count = 2;
+ }
+
+ width = new int[count];
+ height = new int[count];
+ cell_width = new int[count];
+ cell_height = new int[count];
+ adjust_size = new int[count];
+ backing = new Bitmap[count];
+ g = new Graphics[count];
+ cg = new Graphics[count];
+
+ width[0] = Parent.Size.Width;
+ height[0] = Parent.Size.Height;
+
+ backing[0] = new Bitmap(width[0], height[0]);
+ g[0] = Graphics.FromImage(backing[0]);
+ cg[0] = CreateGraphics();
+
+ if (preview != null)
+ {
+ width[1] = preview.Width;
+ height[1] = preview.Height;
+
+ backing[1] = new Bitmap(width[1], height[1]);
+ g[1] = Graphics.FromImage(backing[1]);
+ cg[1] = preview.CreateGraphics();
+ }
+
+ DrawGrid();
+ }
+
+
+ private void DrawGrid()
+ {
+ int x;
+ int y;
+
+ for(int f = 0; f < count; f++)
+ {
+ g[f].Clear(Color.Black);
+
+ cell_width[f] = width[f] / grid_width;
+ cell_height[f] = height[f] / grid_height;
+ adjust_size[f] = 1 - f;
+ }
+
+ cell_width[0] = width[0] / grid_width;
+ cell_height[0] = height[0] / grid_height;
+
+ for(x = 0; x < width[0]; x += cell_width[0])
+ {
+ if (x == width[0]/2)
+ {
+ g[0].DrawLine(Pens.White, x, 0, x, height[0]);
+ }
+ else
+ {
+ g[0].DrawLine(Pens.Gray, x, 0, x, height[0]);
+ }
+ }
+
+ for(y = 0; y < height[0]; y += cell_height[0])
+ {
+ if (y == height[0]/2)
+ {
+ g[0].DrawLine(Pens.White, 0, y, width[0], y);
+ }
+ else
+ {
+ g[0].DrawLine(Pens.Gray, 0, y, width[0], y);
+ }
+ }
+ }
+
+
+ private void RedrawWithoutInvalidate()
+ {
+ for(int x = 0; x < grid_width; x++)
+ {
+ for(int y = 0; y < grid_height; y++)
+ {
+ for(int f = 0; f < count; f++)
+ {
+ Rectangle r = new Rectangle(x * cell_width[f] + adjust_size[f],
+ y * cell_height[f] + adjust_size[f],
+ cell_width[f] - adjust_size[f],
+ cell_height[f] - adjust_size[f]);
+
+ g[f].FillRectangle(brush[grid[x,y]], r);
+ cg[f].DrawImage(backing[f], r, r, GraphicsUnit.Pixel);
+ }
+ }
+ }
+ }
+
+
+ private void RedrawPoint(int i, int x, int y)
+ {
+ if (x > -1 && x < grid_width && y > -1 && y < grid_height)
+ {
+ for(int f = 0; f < count; f++)
+ {
+ g[f].FillRectangle(brush[i],
+ x * cell_width[f] + adjust_size[f],
+ y * cell_height[f] + adjust_size[f],
+ cell_width[f] - adjust_size[f],
+ cell_height[f] - adjust_size[f]);
+
+ grid[x,y] = i;
+ }
+ }
+ }
+
+
+ private void Redraw()
+ {
+ if (grid != null)
+ {
+ for(int x = 0; x < grid_width; x++)
+ {
+ for(int y = 0; y < grid_height; y++)
+ {
+ RedrawPoint(grid[x,y], x, y);
+ }
+ }
+
+ Invalidate();
+
+ if (preview != null)
+ {
+ preview.Invalidate();
+ }
+ }
+ }
+
+
+ private void DrawLine(int x1, int y1,
+ int x2, int y2,
+ int col)
+ {
+ int dx = x2 - x1;
+ int dy = y2 - y1;
+
+ int ix = Math.Sign(dx);
+ int iy = Math.Sign(dy);
+
+ dx = Math.Abs(dx);
+ dy = Math.Abs(dy);
+
+ int incrE;
+ int incrNE;
+ int d;
+ bool ymode;
+
+ if (dy>dx)
+ {
+ ymode = true;
+ d = dx*2-dy;
+ incrE = dx*2;
+ incrNE = (dx-dy)*2;
+ }
+ else
+ {
+ ymode = false;
+ d = dy*2-dx;
+ incrE = dy*2;
+ incrNE = (dy-dx)*2;
+ }
+
+ int x = x1;
+ int y = y1;
+
+ grid[x,y] = col;
+
+ if (ymode)
+ {
+ while(y!=y2)
+ {
+ if (d<=0)
+ {
+ d+=incrE;
+ y+=iy;
+ }
+ else
+ {
+ d+=incrNE;
+ y+=iy;
+ x+=ix;
+ }
+
+ grid[x,y] = col;
+ }
+ }
+ else
+ {
+ while(x!=x2)
+ {
+ if (d<=0)
+ {
+ d+=incrE;
+ x+=ix;
+ }
+ else
+ {
+ d+=incrNE;
+ y+=iy;
+ x+=ix;
+ }
+
+ grid[x,y] = col;
+ }
+ }
+ }
+
+ private void Plot(int i, int x, int y)
+ {
+ if (x > -1 && x < grid_width && y > -1 && y < grid_height && grid[x,y] != i)
+ {
+ SaveUndo();
+
+ for(int f = 0; f < count; f++)
+ {
+ Rectangle r = new Rectangle(x * cell_width[f] + adjust_size[f],
+ y * cell_height[f] + adjust_size[f],
+ cell_width[f] - adjust_size[f],
+ cell_height[f] - adjust_size[f]);
+
+ g[f].FillRectangle(brush[i], r);
+ cg[f].DrawImage(backing[f], r, r, GraphicsUnit.Pixel);
+ }
+
+ grid[x,y] = i;
+ }
+ }
+
+
+ private void FloodFill(int cover, int i, int x, int y)
+ {
+ if (x > -1 && x < grid_width && y > -1 && y < grid_height && grid[x,y] != i && grid[x,y] == cover)
+ {
+ grid[x,y] = i;
+ FloodFill(cover, i, x-1, y);
+ FloodFill(cover, i, x+1, y);
+ FloodFill(cover, i, x, y-1);
+ FloodFill(cover, i, x, y+1);
+ }
+ }
+
+
+ private void Fill(int i, int x, int y)
+ {
+ if (x > -1 && x < grid_width && y > -1 && y < grid_height && grid[x,y] != i)
+ {
+ int cover = grid[x,y];
+
+ SaveUndo();
+ FloodFill(cover, i, x, y);
+ Redraw();
+ }
+ }
+
+
+ private void OnPaletteUpdate(object sender, EventArgs e)
+ {
+ if (brush != null)
+ {
+ foreach (Brush b in brush.Where(b => b != null))
+ {
+ b.Dispose();
+ }
+ }
+
+ brush = new Brush[pal.PaletteSize];
+
+ for(int f = 0; f < pal.PaletteSize; f++)
+ {
+ brush[f] = new SolidBrush(pal.Palette[f]);
+ }
+
+ if (g != null)
+ {
+ DrawGrid();
+ Redraw();
+ }
+ }
+
+ private void OnPreviewPaint(object sender, PaintEventArgs pe)
+ {
+ if (!initialised)
+ {
+ initialised = true;
+ CreateBacking();
+ }
+
+ pe.Graphics.DrawImageUnscaled(backing[1], 0, 0);
+ }
+
+
+ protected override void OnPaint(PaintEventArgs pe)
+ {
+ if (!initialised)
+ {
+ initialised = true;
+ CreateBacking();
+ }
+
+ pe.Graphics.DrawImageUnscaled(backing[0], 0, 0);
+ }
+
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ int gx;
+ int gy;
+
+ gx = e.X / cell_width[0];
+ gy = e.Y / cell_height[0];
+
+ switch(DrawingMode)
+ {
+ case Mode.Plot:
+ if (e.Button != MouseButtons.None)
+ {
+ Plot(e.Button == MouseButtons.Left ? Foreground : Background,
+ e.X / cell_width[0], e.Y / cell_height[0]);
+ }
+ break;
+
+ case Mode.Fill:
+ break;
+
+ case Mode.Line:
+ if (e.Button == drawButton && drawStarted)
+ {
+ if (gx > -1 && gx < grid_width && gy > -1 && gy < grid_height)
+ {
+ int minX;
+ int maxX;
+ int minY;
+ int maxY;
+ int col;
+
+ RestoreCurrent();
+
+ minX = Math.Min(gx, drawX);
+ maxX = Math.Max(gx, drawX);
+ minY = Math.Min(gy, drawY);
+ maxY = Math.Max(gy, drawY);
+ col = drawFg ? Foreground : Background;
+
+ DrawLine(drawX, drawY, gx, gy, col);
+
+ RedrawWithoutInvalidate();
+ }
+ }
+ else
+ {
+ drawStarted = false;
+ }
+ break;
+
+ case Mode.Rect:
+ if (e.Button == drawButton && drawStarted)
+ {
+ if (gx > -1 && gx < grid_width && gy > -1 && gy < grid_height)
+ {
+ int minX;
+ int maxX;
+ int minY;
+ int maxY;
+ int col;
+
+ RestoreCurrent();
+
+ minX = Math.Min(gx, drawX);
+ maxX = Math.Max(gx, drawX);
+ minY = Math.Min(gy, drawY);
+ maxY = Math.Max(gy, drawY);
+ col = drawFg ? Foreground : Background;
+
+ for(int x = minX; x <= maxX; x++)
+ {
+ grid[x,gy] = col;
+ grid[x,drawY] = col;
+ }
+
+ for(int y = minY; y <= maxY; y++)
+ {
+ grid[gx,y] = col;
+ grid[drawX,y] = col;
+ }
+
+ RedrawWithoutInvalidate();
+ }
+ }
+ else
+ {
+ drawStarted = false;
+ }
+ break;
+
+ case Mode.FilledRect:
+ if (e.Button == drawButton && drawStarted)
+ {
+ if (gx > -1 && gx < grid_width && gy > -1 && gy < grid_height)
+ {
+ int minX;
+ int maxX;
+ int minY;
+ int maxY;
+ int col;
+
+ RestoreCurrent();
+
+ minX = Math.Min(gx, drawX);
+ maxX = Math.Max(gx, drawX);
+ minY = Math.Min(gy, drawY);
+ maxY = Math.Max(gy, drawY);
+ col = drawFg ? Foreground : Background;
+
+ for(int x = minX; x <= maxX; x++)
+ {
+ for(int y = minY; y <= maxY; y++)
+ {
+ grid[x,y] = col;
+ }
+ }
+
+ RedrawWithoutInvalidate();
+ }
+ }
+ else
+ {
+ drawStarted = false;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ int gx;
+ int gy;
+
+ gx = e.X / cell_width[0];
+ gy = e.Y / cell_height[0];
+
+ switch(DrawingMode)
+ {
+ case Mode.Plot:
+ Plot(e.Button == MouseButtons.Left ? Foreground : Background, gx, gy);
+ break;
+
+ case Mode.Fill:
+ Fill(e.Button == MouseButtons.Left ? Foreground : Background, gx, gy);
+ break;
+
+ case Mode.Line:
+ case Mode.Rect:
+ case Mode.FilledRect:
+ drawX = gx;
+ drawY = gy;
+
+ if (drawX > -1 && drawX < grid_width && drawY > -1 && drawY < grid_height)
+ {
+ SaveUndo();
+ SaveCurrent();
+ drawStarted = true;
+ drawButton = e.Button;
+ drawFg = (e.Button == MouseButtons.Left);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ int gx;
+ int gy;
+
+ gx = e.X / cell_width[0];
+ gy = e.Y / cell_height[0];
+
+ switch(DrawingMode)
+ {
+ case Mode.Plot:
+ Plot(e.Button == MouseButtons.Left ? Foreground : Background, gx, gy);
+ break;
+
+ case Mode.Fill:
+ break;
+
+ case Mode.Line:
+ case Mode.Rect:
+ case Mode.FilledRect:
+ if (drawStarted)
+ {
+ drawStarted = false;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+
+ public void SetGridSize(int w, int h)
+ {
+ int [,] old = grid;
+ int old_gw = grid_width;
+ int old_gh = grid_height;
+
+ grid_width = w;
+ grid_height = h;
+
+ grid = new int[w,h];
+
+ if (old != null)
+ {
+ for(int x = 0; x < Math.Min(old_gw, grid_width); x++)
+ {
+ for(int y = 0; y < Math.Min(old_gh, grid_height); y++)
+ {
+ grid[x,y] = old[x,y];
+ }
+ }
+ }
+
+ if (g != null)
+ {
+ DrawGrid();
+ Redraw();
+ }
+
+ undo.Clear();
+ OnContentChanged(new EventArgs());
+ }
+
+
+ public void SetPalette(IIndexedPalette p)
+ {
+ if (pal != null)
+ {
+ pal.PaletteChanged -= OnPaletteUpdate;
+ }
+
+ pal = p;
+
+ pal.PaletteChanged += OnPaletteUpdate;
+
+ OnPaletteUpdate(pal, null);
+ }
+
+
+ public int[,] GridData
+ {
+ set
+ {
+ if (value.Rank != 2 || value.GetLength(0) != grid.GetLength(0) || value.GetLength(1) != grid.GetLength(1))
+ {
+ throw new ArgumentException("Array does not match current grid");
+ }
+
+ grid = (int[,])value.Clone();
+ undo.Clear();
+ redo.Clear();
+ Redraw();
+ OnContentChanged(new EventArgs());
+ }
+
+ get
+ {
+ return (int[,])grid.Clone();
+ }
+ }
+
+
+ public int Foreground {get; set;}
+
+
+ public int Background {get; set;}
+
+
+ public Mode DrawingMode {get; set;}
+
+
+ public EventHandler ContentChanged;
+
+ protected void OnContentChanged(EventArgs e)
+ {
+ EventHandler h = ContentChanged;
+
+ if (h != null)
+ {
+ h(this, e);
+ }
+ }
+
+
+ public bool UndoAvailable
+ {
+ get
+ {
+ return undo.Count > 0;
+ }
+ }
+
+
+ public void Undo()
+ {
+ if (undo.Count > 0)
+ {
+ redo.Push((int[,])grid.Clone());
+ grid = undo.Pop();
+ Redraw();
+ OnContentChanged(new EventArgs());
+ }
+ }
+
+
+ public bool RedoAvailable
+ {
+ get
+ {
+ return redo.Count > 0;
+ }
+ }
+
+
+ public void Redo()
+ {
+ if (redo.Count > 0)
+ {
+ undo.Push((int[,])grid.Clone());
+ grid = redo.Pop();
+ Redraw();
+ OnContentChanged(new EventArgs());
+ }
+ }
+
+
+ public void HorizontalFlip()
+ {
+ SaveUndo();
+
+ for(int x = 0; x < grid_width / 2; x++)
+ {
+ for(int y = 0; y < grid_height; y++)
+ {
+ int t = grid[x,y];
+
+ grid[x,y] = grid[grid_width - 1 - x,y];
+ grid[grid_width - 1 - x,y] = t;
+ }
+ }
+
+ Redraw();
+ }
+
+
+ public void VerticalFlip()
+ {
+ SaveUndo();
+
+ for(int x = 0; x < grid_width; x++)
+ {
+ for(int y = 0; y < grid_height / 2; y++)
+ {
+ int t = grid[x,y];
+
+ grid[x,y] = grid[x, grid_height - 1 - y];
+ grid[x, grid_height - 1 - y] = t;
+ }
+ }
+
+ Redraw();
+ }
+
+
+ public void RotateRight()
+ {
+ int[,] cur = (int[,])grid.Clone();
+
+ SaveUndo();
+
+ for(int x = 0; x < grid_width; x++)
+ {
+ for(int y = 0; y < grid_height; y++)
+ {
+ if (y < grid_width && x < grid_height)
+ {
+ grid[grid_width - 1 - x, y] = cur[y, x];
+ }
+ }
+ }
+
+ Redraw();
+ }
+
+
+ public void RotateLeft()
+ {
+ int[,] cur = (int[,])grid.Clone();
+
+ SaveUndo();
+
+ for(int x = 0; x < grid_width; x++)
+ {
+ for(int y = 0; y < grid_height; y++)
+ {
+ if (y < grid_width && x < grid_height)
+ {
+ grid[x, grid_width - 1 - y] = cur[y, x];
+ }
+ }
+ }
+
+ Redraw();
+ }
+
+ public void Shift(int dx, int dy)
+ {
+ int[,] cur = (int[,])grid.Clone();
+
+ SaveUndo();
+
+ for(int x = 0; x < grid_width; x++)
+ {
+ for(int y = 0; y < grid_height; y++)
+ {
+ int nx = x + dx;
+ int ny = y + dy;
+
+ nx = Bound(nx, grid_width);
+ ny = Bound(ny, grid_height);
+
+ grid[nx, ny] = cur[x, y];
+ }
+ }
+
+ Redraw();
+ }
+
+
+ public EditControl(IIndexedPalette palette, Control preview)
+ {
+ Dock = DockStyle.Fill;
+
+ DrawingMode = Mode.Plot;
+ drawStarted = false;
+
+ undo = new Stack<int[,]>();
+ redo = new Stack<int[,]>();
+
+ this.preview = preview;
+
+ if (this.preview != null)
+ {
+ this.preview.Paint += OnPreviewPaint;
+ }
+
+ Foreground = 1;
+ Background = 0;
+
+ InitializeComponent();
+
+ SetPalette(palette);
+ SetGridSize(8, 8);
+ }
+ }
+}
diff --git a/neschr/IIndexedPalette.cs b/neschr/IIndexedPalette.cs new file mode 100644 index 0000000..67b7db1 --- /dev/null +++ b/neschr/IIndexedPalette.cs @@ -0,0 +1,17 @@ +using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UCTest
+{
+ public interface IIndexedPalette
+ {
+ event EventHandler PaletteChanged;
+ int PaletteSize {get;}
+ Color[] Palette {get;}
+ void Set(int index, int r, int g, int b, int a);
+ }
+}
diff --git a/neschr/IndexedPalette.cs b/neschr/IndexedPalette.cs new file mode 100644 index 0000000..7e12d44 --- /dev/null +++ b/neschr/IndexedPalette.cs @@ -0,0 +1,73 @@ +using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UCTest
+{
+ public class IndexedPalette : IIndexedPalette
+ {
+ private Color[] palette;
+
+ public event EventHandler PaletteChanged;
+
+ public int PaletteSize
+ {
+ get
+ {
+ return 4;
+ }
+ }
+
+ public Color[] Palette
+ {
+ get
+ {
+ return palette;
+ }
+ }
+
+ public void Set(int index, int r, int g, int b, int a)
+ {
+ if (index >= 0 && index < PaletteSize)
+ {
+ Color col = Color.FromArgb(a, r, g, b);
+
+ if (palette[index] != col)
+ {
+ palette[index] = col;
+ OnPaletteChanged();
+ }
+ }
+ }
+
+ public void Set(int index, Color color)
+ {
+ if (index >= 0 && index < PaletteSize)
+ {
+ if (palette[index] != color)
+ {
+ palette[index] = color;
+ OnPaletteChanged();
+ }
+ }
+ }
+
+ protected void OnPaletteChanged()
+ {
+ EventHandler e = PaletteChanged;
+
+ if (e != null)
+ {
+ e(this, new EventArgs());
+ }
+ }
+
+ public IndexedPalette()
+ {
+ palette = new Color[PaletteSize];
+ }
+ }
+}
diff --git a/neschr/MainForm.Designer.cs b/neschr/MainForm.Designer.cs new file mode 100644 index 0000000..638ba73 --- /dev/null +++ b/neschr/MainForm.Designer.cs @@ -0,0 +1,499 @@ +namespace UCTest
+{
+ partial class MainForm
+ {
+ /// <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.editPanel = new System.Windows.Forms.Panel();
+ this.check16 = new System.Windows.Forms.CheckBox();
+ this.pal1Panel = new System.Windows.Forms.Panel();
+ this.colourButton = new System.Windows.Forms.Button();
+ this.undoButton = new System.Windows.Forms.Button();
+ this.modeCombo = new System.Windows.Forms.ComboBox();
+ this.previewPanel = new System.Windows.Forms.Panel();
+ this.hflipButton = new System.Windows.Forms.Button();
+ this.vflipButton = new System.Windows.Forms.Button();
+ this.rotccwButton = new System.Windows.Forms.Button();
+ this.rotcwButton = new System.Windows.Forms.Button();
+ this.redoButton = new System.Windows.Forms.Button();
+ this.pal2Panel = new System.Windows.Forms.Panel();
+ this.pal4Panel = new System.Windows.Forms.Panel();
+ this.pal3Panel = new System.Windows.Forms.Panel();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this.tileNumber = new System.Windows.Forms.NumericUpDown();
+ this.revertButton = new System.Windows.Forms.Button();
+ this.shiftRightButton = new System.Windows.Forms.Button();
+ this.shiftDownButton = new System.Windows.Forms.Button();
+ this.shiftLeftButton = new System.Windows.Forms.Button();
+ this.shiftUpButton = new System.Windows.Forms.Button();
+ this.menuStrip1 = new System.Windows.Forms.MenuStrip();
+ this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.paletteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.cHRROMToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.paletteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
+ this.cHRROMToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
+ this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ ((System.ComponentModel.ISupportInitialize)(this.tileNumber)).BeginInit();
+ this.menuStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // editPanel
+ //
+ this.editPanel.Location = new System.Drawing.Point(12, 47);
+ this.editPanel.Name = "editPanel";
+ this.editPanel.Size = new System.Drawing.Size(256, 256);
+ this.editPanel.TabIndex = 0;
+ //
+ // check16
+ //
+ this.check16.AutoSize = true;
+ this.check16.Location = new System.Drawing.Point(12, 313);
+ this.check16.Name = "check16";
+ this.check16.Size = new System.Drawing.Size(61, 17);
+ this.check16.TabIndex = 1;
+ this.check16.Text = "16 x 16";
+ this.check16.UseVisualStyleBackColor = true;
+ this.check16.CheckedChanged += new System.EventHandler(this.OnCheck16);
+ //
+ // pal1Panel
+ //
+ this.pal1Panel.Location = new System.Drawing.Point(311, 47);
+ this.pal1Panel.Name = "pal1Panel";
+ this.pal1Panel.Size = new System.Drawing.Size(77, 24);
+ this.pal1Panel.TabIndex = 2;
+ //
+ // colourButton
+ //
+ this.colourButton.Location = new System.Drawing.Point(519, 47);
+ this.colourButton.Name = "colourButton";
+ this.colourButton.Size = new System.Drawing.Size(83, 24);
+ this.colourButton.TabIndex = 6;
+ this.colourButton.Text = "Select Colour";
+ this.colourButton.UseVisualStyleBackColor = true;
+ this.colourButton.Click += new System.EventHandler(this.OnColourClick);
+ //
+ // undoButton
+ //
+ this.undoButton.Enabled = false;
+ this.undoButton.Location = new System.Drawing.Point(279, 178);
+ this.undoButton.Name = "undoButton";
+ this.undoButton.Size = new System.Drawing.Size(75, 23);
+ this.undoButton.TabIndex = 8;
+ this.undoButton.Text = "Undo";
+ this.undoButton.UseVisualStyleBackColor = true;
+ this.undoButton.Click += new System.EventHandler(this.OnUndo);
+ //
+ // modeCombo
+ //
+ this.modeCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.modeCombo.FormattingEnabled = true;
+ this.modeCombo.Items.AddRange(new object[] {
+ "Plot",
+ "Line",
+ "Fill",
+ "Rectangle",
+ "Filled Rectangle"});
+ this.modeCombo.Location = new System.Drawing.Point(279, 146);
+ this.modeCombo.Name = "modeCombo";
+ this.modeCombo.Size = new System.Drawing.Size(121, 21);
+ this.modeCombo.TabIndex = 9;
+ this.modeCombo.SelectedIndexChanged += new System.EventHandler(this.OnModeCombo);
+ //
+ // previewPanel
+ //
+ this.previewPanel.Location = new System.Drawing.Point(279, 107);
+ this.previewPanel.Name = "previewPanel";
+ this.previewPanel.Size = new System.Drawing.Size(32, 32);
+ this.previewPanel.TabIndex = 7;
+ //
+ // hflipButton
+ //
+ this.hflipButton.Location = new System.Drawing.Point(279, 208);
+ this.hflipButton.Name = "hflipButton";
+ this.hflipButton.Size = new System.Drawing.Size(75, 23);
+ this.hflipButton.TabIndex = 10;
+ this.hflipButton.Text = "Horiz Flip";
+ this.hflipButton.UseVisualStyleBackColor = true;
+ this.hflipButton.Click += new System.EventHandler(this.OnHorizontalFlip);
+ //
+ // vflipButton
+ //
+ this.vflipButton.Location = new System.Drawing.Point(361, 208);
+ this.vflipButton.Name = "vflipButton";
+ this.vflipButton.Size = new System.Drawing.Size(75, 23);
+ this.vflipButton.TabIndex = 11;
+ this.vflipButton.Text = "Vert Flip";
+ this.vflipButton.UseVisualStyleBackColor = true;
+ this.vflipButton.Click += new System.EventHandler(this.OnVerticalFlip);
+ //
+ // rotccwButton
+ //
+ this.rotccwButton.Location = new System.Drawing.Point(361, 237);
+ this.rotccwButton.Name = "rotccwButton";
+ this.rotccwButton.Size = new System.Drawing.Size(75, 23);
+ this.rotccwButton.TabIndex = 13;
+ this.rotccwButton.Text = "Rotate CCW";
+ this.rotccwButton.UseVisualStyleBackColor = true;
+ this.rotccwButton.Click += new System.EventHandler(this.OnRotateLeft);
+ //
+ // rotcwButton
+ //
+ this.rotcwButton.Location = new System.Drawing.Point(279, 237);
+ this.rotcwButton.Name = "rotcwButton";
+ this.rotcwButton.Size = new System.Drawing.Size(75, 23);
+ this.rotcwButton.TabIndex = 12;
+ this.rotcwButton.Text = "Rotate CW";
+ this.rotcwButton.UseVisualStyleBackColor = true;
+ this.rotcwButton.Click += new System.EventHandler(this.OnRotateRight);
+ //
+ // redoButton
+ //
+ this.redoButton.Enabled = false;
+ this.redoButton.Location = new System.Drawing.Point(360, 178);
+ this.redoButton.Name = "redoButton";
+ this.redoButton.Size = new System.Drawing.Size(75, 23);
+ this.redoButton.TabIndex = 14;
+ this.redoButton.Text = "Redo";
+ this.redoButton.UseVisualStyleBackColor = true;
+ this.redoButton.Click += new System.EventHandler(this.OnRedo);
+ //
+ // pal2Panel
+ //
+ this.pal2Panel.Location = new System.Drawing.Point(431, 47);
+ this.pal2Panel.Name = "pal2Panel";
+ this.pal2Panel.Size = new System.Drawing.Size(77, 24);
+ this.pal2Panel.TabIndex = 3;
+ //
+ // pal4Panel
+ //
+ this.pal4Panel.Location = new System.Drawing.Point(431, 77);
+ this.pal4Panel.Name = "pal4Panel";
+ this.pal4Panel.Size = new System.Drawing.Size(77, 24);
+ this.pal4Panel.TabIndex = 5;
+ //
+ // pal3Panel
+ //
+ this.pal3Panel.Location = new System.Drawing.Point(311, 77);
+ this.pal3Panel.Name = "pal3Panel";
+ this.pal3Panel.Size = new System.Drawing.Size(77, 24);
+ this.pal3Panel.TabIndex = 4;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(274, 47);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(31, 13);
+ this.label1.TabIndex = 15;
+ this.label1.Text = "Pal 0";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(394, 47);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(31, 13);
+ this.label2.TabIndex = 16;
+ this.label2.Text = "Pal 1";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(274, 77);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(31, 13);
+ this.label3.TabIndex = 17;
+ this.label3.Text = "Pal 2";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(394, 77);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(31, 13);
+ this.label4.TabIndex = 18;
+ this.label4.Text = "Pal 3";
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(276, 263);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(34, 13);
+ this.label5.TabIndex = 19;
+ this.label5.Text = "Tile #";
+ //
+ // tileNumber
+ //
+ this.tileNumber.Location = new System.Drawing.Point(279, 282);
+ this.tileNumber.Maximum = new decimal(new int[] {
+ 511,
+ 0,
+ 0,
+ 0});
+ this.tileNumber.Name = "tileNumber";
+ this.tileNumber.Size = new System.Drawing.Size(75, 20);
+ this.tileNumber.TabIndex = 20;
+ this.tileNumber.ValueChanged += new System.EventHandler(this.OnTileNumber);
+ //
+ // revertButton
+ //
+ this.revertButton.Location = new System.Drawing.Point(360, 279);
+ this.revertButton.Name = "revertButton";
+ this.revertButton.Size = new System.Drawing.Size(75, 23);
+ this.revertButton.TabIndex = 21;
+ this.revertButton.Text = "Revert";
+ this.revertButton.UseVisualStyleBackColor = true;
+ this.revertButton.Click += new System.EventHandler(this.OnRevert);
+ //
+ // shiftRightButton
+ //
+ this.shiftRightButton.Location = new System.Drawing.Point(524, 237);
+ this.shiftRightButton.Name = "shiftRightButton";
+ this.shiftRightButton.Size = new System.Drawing.Size(75, 23);
+ this.shiftRightButton.TabIndex = 25;
+ this.shiftRightButton.Text = "Shift Right";
+ this.shiftRightButton.UseVisualStyleBackColor = true;
+ this.shiftRightButton.Click += new System.EventHandler(this.OnShift);
+ //
+ // shiftDownButton
+ //
+ this.shiftDownButton.Location = new System.Drawing.Point(442, 237);
+ this.shiftDownButton.Name = "shiftDownButton";
+ this.shiftDownButton.Size = new System.Drawing.Size(75, 23);
+ this.shiftDownButton.TabIndex = 24;
+ this.shiftDownButton.Text = "Shift Down";
+ this.shiftDownButton.UseVisualStyleBackColor = true;
+ this.shiftDownButton.Click += new System.EventHandler(this.OnShift);
+ //
+ // shiftLeftButton
+ //
+ this.shiftLeftButton.Location = new System.Drawing.Point(524, 208);
+ this.shiftLeftButton.Name = "shiftLeftButton";
+ this.shiftLeftButton.Size = new System.Drawing.Size(75, 23);
+ this.shiftLeftButton.TabIndex = 23;
+ this.shiftLeftButton.Text = "Shift Left";
+ this.shiftLeftButton.UseVisualStyleBackColor = true;
+ this.shiftLeftButton.Click += new System.EventHandler(this.OnShift);
+ //
+ // shiftUpButton
+ //
+ this.shiftUpButton.Location = new System.Drawing.Point(442, 208);
+ this.shiftUpButton.Name = "shiftUpButton";
+ this.shiftUpButton.Size = new System.Drawing.Size(75, 23);
+ this.shiftUpButton.TabIndex = 22;
+ this.shiftUpButton.Text = "Shift Up";
+ this.shiftUpButton.UseVisualStyleBackColor = true;
+ this.shiftUpButton.Click += new System.EventHandler(this.OnShift);
+ //
+ // menuStrip1
+ //
+ this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.fileToolStripMenuItem});
+ this.menuStrip1.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip1.Name = "menuStrip1";
+ this.menuStrip1.Size = new System.Drawing.Size(628, 24);
+ this.menuStrip1.TabIndex = 26;
+ this.menuStrip1.Text = "menuStrip1";
+ //
+ // fileToolStripMenuItem
+ //
+ this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.loadToolStripMenuItem,
+ this.saveToolStripMenuItem,
+ this.saveAsToolStripMenuItem,
+ this.exportToolStripMenuItem,
+ this.importToolStripMenuItem});
+ this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
+ this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
+ this.fileToolStripMenuItem.Text = "File";
+ //
+ // loadToolStripMenuItem
+ //
+ this.loadToolStripMenuItem.Name = "loadToolStripMenuItem";
+ this.loadToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.loadToolStripMenuItem.Text = "Load...";
+ this.loadToolStripMenuItem.Click += new System.EventHandler(this.OnLoad);
+ //
+ // saveToolStripMenuItem
+ //
+ this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
+ this.saveToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.saveToolStripMenuItem.Text = "Save";
+ this.saveToolStripMenuItem.Click += new System.EventHandler(this.OnSave);
+ //
+ // exportToolStripMenuItem
+ //
+ this.exportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.paletteToolStripMenuItem,
+ this.cHRROMToolStripMenuItem});
+ this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
+ this.exportToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.exportToolStripMenuItem.Text = "Export";
+ //
+ // paletteToolStripMenuItem
+ //
+ this.paletteToolStripMenuItem.Name = "paletteToolStripMenuItem";
+ this.paletteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.paletteToolStripMenuItem.Text = "Palette...";
+ this.paletteToolStripMenuItem.Click += new System.EventHandler(this.OnExportPalette);
+ //
+ // cHRROMToolStripMenuItem
+ //
+ this.cHRROMToolStripMenuItem.Name = "cHRROMToolStripMenuItem";
+ this.cHRROMToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.cHRROMToolStripMenuItem.Text = "CHR ROM...";
+ this.cHRROMToolStripMenuItem.Click += new System.EventHandler(this.OnExportCHR);
+ //
+ // importToolStripMenuItem
+ //
+ this.importToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.paletteToolStripMenuItem1,
+ this.cHRROMToolStripMenuItem1});
+ this.importToolStripMenuItem.Name = "importToolStripMenuItem";
+ this.importToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.importToolStripMenuItem.Text = "Import";
+ //
+ // paletteToolStripMenuItem1
+ //
+ this.paletteToolStripMenuItem1.Name = "paletteToolStripMenuItem1";
+ this.paletteToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
+ this.paletteToolStripMenuItem1.Text = "Palette...";
+ this.paletteToolStripMenuItem1.Click += new System.EventHandler(this.OnImportPalettte);
+ //
+ // cHRROMToolStripMenuItem1
+ //
+ this.cHRROMToolStripMenuItem1.Name = "cHRROMToolStripMenuItem1";
+ this.cHRROMToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
+ this.cHRROMToolStripMenuItem1.Text = "CHR ROM...";
+ this.cHRROMToolStripMenuItem1.Click += new System.EventHandler(this.OnImportCHR);
+ //
+ // saveAsToolStripMenuItem
+ //
+ this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
+ this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.saveAsToolStripMenuItem.Text = "Save as...";
+ this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.OnSaveAs);
+ //
+ // MainForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.BackColor = System.Drawing.SystemColors.ControlDark;
+ this.ClientSize = new System.Drawing.Size(628, 356);
+ this.Controls.Add(this.shiftRightButton);
+ this.Controls.Add(this.shiftDownButton);
+ this.Controls.Add(this.shiftLeftButton);
+ this.Controls.Add(this.shiftUpButton);
+ this.Controls.Add(this.revertButton);
+ this.Controls.Add(this.tileNumber);
+ this.Controls.Add(this.label5);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.pal4Panel);
+ this.Controls.Add(this.pal2Panel);
+ this.Controls.Add(this.pal3Panel);
+ this.Controls.Add(this.redoButton);
+ this.Controls.Add(this.rotccwButton);
+ this.Controls.Add(this.rotcwButton);
+ this.Controls.Add(this.vflipButton);
+ this.Controls.Add(this.hflipButton);
+ this.Controls.Add(this.modeCombo);
+ this.Controls.Add(this.undoButton);
+ this.Controls.Add(this.previewPanel);
+ this.Controls.Add(this.colourButton);
+ this.Controls.Add(this.pal1Panel);
+ this.Controls.Add(this.check16);
+ this.Controls.Add(this.editPanel);
+ this.Controls.Add(this.menuStrip1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
+ this.MainMenuStrip = this.menuStrip1;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "MainForm";
+ this.Text = "NES CHR Editor";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnClosing);
+ ((System.ComponentModel.ISupportInitialize)(this.tileNumber)).EndInit();
+ this.menuStrip1.ResumeLayout(false);
+ this.menuStrip1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Panel editPanel;
+ private System.Windows.Forms.CheckBox check16;
+ private System.Windows.Forms.Panel pal1Panel;
+ private System.Windows.Forms.Button colourButton;
+ private System.Windows.Forms.Button undoButton;
+ private System.Windows.Forms.ComboBox modeCombo;
+ private System.Windows.Forms.Panel previewPanel;
+ private System.Windows.Forms.Button hflipButton;
+ private System.Windows.Forms.Button vflipButton;
+ private System.Windows.Forms.Button rotccwButton;
+ private System.Windows.Forms.Button rotcwButton;
+ private System.Windows.Forms.Button redoButton;
+ private System.Windows.Forms.Panel pal2Panel;
+ private System.Windows.Forms.Panel pal4Panel;
+ private System.Windows.Forms.Panel pal3Panel;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.NumericUpDown tileNumber;
+ private System.Windows.Forms.Button revertButton;
+ private System.Windows.Forms.Button shiftRightButton;
+ private System.Windows.Forms.Button shiftDownButton;
+ private System.Windows.Forms.Button shiftLeftButton;
+ private System.Windows.Forms.Button shiftUpButton;
+ private System.Windows.Forms.MenuStrip menuStrip1;
+ private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem loadToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem exportToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem paletteToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem cHRROMToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem importToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem paletteToolStripMenuItem1;
+ private System.Windows.Forms.ToolStripMenuItem cHRROMToolStripMenuItem1;
+ private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem;
+ }
+}
+
diff --git a/neschr/MainForm.cs b/neschr/MainForm.cs new file mode 100644 index 0000000..317d2fd --- /dev/null +++ b/neschr/MainForm.cs @@ -0,0 +1,465 @@ +using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace UCTest
+{
+ public partial class MainForm : Form
+ {
+ EditControl editControl;
+ PaletteControl[] paletteControl;
+ IndexedPalette[] palette;
+ int currentPalette;
+
+ NesTileset tiles;
+ int currentTile;
+ bool metaMode;
+
+ string filePath;
+
+ public MainForm()
+ {
+ InitializeComponent();
+
+ tiles = new NesTileset();
+
+ palette = new IndexedPalette[4];
+
+ for(int f = 0; f < 4; f++)
+ {
+ palette[f] = new IndexedPalette();
+ }
+
+ LoadNesTilePalette();
+
+ editControl = new EditControl(palette[0], previewPanel);
+
+ paletteControl = new PaletteControl[4];
+
+ for(int f = 0; f < 4; f++)
+ {
+ paletteControl[f] = new PaletteControl(palette[f]);
+ paletteControl[f].Tag = f;
+ paletteControl[f].SelectionChanged += OnPaletteSelection;
+ paletteControl[f].SelectedForeground = f == 0 ? 1 : -1;
+ }
+
+ editPanel.Controls.Add(editControl);
+ pal1Panel.Controls.Add(paletteControl[0]);
+ pal2Panel.Controls.Add(paletteControl[1]);
+ pal3Panel.Controls.Add(paletteControl[2]);
+ pal4Panel.Controls.Add(paletteControl[3]);
+
+ currentPalette = 0;
+ currentTile = 0;
+ metaMode = false;
+
+ OnPaletteSelection(paletteControl[0], null);
+
+ editControl.ContentChanged += OnContentChanged;
+
+ modeCombo.SelectedIndex = 0;
+ }
+
+ private void LoadNesTilePalette()
+ {
+ for(int f = 0; f < 4; f++)
+ {
+ for(int n = 0; n < 4; n++)
+ {
+ palette[f].Set(n, NesPalette.Palette[tiles.GetPalette(f * 4 + n)]);
+ }
+ }
+
+ }
+
+ private void OnCheck16(object sender, EventArgs e)
+ {
+ if (check16.Checked)
+ {
+ SaveCurrentTile();
+ metaMode = true;
+ editControl.SetGridSize(16, 16);
+ LoadCurrentTile();
+ }
+ else
+ {
+ SaveCurrentTile();
+ metaMode = false;
+ editControl.SetGridSize(8, 8);
+ LoadCurrentTile();
+ }
+ }
+
+ private void OnPaletteSelection(object sender, EventArgs e)
+ {
+ PaletteControl c = (PaletteControl)sender;
+ int i = (int)c.Tag;
+
+ if (i != currentPalette)
+ {
+ paletteControl[currentPalette].SelectedForeground = -1;
+ currentPalette = i;
+ editControl.SetPalette(palette[currentPalette]);
+ }
+
+ editControl.Foreground = paletteControl[currentPalette].SelectedForeground;
+ }
+
+ private void OnContentChanged(object sender, EventArgs e)
+ {
+ undoButton.Enabled = editControl.UndoAvailable;
+ redoButton.Enabled = editControl.RedoAvailable;
+ }
+
+ private void OnUndo(object sender, EventArgs e)
+ {
+ editControl.Undo();
+ }
+
+ private void OnRedo(object sender, EventArgs e)
+ {
+ editControl.Redo();
+ }
+
+ private void OnModeCombo(object sender, EventArgs e)
+ {
+ switch(modeCombo.SelectedIndex)
+ {
+ case 0:
+ editControl.DrawingMode = EditControl.Mode.Plot;
+ break;
+
+ case 1:
+ editControl.DrawingMode = EditControl.Mode.Line;
+ break;
+
+ case 2:
+ editControl.DrawingMode = EditControl.Mode.Fill;
+ break;
+
+ case 3:
+ editControl.DrawingMode = EditControl.Mode.Rect;
+ break;
+
+ case 4:
+ editControl.DrawingMode = EditControl.Mode.FilledRect;
+ break;
+ }
+ }
+
+ private void OnHorizontalFlip(object sender, EventArgs e)
+ {
+ editControl.HorizontalFlip();
+ }
+
+ private void OnVerticalFlip(object sender, EventArgs e)
+ {
+ editControl.VerticalFlip();
+ }
+
+ private void OnRotateRight(object sender, EventArgs e)
+ {
+ editControl.RotateRight();
+ }
+
+ private void OnRotateLeft(object sender, EventArgs e)
+ {
+ editControl.RotateLeft();
+ }
+
+ private void OnColourClick(object sender, EventArgs e)
+ {
+ NesPalette selector = new NesPalette();
+
+ selector.ShowDialog();
+
+ if (selector.ColourWasSelected)
+ {
+ int i = paletteControl[currentPalette].SelectedForeground;
+
+ if (i == 0)
+ {
+ for(int f = 0; f < 4; f++)
+ {
+ palette[f].Set(0, selector.SelectedColour);
+ tiles.SetPalette(f * 4, selector.SelectedNumber);
+ }
+ }
+ else
+ {
+ palette[currentPalette].Set(i, selector.SelectedColour);
+ tiles.SetPalette(currentPalette * 4 + i, selector.SelectedNumber);
+ }
+ }
+ }
+
+ private void ExtractChar(int[,] from, int[,] to, int x, int y)
+ {
+ for(int dx = 0; dx < 8; dx++)
+ {
+ for(int dy = 0; dy < 8; dy++)
+ {
+ to[dx, dy] = from[x + dx, y + dy];
+ }
+ }
+ }
+
+ private void PlaceChar(int[,] from, int[,] to, int x, int y)
+ {
+ for(int dx = 0; dx < 8; dx++)
+ {
+ for(int dy = 0; dy < 8; dy++)
+ {
+ to[x + dx, y + dy] = from[dx, dy];
+ }
+ }
+ }
+
+ private void SaveCurrentTile()
+ {
+ if (metaMode)
+ {
+ int[,] data = editControl.GridData;
+ int[,] copy = new int[8,8];
+
+ ExtractChar(data, copy, 0, 0);
+ tiles.SetChar(currentTile, copy);
+
+ ExtractChar(data, copy, 8, 0);
+ tiles.SetChar(currentTile + 1, copy);
+
+ ExtractChar(data, copy, 0, 8);
+ tiles.SetChar(currentTile + 2, copy);
+
+ ExtractChar(data, copy, 8, 8);
+ tiles.SetChar(currentTile + 3, copy);
+ }
+ else
+ {
+ tiles.SetChar(currentTile, editControl.GridData);
+ }
+ }
+
+ private void LoadCurrentTile()
+ {
+ if (metaMode)
+ {
+ int[,] copy = new int[16,16];
+
+ PlaceChar(tiles.GetChar(currentTile), copy, 0, 0);
+ PlaceChar(tiles.GetChar(currentTile + 1), copy, 8, 0);
+ PlaceChar(tiles.GetChar(currentTile + 2), copy, 0, 8);
+ PlaceChar(tiles.GetChar(currentTile + 3), copy, 8, 8);
+
+ editControl.GridData = copy;
+ }
+ else
+ {
+ editControl.GridData = tiles.GetChar(currentTile);
+ }
+ }
+
+ private void OnTileNumber(object sender, EventArgs e)
+ {
+ SaveCurrentTile();
+ currentTile = Convert.ToInt32(tileNumber.Value);
+ LoadCurrentTile();
+ }
+
+ private void OnRevert(object sender, EventArgs e)
+ {
+ LoadCurrentTile();
+ }
+
+ private void OnShift(object sender, EventArgs e)
+ {
+ if (shiftRightButton.Equals(sender))
+ {
+ editControl.Shift(1, 0);
+ }
+ else if (shiftLeftButton.Equals(sender))
+ {
+ editControl.Shift(-1, 0);
+ }
+ else if (shiftUpButton.Equals(sender))
+ {
+ editControl.Shift(0, -1);
+ }
+ else if (shiftDownButton.Equals(sender))
+ {
+ editControl.Shift(0, 1);
+ }
+ }
+
+ private void OnClosing(object sender, FormClosingEventArgs e)
+ {
+ if (e.CloseReason == CloseReason.UserClosing)
+ {
+ e.Cancel = (MessageBox.Show(this, "Quit?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.No);
+ }
+ }
+
+ private string FileSelectorOpen(string action, string ext, string filter)
+ {
+ OpenFileDialog fsel = new OpenFileDialog();
+
+ fsel.Title = "Select file to " + action;
+ fsel.DefaultExt = ext;
+ fsel.Filter = filter;
+
+ if (fsel.ShowDialog() == DialogResult.OK)
+ {
+ return fsel.FileName;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private string FileSelectorSave(string action, string ext, string filter)
+ {
+ SaveFileDialog fsel = new SaveFileDialog();
+
+ fsel.Title = "Select file to " + action;
+ fsel.DefaultExt = ext;
+ fsel.Filter = filter;
+
+ if (fsel.ShowDialog() == DialogResult.OK)
+ {
+ return fsel.FileName;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private void Error(string err)
+ {
+ MessageBox.Show(this, err, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ private void OnLoad(object sender, EventArgs e)
+ {
+ string path = FileSelectorOpen("open", "neschr", "NES CHR files (*.neschr)|*.neschr|All files (*.*)|*.*");
+
+ if (path != null)
+ {
+ if (!tiles.Load(path))
+ {
+ Error("Failed to load " + path);
+ }
+ else
+ {
+ filePath = path;
+ LoadNesTilePalette();
+ LoadCurrentTile();
+ }
+ }
+ }
+
+ private void OnSave(object sender, EventArgs e)
+ {
+ string path = filePath ?? FileSelectorSave("save", "neschr", "NES CHR files (*.neschr)|*.neschr|All files (*.*)|*.*");
+
+ if (path != null)
+ {
+ SaveCurrentTile();
+
+ if (!tiles.Save(path))
+ {
+ Error("Failed to save " + path);
+ }
+ }
+ }
+
+ private void OnSaveAs(object sender, EventArgs e)
+ {
+ string path = FileSelectorSave("save", "neschr", "NES CHR files (*.neschr)|*.neschr|All files (*.*)|*.*");
+
+ if (path != null)
+ {
+ SaveCurrentTile();
+
+ if (!tiles.Save(path))
+ {
+ Error("Failed to save " + path);
+ }
+ else
+ {
+ filePath = path;
+ }
+ }
+ }
+
+ private void OnExportPalette(object sender, EventArgs e)
+ {
+ string path = FileSelectorSave("export", String.Empty, "All files (*.*)|*.*");
+
+ if (path != null)
+ {
+ if (!tiles.ExportPalette(path))
+ {
+ Error("Failed to export " + path);
+ }
+ }
+ }
+
+ private void OnExportCHR(object sender, EventArgs e)
+ {
+ string path = FileSelectorSave("export", String.Empty, "All files (*.*)|*.*");
+
+ if (path != null)
+ {
+ SaveCurrentTile();
+
+ if (!tiles.ExportCHR(path))
+ {
+ Error("Failed to export " + path);
+ }
+ }
+ }
+
+ private void OnImportPalettte(object sender, EventArgs e)
+ {
+ string path = FileSelectorOpen("import", String.Empty, "All files (*.*)|*.*");
+
+ if (path != null)
+ {
+ if (!tiles.ImportPalette(path))
+ {
+ Error("Failed to import " + path);
+ }
+ else
+ {
+ LoadNesTilePalette();
+ }
+ }
+ }
+
+ private void OnImportCHR(object sender, EventArgs e)
+ {
+ string path = FileSelectorOpen("import", String.Empty, "All files (*.*)|*.*");
+
+ if (path != null)
+ {
+ if (!tiles.ImportCHR(path))
+ {
+ Error("Failed to import " + path);
+ }
+ else
+ {
+ LoadCurrentTile();
+ }
+ }
+ }
+ }
+}
diff --git a/neschr/MainForm.resx b/neschr/MainForm.resx new file mode 100644 index 0000000..0f6d8eb --- /dev/null +++ b/neschr/MainForm.resx @@ -0,0 +1,123 @@ +<?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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+</root>
\ No newline at end of file diff --git a/neschr/NesPalette.Designer.cs b/neschr/NesPalette.Designer.cs new file mode 100644 index 0000000..97f514f --- /dev/null +++ b/neschr/NesPalette.Designer.cs @@ -0,0 +1,59 @@ +namespace UCTest
+{
+ partial class NesPalette
+ {
+ /// <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.panel = new System.Windows.Forms.FlowLayoutPanel();
+ this.SuspendLayout();
+ //
+ // panel
+ //
+ this.panel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panel.Location = new System.Drawing.Point(0, 0);
+ this.panel.Name = "panel";
+ this.panel.Size = new System.Drawing.Size(624, 154);
+ this.panel.TabIndex = 0;
+ //
+ // NesPalette
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(624, 154);
+ this.Controls.Add(this.panel);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "NesPalette";
+ this.Text = "NES Palette";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.FlowLayoutPanel panel;
+ }
+}
\ No newline at end of file diff --git a/neschr/NesPalette.cs b/neschr/NesPalette.cs new file mode 100644 index 0000000..85d0fc0 --- /dev/null +++ b/neschr/NesPalette.cs @@ -0,0 +1,136 @@ +using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace UCTest
+{
+ public partial class NesPalette : Form
+ {
+ private static Color[] pal = new Color[]
+ {
+ Color.FromArgb(124,124,124),
+ Color.FromArgb(0,0,252),
+ Color.FromArgb(0,0,188),
+ Color.FromArgb(68,40,188),
+ Color.FromArgb(148,0,132),
+ Color.FromArgb(168,0,32),
+ Color.FromArgb(168,16,0),
+ Color.FromArgb(136,20,0),
+ Color.FromArgb(80,48,0),
+ Color.FromArgb(0,120,0),
+ Color.FromArgb(0,104,0),
+ Color.FromArgb(0,88,0),
+ Color.FromArgb(0,64,88),
+ Color.FromArgb(0,0,0),
+ Color.FromArgb(0,0,0),
+ Color.FromArgb(0,0,0),
+ Color.FromArgb(188,188,188),
+ Color.FromArgb(0,120,248),
+ Color.FromArgb(0,88,248),
+ Color.FromArgb(104,68,252),
+ Color.FromArgb(216,0,204),
+ Color.FromArgb(228,0,88),
+ Color.FromArgb(248,56,0),
+ Color.FromArgb(228,92,16),
+ Color.FromArgb(172,124,0),
+ Color.FromArgb(0,184,0),
+ Color.FromArgb(0,168,0),
+ Color.FromArgb(0,168,68),
+ Color.FromArgb(0,136,136),
+ Color.FromArgb(0,0,0),
+ Color.FromArgb(0,0,0),
+ Color.FromArgb(0,0,0),
+ Color.FromArgb(248,248,248),
+ Color.FromArgb(60,188,252),
+ Color.FromArgb(104,136,252),
+ Color.FromArgb(152,120,248),
+ Color.FromArgb(248,120,248),
+ Color.FromArgb(248,88,152),
+ Color.FromArgb(248,120,88),
+ Color.FromArgb(252,160,68),
+ Color.FromArgb(248,184,0),
+ Color.FromArgb(184,248,24),
+ Color.FromArgb(88,216,84),
+ Color.FromArgb(88,248,152),
+ Color.FromArgb(0,232,216),
+ Color.FromArgb(120,120,120),
+ Color.FromArgb(0,0,0),
+ Color.FromArgb(0,0,0),
+ Color.FromArgb(252,252,252),
+ Color.FromArgb(164,228,252),
+ Color.FromArgb(184,184,248),
+ Color.FromArgb(216,184,248),
+ Color.FromArgb(248,184,248),
+ Color.FromArgb(248,164,192),
+ Color.FromArgb(240,208,176),
+ Color.FromArgb(252,224,168),
+ Color.FromArgb(248,216,120),
+ Color.FromArgb(216,248,120),
+ Color.FromArgb(184,248,184),
+ Color.FromArgb(184,248,216),
+ Color.FromArgb(0,252,252),
+ Color.FromArgb(248,216,248),
+ Color.FromArgb(0,0,0),
+ Color.FromArgb(0,0,0)
+ };
+
+ private void OnClick(object sender, EventArgs e)
+ {
+ Button b = (Button)sender;
+
+ ColourWasSelected = true;
+
+ int i = (int)b.Tag;
+
+ SelectedColour = pal[i];
+ SelectedNumber = i;
+
+ Close();
+ }
+
+ public bool ColourWasSelected {get; private set;}
+
+ public int SelectedNumber {get; private set;}
+
+ public Color SelectedColour {get; private set;}
+
+ public static Color[] Palette
+ {
+ get
+ {
+ return pal;
+ }
+ }
+
+ public NesPalette()
+ {
+ InitializeComponent();
+
+ int i = 0;
+
+ foreach (Color c in pal)
+ {
+ Button b = new Button();
+
+ b.Text = i.ToString();
+
+ b.Width = 32;
+ b.Height = 32;
+ b.BackColor = c;
+ b.ForeColor = Color.White;
+ b.Click += OnClick;
+ b.Tag = i;
+
+ panel.Controls.Add(b);
+
+ i++;
+ }
+ }
+ }
+}
diff --git a/neschr/NesPalette.resx b/neschr/NesPalette.resx new file mode 100644 index 0000000..29dcb1b --- /dev/null +++ b/neschr/NesPalette.resx @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=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>
+</root>
\ No newline at end of file diff --git a/neschr/NesTileset.cs b/neschr/NesTileset.cs new file mode 100644 index 0000000..980149f --- /dev/null +++ b/neschr/NesTileset.cs @@ -0,0 +1,308 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+
+namespace UCTest
+{
+ class NesTileset
+ {
+ [Serializable]
+ private class NesTile
+ {
+ public int[,] data;
+
+ public void WriteCHR(Stream s)
+ {
+ byte[] plane0 = new byte[8];
+ byte[] plane1 = new byte[8];
+
+ for(int y = 0; y < 8; y++)
+ {
+ for(int x = 0; x < 8; x++)
+ {
+ int bit = 7-x;
+
+ if ((data[x,y] & 1) == 1)
+ {
+ plane0[y] |= Convert.ToByte(1 << bit);
+ }
+
+ if ((data[x,y] & 2) == 2)
+ {
+ plane1[y] |= Convert.ToByte(1 << bit);
+ }
+ }
+ }
+
+ for(int f = 0; f < 8; f++)
+ {
+ s.WriteByte(plane0[f]);
+ }
+
+ for(int f = 0; f < 8; f++)
+ {
+ s.WriteByte(plane1[f]);
+ }
+ }
+
+ public void ReadCHR(Stream s)
+ {
+ int[] plane0 = new int[8];
+ int[] plane1 = new int[8];
+
+ for(int f = 0; f < 8; f++)
+ {
+ plane0[f] = s.ReadByte();
+ }
+
+ for(int f = 0; f < 8; f++)
+ {
+ plane1[f] = s.ReadByte();
+ }
+
+ for(int y = 0; y < 8; y++)
+ {
+ for(int x = 0; x < 8; x++)
+ {
+ int bit = 7-x;
+
+ data[x,y] = 0;
+
+ if ((plane0[y] & (1 << bit)) == (1 << bit))
+ {
+ data[x,y] |= 1;
+ }
+
+ if ((plane1[y] & (1 << bit)) == (1 << bit))
+ {
+ data[x,y] |= 2;
+ }
+ }
+ }
+ }
+
+ public NesTile()
+ {
+ data = new int[8,8];
+ }
+ };
+
+ private NesTile[] chars;
+ private int[] palette;
+
+ private void Reset()
+ {
+ chars = new NesTile[512];
+
+ for(int f = 0 ; f < 512; f++)
+ {
+ chars[f] = new NesTile();
+ }
+
+ palette = new int[16];
+
+ for(int f = 0 ; f < 4; f++)
+ {
+ for(int n = 0; n < 3; n++)
+ {
+ palette[f*4+n+1] = f * 6 + n * 16;
+ }
+
+ palette[f*4] = 13;
+ }
+ }
+
+ public int GetPalette(int i)
+ {
+ return palette[i];
+ }
+
+ public void SetPalette(int i, int p)
+ {
+ palette[i] = p;
+ }
+
+ public int[,] GetChar(int i)
+ {
+ return (int[,])chars[i % 512].data.Clone();
+ }
+
+ public void SetChar(int i, int[,] data)
+ {
+ chars[i % 512].data = (int[,])data.Clone();
+ }
+
+ public bool Load(string path)
+ {
+ bool status = false;
+
+ try
+ {
+ using (FileStream stream = File.OpenRead(path))
+ {
+ IFormatter formatter = new BinaryFormatter();
+ int[] newpal = null;
+ NesTile[] newchars = null;
+
+ newpal = (int[])formatter.Deserialize(stream);
+ newchars = (NesTile[])formatter.Deserialize(stream);
+
+ if (newpal != null && newpal.Length == 16 &&
+ newchars != null && newchars.Length == 512)
+ {
+ palette = newpal;
+ chars = newchars;
+ status = true;
+ }
+
+ stream.Close();
+ }
+ }
+ catch (Exception)
+ {
+ }
+
+ if (!status)
+ {
+ Reset();
+ }
+
+ return status;
+ }
+
+ public bool Save(string path)
+ {
+ bool status = false;
+
+ try
+ {
+ using (FileStream stream = File.Create(path))
+ {
+ IFormatter formatter = new BinaryFormatter();
+
+ formatter.Serialize(stream, palette);
+ formatter.Serialize(stream, chars);
+
+ stream.Close();
+
+ status = true;
+ }
+ }
+ catch (Exception)
+ {
+ }
+
+ return status;
+ }
+
+ public bool ExportPalette(string path)
+ {
+ bool status = false;
+
+ try
+ {
+ using (FileStream stream = File.Create(path))
+ {
+ foreach(int i in palette)
+ {
+ stream.WriteByte(Convert.ToByte(i));
+ }
+
+ stream.Close();
+
+ status = true;
+ }
+ }
+ catch (Exception)
+ {
+ }
+
+ return status;
+ }
+
+ public bool ImportPalette(string path)
+ {
+ bool status = false;
+
+ try
+ {
+ using (FileStream stream = File.Create(path))
+ {
+ for(int f = 0; f < 16; f++)
+ {
+ palette[f] = stream.ReadByte();
+ }
+
+ stream.Close();
+
+ status = true;
+ }
+ }
+ catch (Exception)
+ {
+ }
+
+ return status;
+ }
+
+ public bool ExportCHR(string path)
+ {
+ bool status = false;
+
+ try
+ {
+ using (FileStream stream = File.Create(path))
+ {
+ foreach(NesTile i in chars)
+ {
+ i.WriteCHR(stream);
+ }
+
+ stream.Close();
+
+ status = true;
+ }
+ }
+ catch (Exception)
+ {
+ }
+
+ return status;
+ }
+
+ public bool ImportCHR(string path)
+ {
+ bool status = false;
+
+ try
+ {
+ using (FileStream stream = File.OpenRead(path))
+ {
+ foreach(NesTile i in chars)
+ {
+ i.ReadCHR(stream);
+ }
+
+ stream.Close();
+
+ status = true;
+ }
+ }
+ catch (Exception)
+ {
+ }
+
+ return status;
+ }
+
+ public NesTileset()
+ {
+ Reset();
+ }
+ }
+}
diff --git a/neschr/PaletteControl.Designer.cs b/neschr/PaletteControl.Designer.cs new file mode 100644 index 0000000..ded384b --- /dev/null +++ b/neschr/PaletteControl.Designer.cs @@ -0,0 +1,36 @@ +namespace UCTest
+{
+ partial class PaletteControl
+ {
+ /// <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 Component 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()
+ {
+ components = new System.ComponentModel.Container();
+ }
+
+ #endregion
+ }
+}
diff --git a/neschr/PaletteControl.cs b/neschr/PaletteControl.cs new file mode 100644 index 0000000..10f5717 --- /dev/null +++ b/neschr/PaletteControl.cs @@ -0,0 +1,141 @@ +using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace UCTest
+{
+ public partial class PaletteControl : Control
+ {
+ private bool initialised = false;
+ private IIndexedPalette palette;
+
+ private Bitmap backing;
+ private Graphics g;
+ private Graphics cg;
+
+ private int width;
+ private int height;
+
+ private int cell_width;
+
+ private void CreateBacking()
+ {
+ width = Parent.Size.Width;
+ height = Parent.Size.Height;
+
+ backing = new Bitmap(width, height);
+ g = Graphics.FromImage(backing);
+ cg = CreateGraphics();
+
+ DrawPalette();
+ }
+
+ private void OnPaletteChanged(object sender, EventArgs e)
+ {
+ if (g != null)
+ {
+ DrawPalette();
+ Invalidate();
+ }
+ }
+
+ private void DrawPalette()
+ {
+ g.Clear(Color.Black);
+
+ cell_width = width / palette.PaletteSize;
+
+ for(int f = 0; f < palette.PaletteSize; f++)
+ {
+ using (Brush b = new SolidBrush(palette.Palette[f]))
+ {
+ g.FillRectangle(b, f * cell_width + 1, 1, cell_width - 2, height - 2);
+
+ if (f == SelectedForeground)
+ {
+ g.DrawRectangle(Pens.White, f * cell_width, 0, cell_width - 1, height - 1);
+ }
+ }
+ }
+
+ cg.DrawImageUnscaled(backing, 0, 0);
+ }
+
+ protected override void OnPaint(PaintEventArgs pe)
+ {
+ if (!initialised)
+ {
+ initialised = true;
+ CreateBacking();
+ }
+
+ DrawPalette();
+
+ cg.DrawImageUnscaled(backing, 0, 0);
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ int sel = e.X / cell_width;
+
+ if (sel != SelectedForeground)
+ {
+ SelectedForeground = sel;
+ Invalidate();
+
+ EventHandler h = SelectionChanged;
+
+ if (h != null)
+ {
+ h(this, new EventArgs());
+ }
+ }
+ }
+
+ private int foreground;
+
+ public int SelectedForeground
+ {
+ get
+ {
+ return foreground;
+ }
+
+ set
+ {
+ foreground = value;
+ Invalidate();
+ }
+ }
+
+ public event EventHandler SelectionChanged;
+
+ public void Initialise()
+ {
+ if (!initialised)
+ {
+ initialised = true;
+ CreateBacking();
+ }
+
+ Invalidate();
+ }
+
+ public PaletteControl(IIndexedPalette palette)
+ {
+ Dock = DockStyle.Fill;
+
+ InitializeComponent();
+
+ this.palette = palette;
+
+ this.palette.PaletteChanged += OnPaletteChanged;
+ }
+ }
+}
diff --git a/neschr/Program.cs b/neschr/Program.cs new file mode 100644 index 0000000..ed38aad --- /dev/null +++ b/neschr/Program.cs @@ -0,0 +1,22 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace UCTest
+{
+ static class Program
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new MainForm());
+ }
+ }
+}
diff --git a/neschr/Properties/AssemblyInfo.cs b/neschr/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1b2b71a --- /dev/null +++ b/neschr/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("neschr")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("neschr")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("22e17fea-c5b4-4544-940d-693ad98c8324")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/neschr/Properties/Resources.Designer.cs b/neschr/Properties/Resources.Designer.cs new file mode 100644 index 0000000..0d73c81 --- /dev/null +++ b/neschr/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace neschr.Properties
+{
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("neschr.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/neschr/Properties/Resources.resx b/neschr/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/neschr/Properties/Resources.resx @@ -0,0 +1,117 @@ +<?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.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: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" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </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" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file diff --git a/neschr/Properties/Settings.Designer.cs b/neschr/Properties/Settings.Designer.cs new file mode 100644 index 0000000..fcff614 --- /dev/null +++ b/neschr/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace neschr.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/neschr/Properties/Settings.settings b/neschr/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/neschr/Properties/Settings.settings @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile>
diff --git a/neschr/neschr.csproj b/neschr/neschr.csproj new file mode 100644 index 0000000..38b847b --- /dev/null +++ b/neschr/neschr.csproj @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{22E17FEA-C5B4-4544-940D-693AD98C8324}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>neschr</RootNamespace>
+ <AssemblyName>neschr</AssemblyName>
+ <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Deployment" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="EditControl.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="EditControl.Designer.cs">
+ <DependentUpon>EditControl.cs</DependentUpon>
+ </Compile>
+ <Compile Include="IIndexedPalette.cs" />
+ <Compile Include="IndexedPalette.cs" />
+ <Compile Include="MainForm.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="MainForm.Designer.cs">
+ <DependentUpon>MainForm.cs</DependentUpon>
+ </Compile>
+ <Compile Include="NesPalette.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="NesPalette.Designer.cs">
+ <DependentUpon>NesPalette.cs</DependentUpon>
+ </Compile>
+ <Compile Include="NesTileset.cs" />
+ <Compile Include="PaletteControl.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="PaletteControl.Designer.cs">
+ <DependentUpon>PaletteControl.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <EmbeddedResource Include="MainForm.resx">
+ <DependentUpon>MainForm.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="NesPalette.resx">
+ <DependentUpon>NesPalette.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file |