/// <summary>
        /// Overrides the base class function to handle drag of panels and resizing.
        /// </summary>
        /// <param name="e">A MouseEventArgs that contains the mouse data.</param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            bool inPanelBar = ((panelList.Count > 1) && (e.Y > this.Height-this.DockPadding.Bottom) && (this.DockType != DockContainerType.Document)) || ((e.Y < bottomDock)  && (this.DockType == DockContainerType.Document));

            if (inPanelBar && (this.ClientRectangle.Contains(e.X, e.Y)))
            {
                // Display tool-tip.
                UpdateToolTip(new Point(e.X, e.Y));
            }
            else
            {
                // Check panel movement.
                if ((e.Button == MouseButtons.Left) && (activePanel != null) && !ptStart.Equals(new Point(e.X, e.Y)))
                {
                    Rectangle rc = RectangleToScreen(ClientRectangle);
                    DockWindow form = activePanel.Form;

                    if (dragWindow == null)
                    {
                        dragWindow = new DockWindow();
                        dragWindow.IsDragWindow = true;
                        dragWindow.Size = form.Size;
                        dragWindow.DockType = this.DockType;
                        DockContainer c = TopLevelContainer;
                        if (c != null)
                            dragWindow.DragWindow += new DockEventHandler(c.DragWindow);
                        dragWindow.Show();
                    }

                    if (dragWindow.dragTarget == null)
                        dragWindow.Location = new Point(e.X+rc.X-10, e.Y+rc.Y-10);
                    else
                        dragWindow.MoveWindow();

                    if (dragWindow.dragTarget == null)
                        dragWindow.Size = form.Size;
                }
            }

            base.OnMouseMove(e);
        }
        /// <summary>
        /// Adds a new desktop to the FrontEnd (new view to the project)
        /// </summary>
        public void NewDesktop()
        {
            string tmp = ResManager.GetString("MenuNewViewName");

            //determining the name of the new desktop
            int count = 1;
            foreach (ProjectManager.View view in projectManager.Views)
            {
                if (view.Name.Contains(tmp))
                {
                    //getting the number
                    int number = view.Name.IndexOfAny(new char[] {'0', '1',
                        '2', '3', '4', '5', '6', '7', '8', '9'});
                    if (number != -1)
                    {
                        string numberString = view.Name.Substring(number);
                        number = System.Convert.ToInt32(numberString);

                        if (number > count)
                        {
                            count = number;
                        }
                    }
                }
            }
            string name = tmp + System.Convert.ToString(count + 1);

            //creating new view and its content
            ProjectManager.View newView =
                projectManager.NewView(name);
            FerdaDesktop newDesktop =
                new FerdaDesktop(this, SvgManager, menu, newView, projectManager,
                archive, this, toolBar);
            DockWindow desktopContent = new DockWindow();

            views.Add(newDesktop);
            viewContents.Add(desktopContent);

            //other desktop initializations
            newDesktop.Dock = DockStyle.Fill;
            desktopContent.DockType = DockContainerType.Document;
            desktopContent.Text = newView.Name;
            desktopContent.TextChanged += new EventHandler(desktopContent_TextChanged);
            desktopContent.Closed += new EventHandler(desktopContent_Closed);
            desktopContent.Activated += new EventHandler(desktopContent_Activated);
            newDesktop.ResManager = this.ResManager;
            newDesktop.Clipboard = this;
            newDesktop.PropertiesDisplayer = propertyGrid;
            newDesktop.ContextHelpDisplayer = contextHelp;
            newDesktop.UserNote = userNote;

            //adding the views
            newDesktop.Views = views;

            desktopContent.Controls.Add(newDesktop);
            desktopContent.ResumeLayout(false);

            //setting the IViewDisplayers of the property grid
            propertyGrid.ViewDisplayers.Add(newDesktop);

            //docking the desktop
            dockingManager.AddForm(desktopContent);
            AddOwnedForm(desktopContent);
            dockingManager.DockWindow(desktopContent, DockStyle.Fill);
        }
        /// <summary>
        /// Initializes the user note control of the application
        /// </summary>
        protected void SetupUserNote()
        {
            //creating the user note control and its content
            userNote = new UserNote.FerdaUserNote();
            userNoteContent = new DockWindow();
            //I dont really know how this works, but putting there a smaller number
            //makes the user note a little bit smaller
            userNoteContent.Size = new Size(150, 50);

            //synchronizing the sizes of the content and userNote
            userNoteContent.ClientSize = userNoteContent.Size;
            userNoteContent.Resize += new EventHandler(userNoteContent_Resize);

            //Settings required by teh DockDotNet library to dock anything
            userNoteContent.DockType = DockContainerType.ToolWindow;
            userNoteContent.Text = ResManager.GetString("UserNoteCaption");
            userNoteContent.ResumeLayout(false);

            userNoteContent.Controls.Add(userNote);

            archive.UserNote = userNote;
            foreach (FerdaDesktop desktop in views)
            {
                desktop.UserNote = userNote;
            }
            userNote.Reset();
        }
        /// <summary>
        /// Initializes the property grid of the application
        /// </summary>
        protected void SetupProperties()
        {
            //creating the property grid and its content
            propertyGrid = new Ferda.FrontEnd.Properties.FerdaPropertyGrid(this, menu, toolBar);
            propertyGridContent = new DockWindow();
            propertyGridContent.Resize += new EventHandler(propertyGridContent_Resize);
            propertyGrid.Name = "PropertyGrid";

            //synchronizing the sizes of content and propertiesDisplayer
            propertyGridContent.ClientSize = propertyGrid.Size;

            //Settings required by the DockDotNET library to dock anything
            propertyGridContent.DockType = DockContainerType.ToolWindow;
            propertyGridContent.Text = ResManager.GetString("PropertiesContentText");
            propertyGrid.ResManager = this.ResManager;

            propertyGridContent.Controls.Add(propertyGrid);
            propertyGridContent.ResumeLayout(false);

            //more initializations
        }
        /// <summary>
        /// Initializes the NewBoxTreeView of the application
        /// </summary>
        protected void SetupNewBox()
        {
            //creating the newBox and its content
            newBox = new FrontEnd.NewBox.NewBoxControl(this, menu,
                projectManager.ModulesManager, this, toolBar);
            newBoxContent = new DockWindow();
            newBoxContent.Resize += new EventHandler(newBoxContent_Resize);

            //synchronizin the sizes of content and newbox
            newBoxContent.ClientSize = newBox.Size;

            //Settings required by the DockDotNET library to dock anything
            newBoxContent.DockType = DockContainerType.ToolWindow;
            newBoxContent.Text = ResManager.GetString("NewBoxContentText");
            //newBox.ResManager = this.ResManager;

            newBoxContent.Controls.Add(newBox);
        }
        /// <summary>
        /// Initializes the desktop (view) of the application
        /// </summary>
        protected void SetupDesktop()
        {
            foreach (ProjectManager.View view in projectManager.Views)
            {
                //creating a view and its content
                FerdaDesktop desktop =
                    new FerdaDesktop(this, SvgManager, menu, view,
                    projectManager, archive, this, toolBar);
                DockWindow desktopContent = new DockWindow();

                views.Add(desktop);
                viewContents.Add(desktopContent);

                //other desktop initializations
                desktop.Dock = DockStyle.Fill;
                desktopContent.DockType = DockContainerType.Document;
                desktopContent.Text = view.Name;
                desktop.ResManager = this.ResManager;
                desktop.Clipboard = this;
                desktop.PropertiesDisplayer = propertyGrid;
                desktop.ContextHelpDisplayer = contextHelp;
                desktop.UserNote = userNote;

                //event for changing names
                desktopContent.TextChanged += new EventHandler(desktopContent_TextChanged);
                //the closing event
                desktopContent.Closed += new EventHandler(desktopContent_Closed);

                desktopContent.Controls.Add(desktop);
                desktopContent.ResumeLayout(false);

                desktopContent.Activated += new EventHandler(desktopContent_Activated);

                //setting the IViewDisplayers of the property grid
                propertyGrid.ViewDisplayers.Add(desktop);
            }

            //setting the views property to the archive and all other views
            archive.Views = views;
            foreach (FerdaDesktop desktop in views)
            {
                desktop.Views = views;
            }
        }
        public void RemoveForm(DockWindow wnd)
        {
            if (!listPanel.Contains(wnd.ControlContainer))
                return;

            try
            {
                // Event handler.
                wnd.DragWindow -= dragWindowHandler;

                // Update lists.
                listPanel.Remove(wnd.ControlContainer);
                if (wnd.DockType == DockContainerType.Document)
                    listDocument.Remove(wnd.ControlContainer);
                else if (wnd.DockType == DockContainerType.ToolWindow)
                    listTool.Remove(wnd.ControlContainer);
            }
            catch (Exception ex)
            {
                Console.WriteLine("DockManager.RemoveForm: "+ex.Message);
            }
        }
 /// <summary>
 /// Closes the attached drag window.
 /// </summary>
 private void CloseDragWindow()
 {
     if (dragWindow != null)
     {
         dragWindow.Close();
         dragWindow.Dispose();
         dragWindow = null;
     }
 }
        /// <summary>
        /// Overrides the base class function to handle drag of panels and resizing.
        /// </summary>
        /// <param name="e">A MouseEventArgs that contains the mouse data.</param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            // Destroy drag window.
            if (dragWindow != null)
            {
                dragWindow.Close();
                dragWindow.Dispose();
                dragWindow = null;
            }

            // Test header.
            Focus();

            ptStart = new Point(e.X, e.Y);

            // Test footer.
            if (panelList.Count > 1)
            {
                foreach (DockPanel panel in panelList)
                {
                    if (panel.TabRect.Contains(e.X, e.Y))
                    {
                        ActivePanel = panel;
                        return;
                    }
                }
            }

            base.OnMouseDown(e);
        }
        /// <summary>
        /// The direct version of the DragWindow event handler to dock a window into the container.
        /// Can be used for every container.
        /// </summary>
        /// <param name="wnd">The DockWindow that is to be docked.</param>
        /// <param name="style">The preferred dock style. Use Fill to dock directly into the container.</param>
        /// <returns>The success of the operation.</returns>
        public bool DockWindow(DockWindow wnd, DockStyle style)
        {
            Rectangle rc = RectangleToScreen(this.ClientRectangle);
            Point pt = new Point(0, 0);

            switch (style)
            {
                case DockStyle.Left:
                    pt = new Point(rc.Left+this.DockPadding.Left+dockBorder/2, rc.Top+rc.Height/2);
                    break;
                case DockStyle.Right:
                    pt = new Point(rc.Left+rc.Width-this.DockPadding.Right-dockBorder/2, rc.Top+rc.Height/2);
                    break;
                case DockStyle.Top:
                    pt = new Point(rc.Left+rc.Width/2, rc.Top+this.DockPadding.Top+dockBorder/2);
                    break;
                case DockStyle.Bottom:
                    pt = new Point(rc.Left+rc.Width/2, rc.Top+rc.Height-this.DockPadding.Bottom-dockBorder/2);
                    break;
                case DockStyle.Fill:
                    pt = new Point(rc.Left+rc.Width/2, rc.Top+this.DockPadding.Top/2);
                    break;
                default:
                    return false;
            }

            if ((wnd.IsDocked) && (wnd.HostContainer.Dock == style))
                return true;

            wnd.Release();
            DragWindow(wnd, new DockEventArgs(pt, wnd.DockType, true));
            return wnd.IsDocked;
        }
        /// <summary>
        /// Releases a DockWindow from the container.
        /// The container may destroy itself at the end of this procedure if it is empty and removeable.
        /// </summary>
        /// <param name="form">The DockWindow that is to be released.</param>
        /// <returns>The success of the operation.</returns>
        internal bool ReleaseWindow(DockWindow form)
        {
            bool ret = false;

            if (this.Controls.Contains(form.ControlContainer))
            {
                form.Controls.Add(form.ControlContainer);
                form.Show();
                ret = true;
            }

            if ((panelList.Count == 0) && (containerList.Count == 0) && (this.Parent is DockContainer) && (removeable))
            {
                (this.Parent as DockContainer).RemoveContainer(this);
            }

            return ret;
        }
        /// <summary>
        /// Adds a panel to the container.
        /// </summary>
        /// <param name="src">The source window of the panel.</param>
        /// <param name="pt">The target position.</param>
        public void AddPanel(DockWindow src, Point pt)
        {
            try
            {
                if (!src.IsLoaded)
                    src.CreateContainer();

                blockFocusEvents = true;
                DockPanel panel = src.ControlContainer;
                this.Controls.Add(panel);
                ActivePanel = panel;
                blockFocusEvents = false;

                if (!src.IsLoaded)
                    src.Show();

                src.Hide();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        /// <summary>
        /// Overrides the base class function to handle drag of panels and resizing.
        /// </summary>
        /// <param name="e">A MouseEventArgs that contains the mouse data.</param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (dragWindow != null)
            {
                DockWindow form = activePanel.Form;

                Rectangle rc = RectangleToScreen(this.ClientRectangle);
                dragWindow.Close();
                dragWindow.Dispose();
                dragWindow = null;

                if (form.ConfirmDock() != this)
                {
                    form.Location = new Point(e.X+rc.X-10, e.Y+rc.Y-10);
                    ReleaseWindow(form);
                }
            }

            base.OnMouseUp(e);
        }
Ejemplo n.º 14
0
 public void RegisterWindow(string name, DockWindow window, ToolStripMenuItem menuitem)
 {
     ToolWindowInfo twi = new ToolWindowInfo();
     twi.dw = window;
     twi.tsmi = menuitem;
     menuitem.Checked = true;
     toolwindows[name] = twi;
 }
        /// <summary>
        /// Opens a view that is present in the project but was closed by the user
        /// </summary>
        /// <param name="name">name of the view</param>
        public void OpenView(string name)
        {
            //creating the view and its content
            ProjectManager.View newView = projectManager.GetView(name);
            FerdaDesktop newDesktop = new FerdaDesktop(this, SvgManager, menu, newView,
                projectManager, archive, this, toolBar);
            DockWindow desktopContent = new DockWindow();

            views.Add(newDesktop);
            viewContents.Add(desktopContent);

            //other desktop initializations
            newDesktop.Dock = DockStyle.Fill;
            desktopContent.DockType = DockContainerType.Document;
            desktopContent.Text = newView.Name;
            desktopContent.TextChanged += new EventHandler(desktopContent_TextChanged);
            desktopContent.Closed += new EventHandler(desktopContent_Closed);
            desktopContent.Activated += new EventHandler(desktopContent_Activated);
            newDesktop.ResManager = this.ResManager;
            newDesktop.Clipboard = this;
            newDesktop.PropertiesDisplayer = propertyGrid;
            newDesktop.ContextHelpDisplayer = contextHelp;

            //adding the views
            newDesktop.Views = views;

            desktopContent.Controls.Add(newDesktop);
            desktopContent.ResumeLayout(false);

            //setting the IViewDisplayers of the property grid
            propertyGrid.ViewDisplayers.Add(newDesktop);

            //docking the desktop
            dockingManager.AddForm(desktopContent);
            AddOwnedForm(desktopContent);
            dockingManager.DockWindow(desktopContent, DockStyle.Fill);
        }
        /// <summary>
        /// Initializes the archive of the application
        /// </summary>
        protected void SetupArchive()
        {
            //creating the archive and its content
            archive = new Ferda.FrontEnd.Archive.FerdaArchive(this, menu, this,
                projectManager.Archive, this, toolBar, projectManager);
            archiveContent = new DockWindow();
            archiveContent.Resize += new EventHandler(archiveContent_Resize);

            //synchronizing the sizes of content and archive
            archiveContent.ClientSize = archive.Size;

            //Settings required by the DockDotNET library to dock anything
            archiveContent.DockType = DockContainerType.ToolWindow;
            archiveContent.Text = ResManager.GetString("ArchiveContentText");
            archive.ResManager = this.ResManager;
            archive.PropertiesDisplayer = propertyGrid;
            archive.ContextHelpDisplayer = contextHelp;

            //setting the archive displayer
            propertyGrid.ArchiveDisplayer = archive;
            menu.ArchiveDisplayer = archive;

            archiveContent.Controls.Add(archive);
        }
        /// <summary>
        /// The method shows a control and docks it into the FrontEnd environment
        /// </summary>
        /// <param name="userControl">A  System.Windows.Forms.UserControl</param>
        /// <param name="name">Text of the control</param>
        public void ShowDockableControl(UserControl userControl, string name)
        {
            DockWindow dockWindow = new DockWindow();
            userControl.Dock = DockStyle.Fill;
            dockWindow.DockType = DockContainerType.Document;
            dockWindow.Text = name;
            dockWindow.Controls.Add(userControl);
            dockWindow.ResumeLayout(false);

            dockingManager.AddForm(dockWindow);
            AddOwnedForm(dockWindow);
            dockingManager.DockWindow(dockWindow, DockStyle.Fill);
        }
        /// <summary>
        /// Initializes the dynamic help of the application
        /// </summary>
        protected void SetupContextHelp()
        {
            //creating the dynamic help and its content
            contextHelp = new Ferda.FrontEnd.ContextHelp.FerdaContextHelp(this, menu, toolBar);
            contextHelpContent = new DockWindow();

            //synchronizing the sizes of content and contextHelp
            contextHelpContent.ClientSize = contextHelp.Size;
            contextHelpContent.Resize += new EventHandler(contextHelpContent_Resize);

            //Settings required by the DockDotNET library to dock anything
            contextHelpContent.DockType = DockContainerType.ToolWindow;
            contextHelpContent.Text = ResManager.GetString("ContextHelpContentText");
            contextHelpContent.ResumeLayout(false);
            contextHelp.ResManager = this.ResManager;

            contextHelpContent.Controls.Add(contextHelp);
        }
 /// <summary>
 /// Creates an attached drag window.
 /// </summary>
 private void ShowDragWindow()
 {
     if (!isDragWindow)
     {
         Rectangle rc = RectangleToScreen(this.Bounds);
         dragWindow = new DockWindow();
         dragWindow.IsDragWindow = true;
         dragWindow.Size = this.Size;
         dragWindow.DockType = this.DockType;
         dragWindow.DragWindow += DragWindow;
         dragWindow.Show();
         dragWindow.Location = this.Location;
     }
 }
        public void AddForm(DockWindow wnd)
        {
            try
            {
                // Event handler.
                wnd.DragWindow += dragWindowHandler;
                wnd.Closed += new EventHandler(FormClosed);

                // Update lists.
                listPanel.Add(wnd.ControlContainer);
                if (wnd.DockType == DockContainerType.Document)
                    listDocument.Add(wnd.ControlContainer);
                else if (wnd.DockType == DockContainerType.ToolWindow)
                    listTool.Add(wnd.ControlContainer);
            }
            catch (Exception ex)
            {
                Console.WriteLine("DockManager.AddForm: "+ex.Message);
            }
        }