diff options
| author | Aren <[email protected]> | 2017-04-28 17:00:15 +0200 |
|---|---|---|
| committer | Aren <[email protected]> | 2017-04-28 17:00:15 +0200 |
| commit | e1b3ecc57d42a961c780114e4e582a875e8f3b96 (patch) | |
| tree | 645856e3268d23e8eaa5853c3559bd3cf3f340e3 /ShiftOS.WinForms | |
| parent | 284216ac4c991481da4cac38a476b16c45712317 (diff) | |
| download | shiftos_thereturn-e1b3ecc57d42a961c780114e4e582a875e8f3b96.tar.gz shiftos_thereturn-e1b3ecc57d42a961c780114e4e582a875e8f3b96.tar.bz2 shiftos_thereturn-e1b3ecc57d42a961c780114e4e582a875e8f3b96.zip | |
Add new contact now works.
Diffstat (limited to 'ShiftOS.WinForms')
| -rw-r--r-- | ShiftOS.WinForms/Applications/AddressBook.cs | 49 |
1 files changed, 47 insertions, 2 deletions
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."); + } + }); } } |
