Esempio n. 1
0
        internal void ShowBar()
        {
            if (PassiveBar)
            {
                base.Show();
                this.Update();
                return;
            }

            if (m_BarState == eBarState.Floating)
            {
                if (m_Float == null)
                {
                    m_Float = new FloatingContainer(this);
                    m_Float.CreateControl();
                    if (this.Parent != null)
                    {
                        if (this.Parent is DockSite)
                            ((DockSite)this.Parent).RemoveBar(this);
                        else
                            this.Parent.Controls.Remove(this);
                    }
                    this.Parent = null;
                    m_Float.Controls.Add(this);
                    // WE OVERRIDE BASE LOCATION WE MUST USE BASE.
                    base.Location = new Point(0, 0);
                }
                if (m_Float != null)
                {
                    // TODO: Show method did not want to show the form, check has it been fixed in newer versions
                    //m_Float.Show();
                    //NativeFunctions.SetWindowPos(m_Float.Handle.ToInt32(),NativeFunctions.HWND_TOP,0,0,0,0,NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOSIZE | NativeFunctions.SWP_NOACTIVATE | NativeFunctions.SWP_NOMOVE);
                    //m_Float.TopMost=true;
                    m_Float.TopLevel = true;
                    m_Float.Visible = true;
                    if (!base.Visible)
                        base.Visible = true;
                    m_Float.Refresh();
                }
            }
            else if (m_BarState == eBarState.Popup)
            {
                // Design mode add
                if (m_ParentItem != null && (m_ParentItem.Site != null && m_ParentItem.Site.DesignMode ||
                    m_ParentItem.Parent != null && m_ParentItem.Parent.Site != null && m_ParentItem.Parent.Site.DesignMode))
                {
                    if (AddtoDesignTimeContainer())
                        return;
                }

                //NativeFunctions.sndPlaySound("MenuPopup",NativeFunctions.SND_ASYNC | NativeFunctions.SND_NODEFAULT);
                ePopupAnimation animation = m_PopupAnimation;
                if (!BarFunctions.SupportsAnimation)
                    animation = ePopupAnimation.None;
                else
                {
                    IOwnerMenuSupport ownersupport = m_Owner as IOwnerMenuSupport;
                    if (animation == ePopupAnimation.ManagerControlled)
                    {
                        if (ownersupport != null)
                            animation = ownersupport.PopupAnimation;
                        if (animation == ePopupAnimation.ManagerControlled)
                            animation = ePopupAnimation.SystemDefault;
                    }

                    if (animation == ePopupAnimation.SystemDefault)
                        animation = NativeFunctions.SystemMenuAnimation;
                    else if (animation == ePopupAnimation.Random)
                    {
                        Random r = new System.Random();
                        int i = r.Next(2);
                        animation = ePopupAnimation.Fade;
                        if (i == 1)
                            animation = ePopupAnimation.Slide;
                        else if (i == 2)
                            animation = ePopupAnimation.Unfold;
                    }
                }

                if (BarFunctions.IsOffice2007Style(this.Style) && this.BarType == eBarType.Toolbar)
                    SetRoundRegion(this);

                if (animation == ePopupAnimation.Fade && Environment.OSVersion.Version.Major >= 5)
                {
                    // TODO: Blending was leaving the white dots in the region that was excluded, make sure that it is not happening for final release, test other AnimateWindows
                    NativeFunctions.AnimateWindow(this.Handle, BarFunctions.ANIMATION_INTERVAL, NativeFunctions.AW_BLEND);
                }
                else if (animation == ePopupAnimation.Slide)
                    NativeFunctions.AnimateWindow(this.Handle, BarFunctions.ANIMATION_INTERVAL, (NativeFunctions.AW_SLIDE | NativeFunctions.AW_HOR_POSITIVE | NativeFunctions.AW_VER_POSITIVE));
                else if (animation == ePopupAnimation.Unfold)
                    NativeFunctions.AnimateWindow(this.Handle, BarFunctions.ANIMATION_INTERVAL, (NativeFunctions.AW_HOR_POSITIVE | NativeFunctions.AW_VER_POSITIVE));
                else
                    base.Show();

                if (animation != ePopupAnimation.None && this.Controls.Count > 0)
                    this.Refresh();

                if (this.DisplayShadow && this.AlphaShadow)
                {
                    if (m_DropShadow != null)
                    {
                        m_DropShadow.Hide();
                        m_DropShadow.Dispose();
                    }
                    m_DropShadow = new PopupShadow(true);
                    m_DropShadow.CreateControl();
                    NativeFunctions.SetWindowPos(m_DropShadow.Handle, new IntPtr(NativeFunctions.HWND_NOTOPMOST), this.Left + 5, this.Top + 5, this.Width - 2, this.Height - 2, NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE);
                    m_DropShadow.UpdateShadow();
                }
            }
            else
            {
                // Retain bar's position in controls collection it can change when bar is shown
                // OnVisibleChanged will be triggered and index of the bar will be checked against
                // this value. If it has changed it will be restored.
                if (this.Parent is DockSite)
                    m_BarShowIndex = this.Parent.Controls.IndexOf(this);
                else
                    m_BarShowIndex = -1;

                if (!m_DockingInProgress && !m_LayoutSuspended && this.Parent is DockSite && this.Parent.Dock != DockStyle.Fill && ((DockSite)this.Parent).DocumentDockContainer != null)
                {
                    DockSite ds = this.Parent as DockSite;
                    m_LayoutSuspended = true;
                    base.Show();
                    m_LayoutSuspended = false;
                    ds.GetDocumentUIManager().AdjustContainerSize(this, true);
                    // Reset the side by side docking for the bars so they are uniform
                    if (!m_BarDefinitionLoading)
                    {
                        DocumentBaseContainer dc = ds.GetDocumentUIManager().GetDocumentFromBar(this);
                        if (dc != null && dc.Parent is DocumentDockContainer)
                        {
                            DocumentDockContainer p = dc.Parent as DocumentDockContainer;
                            int visibleCount = p.Documents.VisibleCount;
                            if (visibleCount > 1)
                            {
                                if (p.Orientation == eOrientation.Horizontal && (ds.Dock == DockStyle.Top || ds.Dock == DockStyle.Bottom))
                                {
                                    //float f = 1 + dc.LayoutBounds.Width / (float)(p.DisplayBounds.Width - dc.LayoutBounds.Width);
                                    //dc.SetLayoutBounds(new Rectangle(dc.LayoutBounds.X, dc.LayoutBounds.Y, (int)(dc.LayoutBounds.Width * f), dc.LayoutBounds.Height));
                                    dc.SetLayoutBounds(new Rectangle(dc.LayoutBounds.X, dc.LayoutBounds.Y, (int)(p.LayoutBounds.Width / visibleCount), dc.LayoutBounds.Height));
                                }
                                else if (p.Orientation == eOrientation.Vertical && (ds.Dock == DockStyle.Left || ds.Dock == DockStyle.Right))
                                {
                                    //float f = 1 + dc.LayoutBounds.Height / (float)(p.DisplayBounds.Height - dc.LayoutBounds.Height);
                                    //dc.SetLayoutBounds(new Rectangle(dc.LayoutBounds.X, dc.LayoutBounds.Y, dc.LayoutBounds.Width, (int)(dc.LayoutBounds.Height * f)));
                                    dc.SetLayoutBounds(new Rectangle(dc.LayoutBounds.X, dc.LayoutBounds.Y, dc.LayoutBounds.Width, (int)(p.LayoutBounds.Height / visibleCount)));
                                }
                            }
                        }
                    }
                    DotNetBarManager man = this.Owner as DotNetBarManager;
                    if (man != null && man.SuspendLayout)
                        ds.NeedsLayout = true;
                }
                else
                    base.Show();

                m_BarShowIndex = -1;
            }
            // This makes the bar paint BEFORE it returns out of this function
            this.Update();
        }
Esempio n. 2
0
        protected override void Dispose(bool disposing)
        {
            IsDisposing = true;
            if (m_ParentMsgHandlerRegistered)
            {
                DotNetBarManager.UnRegisterOwnerParentMsgHandler(this, null);
                m_ParentMsgHandlerRegistered = false;
            }
            if (m_Float != null && disposing)
            {
                try
                {
                    if (m_Float.Controls.Contains(this))
                        m_Float.Controls.Remove(this);
                    m_Float.Close();
                    m_Float.Dispose();
                    m_Float = null;
                }
                catch (Exception)
                { }
            }

            if (m_Owner is DotNetBarManager && ((DotNetBarManager)m_Owner).IgnoreLoadedControlDispose)
                this.Controls.Clear();

            if (this.Parent != null)
            {
                try
                {
                    this.Parent.Controls.Remove(this);
                }
                catch (Exception)
                { }
            }
            Microsoft.Win32.SystemEvents.UserPreferenceChanged -= new Microsoft.Win32.UserPreferenceChangedEventHandler(PreferenceChanged);
            if (m_TabDockItems != null)
            {
                m_TabDockItems.Dispose();
                m_TabDockItems = null;
            }
            if (m_DropShadow != null)
            {
                m_DropShadow.Hide();
                m_DropShadow.Dispose();
                m_DropShadow = null;
            }
            if (m_FilterInstalled)
            {
                MessageHandler.UnregisterMessageClient(this);
                m_FilterInstalled = false;
            }

            RestoreContainer();
            m_Owner = null;
            m_ParentItem = null;
            m_OldContainer = null;
            //m_OldParent=null;
            if (m_ItemContainer != null)
                m_ItemContainer.Dispose();
            m_ItemContainer = null;

            base.Dispose(disposing);
            IsDisposing = false;
        }
Esempio n. 3
0
        public void DockingHandler(DockSiteInfo pDockInfo, Point p)
        {
            IOwner owner = m_Owner as IOwner;

            if (m_TempTabBar != null && pDockInfo.TabDockContainer == m_TempTabBar)
                return;

            if (pDockInfo.objDockSite == null && (m_BarState != eBarState.Floating || m_Float == null))
            {
                m_DockingInProgress = true;

                if (m_TempTabBar != null)
                {
                    RemoveTempTabBarItems();
                    m_TempTabBar.RecalcLayout();
                    m_TempTabBar = null;
                }

                // Remember last docking info
                DockSiteInfo tempInfo = m_LastDockSiteInfo;
                m_LastDockSiteInfo = new DockSiteInfo();
                // Preserve the relative last docked to bar in case the return to same docking position is needed
                m_LastDockSiteInfo.LastRelativeDocumentId = tempInfo.LastRelativeDocumentId;
                m_LastDockSiteInfo.LastRelativeDockToBar = tempInfo.LastRelativeDockToBar;

                m_LastDockSiteInfo.DockedHeight = this.Height;
                m_LastDockSiteInfo.DockedWidth = this.Width;
                m_LastDockSiteInfo.DockLine = this.DockLine;
                m_LastDockSiteInfo.DockOffset = this.DockOffset;
                if (this.Parent != null)
                    m_LastDockSiteInfo.DockSide = this.Parent.Dock;
                else
                    m_LastDockSiteInfo.DockSide = DockStyle.Left;

                if (this.Parent != null && this.Parent is DockSite)
                {
                    m_LastDockSiteInfo.InsertPosition = ((DockSite)this.Parent).Controls.GetChildIndex(this);
                    m_LastDockSiteInfo.objDockSite = (DockSite)this.DockedSite;
                }
                if (m_LastDockSiteInfo.objDockSite == null)
                {
                    IOwnerBarSupport barSupp = m_Owner as IOwnerBarSupport;
                    if (barSupp != null)
                    {
                        switch (m_LastDockSiteInfo.DockSide)
                        {
                            case DockStyle.Left:
                                m_LastDockSiteInfo.objDockSite = barSupp.LeftDockSite;
                                break;
                            case DockStyle.Right:
                                m_LastDockSiteInfo.objDockSite = barSupp.RightDockSite;
                                break;
                            case DockStyle.Top:
                                m_LastDockSiteInfo.objDockSite = barSupp.TopDockSite;
                                break;
                            case DockStyle.Bottom:
                                m_LastDockSiteInfo.objDockSite = barSupp.BottomDockSite;
                                break;
                            case DockStyle.Fill:
                                m_LastDockSiteInfo.objDockSite = barSupp.FillDockSite;
                                break;
                        }
                    }
                }

                // Undock the window
                m_BarState = eBarState.Floating;
                if (m_Float == null)
                {
                    m_Float = new FloatingContainer(this);
                    m_Float.CreateControl();
                }

                // Must reset the ActiveControl to null because on MDI Forms if this was not done
                // MDI form could not be closed if bar that had ActiveControl is floating.
                if (owner.ParentForm != null && owner.ParentForm.ActiveControl == this)
                {
                    owner.ParentForm.ActiveControl = null;
                    this.Focus(); // Fixes the problem on SDI forms
                }
                else if (owner.ParentForm != null && IsAnyControl(this, owner.ParentForm.ActiveControl))
                {
                    owner.ParentForm.ActiveControl = null;
                    this.Focus();
                }

                // Check for parent since if bar is deserialized there is no parent and state is Docked by default

                if (this.Parent != null && this.Parent is DockSite)
                {
                    if (((DockSite)this.Parent).IsDocumentDock || ((DockSite)this.Parent).DocumentDockContainer != null)
                    {
                        ((DockSite)this.Parent).GetDocumentUIManager().UnDock(this);
                    }
                    else
                        ((DockSite)this.Parent).RemoveBar(this);
                }

                this.Parent = null;
                m_Float.Controls.Add(this);
                if (!this.Visible/* && !m_BarDefinitionLoading*/)
                    base.Visible = true;
                // IMPORTANT SINCE WE OVERRIDE BASE LOCATION WE HAVE TO USE BASE HERE TO ACTUALLY MOVE IT
                base.Location = new Point(0, 0);

                m_FloatingRect = new Rectangle(m_FloatingRect.Location, GetFloatingSize());
                this.Size = m_FloatingRect.Size;

                this.DockOrientation = eOrientation.Horizontal;
                if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && m_AlwaysDisplayDockTab)
                    RefreshDockTab(true);
                this.RecalcSize();
                m_FloatingRect.Size = this.Size;

                m_Float.Location = p;
                if (m_ItemContainer.LayoutType != eLayoutType.Toolbar)
                    m_MouseDownPt = new Point(this.Width / 2, 8);
                else
                    m_MouseDownPt = new Point(8, 8);

                if (m_LoadingHideFloating)
                    m_Float.Visible = false;
                else
                    m_Float.Show();

                m_FloatingRect.Location = m_Float.Location;

                // TODO: Bug Width was sometimes not reflected properly
                if (m_Float.Width != m_FloatingRect.Width)
                    m_Float.Width = m_FloatingRect.Width;

                if (owner.ParentForm != null)
                {
                    bool activate = true;
                    if (m_BarDefinitionLoading && owner is DotNetBarManager && !((DotNetBarManager)owner).ActivateOnLayoutLoad)
                        activate = false;
                    if (activate)
                        owner.ParentForm.Activate();
                }
                m_DockingInProgress = false;

                // Raise events
                if (BarUndock != null)
                    BarUndock(this, new EventArgs());
                IOwnerBarSupport ownerDockEvents = m_Owner as IOwnerBarSupport;
                if (ownerDockEvents != null)
                    ownerDockEvents.InvokeBarUndock(this, new EventArgs());
                OnBarStateChanged(new BarStateChangedEventArgs(this, eBarStateChange.BarUndocked));

                // Resize Docking Tab if it exists
                ResizeDockTab();
            }
            else
            {
                // Change the Z-Order of the dock-site if needed
                if ((pDockInfo.FullSizeDock || pDockInfo.PartialSizeDock) && pDockInfo.DockSiteZOrderIndex >= 0 && pDockInfo.objDockSite != null && pDockInfo.objDockSite.Parent != null)
                    pDockInfo.objDockSite.Parent.Controls.SetChildIndex(pDockInfo.objDockSite, pDockInfo.DockSiteZOrderIndex);

                if (m_Owner != null)
                {
                    if (pDockInfo.TabDockContainer != null)
                    {
                        if (m_TempTabBar != null && pDockInfo.TabDockContainer != m_TempTabBar)
                        {
                            RemoveTempTabBarItems();
                            m_TempTabBar.RecalcLayout();
                            m_TempTabBar = null;
                        }
                        if (m_TempTabBar != pDockInfo.TabDockContainer)
                        {
                            m_DockingInProgress = true;

                            if (m_DockTabTearOffIndex == -1)
                            {
                                if (m_Float != null && m_Float.Visible)
                                {
                                    if (owner.ParentForm != null)
                                        owner.ParentForm.Activate();
                                    // Remember undocked size
                                    m_FloatingRect = new Rectangle(m_Float.Location, this.Size);
                                    m_DockOffset = pDockInfo.DockOffset;
                                    m_DockLine = pDockInfo.DockLine;
                                    m_Float.Controls.Remove(this);
                                    m_Float.Hide();
                                    m_Float.Dispose();
                                    m_Float = null;
                                }
                                else if (this.Parent != null && this.Parent is DockSite)
                                    ((DockSite)this.Parent).RemoveBar(this);
                                m_BarState = eBarState.Docked;
                                if (!m_BarDefinitionLoading)
                                    base.Visible = false;

                                foreach (BaseItem item in m_ItemContainer.SubItems)
                                {
                                    DockContainerItem dockitem = item as DockContainerItem;
                                    if (dockitem != null)
                                    {
                                        DockContainerItem temp = new DockContainerItem();
                                        temp.Displayed = false;
                                        temp.Text = item.Text;
                                        temp.Image = dockitem.Image;
                                        temp.ImageIndex = dockitem.ImageIndex;
                                        temp.Icon = dockitem.Icon;
                                        temp.Tag = "systempdockitem";
                                        pDockInfo.TabDockContainer.Items.Add(temp);
                                    }
                                    m_TempTabBar = pDockInfo.TabDockContainer;
                                    m_TempTabBar.RecalcLayout();
                                    m_TempTabBar.Refresh();
                                }
                            }
                            else
                            {
                                DockContainerItem dockitem = m_ItemContainer.SubItems[m_DockTabTearOffIndex] as DockContainerItem;
                                if (dockitem != null)
                                {
                                    DockContainerItem temp = new DockContainerItem();
                                    temp.Displayed = false;
                                    temp.Text = dockitem.Text;
                                    temp.Image = dockitem.Image;
                                    temp.ImageIndex = dockitem.ImageIndex;
                                    temp.Icon = dockitem.Icon;
                                    temp.Tag = "systempdockitem";
                                    pDockInfo.TabDockContainer.Items.Add(temp);
                                }
                                m_TempTabBar = pDockInfo.TabDockContainer;
                                m_TempTabBar.RecalcLayout();
                                m_TempTabBar.Refresh();
                            }
                            m_DockingInProgress = false;
                        }

                    }
                    else
                    {
                        if (m_TempTabBar != null)
                        {
                            // Allow tabbed bar to change position only if it is going to different bar
                            if (pDockInfo.objDockSite == m_TempTabBar.Parent)
                                return;
                            RemoveTempTabBarItems();
                            m_TempTabBar.RecalcLayout();
                            m_TempTabBar = null;
                        }
                        // If coming from the tabs
                        if (!this.Visible && !m_BarDefinitionLoading)
                            this.Visible = true;
                        if (pDockInfo.LastRelativeDockToBar != null && pDockInfo.LastRelativeDockToBar.DockedSite != null && owner is DotNetBarManager)
                        {
                            DotNetBarManager manager = (DotNetBarManager)owner;
                            if (pDockInfo.LastRelativeDockToBar.AutoHide)
                            {
                                if (pDockInfo.objDockSite != null)
                                    pDockInfo.objDockSite.GetDocumentUIManager().Dock(this);
                                else
                                    manager.Dock(this, eDockSide.Right);
                            }
                            else if (!pDockInfo.LastRelativeDockToBar.Visible ||
                                pDockInfo.LastRelativeDockToBar.DockSide == eDockSide.None) // Closed or floating
                            {
                                manager.Dock(this, m_LastDockSiteInfo.LastDockSiteSide);
                            }
                            else if (pDockInfo.LastRelativeDockToBar.DockSide != eDockSide.None &&
                           m_LastDockSiteInfo.LastDockSiteSide != pDockInfo.LastRelativeDockToBar.DockSide) // Reference bar docked somewhere else
                            {
                                manager.Dock(this, m_LastDockSiteInfo.LastDockSiteSide);
                            }
                            else
                                manager.Dock(this, pDockInfo.LastRelativeDockToBar, LastDockSide);
                            if (this.IsDisposed) return;
                            m_BarState = eBarState.Docked;
                            pDockInfo.LastRelativeDockToBar = null;
                        }
                        else if (pDockInfo.objDockSite != null && m_BarState != eBarState.Docked)
                        {
                            m_DockingInProgress = true;
                            if (m_Float != null && m_BarState == eBarState.Floating)
                            {
                                if (owner.ParentForm != null)
                                    owner.ParentForm.Activate();
                                // Remember undocked size
                                m_FloatingRect = new Rectangle(m_Float.Location, this.Size);
                                m_DockOffset = pDockInfo.DockOffset;
                                m_DockLine = pDockInfo.DockLine;
                                m_Float.Controls.Remove(this);
                                m_Float.Hide();
                                m_Float.Dispose();
                                m_Float = null;
                            }
                            m_BarState = eBarState.Docked;

                            if (pDockInfo.objDockSite.IsDocumentDock || pDockInfo.objDockSite.DocumentDockContainer != null)
                            {
                                DockDocumentManager(pDockInfo);
                            }
                            else
                            {
                                if (pDockInfo.InsertPosition == -10)
                                    pDockInfo.objDockSite.AddBar(this);
                                else
                                    pDockInfo.objDockSite.AddBar(this, pDockInfo.InsertPosition);
                            }
                            m_DockingInProgress = false;

                            //							// Raise events
                            //							if(BarDock!=null)
                            //								BarDock(this,new EventArgs());
                            //							IOwnerBarSupport ownerDockEvents=m_Owner as IOwnerBarSupport;
                            //							if(ownerDockEvents!=null)
                            //								ownerDockEvents.InvokeBarDock(this,new EventArgs());
                        }
                        else if (pDockInfo.objDockSite != null && pDockInfo.objDockSite != this.Parent)
                        {
                            m_DockingInProgress = true;
                            // Must reset the ActiveControl to null becouse on MDI Forms if this was not done
                            // MDI form could not be closed if bar that had ActiveControl is floating.
                            if (owner.ParentForm != null && owner.ParentForm.ActiveControl == this)
                            {
                                owner.ParentForm.ActiveControl = null;
                                this.Focus(); // Fixes the problem on SDI forms
                            }
                            else if (owner.ParentForm != null && IsAnyControl(this, owner.ParentForm.ActiveControl))
                            {
                                owner.ParentForm.ActiveControl = null;
                                this.Focus();
                            }

                            // It is docked somewhere else, we need to undockit and dockit on another site
                            // If Bar is deserialized there is no parent
                            if (this.Parent != null && this.Parent is DockSite)
                            {
                                if (((DockSite)this.Parent).IsDocumentDock || ((DockSite)this.Parent).DocumentDockContainer != null)
                                    ((DockSite)this.Parent).GetDocumentUIManager().UnDock(this);
                                else
                                    ((DockSite)this.Parent).RemoveBar(this);
                            }

                            // If coming from the tabs
                            if (!this.Visible && !m_BarDefinitionLoading)
                                this.Visible = true;

                            m_DockOffset = pDockInfo.DockOffset;
                            m_DockLine = pDockInfo.DockLine;

                            if (pDockInfo.objDockSite.IsDocumentDock || pDockInfo.objDockSite.DocumentDockContainer != null)
                            {
                                pDockInfo.objDockSite.GetDocumentUIManager().Dock(pDockInfo.MouseOverBar, this, pDockInfo.MouseOverDockSide);
                            }
                            else
                            {
                                if (pDockInfo.InsertPosition == -10)
                                    pDockInfo.objDockSite.AddBar(this);
                                else
                                    pDockInfo.objDockSite.AddBar(this, pDockInfo.InsertPosition);
                            }
                            // Raise events
                            //							if(BarDock!=null)
                            //								BarDock(this,new EventArgs());
                            //							IOwnerBarSupport ownerDockEvents=m_Owner as IOwnerBarSupport;
                            //							if(ownerDockEvents!=null)
                            //								ownerDockEvents.InvokeBarDock(this,new EventArgs());
                            m_DockingInProgress = false;
                        }
                        else if (this.Parent != null && pDockInfo.objDockSite == this.Parent)
                        {
                            if (pDockInfo.objDockSite.IsDocumentDock || pDockInfo.objDockSite.DocumentDockContainer != null)
                            {
                                pDockInfo.objDockSite.GetDocumentUIManager().Dock(pDockInfo.MouseOverBar, this, pDockInfo.MouseOverDockSide);
                            }
                            else
                            {
                                if (m_DockLine != pDockInfo.DockLine || m_DockOffset != pDockInfo.DockOffset && !this.Stretch || pDockInfo.objDockSite.Controls.GetChildIndex(this) != pDockInfo.InsertPosition || pDockInfo.NewLine)
                                {
                                    m_DockLine = pDockInfo.DockLine;
                                    m_DockOffset = pDockInfo.DockOffset;
                                    // If coming from the tabs
                                    if (!this.Visible && !m_BarDefinitionLoading)
                                        this.Visible = true;
                                    if (pDockInfo.NewLine)
                                        pDockInfo.objDockSite.SetBarPosition(this, pDockInfo.InsertPosition, true);
                                    else if (pDockInfo.InsertPosition == -10)
                                    {
                                        pDockInfo.objDockSite.AdjustBarPosition(this);
                                        pDockInfo.objDockSite.RecalcLayout();
                                    }
                                    else
                                        pDockInfo.objDockSite.SetBarPosition(this, pDockInfo.InsertPosition);
                                }
                            }
                        }
                        else
                        {
                            Point newLocation = new Point(p.X - m_MouseDownPt.X, p.Y - m_MouseDownPt.Y);
                            ScreenInformation screen = BarFunctions.ScreenFromControl(m_Float);
                            if (screen != null)
                            {
                                if (newLocation.Y + 8 >= screen.WorkingArea.Bottom)
                                    newLocation.Y = screen.WorkingArea.Bottom - 8;
                            }
                            m_Float.Location = newLocation;
                            if (((IOwner)m_Owner).ParentForm != null)
                                ((IOwner)m_Owner).ParentForm.Update();
                        }
                    }
                }
                if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && (m_TabDockItems == null || !m_TabDockItems.Visible))
                {
                    int iVisible = m_ItemContainer.VisibleSubItems;
                    if (!(m_BarState == eBarState.Floating && iVisible <= 1) && (m_AlwaysDisplayDockTab || iVisible > 0))
                    {
                        eBarState oldBarState = m_BarState;
                        m_BarState = eBarState.Docked;
                        RefreshDockTab(false);
                        m_BarState = oldBarState;
                    }
                }
                if (m_BarState != eBarState.Floating)
                    InvokeBarDockEvents();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the Bar class.
        /// </summary>
        public Bar()
        {
            if (!ColorFunctions.ColorsLoaded)
            {
                NativeFunctions.RefreshSettings();
                NativeFunctions.OnDisplayChange();
                ColorFunctions.LoadColors();
            }

            m_ColorScheme = new ColorScheme();
            m_ParentItem = null;
            m_OldContainer = null;
            m_ClientRect = Rectangle.Empty;
            m_SideBarRect = Rectangle.Empty;
            m_SideBarImage = new SideBarImage();
            m_ItemContainer = new GenericItemContainer();
            m_ItemContainer.GlobalItem = false;
            m_ItemContainer.ContainerControl = this;
            m_ItemContainer.WrapItems = true;
            m_ItemContainer.Stretch = false;
            m_ItemContainer.Displayed = true;
            m_ItemContainer.SystemContainer = true;
            //m_ItemContainer.SetSystemItem(true);
            //m_OldParent=null;
            m_InitialContainerWidth = 164;
            //m_BarState=eBarState.Popup;
            m_BarState = eBarState.Docked;

            m_DockOffset = 0;
            m_DockLine = 0;
            m_GrabHandleStyle = eGrabHandleStyle.None;
            m_GrabHandleRect = Rectangle.Empty;
            m_Owner = null;
            m_MouseDownPt = Point.Empty;
            m_MouseDownSize = new Size(0, 0);
            m_MoveWindow = false;
            m_FloatingRect = Rectangle.Empty;
            m_SizeWindow = 0;

            m_LastDragRect = Rectangle.Empty;

            m_WrapItemsDock = false;
            m_WrapItemsFloat = true;
            m_DockStretch = false;
            m_MenuBar = false;
            this.Text = "";

            m_Float = null;
            m_DockingInProgress = false;

            this.SetStyle(ControlStyles.Selectable, false);
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.Opaque, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            this.TabStop = false;
            base.Font = SystemFonts.MenuFont; // System.Windows.Forms.SystemInformation.MenuFont.Clone() as Font;

            m_CanDockLeft = true;
            m_CanDockRight = true;
            m_CanDockTop = true;
            m_CanDockBottom = true;
            m_CanUndock = true;

            Microsoft.Win32.SystemEvents.UserPreferenceChanged += new Microsoft.Win32.UserPreferenceChangedEventHandler(PreferenceChanged);

            this.IsAccessible = true;

            m_SystemButtons.MouseDownAutoHideChanged += new EventHandler(this.SysButtonHideTooltip);
            m_SystemButtons.MouseDownCloseChanged += new EventHandler(this.SysButtonHideTooltip);
            m_SystemButtons.MouseDownCustomizeChanged += new EventHandler(this.SysButtonHideTooltip);
            m_SystemButtons.MouseOverAutoHideChanged += new EventHandler(this.SysButtonMouseOverAutoHide);
            m_SystemButtons.MouseOverCustomizeChanged += new EventHandler(this.SysButtonMouseOverCustomize);
            m_SystemButtons.MouseOverCloseChanged += new EventHandler(this.SysButtonMouseOverClose);
        }
Esempio n. 5
0
 internal void RemoveFromFloatingContainer()
 {
     if (m_Float == null) return;
     // Remember undocked size
     m_FloatingRect = new Rectangle(m_Float.Location, this.Size);
     m_Float.Controls.Remove(this);
     m_Float.Hide();
     m_Float.Dispose();
     m_Float = null;
 }