// On start-up public RobustWatcher() { InitializeComponent(); this.watchButton.Enabled = false; this.watchButton.Text = this.START; this.startToolstripButton.Enabled = false; this.stopToolstripButton.Enabled = false; this.fsCombobox.DataSource = EXTENSIONS; this.queryForm = new QueryForm(); this.queryForm.Visible = false; // check to see if the database exists. if not, // then make a new one. FileInfo db = new FileInfo(DB_PATH); if (db.Exists) { this.con = new SQLiteConnection("Data Source=" + DB_PATH + ";Version=3;New=false;Compress=true"); } else { this.con = new SQLiteConnection("Data Source=" + DB_PATH + ";Version=3;New=true;Compress=true"); } this.con.Open(); // create the table if it doesn't exist this.cmd = this.con.CreateCommand(); this.cmd.CommandText = "CREATE TABLE IF NOT EXISTS log (name varchar(300), path varchar(300), old_path varchar(300), change varchar(15), date varchar(30))"; this.cmd.ExecuteNonQuery(); }
// event handler that will bring up a form // that allows the user to query the database private void onQuery(object sender, EventArgs e) { if (!this.queryForm.Visible) { if (this.queryForm.IsDisposed) { this.queryForm = new QueryForm(); } this.queryForm.Visible = true; } }