Пример #1
0
        private void viewCodeMenuItem_Click(object sender, EventArgs e)
        {
            if (!(this.tabControl1.SelectedTab.Controls[0] is HostControl))
            {
                return;
            }
            HostSurface hostSurface = (this.tabControl1.SelectedTab.Controls[0] as HostControl).HostSurface;

            foreach (TabPage tp in this.tabControl1.TabPages)
            {
                if (hostSurface.Equals(tp.Tag as HostSurface))
                {
                    this.tabControl1.SelectedTab = tp;
                    return;
                }
            }
            string code     = hostSurface.GetCode();
            string language = this.tabControl1.SelectedTab.Tag.ToString();

            if (String.IsNullOrEmpty(code))
            {
                return;
            }
            string            tabName = this.tabControl1.SelectedTab.Text.Replace("Design", "Code");
            TabPage           tabpage = new TabPage(tabName);
            CodeEditorControl cec     = new CodeEditorControl();

            cec.Parent = tabpage;
            cec.Dock   = DockStyle.Fill;
            cec.ShowText(code, language);
            tabpage.Tag = hostSurface;
            this.tabControl1.TabPages.Add(tabpage);
            this.tabControl1.SelectedTab = tabpage;
        }
Пример #2
0
 private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.tabControl1.SelectedTab.Controls[0] is HostControl)
     {
         // Clicked on designer tab
         HostSurface hostSurface = (this.tabControl1.SelectedTab.Controls[0] as HostControl).HostSurface;
         this.toolbox.DesignerHost = hostSurface.DesignerHost;
         SetupMenus(hostSurface);
         this.propertyGrid.SetSelectedObjects(new object[] { hostSurface.DesignerHost.RootComponent });
     }
     else
     {
         // Clicked on Code tab
         HostSurface       hostSurface = tabControl1.SelectedTab.Tag as HostSurface;
         CodeEditorControl cec         = tabControl1.SelectedTab.Controls[0] as CodeEditorControl;
         cec.ShowText(hostSurface.GetCode(), cec.Language);
         SetupMenus(null);
         this.propertyGrid.SetSelectedObjects(null);
     }
 }