Ejemplo n.º 1
0
 private void TabControl1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (tabControl1.SelectedTab == null) return;
     if (!tabControl1.SelectedTab.Controls.ContainsKey("splitContainer1")) return;
     SplitContainer splitContainer1 = (SplitContainer)tabControl1.SelectedTab.Controls["SplitContainer1"];
     if (splitContainer1.Panel1.Controls.ContainsKey("RichCodeBox1"))
         richCodeBox1 = (RichCodeBox)splitContainer1.Panel1.Controls["RichCodeBox1"];
     if (splitContainer1.Panel2.Controls.ContainsKey("richTextBox2"))
         richTextBox2 = (RichTextBox)splitContainer1.Panel2.Controls["richTextBox2"];
     this.Text = string.Format("NSP Editor - [{0}]", Path.GetFileName(tabControl1.SelectedTab.Tag.ToString()));
     richCodeBox1.Focus();
 }
Ejemplo n.º 2
0
        private void newTabPage()
        {
            TabPage tabPage1 = new TabPage();
            SplitContainer splitContainer1 = new SplitContainer();
            RichTextBox richTextBox2 = new RichTextBox();
            RichCodeBox richCodeBox1 = new RichCodeBox();
            int t = 64;

            //tabControl1.SuspendLayout();
            //((System.ComponentModel.ISupportInitialize)(splitContainer1)).BeginInit();
            //splitContainer1.Panel1.SuspendLayout();
            //splitContainer1.Panel2.SuspendLayout();
            //splitContainer1.SuspendLayout();
            //tabPage1.SuspendLayout();

            richCodeBox1.KeyUp += richCodeBox1_KeyUp;
            richCodeBox1.MouseClick += richCodeBox1_MouseClick;
            richCodeBox1.DragDrop += richCodeBox1_DragDrop;
            richCodeBox1.KeyPress += richCodeBox1_KeyPress;
            //richCodeBox1.KeyDown += richCodeBox1_KeyDown;

            // richTextBox2
            richTextBox2.AcceptsTab = true;
            richTextBox2.Dock = System.Windows.Forms.DockStyle.Fill;
            richTextBox2.Location = new System.Drawing.Point(0, 0);
            richTextBox2.Name = "richTextBox2";
            richTextBox2.ReadOnly = true;
            //			richTextBox2.Size = new System.Drawing.Size(795, 75);
            //richTextBox2.TabIndex = 1;
            richTextBox2.TabStop = false;
            richTextBox2.Text = "";
            richTextBox2.WordWrap = false;

            richTextBox2.SelectionTabs = new int[] { t * 1, t * 2, t * 3, t * 4, t * 5, t * 6 };
            richTextBox2.BackColor = Color.Black;
            richTextBox2.ForeColor = Color.LightGray;
            richTextBox2.Font = new Font("Courier New", 10, FontStyle.Regular);
            richTextBox2.Text = "";

            CB = new ComboBox();
            CB.DropDownStyle = ComboBoxStyle.DropDown;
            CB.AutoCompleteSource = AutoCompleteSource.ListItems;
            CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            CB.FlatStyle = FlatStyle.Flat;
            CB.Font = new Font("Courier New", 10, FontStyle.Regular);
            CB.ForeColor = Color.DarkCyan;
            CB.BackColor = Color.FromArgb(0xCC, 0xFF, 0xFF);
            CB.Sorted = false;
            CB.Visible = false;
            CB.LostFocus += CB_LostFocus;
            CB.KeyDown += CB_KeyDown;
            CB.KeyPress += CB_KeyPress;
            CB.TextChanged += CB_TextChanged;
            splitContainer1.Panel1.Controls.Add(CB);

            // splitContainer1
            splitContainer1.Dock = DockStyle.Fill;
            splitContainer1.Location = new Point(3, 3);
            splitContainer1.Name = "splitContainer1";
            splitContainer1.Orientation = Orientation.Horizontal;
            splitContainer1.Panel1.Controls.Add(richCodeBox1);
            splitContainer1.Panel2.Controls.Add(richTextBox2);
            splitContainer1.FixedPanel = FixedPanel.Panel2;
            //splitContainer1.Size = new System.Drawing.Size(795, 443);
            //splitContainer1.SplitterDistance = 364;
            splitContainer1.Panel2MinSize = 150;
            //splitContainer1.TabIndex = 2;
            splitContainer1.TabStop = false;

            // tabPage1
            tabPage1.Name = "TabPage " + (tabControl1.TabCount + 1).ToString();
            //tabPage1.Text = "Untitled " + (tabControl1.TabCount + 1).ToString();
            tabPage1.Text = "";
            tabPage1.Tag = "Untitled";
            tabPage1.Controls.Add(splitContainer1);
            tabPage1.Location = new Point(4, 22);
            //			tabPage1.Name = "tabPage1";
            tabPage1.Padding = new Padding(0);
            //			tabPage1.Size = new System.Drawing.Size(801, 449);
            //tabPage1.TabIndex = 0;
            tabPage1.TabStop = false;
            tabPage1.UseVisualStyleBackColor = true;

            tabPage1.ToolTipText = tabPage1.Tag.ToString();

            //tabControl1.TabPages.Add(tabPage1);
            tabControl1.Controls.Add(tabPage1);
            tabControl1.SelectedTab = tabPage1;
            tabControl1.ShowToolTips = true;

            //splitContainer1.Panel1.ResumeLayout(false);
            //splitContainer1.Panel2.ResumeLayout(false);
            //((System.ComponentModel.ISupportInitialize)(splitContainer1)).EndInit();
            //splitContainer1.ResumeLayout(false);
            //tabPage1.ResumeLayout(false);

            TabControl1_SelectedIndexChanged(null, null);
            richCodeBox1.LoadScript("");
            splitContainer1.Panel2MinSize = 50;

            //tabControl1.ResumeLayout();
        }