示例#1
0
        private void newToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            // create a new signature form
            using (frmSignature sig = new frmSignature())
            {
                // set the id of the signature
                sig.numId.Text = Signatures.NextId().ToString();

                // if the signature dialog was closed okay
                if (sig.ShowDialog() == DialogResult.OK)
                {
                    // add the new signature
                    var s = new Signature()
                    {
                        Id          = Convert.ToInt32(sig.numId.Text),
                        Definition  = sig.txtDefinition.Text,
                        Description = sig.txtDescription.Text,
                        DateFound   = sig.txtDate.Text
                    };

                    // update the sig pattern
                    s.SetPatternBytes(sig.txtPattern.Text);

                    // add the signature to the controller
                    Signatures.AddOne(s);

                    // update listview item
                    this.lstSignatures.Items.Add(new ListViewItem(new string[] { s.Id.ToString(), s.Definition, s.GetPatternHex(), s.Description, s.DateFound }));

                    // update sig count
                    updateStats();
                }
            }
        }
示例#2
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // If items are selected
            if (lstSignatures.SelectedItems.Count > 0)
            {
                // Loop throug all selected items
                for (int i = 0; i < lstSignatures.SelectedItems.Count; i++)
                {
                    // create a new form sig for each...
                    using (frmSignature sig = new frmSignature())
                    {
                        // get the signature for the item
                        var s = Signatures.GetById(Convert.ToInt32(lstSignatures.SelectedItems[i].SubItems[0].Text));

                        // update the form information
                        sig.numId.Text          = s.Id.ToString();
                        sig.txtDate.Text        = s.DateFound;
                        sig.txtDefinition.Text  = s.Definition;
                        sig.txtDescription.Text = s.Description;
                        sig.txtPattern.Text     = s.GetPatternHex();

                        // if the dialog is closed and okay... we need to update the signature...
                        if (sig.ShowDialog() == DialogResult.OK)
                        {
                            // update all fields
                            s.SetPatternBytes(sig.txtPattern.Text);
                            s.Description = sig.txtDescription.Text;
                            s.Definition  = sig.txtDefinition.Text;

                            // try to update the signature
                            if (Signatures.UpdateOne(s.Id, s))
                            {
                                //update list view
                                lstSignatures.SelectedItems[i].SubItems[1].Text = s.Definition;
                                lstSignatures.SelectedItems[i].SubItems[2].Text = s.GetPatternHex();
                                lstSignatures.SelectedItems[i].SubItems[3].Text = s.Description;

                                updateStats();
                            }
                            else
                            {
                                MessageBox.Show("Unable to update the signature...");
                            }
                        }
                    }
                }
            }
        }