private void button2_Click(object sender, EventArgs e) { //sync if (comboBox1.SelectedIndex == -1) { return; } int sel = comboBox1.SelectedIndex; ContactClass CC = (ContactClass)comboBox1.Items[comboBox1.SelectedIndex]; if (CC.Publickey.Trim() == "") { if (MessageBox.Show(line3,line4, MessageBoxButtons.YesNo) == DialogResult.Yes) { String result = DesClass.Decode(ServerAPIClass.ReadPubKey(DesClass.Encode(CC.Mail.ToLower().Trim()))); if (result.Trim() == "") { MessageBox.Show(line5); } 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(); comboBox1.SelectedIndex = sel; } } } else { FormSavePubkey SMF = new FormSavePubkey(CC.Publickey.Trim(), pass, DesClass.Encrypt(CC.Mail.ToLower().Trim(), pass)); SMF.Text = CC.Mail.ToLower().Trim() + " :: Contact Public key"; SMF.ShowDialog(); LoadContacts(); comboBox1.SelectedIndex = sel; } }
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(line1, line2, 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(line3, line4, 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(line5); } 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(line6); } else { FormSavePubkey SMF = new FormSavePubkey(CC.Publickey.Trim(), pass, DesClass.Encrypt(CC.Mail.ToLower().Trim(), pass)); SMF.Text = CC.Mail.ToLower().Trim()+" :: Contact Public key"; SMF.ShowDialog(); } } ListContact(); }