private void btnDialogOk_Click(object sender, RoutedEventArgs e) { string pattern = "^[a-zA-Z0-9]+$"; string d = ((MainWindow)Application.Current.MainWindow).textBox.Text; string path = ConfigurationManager.ConnectionStrings["SqLiteBase"].ToString(); bool result = SqLiteFunc.GetImportedFileList(path).Contains(txtAnswer.Text); if (Regex.IsMatch(txtAnswer.Text, pattern, RegexOptions.IgnoreCase)) { if (result == false) { ((MainWindow)Application.Current.MainWindow).GetLoadSingle(txtAnswer.Text + FormatList.Text); } SqLiteFunc.Insert(path, txtAnswer.Text + FormatList.Text, d, FormatList.Text); ((MainWindow)Application.Current.MainWindow).Title = txtAnswer.Text + FormatList.Text; this.Close(); } else { MessageBox.Show("Invalid name"); } }
public void GetLoadList (string PathData) { foreach (string FileName in SqLiteFunc.GetImportedFileList(PathData)) { MenuItem fileMenuItem = new MenuItem(); fileMenuItem.Header = FileName; fileMenuItem.Click += openMenuItem_Click; ListFiles.Items.Add(fileMenuItem); } }