示例#1
0
        public void DockTo(IDockPanel parent, DockPanelState state, int size)
        {
            if (parent != null && !parent.Visible)
            {
                return;     // no need to throw exception if it not visible
            }

            var ctrl = parent != null ? parent.Control : _parent;

            //首先先创建一个DockPanel,然后将控件加上去
            DevExpress.XtraBars.Docking.DockPanel panel = new DevExpress.XtraBars.Docking.DockPanel();
            panel.Name      = ((IDockPanelView)_control).DockName;
            panel.Header    = ((IDockPanelView)_control).Caption;
            panel.Image     = ((IDockPanelView)_control).Image;
            panel.Dock      = DockHelper.MapWindowToDevExpress(((IDockPanelView)_control).DefaultDock);
            panel.FloatSize = ((IDockPanelView)_control).DefaultSize;
            _control.Dock   = DockStyle.Fill;
            panel.Controls.Add(_control);

            if (parent != null)
            {
                DevExpress.XtraBars.Docking.DockPanel parentPanel = _dockingManager.Panels[parent.Name];
                if (parentPanel != null)
                {
                    parentPanel.Controls.Add(panel);
                }
            }
            else
            {
                _dockingManager.AddPanel(panel.Dock, panel);
            }
        }
示例#2
0
 public bool GetDockVisible(string dockName)
 {
     DevExpress.XtraBars.Docking.DockPanel panel = _dockingManager.Panels[dockName];
     if (panel == null)
     {
         return(false);
     }
     return(panel.Visible);
 }
示例#3
0
        public void DockTo(string parentName, DockPanelState state, int size)
        {
            DevExpress.XtraBars.Docking.DockPanel parentPanel;
            if (string.IsNullOrEmpty(parentName))
            {
                parentPanel = null;
            }
            else
            {
                parentPanel = _dockingManager.Panels[parentName];

                if (parentPanel != null && parentPanel.Visibility == DockVisibility.Hidden)
                {
                    parentPanel = null;
                }
            }
            DevExpress.XtraBars.Docking.DockingStyle style = DockHelper.MapWindowToDevExpress(((IDockPanelView)_control).DefaultDock);
            if (style == DockingStyle.Fill)
            {
                style = DockingStyle.Float;
            }

            DevExpress.XtraBars.Docking.DockPanel panel = null;
            if (parentPanel == null)
            {
                panel = _dockingManager.AddPanel(style);
            }
            else
            {
                panel = parentPanel.AddPanel();
            }
            panel.Name   = ((IDockPanelView)_control).DockName;
            panel.Header = ((IDockPanelView)_control).Caption;
            panel.Image  = ((IDockPanelView)_control).Image;
            //panel.Dock = DockHelper.MapWindowToDevExpress(((IDockPanelView)_control).DefaultDock);
            panel.FloatSize = ((IDockPanelView)_control).DefaultSize;
            _control.Dock   = DockStyle.Fill;
            panel.TabText   = ((IDockPanelView)_control).Caption;
            panel.Text      = ((IDockPanelView)_control).Caption;
            panel.Controls.Add(_control);


            //    if (parentPanel != null)
            //    {
            //        parentPanel.Controls.Add(panel);
            //    }

            //else
            //{
            //    _dockingManager.AddPanel(panel.Dock, panel);
            //}
        }
示例#4
0
 public void SetDockVisible(string dockName, bool isVisible, bool isActive)
 {
     DevExpress.XtraBars.Docking.DockPanel panel = _dockingManager.Panels[dockName];
     if (panel == null)
     {
         if (isVisible == true)
         {
             IDockPanelView view = _dict.FirstOrDefault(c => c.Key.Key == dockName).Value;
             DockTo("", view);
         }
         return;
     }
     panel.Visible = isVisible;
     if (isVisible == true && isActive)
     {
         _dockingManager.ActivePanel = panel;
     }
 }
示例#5
0
        private DockPanel DockTo(string parentName, IDockPanelView view)
        {
            DevExpress.XtraBars.Docking.DockPanel parentPanel;
            if (string.IsNullOrEmpty(parentName))
            {
                parentPanel = null;
            }
            else
            {
                parentPanel = _dockingManager.Panels[parentName];

                if (parentPanel != null && parentPanel.Visibility == DockVisibility.Hidden)
                {
                    parentPanel = null;
                }
            }
            DevExpress.XtraBars.Docking.DockingStyle style = DockHelper.MapWindowToDevExpress(view.DefaultDock);
            if (style == DockingStyle.Fill)
            {
                style = DockingStyle.Float;
            }

            DevExpress.XtraBars.Docking.DockPanel panel = null;
            if (parentPanel == null)
            {
                panel = _dockingManager.AddPanel(style);
            }
            else
            {
                panel = parentPanel.AddPanel();
            }
            panel.Name   = view.DockName;
            panel.Header = view.Caption;
            panel.Image  = view.Image;
            //panel.Dock = DockHelper.MapWindowToDevExpress(((IDockPanelView)_control).DefaultDock);
            panel.FloatSize      = view.DefaultSize;
            ((Control)view).Dock = DockStyle.Fill;
            panel.TabText        = view.Caption;
            panel.Text           = view.Caption;
            panel.Controls.Add((Control)view);
            return(panel);
        }
示例#6
0
        public static void CreateViews(IContainer components, DockManager dockManager, TabbedView tabbedView)
        {
            if (views != null && views.Count > 0)
            {
                DevExpress.XtraBars.Docking2010.Views.Tabbed.DocumentGroup documentGroup = new DevExpress.XtraBars.Docking2010.Views.Tabbed.DocumentGroup(components);
                tabbedView.DocumentGroups.AddRange(new DevExpress.XtraBars.Docking2010.Views.Tabbed.DocumentGroup[] { documentGroup });

                for (int i = 0; i < views.Count; i++)
                {
                    XtraUserControl uc = (XtraUserControl)views[i];

                    DockPanel dockPanel = new DevExpress.XtraBars.Docking.DockPanel();
                    DevExpress.XtraBars.Docking2010.Views.Tabbed.Document dockPanel_Document = new DevExpress.XtraBars.Docking2010.Views.Tabbed.Document(components);
                    ControlContainer dockPanel_Container = new ControlContainer();

                    dockManager.RootPanels.AddRange(new DevExpress.XtraBars.Docking.DockPanel[] { dockPanel });
                    tabbedView.Documents.Add(dockPanel_Document);
                    documentGroup.Items.Add(dockPanel_Document);

                    dockPanel.Controls.Add(dockPanel_Container);
                    dockPanel.DockedAsTabbedDocument            = true;
                    dockPanel.Options.AllowDockAsTabbedDocument = true;
                    dockPanel.Options.AllowDockLeft             = false;
                    dockPanel.Options.AllowDockRight            = false;
                    dockPanel.Options.AllowDockTop    = false;
                    dockPanel.Options.AllowDockBottom = false;
                    dockPanel.Options.AllowDockFill   = false;
                    dockPanel.ID = System.Guid.NewGuid();
                    string strName = DateTime.Now.Ticks.ToString();
                    dockPanel.Name             = "dockPanel" + strName;
                    dockPanel.OriginalSize     = new System.Drawing.Size(300, 300);
                    dockPanel.Text             = views[i].Title;
                    dockPanel.SavedIndex       = i;
                    dockPanel.SavedMdiDocument = true;
                    dockPanel.FloatLocation    = new System.Drawing.Point(0, 0);
                    if (views[i].ShowCloseButton)
                    {
                        dockPanel.Options.ShowCloseButton = true;
                    }
                    else
                    {
                        dockPanel.Options.ShowCloseButton = false;
                    }
                    dockPanel_Container.Controls.Add(uc);
                    dockPanel_Container.Location = new System.Drawing.Point(0, 0);
                    dockPanel_Container.Name     = "dockPanel_Container" + strName;
                    dockPanel_Container.Size     = new System.Drawing.Size(300, 300);
                    dockPanel_Container.TabIndex = 0;

                    uc.Dock     = System.Windows.Forms.DockStyle.Fill;
                    uc.Location = new System.Drawing.Point(0, 0);
                    uc.Name     = "uc" + strName;
                    uc.Size     = new System.Drawing.Size(300, 300);
                    uc.TabIndex = 0;

                    dockPanel_Document.Caption       = views[i].Title;
                    dockPanel_Document.ControlName   = dockPanel.Name;
                    dockPanel_Document.FloatLocation = new System.Drawing.Point(0, 0);
                    dockPanel_Document.FloatSize     = new System.Drawing.Size(300, 300);
                    if (views[i].ShowCloseButton)
                    {
                        dockPanel_Document.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.True;
                    }
                    else
                    {
                        dockPanel_Document.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.False;
                    }

                    if (views[i].IsActive)
                    {
                        InitActivateViewText = views[i].Title;
                    }
                    ContentCollection.Add(views[i]);
                }
            }
        }
示例#7
0
        public static void CreateAutoHidePad(System.Windows.Forms.Form form, DockManager dockManager, List <IPadContent> pads, System.Windows.Forms.DockStyle dockStyle, DevExpress.XtraBars.Docking.DockingStyle dockStyle1)
        {
            if (pads == null || pads.Count == 0)
            {
                return;
            }
            string            strName        = DateTime.Now.Ticks.ToString();
            AutoHideContainer panelContainer = new DevExpress.XtraBars.Docking.AutoHideContainer();

            dockManager.AutoHideContainers.AddRange(new DevExpress.XtraBars.Docking.AutoHideContainer[] { panelContainer });

            panelContainer.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(236)))), ((int)(((byte)(239)))));
            panelContainer.Dock      = dockStyle;
            panelContainer.Location  = new System.Drawing.Point(20, 147);
            panelContainer.Name      = "panelContainer" + strName;
            panelContainer.Size      = new System.Drawing.Size(864, 20);

            for (int i = 0; i < pads.Count; i++)
            {
                XtraUserControl uc = (XtraUserControl)pads[i];

                DockPanel        dockPanel           = new DevExpress.XtraBars.Docking.DockPanel();
                ControlContainer dockPanel_Container = new ControlContainer();

                dockPanel.Controls.Add(dockPanel_Container);
                dockPanel.DockedAsTabbedDocument            = false;
                dockPanel.Options.AllowDockAsTabbedDocument = false;
                dockPanel.Dock          = dockStyle1;
                dockPanel.SavedDock     = dockStyle1;
                dockPanel.FloatVertical = true;
                dockPanel.ID            = System.Guid.NewGuid();
                dockPanel.Location      = new System.Drawing.Point(0, 0);
                strName                = DateTime.Now.Ticks.ToString();
                dockPanel.Name         = "dockPanel" + strName;
                dockPanel.OriginalSize = new System.Drawing.Size(200, 200);
                dockPanel.Size         = new System.Drawing.Size(200, 200);
                dockPanel.Text         = pads[i].Title;
                if (pads[i].ShowCloseButton)
                {
                    dockPanel.Options.ShowCloseButton = true;
                }
                else
                {
                    dockPanel.Options.ShowCloseButton = false;
                }
                dockPanel.Visibility = DockVisibility.AutoHide;

                dockPanel.Options.ShowMaximizeButton = true;

                dockPanel_Container.Controls.Add(uc);
                dockPanel_Container.Location = new System.Drawing.Point(0, 0);
                dockPanel_Container.Name     = "dockPanel_Container" + strName;
                dockPanel_Container.Size     = new System.Drawing.Size(200, 200);
                dockPanel_Container.TabIndex = 0;

                uc.Dock     = System.Windows.Forms.DockStyle.Fill;
                uc.Location = new System.Drawing.Point(0, 0);
                uc.Name     = "uc" + strName;
                uc.Size     = new System.Drawing.Size(200, 200);
                uc.TabIndex = 0;

                panelContainer.Controls.Add(dockPanel);

                ContentCollection.Add(pads[i]);
            }
            form.Controls.Add(panelContainer);
        }
示例#8
0
        public static void CreatePad(System.Windows.Forms.Form form, DockManager dockManager, List <IPadContent> pads, DockingStyle dockStyle)
        {
            if (pads == null || pads.Count == 0)
            {
                return;
            }
            if (pads.Count == 1)
            {
                IPadContent      pad                 = pads[0];
                XtraUserControl  uc                  = (XtraUserControl)pad;
                DockPanel        dockPanel           = new DevExpress.XtraBars.Docking.DockPanel();
                ControlContainer dockPanel_Container = new ControlContainer();
                dockManager.RootPanels.AddRange(new DevExpress.XtraBars.Docking.DockPanel[] { dockPanel });

                dockPanel.Controls.Add(dockPanel_Container);
                dockPanel.Dock = dockStyle;
                dockPanel.DockedAsTabbedDocument            = false;
                dockPanel.Options.AllowDockAsTabbedDocument = false;
                dockPanel.ID       = System.Guid.NewGuid();
                dockPanel.Location = new System.Drawing.Point(0, 0);
                string strName = DateTime.Now.Ticks.ToString();
                dockPanel.Name         = "dockPanel" + strName;
                dockPanel.OriginalSize = new System.Drawing.Size(200, 200);
                dockPanel.Size         = new System.Drawing.Size(200, 200);
                dockPanel.Text         = pad.Title;
                if (pad.ShowCloseButton)
                {
                    dockPanel.Options.ShowCloseButton = true;
                }
                else
                {
                    dockPanel.Options.ShowCloseButton = false;
                }

                dockPanel.Options.ShowMaximizeButton = true;

                dockPanel_Container.Controls.Add(uc);
                dockPanel_Container.Location = new System.Drawing.Point(0, 0);
                dockPanel_Container.Name     = "dockPanel_Container" + strName;
                dockPanel_Container.Size     = new System.Drawing.Size(200, 200);
                dockPanel_Container.TabIndex = 0;

                uc.Dock     = System.Windows.Forms.DockStyle.Fill;
                uc.Location = new System.Drawing.Point(0, 0);
                uc.Name     = "uc" + strName;
                uc.Size     = new System.Drawing.Size(200, 200);
                uc.TabIndex = 0;

                form.Controls.Add(dockPanel);

                ContentCollection.Add(pads[0]);
            }
            else
            {
                string    strName        = DateTime.Now.Ticks.ToString();
                DockPanel panelContainer = new DevExpress.XtraBars.Docking.DockPanel();

                dockManager.RootPanels.AddRange(new DevExpress.XtraBars.Docking.DockPanel[] { panelContainer });
                panelContainer.Dock         = dockStyle;
                panelContainer.ID           = System.Guid.NewGuid();
                panelContainer.Location     = new System.Drawing.Point(0, 0);
                panelContainer.Name         = "panelContainer" + strName;
                panelContainer.OriginalSize = new System.Drawing.Size(200, 200);
                panelContainer.Size         = new System.Drawing.Size(200, 200);
                panelContainer.Text         = "panelContainer" + strName;
                bool             bHaveActive = false;
                List <DockPanel> list        = new List <DockPanel>();
                for (int i = 0; i < pads.Count; i++)
                {
                    XtraUserControl uc = (XtraUserControl)pads[i];

                    DockPanel        dockPanel           = new DevExpress.XtraBars.Docking.DockPanel();
                    ControlContainer dockPanel_Container = new ControlContainer();

                    dockPanel.Controls.Add(dockPanel_Container);
                    dockPanel.DockedAsTabbedDocument            = false;
                    dockPanel.Options.AllowDockAsTabbedDocument = false;
                    dockPanel.Dock          = DevExpress.XtraBars.Docking.DockingStyle.Fill;
                    dockPanel.FloatVertical = true;
                    dockPanel.ID            = System.Guid.NewGuid();
                    dockPanel.Location      = new System.Drawing.Point(0, 0);
                    strName                = DateTime.Now.Ticks.ToString();
                    dockPanel.Name         = "dockPanel" + strName;
                    dockPanel.OriginalSize = new System.Drawing.Size(200, 200);
                    dockPanel.Size         = new System.Drawing.Size(200, 200);
                    dockPanel.Text         = pads[i].Title;
                    if (pads[i].ShowCloseButton)
                    {
                        dockPanel.Options.ShowCloseButton = true;
                    }
                    else
                    {
                        dockPanel.Options.ShowCloseButton = false;
                    }
                    dockPanel.Options.ShowMaximizeButton = true;
                    dockPanel.Height = pads[i].PHeight;

                    dockPanel_Container.Controls.Add(uc);
                    dockPanel_Container.Location = new System.Drawing.Point(0, 0);
                    dockPanel_Container.Name     = "dockPanel_Container" + strName;
                    dockPanel_Container.Size     = new System.Drawing.Size(200, 200);
                    dockPanel_Container.TabIndex = 0;
                    dockPanel_Container.Height   = pads[i].PHeight;

                    uc.Dock     = System.Windows.Forms.DockStyle.Fill;
                    uc.Location = new System.Drawing.Point(0, 0);
                    uc.Name     = "uc" + strName;
                    uc.Size     = new System.Drawing.Size(200, 200);
                    uc.TabIndex = 0;
                    uc.Height   = pads[i].PHeight;

                    list.Add(dockPanel);

                    if (pads[i].IsActive)
                    {
                        panelContainer.FloatVertical = true;
                        panelContainer.ActiveChild   = dockPanel;
                        bHaveActive = true;
                    }
                    ContentCollection.Add(pads[i]);
                }
                panelContainer.Controls.AddRange(list.ToArray());

                if (bHaveActive)
                {
                    panelContainer.Tabbed = true;
                }
                form.Controls.Add(panelContainer);
            }
        }