private void save_Click(object sender, EventArgs e) { string filepath = tabWindow.SelectedTab.ToolTipText; if (File.Exists(filepath)) { Control[] ctrs = tabWindow.SelectedTab.Controls.Find("RegexTabPage", false); RegexTabPage regexTab = (RegexTabPage)ctrs.First(); regexTab.SaveRules(filepath); ShowMessage("Replace Rule Saved In: " + filepath); } else { SaveAsToolStripMenuItem_Click(sender, e); } }
private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Application.StartupPath; saveFileDialog.Filter = "Yml (*.yml)|*.yml|Yaml (*.yaml)|*.yaml|All Files (*.*)|*.*"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { Control[] ctrs = tabWindow.SelectedTab.Controls.Find("RegexTabPage", false); RegexTabPage regexTab = (RegexTabPage)ctrs.First(); regexTab.SaveRules(saveFileDialog.FileName); FileInfo fi = new FileInfo(saveFileDialog.FileName); tabWindow.SelectedTab.Text = fi.Name; tabWindow.SelectedTab.ToolTipText = fi.FullName; } }