Ejemplo n.º 1
0
        public void Show(Control view, ViewShowType showType)
        {
            var form = view as Form;

            if (form != null)
            {
                if (showType == ViewShowType.Dialog)
                {
                    form.ShowDialog();
                }
                else if (showType == ViewShowType.Mdi)
                {
                    _tabbedView.Manager.BeginUpdate();
                    form.MdiParent = _tabbedView.Manager.MdiParent;
                    form.Show();
                    _tabbedView.Manager.EndUpdate();
                }
                else
                {
                    form.Show();
                }
            }
            else
            {
                _tabbedView.AddDocument(view);
            }
        }
Ejemplo n.º 2
0
        private void CreateNewDocument()
        {
            string   docName = string.Format("document{0}", tabbedView.Documents.Count + 1);
            Document doc     = tabbedView.AddDocument(GetControl()) as Document;

            doc.Caption     = docName;
            doc.ControlName = docName;
            doc.Appearance.HeaderActive.BackColor = ExampleHelper.GetRandomColor();
        }
Ejemplo n.º 3
0
        public static void LoadControl(XtraUserControl control)
        {
            tabbedView.BeginUpdate();
            BaseDocument document = tabbedView.AddDocument(control);

            //document.Image = fileTypeImages.Images[12];
            document.Footer  = Directory.GetCurrentDirectory();
            document.Caption = control.Name;
            tabbedView.EndUpdate();
            tabbedView.Controller.Activate(document);
        }
Ejemplo n.º 4
0
        public void Show(string name, string caption, DockingStyle dockingStyle, Func <UserControl> getUserControl)
        {
            switch (dockingStyle)
            {
            case DockingStyle.Left:
            case DockingStyle.Right:
            case DockingStyle.Top:
            case DockingStyle.Bottom:
                var dockPanel = _dockManager.Panels.FirstOrDefault(m => m.Name == name);
                if (dockPanel != null)
                {
                    dockPanel.Visibility = DockVisibility.Visible;
                }
                else
                {
                    var pnlContainer = _dockManager.Panels.FirstOrDefault(m => m.Dock == dockingStyle);
                    if (pnlContainer == null)
                    {
                        dockPanel = _dockManager.AddPanel(dockingStyle);
                    }
                    else
                    {
                        dockPanel = pnlContainer.AddPanel();
                        dockPanel.ParentPanel.Tabbed = true;
                    }
                    dockPanel.Text = caption;
                    dockPanel.Name = name;
                    var ctrl = getUserControl();
                    ctrl.Dock      = DockStyle.Fill;
                    dockPanel.Size = ctrl.Size;
                    dockPanel.ControlContainer.Controls.Add(ctrl);
                }
                _dockManager.ActivePanel = dockPanel;
                break;

            case DockingStyle.Fill:
                var document = _tabbedView.Documents.FindFirst(m => m.Control.Name == name);
                if (document == null)
                {
                    var ctrl = getUserControl();
                    ctrl.Name        = name;
                    ctrl.Dock        = DockStyle.Fill;
                    document         = _tabbedView.AddDocument(ctrl);
                    document.Caption = caption;
                }
                _tabbedView.Controller.Activate(document);
                break;

            default:
                throw new NotSupportedException();
            }
        }
Ejemplo n.º 5
0
        public void OpenView(IView view)
        {
            Waiting(() =>
            {
                if (view is IDockView)
                {
                    var dockPanel   = this.DockManager.AddPanel(DockingStyle.Right);
                    dockPanel.ID    = new Guid(view.ID);
                    dockPanel.Text  = view.Caption;
                    dockPanel.Image = view.Icon;
                    dockPanel.Options.ShowCloseButton           = false;
                    dockPanel.Options.AllowDockAsTabbedDocument = false;
                    dockPanel.ClosingPanel += (sender, e) =>
                    {
                        if (DialogResult != DialogResult.OK)
                        {
                            e.Cancel = true;
                        }
                    };
                    var control = view as Control;
                    dockPanel.Controls[0].Controls.Add(control);
                    control.Dock = DockStyle.Fill;

                    var dockView = view as IDockView;
                    if (!DockViews.Contains(dockView))
                    {
                        DockViews.Add(dockView);
                    }
                }
                else
                {
                    var docControl    = view as Control;
                    var tabbedDoc     = TabbedView.AddDocument(docControl);
                    tabbedDoc.Caption = view.Caption;
                    tabbedDoc.Image   = view.Icon;
                }
            }, "正在打开文档");
        }