Пример #1
0
        public MainForm()
        {
            _formatList = new Dictionary <FormatKind, FileFormat>();

            _formatList[FormatKind.NES] = new FileFormat(
                "NES",
                Utils.TileType("NESTile"),
                new string[] { "nes", "fds", "chr", "bin" },
                new ColorList(Utils.NESPalette, Utils.NESDefSel)
                );

            _formatList[FormatKind.SNES] = new FileFormat(
                "SNES",
                Utils.TileType("SNESTile"),
                new string[] { "smc", "sfc", "chr", "bin" },
                new ColorPattern(Utils.SNESRGBAOrderAndDepth, Utils.SNESDefSel)
                );

            _formatList[FormatKind.MD] = new FileFormat(
                "Genesis",
                Utils.TileType("MDTile"),
                new string[] { "smd", "md", "bin" },
                new ColorPattern(Utils.MDRGBAOrderAndDepth, Utils.MDDefSel)
                );

            InitializeComponent();

            string filter = "";

            foreach (var fmt in _formatList)
            {
                filter += fmt.Value.Filter;
            }

            filter = filter.Remove(filter.Length - 1);
            this.openFileDialog1.Filter = filter;

            inputWnd  = new InputWindow(this);
            spriteWnd = new SpriteWindow(this);
            toolBox   = new ToolBox(this, inputWnd);

            // Setup MainForm events
            this.KeyPreview = true;
            this.KeyUp     += this.keyUpHandler;
            this.KeyDown   += this.keysHandler;
            this.Resize    += this.catchWindowState;
            this.Layout    += this.layoutHandler;
            Utils.ApplyRecursiveControlFunc(this, this.ConfigureControls);

            _sendTileEvents = new[]
            {
                new EventPair("Click", (s, e) => { CopyTile(inputWnd); PasteTile(spriteWnd); _tempSpriteSel = true; }),
                new EventPair("MouseEnter", (s, e) => { _tempSpriteSel = spriteWnd.Selected; spriteWnd.Selected = true; spriteWnd.Draw(); }),
                new EventPair("MouseLeave", (s, e) => { spriteWnd.Selected = _tempSpriteSel; spriteWnd.Draw(); })
            };

            UpdateMinimumSize();
            inputWnd.Focus(this);
        }
Пример #2
0
        public PaletteTab(MainForm main, SpriteWindow wnd)
        {
            _main = main;
            _wnd  = wnd;
            _id   = "paletteTab";
            _name = "Palette";

            _tabButton     = new ToolBoxButton(_name);
            _tabButton.Tag = this;

            _panel      = new Panel();
            _panel.Name = "palettePanel";

            _primary      = new PalettePanel(this, _wnd.Collage);
            _primary.Name = "primaryBox";

            _panel.Controls.Add(_primary);
        }
Пример #3
0
        public SpriteControlsTab(SpriteWindow wnd)
        {
            _wnd  = wnd;
            _id   = "spriteControlsTab";
            _name = "Controls";

            _tabButton     = new ToolBoxButton(_name);
            _tabButton.Tag = this;

            _panel        = new Panel();
            _panel.Name   = "spriteControlsPanel";
            _panel.Paint += this.drawDivider;

            _folderBrowser = new FolderBrowserDialog();
            var resources = new ComponentResourceManager(typeof(SpriteControlsTab));

            _tileLabel          = new Label();
            _tileLabel.Font     = new Font(Label.DefaultFont, FontStyle.Bold);
            _tileLabel.Name     = "tileLabel";
            _tileLabel.Text     = "Tile";
            _tileLabel.AutoSize = true;
            _tileLabel.Location = new Point(20, 8);

            _outputLabel          = new Label();
            _outputLabel.Font     = new Font(Label.DefaultFont, FontStyle.Bold);
            _outputLabel.Name     = "outputLabel";
            _outputLabel.Text     = "Output";
            _outputLabel.AutoSize = true;
            _outputLabel.Location = new Point(136, 8);

            _rotateLeftBtn           = new Button();
            _rotateLeftBtn.Name      = "rotateLeftBtn";
            _rotateLeftBtn.Size      = new Size(32, 32);
            _rotateLeftBtn.Location  = new Point(26, 30);
            _rotateLeftBtn.BackColor = Color.Transparent;
            _rotateLeftBtn.Image     = (Image)(resources.GetObject("rotateLeftImg"));
            _rotateLeftBtn.Click    += (s, e) => _wnd.FlipTile(Translation.Left);

            _rotateRightBtn           = new Button();
            _rotateRightBtn.Name      = "rotateRightBtn";
            _rotateRightBtn.Size      = new Size(32, 32);
            _rotateRightBtn.Location  = new Point(66, 30);
            _rotateRightBtn.BackColor = Color.Transparent;
            _rotateRightBtn.Image     = (Image)(resources.GetObject("rotateRightImg"));
            _rotateRightBtn.Click    += (s, e) => _wnd.FlipTile(Translation.Right);

            _mirrorHoriBtn           = new Button();
            _mirrorHoriBtn.Name      = "mirrorHoriBtn";
            _mirrorHoriBtn.Size      = new Size(32, 32);
            _mirrorHoriBtn.Location  = new Point(26, 70);
            _mirrorHoriBtn.BackColor = Color.Transparent;
            _mirrorHoriBtn.Image     = (Image)(resources.GetObject("mirrorHoriImg"));
            _mirrorHoriBtn.Click    += (s, e) => _wnd.FlipTile(Translation.Horizontal);

            _mirrorVertBtn           = new Button();
            _mirrorVertBtn.Name      = "mirrorVertBtn";
            _mirrorVertBtn.Size      = new Size(32, 32);
            _mirrorVertBtn.Location  = new Point(66, 70);
            _mirrorVertBtn.BackColor = Color.Transparent;
            _mirrorVertBtn.Image     = (Image)(resources.GetObject("mirrorVertImg"));
            _mirrorVertBtn.Click    += (s, e) => _wnd.FlipTile(Translation.Vertical);

            _eraseBtn           = new Button();
            _eraseBtn.Name      = "eraseBtn";
            _eraseBtn.Text      = "Erase";
            _eraseBtn.AutoSize  = true;
            _eraseBtn.Location  = new Point(25, 110);
            _eraseBtn.BackColor = Color.Transparent;
            _eraseBtn.Click    += (s, e) => _wnd.EraseTile();

            _scaleLabel          = new Label();
            _scaleLabel.Name     = "scaleLabel";
            _scaleLabel.Text     = "Scale:  x";
            _scaleLabel.AutoSize = true;
            _scaleLabel.Location = new Point(142, 32);

            _scaleBox               = new NumericUpDown();
            _scaleBox.Name          = "scaleBox";
            _scaleBox.Size          = new Size(40, 20);
            _scaleBox.Location      = new Point(190, 30);
            _scaleBox.Increment     = 1;
            _scaleBox.Minimum       = 1;
            _scaleBox.Maximum       = 256;
            _scaleBox.Text          = "";
            _scaleBox.ValueChanged += (s, e) => UpdateUI();
            _scaleBox.Leave        += (s, e) => UpdateUI();

            _scaleHint           = new Label();
            _scaleHint.Name      = "scaleHint";
            _scaleHint.Text      = "No scale set";
            _scaleHint.Font      = new Font(Label.DefaultFont, FontStyle.Italic);
            _scaleHint.ForeColor = infoColor;
            _scaleHint.AutoSize  = true;
            _scaleHint.Location  = new Point(234, 33);

            _folderLabel          = new Label();
            _folderLabel.Name     = "folderLabel";
            _folderLabel.Text     = "Folder: ";
            _folderLabel.AutoSize = true;
            _folderLabel.Location = new Point(142, 58);

            _folderBtn           = new Button();
            _folderBtn.Name      = "folderBtn";
            _folderBtn.Text      = "...";
            _folderBtn.Size      = new Size(30, 20);
            _folderBtn.Location  = new Point(189, 55);
            _folderBtn.BackColor = Color.Transparent;
            _folderBtn.Click    += this.browseFolderHandler;

            _folderText              = new Label();
            _folderText.Name         = "folderText";
            _folderText.Text         = "No path set";
            _folderText.Font         = new Font(Label.DefaultFont, FontStyle.Italic);
            _folderText.ForeColor    = infoColor;
            _folderText.AutoEllipsis = true;
            _folderText.Size         = new Size(70, 13);
            _folderText.Location     = new Point(226, 58);

            _nameLabel          = new Label();
            _nameLabel.Name     = "nameLabel";
            _nameLabel.Text     = "Name: ";
            _nameLabel.AutoSize = true;
            _nameLabel.Location = new Point(142, 84);

            _nameBox              = new TextBox();
            _nameBox.Name         = "nameBox";
            _nameBox.Text         = "";
            _nameBox.AutoSize     = true;
            _nameBox.Location     = new Point(190, 81);
            _nameBox.TextChanged += (s, e) => UpdateUI();
            _nameBox.Leave       += (s, e) => UpdateUI();

            _nameHint           = new Label();
            _nameHint.Name      = "nameHint";
            _nameHint.Text      = "No name set";
            _nameHint.Font      = new Font(Label.DefaultFont, FontStyle.Italic);
            _nameHint.ForeColor = infoColor;
            _nameHint.AutoSize  = true;
            _nameHint.Location  = new Point(190, 104);

            _overwriteBtn                 = new RadioButton();
            _overwriteBtn.Name            = "overwriteBtn";
            _overwriteBtn.Text            = "Overwrite";
            _overwriteBtn.AutoSize        = true;
            _overwriteBtn.Location        = new Point(186, 124);
            _overwriteBtn.Checked         = true;
            _overwriteBtn.CheckedChanged += this.writeModeCheck;

            _appendBtn                 = new RadioButton();
            _appendBtn.Name            = "appendBtn";
            _appendBtn.Text            = "Append:";
            _appendBtn.AutoSize        = true;
            _appendBtn.Location        = new Point(186, 144);
            _appendBtn.CheckedChanged += this.writeModeCheck;

            _appendBox          = new TextBox();
            _appendBox.Name     = "appendBox";
            _appendBox.Text     = "_{d2}";
            _appendBox.Size     = new Size(50, 20);
            _appendBox.Location = new Point(254, 143);
            _appendBox.Enabled  = false;
            // No TextChanged event here ;)
            _appendBox.Leave += (s, e) => UpdateUI();

            _saveButton           = new Button();
            _saveButton.Name      = "saveButton";
            _saveButton.Size      = new Size(32, 32);
            _saveButton.Location  = new Point(140, 127);
            _saveButton.BackColor = Color.Transparent;
            _saveButton.Image     = (Image)(resources.GetObject("saveImg"));
            _saveButton.Click    += this.saveButtonHandler;
            _saveButton.Enabled   = false;

            _saveMsg              = new Label();
            _saveMsg.Name         = "saveMsg";
            _saveMsg.Text         = "";
            _saveMsg.Font         = new Font(Label.DefaultFont, FontStyle.Italic);
            _saveMsg.ForeColor    = infoColor;
            _saveMsg.AutoEllipsis = true;
            _saveMsg.Size         = new Size(100, 13);
            _saveMsg.Location     = new Point(142, 172);

            _panel.Controls.Add(_tileLabel);
            _panel.Controls.Add(_outputLabel);

            _panel.Controls.Add(_rotateRightBtn);
            _panel.Controls.Add(_rotateLeftBtn);
            _panel.Controls.Add(_mirrorHoriBtn);
            _panel.Controls.Add(_mirrorVertBtn);
            _panel.Controls.Add(_eraseBtn);

            _panel.Controls.Add(_scaleLabel);
            _panel.Controls.Add(_scaleBox);
            _panel.Controls.Add(_scaleHint);

            _panel.Controls.Add(_folderLabel);
            _panel.Controls.Add(_folderBtn);
            _panel.Controls.Add(_folderText);

            _panel.Controls.Add(_nameLabel);
            _panel.Controls.Add(_nameBox);
            _panel.Controls.Add(_nameHint);

            _panel.Controls.Add(_overwriteBtn);
            _panel.Controls.Add(_appendBtn);
            _panel.Controls.Add(_appendBox);
            _panel.Controls.Add(_saveButton);
            _panel.Controls.Add(_saveMsg);
        }