Exemplo n.º 1
0
 /// <summary>
 /// Loads the given tab control into this display.
 /// </summary>
 /// <param name="tabControl">The tabcontrol that will be loaded by this display</param>
 public void AttachTabControl(NewTabControl tabControl)
 {
     TabControl = tabControl;
     tabControl.SelectedIndexChanged += (sender, eventArgs) => {
         string tabName = tabControl.SelectedIndex != -1 ? tabControl.TabPages[TabControl.SelectedIndex].Text.TrimStart('*') : null;
         DisplayTabChanged?.Invoke(tabName);
     };
     tabControl.TabXClicked += (sender, eventArgs) => {
         DisplayTabClosing?.Invoke(((TabPage)sender).Text.TrimStart('*'));
     };
     pnlMain.Controls.Add(TabControl, 0, 0);
     TabControl.Dock = DockStyle.Fill;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Loads the given tab control into this display.
 /// </summary>
 /// <param name="tabControl">The tabcontrol that will be loaded by this display</param>
 public void AttachTabControl(NewTabControl tabControl)
 {
     TabControl = tabControl;
     TabControl.SelectedIndexChanged += (sender, eventArgs) => {
         string tabName = TabControl.SelectedIndex != -1 ? TabControl.TabPages[TabControl.SelectedIndex].Text : null;
         if (tabName != null)
         {
             UpdateTickControls(!tabName.Contains("."));
         }
         DisplayTabChanged?.Invoke(tabName);
     };
     TabControl.TabXClicked += (sender, eventArgs) => {
         DisplayTabClosing?.Invoke(((TabPage)sender).Text);
     };
     pnlMain.Controls.Add(pnlOutputControls, 0, 0);
     pnlMain.Controls.Add(TabControl, 0, 1);
     TabControl.Dock = DockStyle.Fill;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Constructs an instance of DisplayController with a handle to the two displays.
        /// </summary>
        /// <param name="editDisplay">Handle to the edit display hosted by the MainWindow</param>
        /// <param name="runDisplay">Handle to the run display hosted by the MainWindow</param>
        public DisplayController(IDisplay editDisplay, IDisplay runDisplay)
        {
            // Init tab control
            var designTabControl = new NewTabControl();

            designTabControl.Font                 = new Font("Segoe UI", 10.75F);
            designTabControl.SelectedTabColor     = Color.DodgerBlue;
            designTabControl.TabBoundaryColor     = SystemColors.ControlDarkDark;
            designTabControl.SelectedTabTextColor = Color.White;
            designTabControl.TabSwapped          += (sender, e) => {
                MainWindowController.SwapDesignNodes(e.SourceTabPageIndex, e.DestinationTabPageIndex);
            };

            var browserTabControl = new NewTabControl();

            browserTabControl.Font                 = new Font("Segoe UI", 10.75F);
            browserTabControl.SelectedTabColor     = Color.DodgerBlue;
            browserTabControl.TabBoundaryColor     = SystemColors.ControlDarkDark;
            browserTabControl.SelectedTabTextColor = Color.White;

            // Create html builder
            HtmlBuilder = new HtmlBuilder();

            // Init edit display
            EditDisplay = editDisplay;
            EditDisplay.AttachTabControl(designTabControl);
            EditDisplay.DisplayTabChanged += (tabName) => {
                // Select the tab associated with the tab
                MainWindowController.SelectFile(tabName);
                if (tabName != null)
                {
                    MainWindowController.LoadDisplay(DisplayType.EDIT);
                }
            };
            EditDisplay.DisplayTabClosing += (tabName) => {
                // Close file associated with the tab
                MainWindowController.CloseFile(tabName, true);
            };

            // Init run display
            RunDisplay = runDisplay;
            RunDisplay.AttachTabControl(browserTabControl);
            RunDisplay.DisplayTabChanged += (tabName) => {
                if (tabName != null)
                {
                    if (DesignController.ActiveDesign.FileName != InstantiationClicks.Text)
                    {
                        // Select top level
                        MainWindowController.SelectFile(InstantiationClicks.Text);
                    }

                    // Select the tab associated with the tab
                    MainWindowController.SelectFile(tabName);
                }
            };
            RunDisplay.DisplayTabClosing += (tabName) => {
                CurrentDisplay.CloseTab(tabName);
            };
            RunDisplay.DisplayTabClosed += (tabName, tabCount) => {
                // If the tab is an instantiation parser
                if (tabName.Contains("."))
                {
                    if (DesignController.ActiveDesign.FileName != InstantiationClicks.Text)
                    {
                        // Select top level
                        MainWindowController.SelectFile(InstantiationClicks.Text);
                    }

                    // Close parser associated with the tab
                    MainWindowController.CloseInstantiation(tabName);

                    var treeNodes = Collect(InstantiationClicks.Nodes).ToList();
                    foreach (TreeNode treeNode in treeNodes)
                    {
                        if (treeNode.Text == tabName)
                        {
                            var childNodes = Collect(treeNode.Nodes).ToList();
                            foreach (var childNode in childNodes)
                            {
                                CurrentDisplay.CloseTab(childNode.Name);
                            }
                            treeNode.Parent.Nodes.Remove(treeNode);
                            break;
                        }
                    }
                }
                else
                {
                    // Select the tab associated with the tab
                    MainWindowController.SelectFile(tabName);
                    MainWindowController.SuspendRunDisplay();

                    if (CurrentDisplay is DisplayRun)
                    {
                        MainWindowController.LoadDisplay(DisplayType.EDIT);
                    }
                }
            };

            CurrentDisplay = editDisplay;
        }