diff --git a/ShiftOS.WinForms/Applications/AddressBook.cs b/ShiftOS.WinForms/Applications/AddressBook.cs index c75247f..0347669 100644 --- a/ShiftOS.WinForms/Applications/AddressBook.cs +++ b/ShiftOS.WinForms/Applications/AddressBook.cs @@ -25,13 +25,13 @@ namespace ShiftOS.WinForms.Applications } string data_dir = Paths.GetPath("data") + "/address_book"; - public void OnLoad() { if (!DirectoryExists(data_dir)) CreateDirectory(data_dir); - + tvcontacts.Nodes.RemoveByKey("userdefined"); var userDefined = new TreeNode(); + userDefined.Name = "userdefined"; userDefined.Text = "User-defined"; foreach(var f in GetFiles(data_dir)) { @@ -64,6 +64,51 @@ namespace ShiftOS.WinForms.Applications private void addContactToolStripMenuItem_Click(object sender, EventArgs e) { + Infobox.PromptText("Add Contact", "What is the contact's name?", delegate(string name) { + if (name != "") + { + Infobox.PromptText("Add Contact", "What is the user's username?", delegate (string uname) + { + if (uname != "") + { + Infobox.PromptText("Add Contact", "What is the user's systemname?", delegate(string sysname) + { + if (sysname != "") + { + Infobox.PromptText("Add Contact", "How would you describe this user?", delegate (string desc) + { + if (desc != "") + { + Contact contact= new Contact(); + contact.Name = name; + contact.UserName = uname; + contact.SystemName = sysname; + contact.Relationship = ContactRelationship.Acquaintance; + contact.IsStoryCharacter = false; + contact.Description = desc; + var contactJson = JsonConvert.SerializeObject(contact); + WriteAllText(data_dir + "/" + name, contactJson); + OnLoad(); // Reload to show changes + } else + { + Infobox.Show("Add Contact", "Description cannot be empty."); + } + }); + } else + { + Infobox.Show("Add Contact", "System name cannot be empty."); + } + }); + } else + { + Infobox.Show("Add Contact", "Username cannot be empty."); + } + }); + } else + { + Infobox.Show("Add Contact", "Name cannot be empty."); + } + }); } }