Ejemplo n.º 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
                }
            }
        }
Ejemplo n.º 2
0
        private void VesselFlagExchange_Click(object sender, RoutedEventArgs e)
        {
            KmlVessel vessel = ((sender as MenuItem).DataContext as KmlVessel);

            if (vessel.Flags.Count > 0)
            {
                string oldFlag    = vessel.Flags[0];
                string otherFlags = "";
                foreach (string flag in vessel.Flags)
                {
                    if (flag.ToLower() != oldFlag.ToLower())
                    {
                        otherFlags += "\n - " + flag;
                    }
                }
                if (otherFlags.Length > 0)
                {
                    otherFlags = "\nThese other flags will not be changed" + otherFlags;
                }
                string newFlag;
                if (DlgInput.Show("All parts with flag '" + oldFlag + "' will be changed." + otherFlags + "\n\nEnter the new flag:", "Change vessel flag", Icons.VesselFlag, oldFlag, out newFlag))
                {
                    vessel.FlagExchange(oldFlag, newFlag);
                }
            }
        }
Ejemplo n.º 3
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
                }
            }
        }
Ejemplo n.º 4
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);
            }
        }