private void button2_Click(object sender, EventArgs e) { //sync if (comboBox1.SelectedIndex == -1) { return; } ContactClass CC = (ContactClass)comboBox1.Items[comboBox1.SelectedIndex]; if (CC.Publickey.Trim() == "") { if (MessageBox.Show("No publickey. Sync pubkey?", "Sync pubkey", MessageBoxButtons.YesNo) == DialogResult.Yes) { String result = DesClass.Decode(ServerAPIClass.ReadPubKey(DesClass.Encode(CC.Mail.ToLower().Trim()))); if (result.Trim() == "") { MessageBox.Show("ERROR"); } else { String pubkey = "<RSAKeyValue><Modulus>" + result + "</Exponent></RSAKeyValue>"; DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); sql.SQLTransact("UPDATE MyContacts SET publickey='" + DesClass.Encrypt(pubkey, pass) + "' where name='" + DesClass.Encrypt(CC.Mail.ToLower().Trim(), pass) + "'"); MessageBox.Show("OK"); LoadContacts(); } } } else { MessageBox.Show("<RSAKeyValue><Modulus>" + CC.Publickey.Trim() + "</Exponent></RSAKeyValue>"); } }
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (listBox1.SelectedIndex == -1) { return; } if (e.ClickedItem == contextMenuStrip1.Items[0]) { //edit ContactClass CC = (ContactClass)listBox1.Items[listBox1.SelectedIndex]; String contact = Microsoft.VisualBasic.Interaction.InputBox("Input Contact", "Contact", CC.Mail, this.Location.X + 100, this.Location.Y + 100); if (contact.Trim() == "") { return; } DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); sql.SQLTransact("UPDATE MyContacts SET name='" + DesClass.Encrypt(contact.ToLower().Trim(), pass) + "' where name='" + DesClass.Encrypt(CC.Mail.ToLower().Trim(), pass) + "'"); } if (e.ClickedItem == contextMenuStrip1.Items[1]) { //del if (MessageBox.Show("Delete the selected contact?", "Delete contact", MessageBoxButtons.YesNo) == DialogResult.Yes) { ContactClass CC = (ContactClass)listBox1.Items[listBox1.SelectedIndex]; DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); sql.SQLTransact("Delete from MyContacts where name='" + DesClass.Encrypt(CC.Mail.ToLower().Trim(), pass) + "'"); } } if (e.ClickedItem == contextMenuStrip1.Items[4]) { //sync ContactClass CC = (ContactClass)listBox1.Items[listBox1.SelectedIndex]; String result = DesClass.Decode(ServerAPIClass.ReadPubKey(DesClass.Encode(CC.Mail.ToLower().Trim()))); if (result.Trim() == "") { MessageBox.Show("ERROR"); } else { String pubkey = "<RSAKeyValue><Modulus>" + result + "</Exponent></RSAKeyValue>"; //MessageBox.Show(pubkey); DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); sql.SQLTransact("UPDATE MyContacts SET publickey='" + DesClass.Encrypt(pubkey, pass) + "' where name='" + DesClass.Encrypt(CC.Mail.ToLower().Trim(), pass) + "'"); MessageBox.Show("OK"); } } if (e.ClickedItem == contextMenuStrip1.Items[2]) { //create cryptomail ContactClass CC = (ContactClass)listBox1.Items[listBox1.SelectedIndex]; SendMailForm SMF = new SendMailForm(pass, CC.Mail.Trim(), ""); SMF.ShowDialog(); } if (e.ClickedItem == contextMenuStrip1.Items[3]) { //show publickey ContactClass CC = (ContactClass)listBox1.Items[listBox1.SelectedIndex]; if (CC.Publickey.Trim() == "") { MessageBox.Show("No publickey"); } else { MessageBox.Show("<RSAKeyValue><Modulus>" + CC.Publickey.Trim() + "</Exponent></RSAKeyValue>"); } } ListContact(); }