コード例 #1
0
        private void UpdateTable(RegisterEntry entry)
        {
            TreeGridNode node;
            string       group = entry.GetGroup();

            object[] ent = entry.GetTableEntry();
            bool     b, isField = entry.GetRegType() == RegisterEntry.type_field.FIELD;

            treeGridView1.Rows.AddRange();
            foreach (TreeGridNode group_node in treeGridView1.Nodes)
            {
                if (group_node.Cells["Registers"].Value.ToString().Equals(group))
                {
                    if (!isField)
                    {
                        node = group_node.Nodes.Add(ent);
                        group_node.Expand();
                    }
                    else
                    {
                        TreeGridNode tmp = null;
                        group_node.Expand();
                        foreach (TreeGridNode reg in group_node.Nodes)
                        {
                            b = reg.GetIsExpanded();
                            reg.Expand();
                            if ((int)reg.Cells["IndexColumn"].Value == entry.GetIndex())
                            {
                                tmp = reg;
                                break;
                            }
                            else if (!b)
                            {
                                reg.Collapse();
                            }
                        }
                        if (tmp != null)
                        {
                            node = tmp.Nodes.Add(ent);
                            //group_node.Expand();
                            tmp.Expand();
                        }
                        break;
                    }
                }
            }
        }
コード例 #2
0
        private void AddEntryToTable(RegisterEntry entry, bool open = false)
        {
            bool isField = entry.GetRegType() == RegisterEntry.type_field.FIELD;

            if (isField)
            {
                RegList[entry.GetIndex()].AddField(entry);
            }
            else
            {
                entry.SetIndex(RegList.Count); // only outer index
                RegList.Add(entry);
            }
            if (!open)
            {
                UpdateDataBase();
            }
            UpdateTable(entry);
        }
コード例 #3
0
        /* Edit a register */
        private void Load_Click(object sender, EventArgs e)
        {
            RegisterEntry re   = null;
            TreeGridNode  node = null;

            foreach (TreeGridNode item in treeGridView1.SelectedRows)
            {
                try
                {
                    re = RegList[(int)item.Cells["IndexColumn"].Value];
                    int index = (int)item.Cells["SecondaryIndexColumn"].Value;
                    if (index != -1)
                    {
                        re = re.GetFields()[index];
                    }
                    node = item;
                    break;
                }
                catch (NullReferenceException)
                {
                    //do nothing for groups
                    return;
                }
            }
            if (re == null)
            {
                MessageBox.Show("Please select a register in order to edit");
                return;
            }
            string name = RegNameText.Text;

            if (!re.GetName().Equals(name))
            {
                MessageBox.Show("You can't edit a register's name");
                RegNameText.Text = re.GetName();
                return;
            }
            string        mais    = MAISOpts.Text;
            string        lsb     = LSBOpts.Text;
            string        msb     = MSBOpts.Text;
            string        type    = TypeOpts.Text;
            string        fpga    = FPGAOpts.Text;
            string        init    = InitText.Text;
            string        comment = CommentText.Text;
            string        group   = RegGroupOpts.Text;
            RegisterEntry entry;
            int           i = re.GetIndex(), j = re.GetSecondaryIndex();

            if (i == -1)
            {
                MessageBox.Show("No such register " + name);
                InitFields();
                return;
            }
            entry = RegList[i];
            if (j != -1)
            {
                entry = entry.GetFields()[j];
            }
            if (entry.GetIsComment())
            {
                MessageBox.Show("This register is a comment and can't be edited");
                //InitFields();
                return;
            }
            Enum.TryParse(type, out RegisterEntry.type_field t);
            RegisterEntry.type_field s = entry.GetRegType();
            if ((s == RegisterEntry.type_field.FIELD && t != RegisterEntry.type_field.FIELD) ||
                s != RegisterEntry.type_field.FIELD && t == RegisterEntry.type_field.FIELD)
            {
                MessageBox.Show("Can't edit a field or create one using Load");
                TypeOpts.SelectedIndex = (int)s;
                return;
            }
            if (!RegisterEntry.IsValidLsbMsb(msb, lsb))
            {
                MessageBox.Show("Can't edit an entry to have LSB > MSB");
                //InitFields();
                return;
            }
            Enum.TryParse(fpga, out RegisterEntry.fpga_field r);
            entry.EditRegister(mais, lsb, msb, t, r, init, comment, group);
            OpenValidation();
            UpdateDataBase();
            EditCell(node, entry.GetTableEntry());
        }