Example #1
0
        private void AddAttrib(KmlNode toItem, KmlAttrib beforeItem)
        {
            KmlNode node = toItem;
            string  input;
            string  preset = "";
            bool    loop   = true;

            while (loop && DlgInput.Show("Enter the name for the new attribute:", "NEW attribute", Icons.Add, preset, out input))
            {
                string attrib = input;
                if (attrib.Length > 0 && attrib.IndexOf('=') < 0)
                {
                    attrib = attrib + "=";
                }
                KmlItem item = KmlItem.CreateItem(attrib);
                if (item is KmlAttrib && beforeItem != null)
                {
                    node.InsertBefore(beforeItem, (KmlAttrib)item);
                    loop = false;
                    // View will be refreshed in AttribChanged event
                }
                else if (item is KmlAttrib)
                {
                    node.Add((KmlAttrib)item);
                    loop = false;
                    // View will be refreshed in AttribChanged event
                }
                else
                {
                    DlgMessage.Show("Attribute name is not allowed to be empty or contain following characters: {}", "NEW attribute", Icons.Warning);
                    preset = input;
                    // Input will pop up again while loop == true
                }
            }
        }
Example #2
0
        private void AddChildNode(KmlNode toItem, KmlNode beforeItem)
        {
            KmlNode node = toItem;
            string  input;
            string  preset = "";
            bool    loop   = true;

            while (loop && DlgInput.Show("Enter the tag for the new node:", "NEW node", Icons.Add, preset, out input))
            {
                KmlItem item = KmlItem.CreateItem(input);
                if (item is KmlNode && beforeItem != null)
                {
                    node.InsertBefore(beforeItem, (KmlNode)item);
                    loop = false;
                    // View will be refreshed in ChildrenChanged event
                }
                else if (item is KmlNode)
                {
                    node.Add((KmlNode)item);
                    loop = false;
                    // View will be refreshed in ChildrenChanged event
                }
                else
                {
                    DlgMessage.Show("Tag is not allowed to be empty or contain following characters: ={}", "NEW node", Icons.Warning);
                    preset = input;
                    // Input will pop up again while loop == true
                }
            }
        }
Example #3
0
        private void AttribInsertBefore_Click(object sender, RoutedEventArgs e)
        {
            // TODO GuiTreeAttrib.AttribInsertBefore_Click(): Almost same code as private GuiTreeNode.AddAttrib()

            KmlAttrib beforeItem = ((sender as MenuItem).DataContext as KmlAttrib);
            KmlNode   node       = beforeItem.Parent;

            if (node != null)
            {
                string input;
                string preset = "";
                bool   loop   = true;
                while (loop && DlgInput.Show("Enter the name for the new attribute:", "NEW attribute", Icons.Add, preset, out input))
                {
                    string attrib = input;
                    if (attrib.Length > 0 && attrib.IndexOf('=') < 0)
                    {
                        attrib = attrib + "=";
                    }
                    KmlItem item = KmlItem.CreateItem(attrib);
                    if (item is KmlAttrib && beforeItem != null)
                    {
                        node.InsertBefore(beforeItem, (KmlAttrib)item);
                        loop = false;
                        // View will be refreshed in AttribChanged event
                    }
                    else if (item is KmlAttrib)
                    {
                        node.Add((KmlAttrib)item);
                        loop = false;
                        // View will be refreshed in AttribChanged event
                    }
                    else
                    {
                        DlgMessage.Show("Attribute name is not allowed to be empty or contain following characters: {}", "NEW attribute", Icons.Warning);
                        preset = input;
                        // Input will pop up again while loop == true
                    }
                }
            }
            else
            {
                DlgMessage.Show("Can not insert, attribute has no parent", "NEW attribute", Icons.Warning);
            }
        }