Пример #1
0
 public void RemoveEntry(EnumParserTypeEntry entry)
 {
     if (entry.Parent == this)
     {
         entry.Parent        = null;
         entry.DirtyChanged -= entry_DirtyChanged;
         _entries.Remove(entry);
         OnDirty();
     }
     else
     {
         throw new ArgumentException(CANAPE.Parser.Properties.Resources.SequenceParserType_NotOurMember);
     }
 }
Пример #2
0
        public void AddEntry(EnumParserTypeEntry entry)
        {
            if (FindEntry(entry.Name) != null)
            {
                throw new ArgumentException(String.Format(CANAPE.Parser.Properties.Resources.SequenceParserType_NameExists, entry.Name));
            }

            if (entry.Parent != null)
            {
                throw new ArgumentException(String.Format(CANAPE.Parser.Properties.Resources.SequenceParserType_MemberAlreadyParented, entry.Name));
            }

            entry.Parent        = this;
            entry.DirtyChanged += new EventHandler(entry_DirtyChanged);

            _entries.Add(entry);
            OnDirty();
        }
Пример #3
0
        public void AddEntry(EnumParserTypeEntry entry)
        {
            if (FindEntry(entry.Name) != null)
            {
                throw new ArgumentException(String.Format(CANAPE.Parser.Properties.Resources.SequenceParserType_NameExists, entry.Name));
            }

            if (entry.Parent != null)
            {
                throw new ArgumentException(String.Format(CANAPE.Parser.Properties.Resources.SequenceParserType_MemberAlreadyParented, entry.Name));
            }

            entry.Parent = this;
            entry.DirtyChanged += new EventHandler(entry_DirtyChanged);

            _entries.Add(entry);
            OnDirty();
        }
Пример #4
0
 public void RemoveEntry(EnumParserTypeEntry entry)
 {
     if (entry.Parent == this)
     {
         entry.Parent = null;
         entry.DirtyChanged -= entry_DirtyChanged;
         _entries.Remove(entry);
         OnDirty();
     }
     else
     {
         throw new ArgumentException(CANAPE.Parser.Properties.Resources.SequenceParserType_NotOurMember);
     }
 }
Пример #5
0
        private void addEntryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_enumType != null)
            {
                long value = 0;
                HashSet<long> values = new HashSet<long>();
                string name = GenerateName();

                if (name != null)
                {
                    foreach (EnumParserTypeEntry ent in _enumType.Entries)
                    {
                        if (!values.Contains(ent.Value))
                        {
                            values.Add(ent.Value);
                        }
                    }

                    if (!_enumType.IsFlags)
                    {
                        if (values.Count > 0)
                        {
                            value = values.Max() + 1;
                        }
                    }
                    else
                    {
                        // Find the next positive enum value for simplicity
                        for (value = 1; value < 0x4000000000000001L; value <<= 1)
                        {
                            if (!values.Contains(value))
                            {
                                break;
                            }
                        }
                    }

                    EnumParserTypeEntry entry = new EnumParserTypeEntry(name, value);
                    _enumType.AddEntry(entry);
                    AddEnumEntryToList(entry, true);
                }
            }
        }
Пример #6
0
        private void AddEnumEntryToList(EnumParserTypeEntry entry, bool editName)
        {
            ListViewItem item = listViewMembers.Items.Add(entry.Name);
            if (_enumType.IsFlags)
            {
                item.SubItems.Add(String.Format("0x{0:X}", entry.Value));
            }
            else
            {
                item.SubItems.Add(entry.Value.ToString());
            }
            item.Tag = entry;

            if (editName)
            {
                item.BeginEdit();
            }
        }