Exemplo n.º 1
0
 private void ColorInValid()
 {
     foreach (DataGridViewRow row in dataGridView1.Rows)
     {
         int index = (int)row.Cells["Index"].Value;
         //MessageBox.Show(index + ", " + Ports.Count);
         PortEntry port = Ports[index];
         bool      isComment = port.GetIsComment(), isValid = port.GetValid();
         foreach (DataGridViewCell cell in row.Cells)
         {
             if (isComment)
             {
                 cell.Style.BackColor = Color.LimeGreen;
             }
             else if (!isValid)
             {
                 cell.Style.BackColor = Color.Red;
             }
             else
             {
                 cell.Style.BackColor = Color.White;
             }
         }
     }
 }
Exemplo n.º 2
0
        public static bool ValidEntry(PortEntry entry)
        {
            if (entry.GetIsComment())
            {
                return(true);
            }
            bool b = true;

            if (!entry.IsValidData_size())
            {
                entry.SetReason("The port " + entry.GetName() + " has invalid data size: " + entry.GetData_size());
                entry.SetValid(false);
                b = false;
            }
            if (!entry.IsValidMemorySection())
            {
                entry.SetReason("The port " + entry.GetName() + " has invalid memory section: " + entry.GetMemory_section());
                entry.SetValid(false);
                b = false;
            }
            if (!entry.IsValidPriority())
            {
                entry.SetReason("The port " + entry.GetName() + " has Priority out of range [0, 99]");
                entry.SetValid(false);
                b = false;
            }
            if (!entry.IsValidR_W())
            {
                entry.SetReason("The port " + entry.GetName() + " has R_W different from 'R' or 'W': " + entry.GetR_W());
                entry.SetValid(false);
                b = false;
            }
            if (!entry.IsValidAnableEmerge())
            {
                entry.SetReason("The port " + entry.GetName() + " has anable emerge different from 'N' or 'Y': " + entry.GetAnable_emerge());
                entry.SetValid(false);
                b = false;
            }
            if (!entry.IsValidBank())
            {
                entry.SetReason("The port " + entry.GetName() + " has bank different from 'A' or 'B': " + entry.GetBank());
                entry.SetValid(false);
                b = false;
            }
            return(b);
        }
Exemplo n.º 3
0
        private void DataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            PortEntry pe = null;

            foreach (DataGridViewRow item in dataGridView1.SelectedRows)
            {
                pe = Ports[(int)item.Cells["Index"].Value];
                //MessageBox.Show(item.Cells["Index"].Value.ToString());
                break;
            }
            if (pe != null)
            {
                PortNameText.Text               = pe.GetName();
                CommentText.Text                = pe.GetComment();
                MemorySizeText.Text             = pe.GetMemorySize();
                ValidCheckBox.Checked           = pe.GetValidField();
                RelativeAddressCheckBox.Checked = pe.GetRelative_address();
                EmergencyCheckBox.Checked       = pe.GetAnable_emerge() == 'Y';
                DebugCheckBox.Checked           = pe.GetRead_bk_address();

                int index = R_WCombo.FindStringExact(pe.GetR_W().ToString());
                if (index == -1)
                {
                    index = 0;
                }
                R_WCombo.SelectedIndex = index;
                index = DataSizeBox.FindStringExact(pe.GetData_size().ToString());
                if (index == -1)
                {
                    index = 0;
                }
                DataSizeBox.SelectedIndex = index;
                index = TypeOpts.FindStringExact(pe.GetPortType().ToString());
                if (index == -1)
                {
                    index = 0;
                }
                TypeOpts.SelectedIndex = index;
                index = BankBox.FindStringExact(pe.GetBank().ToString());
                if (index == -1)
                {
                    index = 0;
                }
                BankBox.SelectedIndex = index;
                index = pe.GetPriority();
                if (index >= 100 || index <= 0)
                {
                    index = 99;
                }
                numericUpDown1.Value = index;
                index = pe.GetMemory_section();
                if (index < 0)
                {
                    index = 1;
                }
                numericUpDown2.Value = index;

                if (pe.GetIsComment())
                {
                    ErrorMessage.Text = "Message: ";
                }
                else if (!pe.GetValid())
                {
                    ErrorMessage.Text = "Message: " + pe.GetReason();
                }
                else
                {
                    ErrorMessage.Text = "Message: ";
                }
            }
        }
Exemplo n.º 4
0
        private void Load_Click(object sender, EventArgs e)
        {
            PortEntry       pe     = null;
            DataGridViewRow item_f = null;
            int             i      = -1;

            foreach (DataGridViewRow item in dataGridView1.SelectedRows)
            {
                i      = (int)item.Cells["Index"].Value;
                pe     = Ports[i];
                item_f = item;
                break;
            }
            if (pe == null)
            {
                MessageBox.Show("Please select a port in order to edit");
                return;
            }
            string name = PortNameText.Text;

            if (!pe.GetName().Equals(name))
            {
                MessageBox.Show("You can't edit a port's name");
                PortNameText.Text = pe.GetName();
                return;
            }
            string memory_size      = MemorySizeText.Text;
            bool   valid            = ValidCheckBox.Checked;
            char   r_w              = R_WCombo.SelectedItem.ToString()[0];
            bool   relative_address = RelativeAddressCheckBox.Checked;
            char   emergency_enable = 'N';

            if (EmergencyCheckBox.Checked)
            {
                emergency_enable = 'Y';
            }
            bool   debug_enable   = DebugCheckBox.Checked;
            int    priority       = (int)numericUpDown1.Value;
            int    memory_section = (int)numericUpDown2.Value;
            int    data_size      = int.Parse(DataSizeBox.SelectedItem.ToString());
            char   bank           = BankBox.SelectedItem.ToString()[0];
            string comment        = CommentText.Text;
            p_type type           = (p_type)Enum.Parse(typeof(p_type), TypeOpts.Text, true);

            if (i == -1)
            {
                MessageBox.Show("No such port " + name);
                InitFields();
                return;
            }
            if (pe.GetIsComment())
            {
                MessageBox.Show("This port is a comment and can't be edited");
                //InitFields();
                return;
            }
            pe.EditPort(valid, type, r_w, data_size, bank, memory_size, memory_section, relative_address, priority, emergency_enable, debug_enable, comment);
            OpenValidation();
            UpdateDataBase();
            EditCell(item_f, pe.GetTableEntry());
            //MessageBox.Show(pe.ToString());
            saved = false;
        }