Пример #1
0
        private void DeleteNode(EsfNode node)
        {
            RecordArrayNode parent = node.Parent as RecordArrayNode;

            if (parent != null)
            {
                List <EsfNode> nodes = new List <EsfNode>(parent.Value);
                nodes.Remove(node);
                parent.Value = nodes;
            }
        }
Пример #2
0
        private void DeleteNode(EsfNode node)
        {
            RecordArrayNode recordArrayNode = node.Parent as RecordArrayNode;

            if (recordArrayNode != null)
            {
                List <EsfNode> list = new List <EsfNode>(recordArrayNode.Value);
                list.Remove(node);
                recordArrayNode.Value = list;
            }
        }
Пример #3
0
        private void MoveNode(EsfNode node)
        {
            RecordArrayNode recordArrayNode = node.Parent as RecordArrayNode;

            if (recordArrayNode == null)
            {
                return;
            }

            InputBox inputBox = new InputBox();

            inputBox.Input = "Move to index";
            InputBox inputBox2 = inputBox;

            if (inputBox2.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            int            result = -1;
            List <EsfNode> list   = new List <EsfNode>(recordArrayNode.Value);

            if (int.TryParse(inputBox2.Input, out result))
            {
                if (result >= 0 && result < list.Count)
                {
                    list.Remove(node);
                    list.Insert(result, node);
                    recordArrayNode.Value = list;
                }
                else
                {
                    MessageBox.Show($"Entry only valid between 0 and {list.Count - 1}", "Invalid input",
                                    MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            else
            {
                MessageBox.Show($"Enter index (between 0 and {list.Count - 1})", "Invalid input", MessageBoxButtons.OK,
                                MessageBoxIcon.Hand);
            }
        }
Пример #4
0
        public void TestRecordArrayNode()
        {
            List <EsfNode> records = new List <EsfNode>();

            for (int i = 0; i < 5; i++)
            {
                RecordEntryNode entry = new RecordEntryNode(codec)
                {
                    Name  = "test - " + i,
                    Value = createSomeNodes()
                };
                records.Add(entry);
            }
            RecordArrayNode array = new RecordArrayNode(codec, (byte)EsfType.RECORD_BLOCK)
            {
                Name  = "test",
                Value = records
            };

            VerifyEncodeDecode(array, false);
        }
Пример #5
0
        private void MoveNode(EsfNode node)
        {
            RecordArrayNode parent = node.Parent as RecordArrayNode;

            if (parent != null)
            {
                InputBox input = new InputBox {
                    Input = "Move to index"
                };
                if (input.ShowDialog() == DialogResult.OK)
                {
                    int            moveToIndex = -1;
                    List <EsfNode> nodes       = new List <EsfNode>(parent.Value);
                    if (int.TryParse(input.Input, out moveToIndex))
                    {
                        if (moveToIndex >= 0 && moveToIndex < nodes.Count)
                        {
                            nodes.Remove(node);
                            nodes.Insert(moveToIndex, node);
#if DEBUG
                            Console.Out.WriteLine("new list now {0}", string.Join(",", nodes));
#endif
                            parent.Value = nodes;
                        }
                        else
                        {
                            MessageBox.Show(string.Format("Entry only valid between 0 and {0}", nodes.Count - 1),
                                            "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show(string.Format("Enter index (between 0 and {0})", nodes.Count - 1),
                                        "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }