Ejemplo n.º 1
0
        public void AddRecord(ResourceBlock block, ResourceForm form)
        {
            ResourceRecord newRecord = new ResourceRecord();

            newRecord.Id            = m_iIdCounter++;
            newRecord.ResourceBlock = block;
            newRecord.ResourceForm  = form;

            m_aRecords.Add(newRecord);
        }
Ejemplo n.º 2
0
 public ResourceBlock GetResourceBlock(ResourceForm form)
 {
     for (int i = 0; i < m_aRecords.Count; i++)
     {
         if (m_aRecords[i].ResourceForm == form)
         {
             return(m_aRecords[i].ResourceBlock);
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
        public void RemoveRecord(ResourceForm form)
        {
            int iIndex = -1;

            for (int i = 0; i < m_aRecords.Count; i++)
            {
                if (m_aRecords[i].ResourceForm == form)
                {
                    iIndex = i;
                    break;
                }
            }
            if (iIndex >= 0)
            {
                m_aRecords.RemoveAt(iIndex);
            }
        }
Ejemplo n.º 4
0
        private void OnResourceFormClosed(ResourceForm form)
        {
            ResourceBlock block = tmSingleton <ResourceBlockManager> .Instance.GetResourceBlock(form);

            if (block == null)
            {
                return;
            }

            string sConsoleString = block.GetFullDescription();

            tmSingleton <ResourceBlockManager> .Instance.RemoveRecord(form);

            ConsoleLog(String.Format("Removed resource block: {0}", sConsoleString));

            UpdateResourcesList();
        }
Ejemplo n.º 5
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();
        }