Exemple #1
0
        private void InitWindow()
        {
            if (ResourceBlock == null)
            {
                return;
            }

            ColorResourceBlock block = (ColorResourceBlock)ResourceBlock;

            textBox_summary.Text = block.GetShortDescription() + " - 100%";;

            panel_color.BackColor = Color.FromArgb(block.ResourceColor);

            StringBuilder hexBuilder = new StringBuilder(block.Data.Length * 2);

            for (int i = 0; i < block.Data.Length && i < DATA_PREVIEW_SIZE; i++)
            {
                hexBuilder.AppendFormat("{0:x2} ", block.Data[i]);
            }
            textBox_resource_data_hex.Text = hexBuilder.ToString();
        }
Exemple #2
0
        private void button_add_Click(object sender, EventArgs e)
        {
            // Collect data
            int iSizeMB = 0;

            try
            {
                iSizeMB = Convert.ToInt32(textBox_add.Text);
            }
            catch
            {
                MessageBox.Show("Invalid value for resource size");
                return;
            }

            ResourceBlock newBlock = null;
            ResourceForm  newForm  = null;

            switch (tabControl_add.SelectedIndex)
            {
            case 0:     // Text
                newBlock = new TextResourceBlock(iSizeMB, textBox_text.Text);

                TextResourceForm textForm = new TextResourceForm();
                textForm.ResourceBlock = newBlock;
                textForm.OnClose       = OnResourceFormClosed;
                newForm = textForm;
                break;

            case 1:     // Color
                colorDialog.ShowDialog();
                newBlock = new ColorResourceBlock(iSizeMB, colorDialog.Color.ToArgb());

                ColorResourceForm colorForm = new ColorResourceForm();
                colorForm.ResourceBlock = newBlock;
                colorForm.OnClose       = OnResourceFormClosed;
                newForm = colorForm;
                break;

            case 2:     // Random
                newBlock = new RandomResourceBlock(iSizeMB);

                RandomResourceForm randomForm = new RandomResourceForm();
                randomForm.ResourceBlock = newBlock;
                randomForm.OnClose       = OnResourceFormClosed;
                newForm = randomForm;
                break;

            default:
                MessageBox.Show("Invalid tab selected");
                return;
            }

            // Cleanup
            textBox_add.Clear();

            // Add
            tmSingleton <ResourceBlockManager> .Instance.AddRecord(newBlock, newForm);

            newForm.Show();

            ConsoleLog(String.Format("Added new resource block: {0}", newBlock.GetFullDescription()));

            UpdateResourcesList();
        }