Пример #1
0
        /// <inheritdoc />
        protected override void OnShowEditor(IEditor editor)
        {
            if (editor == null)
            {
                return;
            }

            using (iDockPanel.DeferLayout()) {
                // If there is an open editor, close it before
                if (iDocumentDockContent != null)
                {
                    iDocumentDockContent.Close();
                    iDocumentDockContent = null;
                }

                // Add ToolStripContainer to the top of the perspective
                ToolStripContainer toolStripContainer = new ToolStripContainer {
                    Dock = DockStyle.Top
                };

                // Let the editor configure the tool bar
                iCurrentToolBar = new ToolBar();
                editor.ConfigureToolBar(iCurrentToolBar);

                // Add the tool bar to the controls
                toolStripContainer.TopToolStripPanel.Controls.Add(iCurrentToolBar);
                iDockPanel.Controls.Add(iCurrentToolBar);

                // Let the editor create its content
                GridPanel editorPanel = new GridPanel {
                    Dock = DockStyle.Fill
                };
                editor.CreateContents(editorPanel);

                // Place into a dock content
                iDocumentDockContent = new DockContent {
                    Tag = editor
                };
                iDocumentDockContent.Controls.Add(editorPanel);
                iDocumentDockContent.Show(iDockPanel, DockState.Document);

                // Register events
                iDocumentDockContent.TabText  = editor.EditorTabText;
                iDocumentDockContent.Closing += OnDockContentClosing;
                iDocumentDockContent.Closed  += OnDockContentClosed;
                iDocumentDockContent.Enter   += OnDockContentGotFocus;

                editor.PropertyChanged += OnEditorPropertyChanged;
                editor.DirtyChanged    += OnEditorDirtyChanged;
            }
        }