Add new contact now works.
This commit is contained in:
parent
284216ac4c
commit
e1b3ecc57d
1 changed files with 47 additions and 2 deletions
|
@ -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.");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue