public ControlContainerTabs Rebuild()
        {
            ControlContainerTabs tabControl = new ControlContainerTabs
            {
                BorderStyle           = System.Windows.Forms.BorderStyle.FixedSingle,
                Dock                  = System.Windows.Forms.DockStyle.Fill,
                Current               = null,
                TabIndex              = 0,
                ShowHeaderWhenOnlyOne = ShowHeaderWhenOnlyOne
            };

            foreach (string name in ChildrenName)
            {
                Type type = FactoryOfTaxonControl.TaxonUserControlTypeFromName(name);
                if (type == null)
                {
                    continue;
                }
                object o = type.GetConstructor(new Type[] { }).Invoke(new object[] { });
                if (!(o is Controls.TaxonControl))
                {
                    continue;
                }
                tabControl.Add(o as Controls.TaxonControl);
            }

            if (CurrentIndex >= 0 && CurrentIndex < tabControl.Children.Count)
            {
                tabControl.Current = tabControl.Children[CurrentIndex];
            }

            return(tabControl);
        }
Exemple #2
0
        //---------------------------------------------------------------------------------
        public void UpdateName()
        {
            ControlContainerTabs tab = GetTabsContainer();

            if (tab != null && tab.Current != null)
            {
                Text = tab.Current.ToString();
                return;
            }

            Text = "Floating tool";
        }
Exemple #3
0
        //---------------------------------------------------------------------------------
        public void SetTabsContainer(ControlContainerTabs _tabs = null)
        {
            if (_tabs == null)
            {
                _tabs = new ControlContainerTabs
                {
                    ShowHeaderWhenOnlyOne = false
                };
            }
            _tabs.OnCurrentTabChanged += OnCurrentTabChanged;

            Controls.Clear();
            Controls.Add(_tabs);
        }
Exemple #4
0
        //---------------------------------------------------------------------------------
        public static FormContainer GetFormContainer(ControlContainerTabs _container)
        {
            Control current = _container;

            while (current != null)
            {
                if (current is FormContainer)
                {
                    return(current as FormContainer);
                }
                current = current.Parent;
            }
            return(null);
        }
        public static ControlContainerTabsDesc FromTaxonTabControls(ControlContainerTabs _tab)
        {
            ControlContainerTabsDesc desc = new ControlContainerTabsDesc
            {
                ChildrenName = new List <string>()
            };

            foreach (Controls.TaxonControl tuc in _tab.Children)
            {
                desc.ChildrenName.Add(tuc.GetType().FullName);
            }
            desc.CurrentIndex          = _tab.Children.IndexOf(_tab.Current);
            desc.ShowHeaderWhenOnlyOne = _tab.ShowHeaderWhenOnlyOne;
            return(desc);
        }
Exemple #6
0
        //-----------------------------------------------------------------------------------------
        void MainWindowContentToUI()
        {
            Panel mainPanel = TaxonUtils.MainWindow.GetMainPanel();

            if (_SplitterContainerDescriptor != null)
            {
                GUI.ControlContainerSplitter split = _SplitterContainerDescriptor.Rebuild();
                mainPanel.Controls.Add(split);
                _SplitterContainerDescriptor.AfterAdd(split);
            }
            else if (_TaxonTabControlsDescriptor != null)
            {
                GUI.ControlContainerTabs tabControl = _TaxonTabControlsDescriptor.Rebuild();
                mainPanel.Controls.Add(tabControl);
            }
        }
Exemple #7
0
        //-------------------------------------------------------------------
        public ControlContainerInterface Split(DockStyle _dock)
        {
            if (_dock == DockStyle.None || _dock == DockStyle.Fill)
            {
                return(null);
            }
            if (Parent == null)
            {
                return(null);
            }

            ControlContainerSplitter split = new ControlContainerSplitter();
            Orientation orientation        = Orientation.Horizontal;
            int         distance           = ClientRectangle.Height / 2;

            if ((_dock == DockStyle.Left) || (_dock == DockStyle.Right))
            {
                orientation = Orientation.Vertical;
                distance    = ClientRectangle.Width / 2;
            }

            ShowHeaderWhenOnlyOne = true;
            ControlContainerTabs newTabs = new ControlContainerTabs();

            split.Orientation = orientation;
            split.Dock        = DockStyle.Fill;
            split.Location    = new Point(0, 0);

            Control parent = Parent;

            parent.Controls.Remove(this);
            if ((_dock == DockStyle.Left) || (_dock == DockStyle.Top))
            {
                split.Panel1.Controls.Add(newTabs);
                split.Panel2.Controls.Add(this);
            }
            else
            {
                split.Panel1.Controls.Add(this);
                split.Panel2.Controls.Add(newTabs);
            }
            parent.Controls.Add(split);

            split.SplitterDistance = distance;

            return(newTabs);
        }
Exemple #8
0
        //---------------------------------------------------------------------------------
        public FormContainer(GuiControlInterface _itf) : this()
        {
            SetTabsContainer();
            ControlContainerTabs tabControl = GetTabsContainer();

            if (tabControl == null)
            {
                return;
            }
            if (_itf == null || _itf.Control == null)
            {
                return;
            }
            tabControl.Add(_itf);
            UpdateName();

            if (_itf.Control.MinimumSize.Width != 0 && _itf.Control.MinimumSize.Height != 0)
            {
                int addX = Size.Width - ClientRectangle.Width;
                int addY = Size.Height - ClientRectangle.Height;
                MinimumSize = new Size(_itf.Control.MinimumSize.Width + addX, _itf.Control.MinimumSize.Height + addY);
            }
        }
Exemple #9
0
 //---------------------------------------------------------------------------------
 public FormContainer(ControlContainerTabs _tabs) : this()
 {
     SetTabsContainer(_tabs);
     UpdateName();
 }