Example #1
0
        /// <summary>
        /// 在中间的tab 页新添加一个文档
        /// </summary>
        /// <param name="documentControl"></param>
        /// <returns></returns>
        public IDocumentControl AddADocument(IDocumentControl documentControl, string name)
        {
            if (!(documentControl is Control))
            {
                throw new WinformUIExceptionDeal("Type of " + documentControl.GetType().FullName + " is not a control.");
            }
            //XtraUserControl child = new XtraUserControl();
            DocumentSettings DocumentSettings = new DocumentSettings();

            if (documentControl.Document != null)
            {
                DocumentSettings.Caption = documentControl.Document.DocumentName ?? name;
                if (documentControl.DocumentImage != null)
                {
                    DocumentSettings.Image = documentControl.DocumentImage;
                }
            }
            //DocumentSettings.Attach(child, DocumentSettings);
            //((Control)documentControl).Parent = child;
            ((Control)documentControl).Dock      = DockStyle.Fill;
            ((Control)documentControl).GotFocus += (sender, e) => {
            };
            ((Control)documentControl).Visible   = true;
            DocumentSettings.Attach((Control)documentControl, DocumentSettings);
            this.documentManagerDocking.TabbedView.AddDocument((Control)documentControl);
            return(documentControl);
        }
Example #2
0
        /// <summary>
        /// 在中间的tab 页新添加一个文档
        /// </summary>
        /// <param name="documentControl"></param>
        /// <returns></returns>
        public IDocumentControl AddADocument(IDocumentControl documentControl, string name)
        {
            if (!(documentControl is Control))
            {
                throw new WinformUIExceptionDeal("Type of " + documentControl.GetType().FullName + " is not a control.");
            }
            XtraUserControl  child            = new XtraUserControl();
            DocumentSettings DocumentSettings = new DocumentSettings();

            if (documentControl.Document != null)
            {
                DocumentSettings.Caption = documentControl.Document.DocumentName ?? name;
                if (documentControl.DocumentImage != null)
                {
                    DocumentSettings.Image = documentControl.DocumentImage;
                }
            }
            DocumentSettings.Attach(child, DocumentSettings);
            ((Control)documentControl).Parent    = child;
            ((Control)documentControl).Dock      = DockStyle.Fill;
            ((Control)documentControl).GotFocus += (sender, e) => {
                var tempActiveDocument = this.ActiveDocumentControl;
                this.ActiveDocumentControl = sender as IDocumentControl;
                if (this.ActiveDocumentControl.PropertiesControl != null)
                {
                    Control propertiesControl = (Control)this.ActiveDocumentControl.PropertiesControl;
                    propertiesControl.Dock = DockStyle.Fill;
                    if (this.PropertiesPanel.Controls.Count > 0)
                    {
                        this.PropertiesPanel.Controls.Clear();
                    }
                    this.PropertiesPanel.AddControl(propertiesControl);
                }
                EventBus.Default.Trigger(new DocumentActiveChangeEventData {
                    ChangeFromDocumentControl = tempActiveDocument, ChangeToDocumentControl = ActiveDocumentControl
                });
            };
            ((Control)documentControl).Visible = true;
            this.documentManagerDocking.TabbedView.AddDocument(child);

            return(documentControl);
        }