Exemplo n.º 1
0
        /// <summary>
        /// Create a tab page for passed tabFile.
        /// </summary>
        /// <param name="tabFile"></param>
        private void CreateTab(TabFile tabFile)
        {
            Log.Information("Creating tab for tabFile: " + tabFile);

            var tabPage = new TabPage(tabFile.TabName)
            {
                Width = 100
            };

            var textBox = new MainTextBox {
                Name = "TextBox"
            };

            var host = new ElementHost
            {
                Name  = "Host",
                Dock  = DockStyle.Fill,
                Child = textBox
            };

            tabPage.ToolTipText = tabFile.File;
            tabPage.Name        = tabFile.Name;

            textBox.PreviewKeyDown    += MainTextBox1_PreviewKeyDown;
            textBox.PreviewKeyUp      += MainTextBox1_PreviewKeyUp;
            textBox.PreviewMouseWheel += MainTextBox1_MouseWheel;
            textBox.AllowDrop          = true;
            textBox.Drop      += MainTextBox1_Drop;
            textBox.DragEnter += MainTextBox1_DragEnter;
            textBox.SetDataFile(tabFile.File, _colorRules, Logger, tabPage.Name);

            tabPage.Controls.Add(host);
            tabControl1.TabPages.Add(tabPage);
            textBox.SetSize(host.Width, host.Height);
            textBox.ScrollToEnd();

            _files.Add(tabFile);

            tabControl1.SelectTab(tabPage);
        }