Beispiel #1
0
        internal AutoHideGroup GetAutoHideGroup(DockWindow window)
        {
            int index = this.FindGroupIndex(window);

            if (index != -1)
            {
                return(this.autoHideGroups[index]);
            }

            return(null);
        }
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            DockWindow pane = this.SelectedPane;

            if (pane != null)
            {
                this.dockManager.ActiveWindow = pane;
            }
        }
Beispiel #3
0
        protected internal override void UpdateAfterControlRemoved(Control value)
        {
            base.UpdateAfterControlRemoved(value);

            DockWindow active = this.ActiveWindow;

            if (active != null)
            {
                this.UpdateActiveWindow(active, false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Attempts to restore the state the window to the desired dock state.
        /// </summary>
        /// <param name="window"></param>
        /// <param name="state">The target state which is to be restored.</param>
        /// <param name="defaultAction">True to perform default action if no state is recorded for a window, false otherwise.</param>
        public void RestoreState(DockWindow window, DockState state, bool defaultAction)
        {
            if (!this.CanOperate())
            {
                return;
            }

            RedockTransaction transaction = new RedockTransaction(state, new DockWindow[] { window }, defaultAction);

            this.DockManager.RegisterTransaction(transaction, true);
        }
Beispiel #5
0
        /// <summary>
        /// Determines whether a context menu can be displayed for the specified window.
        /// </summary>
        /// <param name="window"></param>
        /// <returns></returns>
        protected virtual bool CanDisplayMenu(DockWindow window)
        {
            //check whether we can display a menu for the specified window
            switch (window.DockState)
            {
            case DockState.TabbedDocument:
                return(this.allowDocumentContextMenu);

            default:
                return(this.allowToolContextMenu);
            }
        }
Beispiel #6
0
 /// <summary>
 /// Receives a notification for a change in the DockState property of a DockWindow.
 /// We may have a situation where a ToolWindow becomes a TabbedDocument and vice-versa.
 /// </summary>
 /// <param name="window"></param>
 internal void OnDockWindowDockStateChanged(DockWindow window)
 {
     //update the documents collection
     if (window.DockState == DockState.TabbedDocument)
     {
         this.InsertDocument(-1, window);
     }
     else
     {
         this.RemoveDocument(-1, window);
     }
 }
Beispiel #7
0
        void form_Shown(object sender, EventArgs e)
        {
            Form form = (Form)sender;

            form.Shown -= new EventHandler(form_Shown);
            DockWindow host = this.dockManager.GetHostWindow(form);

            if (host != null)
            {
                host.Text = form.Text;
            }
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnControlRemoved(System.Windows.Forms.ControlEventArgs e)
        {
            base.OnControlRemoved(e);

            DockWindow window = e.Control as DockWindow;

            if (window.TabStripItem == this.boldedItem)
            {
                this.boldedItem = null;
            }

            UpdateView();
        }
Beispiel #9
0
        internal void RemoveAutoHideGroup(DockWindow window)
        {
            int index = this.FindGroupIndex(window);

            if (index == -1)
            {
                return;
            }

            AutoHideGroup group = this.autoHideGroups[index];

            group.Windows.Clear();
            this.autoHideGroups.RemoveAt(index);
        }
Beispiel #10
0
        /// <summary>
        /// Builds the default list of documents. Called upon initialization completion.
        /// </summary>
        internal void BuildDocumentList()
        {
            this.ClearDocuments();

            foreach (Control child in ControlHelper.EnumChildControls(this.dockManager.MainDocumentContainer, true))
            {
                DockWindow document = child as DockWindow;
                if (document != null && document.DockManager == this.dockManager)
                {
                    document.InnerDockState = DockState.TabbedDocument;
                    this.InsertDocument(-1, document);
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Saves the current state of the specified window.
        /// </summary>
        /// <param name="window"></param>
        /// <returns></returns>
        public virtual bool SaveState(DockWindow window)
        {
            if (!this.CanOperate())
            {
                return(false);
            }

            if (!IsSaveApplicable(window))
            {
                return(false);
            }

            return(this.SaveStateCore(window));
        }
Beispiel #12
0
        private void DeactivatePreviousActive(DockWindow newActive)
        {
            if (this.documents.Count == 0)
            {
                return;
            }

            DockWindow currActive = this.documents[0];

            if (currActive != null && currActive != newActive)
            {
                currActive.UpdateActiveState(false);
            }
        }
Beispiel #13
0
        /// <summary>
        /// Collects all the DockWindow instances, residing on the specified parent, and associated with the provided RadDock instance.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="recursive"></param>
        /// <param name="dockManager"></param>
        /// <returns></returns>
        public static List <DockWindow> GetDockWindows(Control parent, bool recursive, RadDock dockManager)
        {
            List <DockWindow> descendants = new List <DockWindow>();

            foreach (Control child in ControlHelper.EnumChildControls(parent, recursive))
            {
                DockWindow window = child as DockWindow;
                if (window != null && window.DockManager == dockManager)
                {
                    descendants.Add(window);
                }
            }

            return(descendants);
        }
Beispiel #14
0
        /// <summary>
        ///
        /// </summary>
        protected internal override void UpdateAfterTransaction()
        {
            base.UpdateAfterTransaction();

            if (this.DockManager == null)
            {
                return;
            }

            DockWindow   activeDocument = this.DockManager.DocumentManager.ActiveDocument;
            DockWindow   active         = this.ActiveWindow;
            TabStripItem item           = active == activeDocument ? active.TabStripItem : null;

            this.BoldSelectedDocument(item);
        }
Beispiel #15
0
 private void EnsureActiveDocument()
 {
     //search all DocumentTabStrip instances and select the first opened document
     foreach (Control child in ControlHelper.EnumChildControls(this.dockManager.MainDocumentContainer, true))
     {
         DocumentTabStrip strip = child as DocumentTabStrip;
         if (strip != null && strip.TabPanels.Count > 0 && strip.DockManager == this.dockManager)
         {
             DockWindow active = strip.ActiveWindow;
             this.InsertDocument(-1, active);
             strip.UpdateActiveWindow(active, true);
             break;
         }
     }
 }
Beispiel #16
0
        private void CloseAllDocuments(DockWindow toSkip)
        {
            this.DockManager.BeginTransactionBlock();

            foreach (DockWindow docWindow in DockHelper.GetDockWindows(this.DockManager.MainDocumentContainer, true, this.DockManager))
            {
                if (docWindow == toSkip)
                {
                    continue;
                }

                docWindow.Close();
            }

            this.DockManager.EndTransactionBlock();
        }
Beispiel #17
0
        private void OnActiveDocumentMenuItemClick(object sender, EventArgs e)
        {
            RadMenuItem item = sender as RadMenuItem;

            if (item == null)
            {
                return;
            }

            DockWindow window = item.Tag as DockWindow;

            if (window != null)
            {
                window.EnsureVisible();
            }
        }
Beispiel #18
0
        private int FindGroupIndex(DockWindow window)
        {
            for (int i = 0; i < this.autoHideGroups.Count; i++)
            {
                AutoHideGroup group = this.autoHideGroups[i];
                for (int j = 0; j < group.Windows.Count; j++)
                {
                    if (group.Windows[j] == window)
                    {
                        return(i);
                    }
                }
            }

            return(-1);
        }
Beispiel #19
0
        private void ApplyDockWindowSettings(DockWindow dockWindow)
        {
            dockWindow.Text = this.Text;
            DockState dockState = XmlDockable.ParseDockState(this.DockState);

            if (dockState != Telerik.WinControls.UI.Docking.DockState.TabbedDocument)
            {
                dockWindow.DockState = dockState;
            }
            else
            {
                dockWindow.InnerDockState   = dockState;
                dockWindow.DesiredDockState = dockState;
            }
            dockWindow.Size = XmlDockable.ParseSize(this.PreferredDockSize);
        }
Beispiel #20
0
        /// <summary>
        /// Performs the core action, depending on the clicked menu item.
        /// </summary>
        /// <param name="menuItem"></param>
        /// <param name="window"></param>
        protected virtual void PerformMenuItemAction(DockWindow window, RadMenuItemBase menuItem)
        {
            switch (menuItem.Name)
            {
            case ActivateWindow:
                this.DockManager.ActiveWindow = window;
                window.EnsureVisible();
                break;

            case DockStateAutoHide:
            case DockStateDocked:
            case DockStateFloating:
            case DockStateHidden:
            case DockStateTabbedDocument:
                this.DockManager.SetWindowState(window, (DockState)Enum.Parse(typeof(DockState), menuItem.Name));
                break;

            case CloseAll:
                this.CloseAllDocuments(null);
                break;

            case CloseAllButThis:
                this.CloseAllDocuments(window);
                break;

            case CloseWindow:
                window.Close();
                break;

            case NewHTabGroup:
                this.DockManager.AddDocument(window, window.TabStrip as DocumentTabStrip, DockPosition.Bottom);
                break;

            case NewVTabGroup:
                this.DockManager.AddDocument(window, window.TabStrip as DocumentTabStrip, DockPosition.Right);
                break;

            case MoveToPrevTabGroup:
                this.DockManager.MoveToPreviousDocumentTabStrip(window);
                break;

            case MoveToNextTabGroup:
                this.DockManager.MoveToNextDocumentTabStrip(window);
                break;
            }
        }
Beispiel #21
0
        /// <summary>
        /// Updates the currently active window by setting bold if the specified window instance is the currently active document within the owning RadDock instance.
        /// </summary>
        /// <param name="window"></param>
        /// <param name="active"></param>
        protected internal override void UpdateActiveWindow(DockWindow window, bool active)
        {
            base.UpdateActiveWindow(window, active);

            if (window == null || this.DockManager == null || ((IComponentTreeHandler)this.DockManager).Initializing)
            {
                return;
            }

            TabStripItem item = null;

            if (active && window == this.DockManager.DocumentManager.ActiveDocument)
            {
                item = window.TabStripItem;
            }
            this.BoldSelectedDocument(item);
        }
Beispiel #22
0
        /// <summary>
        ///
        /// </summary>
        protected internal override void UpdateButtons()
        {
            base.UpdateButtons();

            if (this.DockManager == null)
            {
                return;
            }

            DockWindow active = this.ActiveWindow;

            if (active == null)
            {
                return;
            }

            DocumentStripButtons buttons = active.DocumentButtons;

            //update close button
            if ((buttons & DocumentStripButtons.Close) == 0)
            {
                this.closeButton.Visibility = ElementVisibility.Collapsed;
            }
            else
            {
                if (this.DockManager.CanChangeWindowState(active, DockState.Hidden, false))
                {
                    this.closeButton.Visibility = ElementVisibility.Visible;
                }
                else
                {
                    this.closeButton.Visibility = ElementVisibility.Collapsed;
                }
            }

            //update active window list button
            if ((buttons & DocumentStripButtons.ActiveWindowList) == 0)
            {
                this.overflowMenuButton.Visibility = ElementVisibility.Collapsed;
            }
            else
            {
                this.overflowMenuButton.Visibility = ElementVisibility.Visible;
            }
        }
Beispiel #23
0
        private QuickNavigatorListItem CreateListItem(DockWindow pane)
        {
            QuickNavigatorListItem element = (QuickNavigatorListItem)Activator.CreateInstance(this.settings.ListItemType);

            element.ImagePrimitive.ImageLayout = ImageLayout.Zoom;
            element.Image = pane.Image;
            element.Text  = pane.Text;
            element.TextElement.TextWrap            = false;
            element.TextElement.AutoEllipsis        = true;
            element.TextElement.StretchHorizontally = true;
            element.TextElement.StretchVertically   = true;
            element.TextElement.AutoSize            = true;
            element.MinSize = this.settings.ListItemSize;
            //pass the associated pane as a Tag
            element.Tag = pane;

            return(element);
        }
Beispiel #24
0
        /// <summary>
        /// Gets the menu items, associated with the specified DockWindow.
        /// </summary>
        /// <param name="window"></param>
        /// <param name="defaultAction">True to execute the default action, associated with each item, when an item is clicked.</param>
        /// <returns></returns>
        public List <RadMenuItemBase> GetContextMenuItems(DockWindow window, bool defaultAction)
        {
            if (window == null)
            {
                throw new ArgumentNullException("Window");
            }
            if (window.DockManager != this.DockManager)
            {
                throw new ArgumentException("Specified DockWindow is not owned by the DockManager this service is registered with.");
            }

            this.hookItemClick = defaultAction;
            List <RadMenuItemBase> items = this.BuildContextMenuItems(window);

            this.hookItemClick = true;

            return(items);
        }
        public override object Execute(params object[] settings)
        {
            RadDock dockManager = settings[0] as RadDock;

            if (dockManager == null)
            {
                throw new ArgumentNullException("DockManager");
            }

            DockWindow activeDoc = dockManager.DocumentManager.ActiveDocument;

            if (activeDoc != null)
            {
                dockManager.CloseWindow(activeDoc);
            }

            return(base.Execute(settings));
        }
Beispiel #26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            if (!this.ContainsFocus)
            {
                base.Focus();
            }

            base.OnMouseDown(e);

            if (this.dockManager != null)
            {
                this.dockManager.ActiveWindow = this.ActiveWindow;
            }

            if (e.Button == MouseButtons.Left)
            {
                this.initialMousePosition = e.Location;
            }
        }
Beispiel #27
0
        private void UpdateCaptions(bool checkDockManager)
        {
            List <ToolTabStrip> visibleStrips = new List <ToolTabStrip>();

            foreach (Control child in ControlHelper.EnumChildControls(this.dockContainer, true))
            {
                ToolTabStrip strip = child as ToolTabStrip;
                if (strip == null || strip.Collapsed)
                {
                    continue;
                }
                if (checkDockManager && strip.DockManager != this.dockManager)
                {
                    continue;
                }

                visibleStrips.Add(strip);
            }

            bool hasCaption = visibleStrips.Count > 1;

            foreach (ToolTabStrip strip in visibleStrips)
            {
                strip.CanDisplayCaption = hasCaption;
                strip.PerformLayout();
            }

            if (hasCaption)
            {
                this.Text = string.Empty;
            }
            else if (visibleStrips.Count == 1)
            {
                DockWindow window = ((DockTabStrip)visibleStrips[0]).ActiveWindow;
                if (window != null)
                {
                    this.Text = window.Text;
                }
            }

            this.dockContainer.PerformLayout();
        }
Beispiel #28
0
        /// <summary>
        /// Overrides the method to provide support for instanciating a DragDropService operation.
        /// </summary>
        /// <param name="mouse"></param>
        protected override void OnDragInitialized(Point mouse)
        {
            if (this.DockManager == null)
            {
                return;
            }

            DockWindow activeWindow = this.ActiveWindow;

            if (activeWindow == null)
            {
                return;
            }

            draggedItem = this.elementTree.GetElementAtPoint(mouse) as TabStripItem;
            object dragged = null;

            if (draggedItem != null)
            {
                if (!this.tabStripElement.ItemContainer.ControlBoundingRectangle.Contains(mouse))
                {
                    dragged = activeWindow;
                }

                if (this.TabPanels.Count == 1 && this.ActiveWindow.DockState == DockState.Floating)
                {
                    dragged = null;
                }
            }
            else
            {
                if (activeWindow.DockState != DockState.AutoHide && this.IsDragAllowed(this.DragStart))
                {
                    dragged = this;
                }
            }

            if (dragged != null)
            {
                this.dockManager.BeginDrag(dragged);
            }
        }
Beispiel #29
0
        /// <summary>
        /// Removes previously saved redock state for the specified window for the specified DockState.
        /// </summary>
        /// <param name="window"></param>
        /// <param name="dockState"></param>
        /// <returns></returns>
        public bool ClearState(DockWindow window, DockState dockState)
        {
            RedockState state = this.GetState(window, dockState, true);

            if (state == null)
            {
                return(false);
            }

            this.RemovePreviousState(state);
            //remove from clean-up list
            int index = this.oldStates.IndexOf(state);

            if (index != -1)
            {
                this.oldStates.RemoveAt(index);
            }

            return(true);
        }
Beispiel #30
0
        /// <summary>
        /// Preforms the core Save logic.
        /// </summary>
        /// <param name="window"></param>
        /// <returns></returns>
        protected virtual bool SaveStateCore(DockWindow window)
        {
            Dictionary <DockState, RedockState> states;

            this.redockStates.TryGetValue(window.Name, out states);

            if (states == null)
            {
                states = new Dictionary <DockState, RedockState>();
                this.redockStates[window.Name] = states;
            }

            RedockState savedState;

            if (window.DockState == DockState.Floating)
            {
                savedState = new RedockFloatingState(window);
            }
            else
            {
                savedState = new RedockState(window, window.DockState);
            }

            //invalid state
            if (!savedState.IsValid)
            {
                return(false);
            }

            RedockState oldState;

            states.TryGetValue(window.DockState, out oldState);
            if (oldState != null)
            {
                oldStates.Add(oldState);
            }

            states[window.DockState] = savedState;

            return(true);
        }