Beispiel #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
                }
            }
        }
Beispiel #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);
                }
            }
        }
Beispiel #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
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Show a dialog window with given title and message.
        /// </summary>
        /// <param name="message">The message to show</param>
        /// <param name="title">The window title</param>
        /// <param name="image">The image for the window icon.</param>
        /// <param name="presetText">The preset text for the input</param>
        /// <param name="input">Out: Returns the input text if "Ok" was clicked, the preset text otherwise</param>
        /// <returns>True if "Ok" was clicked, false otherwise</returns>
        public static bool Show(string message, string title, Image image, string presetText, out string input)
        {
            DlgInput dlg    = new DlgInput(message, title, image, presetText);
            bool?    result = dlg.ShowDialog();

            if (result == true)
            {
                input = dlg.TextBoxInput.Text;
            }
            else
            {
                input = presetText;
            }
            return(result == true);
        }
Beispiel #5
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);
            }
        }