示例#1
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);
        }