Beispiel #1
0
        /// <summary>
        /// Show a dialog window with given message.
        /// </summary>
        /// <param name="message">The Syntax.Message to show</param>
        /// <returns>True if "Ok" was clicked, false otherwise</returns>
        public static bool?Show(Syntax.Message message)
        {
            string title = null;
            Image  img   = null;

            if (message is Syntax.ErrorMessage)
            {
                title = "KML Error";
                img   = Icons.Error;
            }
            else if (message is Syntax.WarningMessage)
            {
                title = "KML Error";
                img   = Icons.Warning;
            }
            DlgMessage dlg = new DlgMessage(message.ToString(true), title, img);

            return(dlg.ShowDialog());
        }
Beispiel #2
0
        /// <summary>
        /// Show a dialog with a summary of all given messages.
        /// </summary>
        /// <param name="messages">A list of Syntax.Messages to show</param>
        /// <returns>True if "Ok" was clicked, false otherwise</returns>
        public static bool?Show(List <Syntax.Message> messages)
        {
            string        title = null;
            Image         img   = null;
            StringBuilder str   = new StringBuilder();

            if (messages.Any(x => x is Syntax.ErrorMessage))
            {
                title = "KML Error";
                img   = Icons.Error;
            }
            else if (messages.Any(x => x is Syntax.WarningMessage))
            {
                title = "KML Warning";
                img   = Icons.Warning;
            }
            // TODO DlgMessage.Show(List<Syntax.Message>): Supposed to use messages instead of Syntax.Messages?
            if (Syntax.Messages.Count > 0)
            {
                str.Append(Syntax.Messages[0].ToString(true));
            }
            else
            {
                // Usually Show is called when either a warning/error
                // or a successful message is expected.
                // Should be avoided to have no feedback.
                string txt = "Sorry, nothing happened or no feedback from action!\n\n" +
                             "Please report your steps and any details on the KSP forum thread or via GitHub issue.";
                title = "KML Warning";
                img   = Icons.Warning;
                str.Append(txt);
            }
            for (int i = 1; i < Syntax.Messages.Count; i++)
            {
                str.AppendLine();
                str.AppendLine();
                str.Append(Syntax.Messages[i].ToString(true));
            }
            DlgMessage dlg = new DlgMessage(str.ToString(), title, img);

            return(dlg.ShowDialog());
        }
Beispiel #3
0
        /// <summary>
        /// Show a dialog window with given title, message and image.
        /// </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>
        /// <returns>True if "Ok" was clicked, false otherwise</returns>
        public static bool Show(string message, string title, Image image)
        {
            DlgMessage dlg = new DlgMessage(message, title, image);

            return(dlg.ShowDialog() == true);
        }