/// <summary> /// Creates a new message box with the specified name. If null is specified /// in the message name then the message box is not managed by the Manager and /// will be disposed automatically after a call to Show() /// </summary> /// <param name="name">The name of the message box</param> /// <returns>A new message box</returns> public static MessageBoxEx CreateMessageBox(string name) { if(name != null && _messageBoxes.ContainsKey(name)) { string err = string.Format("A MessageBox with the name {0} already exists.",name); throw new ArgumentException(err,"name"); } MessageBoxEx msgBox = new MessageBoxEx(); msgBox.Name = name; if(msgBox.Name != null) { _messageBoxes[name] = msgBox; } return msgBox; }
/// <summary> /// Gets the saved response for the specified message box /// </summary> /// <param name="msgBox">The message box whose saved response is to be retrieved</param> /// <returns>The saved response if exists, null otherwise</returns> internal static string GetSavedResponse(MessageBoxEx msgBox) { string msgBoxName = msgBox.Name; if(msgBoxName == null) { return null; } if(_savedResponses.ContainsKey(msgBoxName)) { return _savedResponses[msgBox.Name].ToString(); } else { return null; } }
/// <summary> /// Set the saved response for the specified message box /// </summary> /// <param name="msgBox">The message box whose response is to be set</param> /// <param name="response">The response to save for the message box</param> internal static void SetSavedResponse(MessageBoxEx msgBox, string response) { if(msgBox.Name == null) return; _savedResponses[msgBox.Name] = response; }