private void ParseMethod(TreeNode n , string fileName , string password) { DBParse db = new DBParse(); db.ParseCollection(n, fileName, password); Tuple <bool, string, string> data = n.Tag as Tuple <bool, string, string>; n.Tag = new Tuple <bool, string, string>(true, data.Item2, data.Item3); SlStatus.Text = "Complete"; }
private void BtnOpenDatabase_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog { AutoUpgradeEnabled = true, CheckFileExists = true, CheckPathExists = true, DereferenceLinks = true, Multiselect = false, ShowHelp = false, ShowReadOnly = false, SupportMultiDottedExtensions = true, Title = "Please choose a LiteDB to open" }) { DialogResult result = ofd.ShowDialog(this); if ((result == DialogResult.OK) || (result == DialogResult.Yes)) { string pwd = string.Empty; if (!ValidDB(ofd.FileName)) { MessageBox.Show("This does not appear to be a valid LiteDB database."); return; } if (NeedPassword(ofd.FileName)) { using (FrmPassword pwdDlg = new FrmPassword()) { pwdDlg.ShowDialog(this); pwd = pwdDlg.TbPassword.Text; } if (!PasswordCorrect(ofd.FileName, pwd)) { MessageBox.Show("It appears that this password is incorrect."); return; } DBParse db = new DBParse(); TvDB.Nodes.Clear(); db.GetCollections(ofd.FileName, pwd).ForEach(n => TvDB.Nodes.Add(n)); TvDB.Nodes.OfType <TreeNode>().ToList().ForEach(n => { TreeNode placeHolder = new TreeNode("Placeholder"); n.Nodes.Add(placeHolder); Tuple <bool, string, string> data = new Tuple <bool, string, string>(false, ofd.FileName, pwd); n.Tag = data; }); } } } }