示例#1
0
        /* Public methods */
        public void CreateTab(EventHandler <TextChangedEventArgs> textChanged, FileSystemInfo fileInfo = null)
        {
            var index = SettingsManager.ApplicationSettings.ApplicationWindow.Theme;
            var tb    = new FastColoredTextBox
            {
                Dock        = DockStyle.Fill,
                LeftPadding = 5,
                BorderStyle = BorderStyle.None,
                DelayedTextChangedInterval = 500,
                BackColor = index == 1 ? Color.Black : Color.White,
                ForeColor = index == 1 ? Color.Silver : Color.Black,
                Zoom      = SettingsManager.ApplicationSettings.EditorWindow.Zoom
            };

            tb.TextChangedDelayed += textChanged;
            tb.ZoomChanged        += OnZoomChanged;
            var fileName = fileInfo != null ? fileInfo.FullName : null;
            var caption  = !string.IsNullOrEmpty(fileName) ? Path.GetFileName(fileName) : "Untitled.txt";
            var tab      = new FaTabStripItem(caption, tb)
            {
                Tag = fileName
            };

            if (fileInfo != null)
            {
                tb.OpenFile(fileInfo.FullName);
                tb.Language = LanguageControl.GetSyntaxHighLightAuto(Path.GetExtension(fileInfo.FullName));
                tb.OnSyntaxHighlight(new TextChangedEventArgs(tb.Range));
            }
            _tabStrip.AddTab(tab);
            _tabStrip.SelectedItem = tab;
            tb.Focus();
        }