Ejemplo n.º 1
0
        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Application.StartupPath;
            openFileDialog.Filter           = "Yml (*.yml)|*.yml|Yaml (*.yaml)|*.yaml|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                //Open a new TabPage.
                FileInfo fi  = new FileInfo(openFileDialog.FileName);
                int      idx = tabWindow.TabPages.IndexOfKey(fi.Name);
                if (idx >= 0)
                {
                    tabWindow.SelectedTab = tabWindow.TabPages[idx];
                }
                else
                {
                    tabWindow.SelectedTab             = NewTabPage(fi.Name);
                    tabWindow.SelectedTab.ToolTipText = fi.FullName;
                }

                Control[]    ctrs     = tabWindow.SelectedTab.Controls.Find("RegexTabPage", false);
                RegexTabPage regexTab = (RegexTabPage)ctrs.First();
                regexTab.LoadRules(openFileDialog.FileName);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        private TabPage NewTabPage(string pageText)
        {
            tabWindow.SuspendLayout();
            tabWindow.TabPages.Add(pageText, pageText);
            TabPage      page = tabWindow.TabPages[pageText];
            RegexTabPage r    = new RegexTabPage();

            r.Dock    = DockStyle.Fill;
            r.TabStop = false;
            r.Name    = "RegexTabPage";

            KeyDown        += r.FrmRegex_KeyDown;
            btnMatch.Click += r.btnMatch_Click;

            page.Controls.Add(r);
            tabWindow.ResumeLayout();
            return(page);
        }