Пример #1
0
        /// <summary>
        /// Add new tab.
        /// </summary>
        /// <param name="path"></param>
        private int AddTab(string path)
        {
            // load file
            var filename = path != null ? Path.GetFileName(path) : "unnamed.tech";
            var text = path != null ? System.IO.File.ReadAllText(path) : "// Unnamed file";

            // create new tab objects
            var tabSourcePage = new TabPageEx(path);
            var editor = new CodeEditor(Properties.Resources.keywordsXML, text);
            editor.UpdateUI += new EventHandler<UpdateUIEventArgs>(editor_UpdateUI);
            editor.MouseMove += new MouseEventHandler(editor_MouseMove);
            editor.ShowCallTip += new ShowTipEventHandler(editor_ShowCallTip);
            editor.CancleCallTip += new CancleTipEventHandler(editor_CancleCallTip);

            // tabSourcePage
            Theme.Apply(tabSourcePage);
            tabSourcePage.Controls.Add(editor);
            tabSourcePage.Location = new Point(4, 31);
            tabSourcePage.TabIndex = 0;
            tabSourcePage.Text = filename;
            tabSourcePage.AllowDrop = true;

            // add tab
            tabSource.Controls.Add(tabSourcePage);
            return tabSource.TabPages.Count - 1;
        }
Пример #2
0
 private static bool ApplyTo(TabPageEx c)
 {
     c.BackColor = BackColor;
     c.ForeColor = ForeColor;
     return true;
 }
Пример #3
0
        /// <summary>
        /// Save tab.
        /// </summary>
        /// <param name="tabPage"></param>
        /// <param name="newfile"></param>
        private void SaveTabPage(TabPageEx tabPage, bool newfile)
        {
            if (tabPage == null)
                return;

            var editor = (CodeEditor)tabPage.Controls[0];

            if (tabPage.FilePath == null || newfile)
            {
                var saveDlg = new SaveFileDialog();
                saveDlg.Filter = "Text Files (.tech)|*.tech|All Files (*.*)|*.*";
                saveDlg.FilterIndex = 1;

                var result = saveDlg.ShowDialog();
                if (result != DialogResult.OK)
                    return;

                tabPage.FilePath = saveDlg.FileName;
                tabPage.Text = Path.GetFileName(saveDlg.FileName);
            }

            System.IO.File.WriteAllText(tabPage.FilePath, editor.Text);
        }