Пример #1
0
 private void UpdateListView(SignatureReference sig)
 {
     foreach (ListViewItem lvi in listView1.Items)
     {
         if (lvi.SubItems[0].Text == sig.Name && lvi.SubItems[1].Text == sig.Email)
         {
             lvi.SubItems[2].Text = sig.SigText;
             return;
         }
     }
 }
        public void ShowDialog(SignatureReference sigRef)
        {
            txtName.Text  = sigRef.Name;
            txtEmail.Text = sigRef.Email;
            if (sigRef.SigText != null && sigRef.SigText.Length > 50)
            {
                txtSigText.Text = sigRef.SigText.Substring(0, 50) + "..";
            }

            txtName.Enabled  = false;
            txtEmail.Enabled = false;
        }
Пример #3
0
        private ListViewItem CreateListViewItem(SignatureReference sigRef)
        {
            ListViewItem lvi = new ListViewItem();

            lvi.SubItems.Add(sigRef.Name);
            lvi.SubItems.Add(sigRef.Email);
            if (sigRef.SigText != null && sigRef.SigText.Length > 50)
            {
                lvi.SubItems.Add(sigRef.SigText.Substring(0, 50) + "...");
            }
            else
            {
                lvi.SubItems.Add(" ");
            }

            return(lvi);
        }
Пример #4
0
        public DialogResult ShowDialog(SignatureDatabase sigDb, string name, string email, string reason)
        {
            _sigDb = sigDb;
            if (_sigDb == null)
            {
                MessageBox.Show("Signature database is empty");
                return(this.ShowDialog());
            }
            foreach (SignatureReference sigRef in _sigDb.List)
            {
                cboName.Items.Add(sigRef.Name);
            }
            if (cboName.Items.Count > 0)
            {
                cboName.SelectedIndex = 0;
                lblEmail.Text         = _sigDb.List[cboName.SelectedIndex].Email;
            }

            if (name != null && email != null)
            {
                for (int i = 0; i < _sigDb.List.Length; i++)
                {
                    SignatureReference sigRef = _sigDb.List[i];
                    if (sigRef.Name == name && sigRef.Email == email)
                    {
                        cboName.SelectedIndex = i;
                        lblEmail.Text         = email;
                    }
                }
            }

            if (reason != null)
            {
                txtReason.Text = reason;
            }

            return(this.ShowDialog());
        }
Пример #5
0
 private void listView1_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back)
     {
         if (listView1.SelectedItems.Count > 0)
         {
             int selIndex = listView1.SelectedItems[0].Index;
             sigRefList.RemoveAt(selIndex);
             listView1.Items.RemoveAt(selIndex);
             listView1.Refresh();
         }
     }
     else if (e.KeyCode == Keys.Enter)
     {
         if (listView1.SelectedItems.Count > 0)
         {
             SignatureReference     sigRef    = sigRefList[listView1.SelectedItems[0].Index];
             SignatureCollectorForm collector = new SignatureCollectorForm();
             collector.SignatureExistDelegate = CheckSignatureExist;
             collector.SaveSignatureDelegate  = SaveSignature;
             collector.ShowDialog(sigRef);
         }
     }
 }
Пример #6
0
        private bool SaveSignature(string name, string email, string sigText)
        {
            foreach (SignatureReference sigRef in sigRefList)
            {
                if (sigRef.Name == name && sigRef.Email == email)
                {
                    sigRef.SigText = sigText;
                    if (SerializeSigRefListToFile())
                    {
                        UpdateListView(sigRef);
                        listView1.Refresh();
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            SignatureReference sig = new SignatureReference();

            sig.Name    = name;
            sig.Email   = email;
            sig.SigText = sigText;
            sigRefList.Add(sig);
            if (SerializeSigRefListToFile())
            {
                InsertIntoListView(sig);
                listView1.Refresh();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
 private void InsertIntoListView(SignatureReference sig)
 {
     listView1.Items.Add(CreateListViewItem(sig));
 }