Exemplo n.º 1
0
 public void AddDocument(ITabDocument document, string pluginId)
 {
     var newTab = new TabDocument(document, pluginId);
     _documents.Add(newTab);
     document.InstanceId = newTab.Id;
     _container.SelectedIndex = _documents.Count - 1;
 }
Exemplo n.º 2
0
 public TabDocument(ITabDocument document, string pluginId)
 {
     _document = document;
     _idCounter++;
     _id = _idCounter;
     _pluginId = pluginId;
     _activeMenuKeys = new List<string>();
 }
Exemplo n.º 3
0
        private void bottomTabControl_TabClosed(object sender, MySQL.Controls.TabClosedEventArgs e)
        {
            if (bottomTabControl.TabCount == 0)
            {
                contentSplitContainer.Panel2Collapsed = true;
            }

            ITabDocument document = (sender as FlatTabControl).DocumentFromPage(e.page);

            CloseTabDocument(document);
        }
Exemplo n.º 4
0
        private void tabControl_TabClosing(object sender, TabClosingEventArgs e)
        {
            ITabDocument document = (sender as FlatTabControl).DocumentFromPage(e.page);

            if (document is IWorkbenchDocument)
            {
                e.canClose = (document as IWorkbenchDocument).CanCloseDocument();
            }
            else
            if (document is MySQL.Forms.AppViewDockContent)
            {
                MySQL.Forms.AppViewDockContent content = document as MySQL.Forms.AppViewDockContent;
                e.canClose = content.CanCloseDocument();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Removes a previously added document from this control. This method removes the hosting tab,
        /// regardless of other content on it. The document itself is not freed.
        /// </summary>
        /// <param name="document"></param>
        public void RemoveDocument(ITabDocument document)
        {
            foreach (TabPage page in TabPages)
            if (DocumentFromHierarchy(page) == document)
            {
              page.Controls.Clear();
              TabPages.Remove(page);

              return;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Returns the index for the given document or -1 if not found.
        /// </summary>
        public int IndexFromDocument(ITabDocument document)
        {
            int i = 0;
              foreach (TabPage page in TabPages)
              {
            if (DocumentFromHierarchy(page) == document)
              return i;
            i++;
              }

              return -1;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Docks the given document to the editor tab control (object editors and plugins).
        /// </summary>
        public TabPage DockDocument(ITabDocument document, bool activate)
        {
            Logger.LogDebug("WQE.net", 1, "Docking new document (activate it: " + activate + ")\n");
              if (document is DockablePlugin)
            (document as DockablePlugin).UpdateColors();

              if (!mainContentTabControl.HasDocument(document))
            mainContentTabControl.AddDocument(document);
              if (activate)
            document.Activate();

              return mainContentTabControl.SelectedTab;
        }
Exemplo n.º 8
0
 public void UndockDocument(ITabDocument document)
 {
     if (bottomTabControl.HasDocument(document))
     bottomTabControl.RemoveDocument(document);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Tries to close the given document by sending out TabClosing. If that returns true
        /// the document is closed and its hosting tab removed.
        /// </summary>
        /// <returns>True if the document was closed, otherwise false.</returns>
        public bool CloseDocument(ITabDocument document)
        {
            foreach (TabPage page in TabPages)
            if (DocumentFromHierarchy(page) == document)
              return CloseTabPage(page);

              return false;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Adds the given document to a new tab page and returns the index of that new page.
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        public int AddDocument(ITabDocument document)
        {
            TabPage page = new TabPage();
              TabDocument control = document as TabDocument;
              control.SetHost(page);
              page.Controls.Add(control);
              control.Dock = DockStyle.Fill;
              control.Margin = new Padding(0);
              control.Padding = new Padding(0);
              control.Show();
              TabPages.Add(page);

              return TabPages.Count - 1;
        }
Exemplo n.º 11
0
 /// <summary>
 /// Undocks the given document from our tab control if it is there.
 /// If not forward the call to the currently active document.
 /// </summary>
 /// <param name="document"></param>
 public void UndockDocument(ITabDocument document)
 {
     if (contentTabControl.HasDocument(document))
     contentTabControl.RemoveDocument(document);
       else
       {
     ITabDocument host = contentTabControl.ActiveDocument;
     if (host is ModelDiagramForm)
       (host as ModelDiagramForm).UndockDocument(document);
     else
       if (host is ModelOverviewForm)
     (host as ModelOverviewForm).UndockDocument(document);
       else
     if (host is SqlIdeForm)
       (host as SqlIdeForm).UndockDocument(document);
       }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Docks the given document to either the own tab control (as main document) or as
        /// editor window to the currently active main document.
        /// </summary>
        /// <param name="document">The document to dock.</param>
        /// <param name="main">If true then dock that document to our own tab control, otherwise
        /// dock it to the currently active main document.</param>
        public void DockDocument(ITabDocument document, bool main, bool activate)
        {
            if (main)
              {
            int index = -1;
            if (!contentTabControl.HasDocument(document))
            {
              IWorkbenchDocument wbDocument = document as IWorkbenchDocument;
              SetupDockLayout(document, (wbDocument != null) ? wbDocument.BackendForm : null, contentTabControl.TabCount > 0);
              index = contentTabControl.AddDocument(document);
            }

            if (index == 0) // Replace the title by an icon.
            {
              contentTabControl.TabPages[index].ImageIndex = 0;
              contentTabControl.SetCloseButtonVisibility(0, FlatTabControl.CloseButtonVisiblity.HideButton);
            }

            if (activate)
            {
              document.Activate();
              AdjustGlassFrame(document.ToolbarHeight);
            }
              }
              else
              {
            ITabDocument host = contentTabControl.ActiveDocument;
            if (host is ModelDiagramForm)
              (host as ModelDiagramForm).DockDocument(document, activate);
            else
              if (host is ModelOverviewForm)
            (host as ModelOverviewForm).DockDocument(document, activate);
              else
            if (host is SqlIdeForm)
              (host as SqlIdeForm).DockDocument(document, activate);
              }

              // Do the color updates after everything set up as this depends on the structure.
              if (document is IWorkbenchDocument)
            (document as IWorkbenchDocument).UpdateColors();
              else
            if (document is AppViewDockContent)
              (document as AppViewDockContent).UpdateColors();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Prepares the given document to conform to the overall layout. This requires to draw an
        /// intermediate set of controls (panels) and add menu + toolbar.
        /// </summary>
        /// <param name="document">The document to adjust, which comes with the actual content.</param>
        /// <param name="backend">The backend UI form used to get toolbar and menu.</param>
        /// <param name="withPadding">Indicates if we need padding around the content or not.</param>
        private void SetupDockLayout(ITabDocument document, UIForm backend, bool withPadding)
        {
            // Setting up the layout requires some additional nesting of controls.
              // A tab document should have only one container as top level control, which we re-host.
              Control root = document.Content;
              Control content = (root.Controls.Count > 0) ? root.Controls[0] : null;

              // If there's already a drawable panel then this document has already been set up
              // and just needs to be shown. Happens for re-used views (like the Output view).
              if (content is DrawablePanel)
            return;

              root.Controls.Clear();

              // Content area.
              DrawablePanel contentPanel = new DrawablePanel();
              contentPanel.BackColor = MySQL.Conversions.GetApplicationColor(ApplicationColor.AppColorMainBackground, false);
              contentPanel.CustomBackground = false;
              contentPanel.Dock = DockStyle.Fill;
              contentPanel.Padding = withPadding ? new Padding(6) : new Padding(0);
              root.Controls.Add(contentPanel);
              if (content != null)
              {
            contentPanel.Controls.Add(content);
            content.Dock = DockStyle.Fill;
              }

              // Menu + toolbar area. We have two types of tab documents:
              // - appview based (and hence backend-managed)
              // - native Form (with interface via WBContext).
              // Appview based documents have own methods to return their menu and toolbar because
              // retrieval via managed code requires a managed UIForm. However appview classes are
              // already managed via mforms and adding another reference management via UIForm
              // will lead to unpredictable results.
              ToolStrip toolbar;
              MenuStrip menu;
              if (backend != null)
              {
            // Retrieval via WBContext will return a default toolbar if no other is defined.
            toolbar = wbContext.toolbar_for_form(backend);
            menu = wbContext.menu_for_form(backend);
              }
              else
              {
            AppViewDockContent dockContent = document as AppViewDockContent;
            toolbar = dockContent.GetToolBar();
            if (toolbar == null)
              toolbar = wbContext.toolbar_for_form(null); // Currently never returns a toolbar.
            menu = wbContext.menu_for_appview(dockContent);
              }
              DrawablePanel menuPanel = new DrawablePanel();
              if (toolbar != null || menu != null)
              {
            menuPanel.BackColor = Color.Transparent;
            menuPanel.CustomBackground = true;
            menuPanel.Dock = DockStyle.Top;
            menuPanel.AutoSize = true;
            root.Controls.Add(menuPanel);
            if (toolbar != null)
            {
              toolbar.BackColor = Conversions.GetApplicationColor(ApplicationColor.AppColorMainTab, false);

              menuPanel.Controls.Add(toolbar);
              toolbar.Dock = DockStyle.Top;
            }

            if (menu != null)
            {
              menu.BackColor = Conversions.GetApplicationColor(ApplicationColor.AppColorMainTab, false);

              menuPanel.Controls.Add(menu);
              menu.Dock = DockStyle.Top;
              menu.AutoSize = true;
            }
              }
        }
Exemplo n.º 14
0
 public void UndockDocument(ITabDocument document)
 {
     mainContentTabControl.RemoveDocument(document);
 }
Exemplo n.º 15
0
 private void CloseTabDocument(ITabDocument document)
 {
     if (document is IWorkbenchDocument)
     (document as IWorkbenchDocument).CloseDocument();
       else
     if (document is MySQL.Forms.AppViewDockContent)
     {
       MySQL.Forms.AppViewDockContent content = document as MySQL.Forms.AppViewDockContent;
       content.CloseDocument();
     }
 }
Exemplo n.º 16
0
        /// <summary>
        /// Returns the list of documents in an array, e.g. to allow manipulation of this list in a loop.
        /// </summary>
        /// <returns></returns>
        public ITabDocument[] DocumentsToArray()
        {
            ITabDocument[] result = new ITabDocument[TabCount];
              int i = 0;
              foreach (ITabDocument content in Documents)
            result[i++] = content;

              return result;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Docks the given document to the bottom tab control (like object editors etc.).
        /// </summary>
        /// <param name="document"></param>
        public void DockDocument(ITabDocument document, bool activate)
        {
            if (!bottomTabControl.HasDocument(document))
            bottomTabControl.AddDocument(document);
              if (activate)
            document.Activate();

              if (contentSplitContainer.Panel2Collapsed)
              {
            contentSplitContainer.Panel2Collapsed = false;

            // Set a splitter distance or we end up at almost full display. Use a relatively small
            // value for panel2. The document's min height will kick in and does the right job.
            contentSplitContainer.SplitterDistance = contentSplitContainer.Height - 100;
              }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Checks if the document is the first control on any of our pages.
        /// </summary>
        /// <returns>True if the document was found, otherwise false.</returns>
        public bool HasDocument(ITabDocument document)
        {
            foreach (TabPage page in TabPages)
            if (DocumentFromHierarchy(page) == document)
              return true;

              return false;
        }
Exemplo n.º 19
0
        private void DockSideDocument(ITabDocument document, bool top, bool activate)
        {
            if (top)
              {
            if (!sideTopTabControl.HasDocument(document))
            {
              int index = sideTopTabControl.AddDocument(document);
              sideTopTabControl.TabPages[index].BackColor = Color.White;
            }
              }
              else
              {
            if (!sideBottomTabControl.HasDocument(document))
            {
              int index = sideBottomTabControl.AddDocument(document);
              sideBottomTabControl.TabPages[index].BackColor = Color.White;
            }
              }
              if (activate)
            document.Activate();

              if (sideBottomTabControl.TabCount == 0)
            sideSplitContainer.Panel2Collapsed = true; // This will implicitly expand panel1.
              else
            sideSplitContainer.Panel1Collapsed = false;
              if (sideTopTabControl.TabCount == 0)
            sideSplitContainer.Panel1Collapsed = true; // This will implicitly expand panel2.
              else
            sideSplitContainer.Panel2Collapsed = false;
        }
Exemplo n.º 20
0
 public void AddDocumentTab(ITabDocument document, string pluginId)
 {
     _tabDocumentController.AddDocument(document, pluginId);
 }