Пример #1
0
        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = treeViewTypes.SelectedNode;

            if (selectedNode != null)
            {
                ParserType type = selectedNode.Tag as ParserType;

                if (type != null)
                {
                    if (MessageBox.Show(this, String.Format(CANAPE.Properties.Resources.ParserDocumentControl_RemoveType, type.Name),
                                        String.Format(CANAPE.Properties.Resources.ParserDocumentControl_RemoveTypeCaption, type.Name),
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        RemoveTreeNode(type);
                        ParserType[] types = _document.Types.ToArray();

                        foreach (ParserType t in types)
                        {
                            if (t is SequenceParserType)
                            {
                                SequenceParserType seq        = t as SequenceParserType;
                                List <MemberEntry> removeList = new List <MemberEntry>();

                                foreach (MemberEntry entry in seq.Members)
                                {
                                    if (entry.BaseType.Uuid == type.Uuid)
                                    {
                                        removeList.Add(entry);
                                    }
                                }

                                foreach (MemberEntry ent in removeList)
                                {
                                    seq.RemoveMember(ent);
                                }
                            }
                            else if (t is StreamParserType)
                            {
                                StreamParserType parser = t as StreamParserType;

                                if (parser.BaseType.Uuid == type.Uuid)
                                {
                                    RemoveTreeNode(parser);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if ((_type != null) && (listViewEntries.SelectedItems.Count > 0))
            {
                listViewEntries.BeginUpdate();
                int index = listViewEntries.SelectedIndices[0];
                listViewEntries.SelectedIndices.Clear();

                ListViewItem item = listViewEntries.Items[index];
                _type.RemoveMember((MemberEntry)item.Tag);
                listViewEntries.Items.Remove(item);

                if (index < listViewEntries.Items.Count)
                {
                    listViewEntries.SelectedIndices.Add(index);
                }
                else if (listViewEntries.Items.Count > 0)
                {
                    listViewEntries.SelectedIndices.Add(listViewEntries.Items.Count - 1);
                }

                listViewEntries.EndUpdate();
            }
        }