Beispiel #1
0
        private void AutoHideStateChanged()
        {
            IOwner owner = m_Owner as IOwner;
            IOwnerAutoHideSupport ownerAutoHide = m_Owner as IOwnerAutoHideSupport;
            if (owner == null)
                return;

            Control parentControl = GetOwnerControl();

            if (parentControl == null)
                return;

            if (m_AutoHideState)
            {
                if (m_BarState == eBarState.AutoHide)
                    return;
                if (m_TabDockItems != null)
                    m_TabDockItems.Visible = false;
                // 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;

                if (!m_BarDefinitionLoading)
                {
                    if (this.Height > 0)
                        m_LastDockSiteInfo.DockedHeight = this.Height;
                    else if (m_ItemContainer != null && m_ItemContainer.MinHeight > 0)
                        m_LastDockSiteInfo.DockedHeight = m_ItemContainer.MinHeight + 22;
                    if (this.Width > 0)
                        m_LastDockSiteInfo.DockedWidth = this.Width;
                    else if (m_ItemContainer != null && m_ItemContainer.MinWidth > 0)
                        m_LastDockSiteInfo.DockedWidth = m_ItemContainer.MinWidth + 22;

                    // This will force proper recalculation in SetAutoHideSize procedure
                    System.Drawing.Size minSize = GetLargestMinSize();
                    if (minSize.Width > m_LastDockSiteInfo.DockedWidth)
                        m_LastDockSiteInfo.DockedWidth = 0;
                    if (minSize.Height > m_LastDockSiteInfo.DockedHeight)
                        m_LastDockSiteInfo.DockedHeight = 0;
                }

                m_LastDockSiteInfo.DockLine = this.DockLine;
                m_LastDockSiteInfo.DockOffset = this.DockOffset;
                if (this.Parent != null && m_BarState == eBarState.Docked)
                    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;
                }

                // Undock the window
                m_BarState = eBarState.AutoHide;
                ResetActiveControl();
                parentControl.SuspendLayout();
                try
                {
                    // Check for parent since if bar is deserialized there is no parent and state is Docked by default
                    base.Visible = false;
                    if (this.Parent != null && this.Parent is DockSite)
                    {
                        DockSite ds = this.Parent as DockSite;
                        if (ds.DocumentDockContainer != null)
                        {
                            // Remember the split view docking if it was in effect
                            if (ds.Dock != DockStyle.Fill)
                            {
                                DocumentBarContainer dbr = ds.GetDocumentUIManager().GetDocumentFromBar(this) as DocumentBarContainer;
                                if (dbr != null && dbr.Parent is DocumentDockContainer)
                                {
                                    DocumentDockContainer ddc = dbr.Parent as DocumentDockContainer;
                                    if (ddc.Orientation == eOrientation.Horizontal && (ds.Dock == DockStyle.Top || ds.Dock == DockStyle.Bottom) ||
                                        ddc.Orientation == eOrientation.Vertical && (ds.Dock == DockStyle.Left || ds.Dock == DockStyle.Right) && ddc.Documents.Count > 1)
                                    {
                                        for (int i = 0; i < ddc.Documents.Count; i++)
                                        {
                                            if (ddc.Documents[i] is DocumentBarContainer && ddc.Documents[i].Visible && ddc.Documents[i] != dbr)
                                            {
                                                m_LastDockSiteInfo.MouseOverBar = ((DocumentBarContainer)ddc.Documents[i]).Bar;
                                                if (i < ddc.Documents.IndexOf(dbr))
                                                    m_LastDockSiteInfo.MouseOverDockSide = (ddc.Orientation == eOrientation.Horizontal ? eDockSide.Left : eDockSide.Bottom);
                                                else
                                                    m_LastDockSiteInfo.MouseOverDockSide = (ddc.Orientation == eOrientation.Horizontal ? eDockSide.Right : eDockSide.Top);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            ds.GetDocumentUIManager().UnDock(this);
                        }
                        else
                            ((DockSite)this.Parent).RemoveBar(this);
                    }
                    this.Parent = null;

                    parentControl.Controls.Add(this);
                    parentControl.Controls.SetChildIndex(this, 0);
                    AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide);
                    panel.AddBar(this);

                    if (!m_BarDefinitionLoading)
                        SetAutoHideSize();
                    if (!m_IgnoreAnimation && m_AutoHideAnimationTime != 0)
                        this.Visible = true;
                }
                finally
                {
                    parentControl.ResumeLayout();
                }
                //this.RecalcSize();
                if (!m_BarDefinitionLoading)
                {
                    this.Update();
                    AnimateHide();
                }
            }
            else
            {
                AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide);
                panel.RemoveBar(this);
                if (m_LastDockSiteInfo.objDockSite != null)
                {
                    if (m_LastDockSiteInfo.MouseOverBar != null)
                    {
                        if (m_LastDockSiteInfo.objDockSite.GetDocumentUIManager() == null ||
                            m_LastDockSiteInfo.objDockSite.GetDocumentUIManager().GetDocumentFromBar(m_LastDockSiteInfo.MouseOverBar) == null)
                        {
                            m_LastDockSiteInfo.MouseOverBar = null;
                            m_LastDockSiteInfo.MouseOverDockSide = eDockSide.None;
                            m_LastDockSiteInfo.NewLine = true;
                        }
                    }
                }
                else
                {
                    m_LastDockSiteInfo.MouseOverBar = null;
                    m_LastDockSiteInfo.MouseOverDockSide = eDockSide.None;
                    m_LastDockSiteInfo.NewLine = true;
                }

                //m_LastDockSiteInfo.NewLine = true;
                DockingHandler(m_LastDockSiteInfo, Point.Empty);
                if (!this.IsVisible)
                    this.Visible = true;
                this.RefreshDockTab(true);
                this.ResizeDockTab();
                m_ItemContainer.MinHeight = 0;
                m_ItemContainer.MinWidth = 0;
            }
        }
Beispiel #2
0
        private void LoadCommonProperties(System.Xml.XmlElement xmlBar)
        {
            m_BarState = eBarState.Docked;
            this.Name = xmlBar.GetAttribute("name");
            if (xmlBar.HasAttribute("candockleft"))
                m_CanDockLeft = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candockleft"));
            if (xmlBar.HasAttribute("candockright"))
                m_CanDockRight = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candockright"));
            if (xmlBar.HasAttribute("candocktop"))
                m_CanDockTop = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candocktop"));
            if (xmlBar.HasAttribute("candockbottom"))
                m_CanDockBottom = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candockbottom"));
            if (xmlBar.HasAttribute("candockdoc"))
                m_CanDockDocument = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candockdoc"));
            if (xmlBar.HasAttribute("candocktab"))
                m_CanDockTab = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candocktab"));
            if (xmlBar.HasAttribute("text"))
                this.Text = xmlBar.GetAttribute("text");
            if (xmlBar.HasAttribute("dockline"))
                m_DockLine = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dockline"));
            if (xmlBar.HasAttribute("dockoffset"))
                m_DockOffset = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dockoffset"));
            if (xmlBar.HasAttribute("grabhandle"))
                m_GrabHandleStyle = (eGrabHandleStyle)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("grabhandle"));
            if (xmlBar.HasAttribute("menubar"))
                m_MenuBar = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("menubar"));
            if (xmlBar.HasAttribute("stretch"))
                m_DockStretch = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("stretch"));
            if (xmlBar.HasAttribute("wrapdock"))
                m_WrapItemsDock = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("wrapdock"));
            if (xmlBar.HasAttribute("wrapfloat"))
                m_WrapItemsFloat = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("wrapfloat"));
            if (xmlBar.HasAttribute("custom"))
                m_CustomBar = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("custom"));
            if (xmlBar.HasAttribute("canhide"))
                m_CanHide = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("canhide"));
            if (xmlBar.HasAttribute("imagesize"))
                m_ImageSize = (eBarImageSize)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("imagesize"));

            if (xmlBar.HasAttribute("itemsp"))
                m_ItemContainer.ItemSpacing = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("itemsp"));
            //			else
            //				m_ItemContainer.ItemSpacing=0;

            if (xmlBar.HasAttribute("backcolor"))
                m_ItemContainer.BackColor = BarFunctions.ColorFromString(xmlBar.GetAttribute("backcolor"));

            if (xmlBar.HasAttribute("layout"))
                m_ItemContainer.LayoutType = (eLayoutType)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("layout"));

            if (xmlBar.HasAttribute("eqbutton"))
                m_ItemContainer.EqualButtonSize = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("eqbutton"));

            if (xmlBar.HasAttribute("dborder"))
                m_DockedBorder = (eBorderType)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dborder"));
            //else
            //    m_DockedBorder=eBorderType.None;

            if (xmlBar.HasAttribute("acceptdrop"))
                m_AcceptDropItems = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("acceptdrop"));

            if (xmlBar.HasAttribute("slcolor"))
                m_SingleLineColor = BarFunctions.ColorFromString(xmlBar.GetAttribute("slcolor"));

            if (xmlBar.HasAttribute("captionbc"))
                m_CaptionBackColor = BarFunctions.ColorFromString(xmlBar.GetAttribute("captionbc"));
            if (xmlBar.HasAttribute("captionfc"))
                m_CaptionForeColor = BarFunctions.ColorFromString(xmlBar.GetAttribute("captionfc"));

            if (xmlBar.HasAttribute("dockwidth"))
                m_ItemContainer.MinWidth = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dockwidth"));
            if (xmlBar.HasAttribute("dockheight"))
                m_ItemContainer.MinHeight = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dockheight"));

            if (xmlBar.HasAttribute("splitwidthpercent"))
                m_SplitDockWidthPercent = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("splitwidthpercent"));
            else
                m_SplitDockWidthPercent = 0;
            if (xmlBar.HasAttribute("splitheightpercent"))
                m_SplitDockHeightPercent = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("splitheightpercent"));
            //			else
            //				m_SplitDockHeightPercent=0;

            if (xmlBar.HasAttribute("padbottom"))
                m_ItemContainer.PaddingBottom = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("padbottom"));
            if (xmlBar.HasAttribute("padleft"))
                m_ItemContainer.PaddingLeft = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("padleft"));
            if (xmlBar.HasAttribute("padright"))
                m_ItemContainer.PaddingRight = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("padright"));
            if (xmlBar.HasAttribute("padtop"))
                m_ItemContainer.PaddingTop = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("padtop"));

            if (xmlBar.HasAttribute("lockdockpos"))
                m_LockDockPosition = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("lockdockpos"));
            if (xmlBar.HasAttribute("canundock"))
                m_CanUndock = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("canundock"));
            if (xmlBar.HasAttribute("canreordertabs"))
                m_CanReorderTabs = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("canreordertabs"));
            if (xmlBar.HasAttribute("cantearoff"))
                m_CanTearOffTabs = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("cantearoff"));

            if (xmlBar.HasAttribute("canautohide"))
                m_CanAutoHide = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("canautohide"));

            if (xmlBar.HasAttribute("cancust"))
                m_ItemContainer.CanCustomize = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("cancust"));

            if (xmlBar.HasAttribute("tabalign"))
                m_DockTabAlignment = (eTabStripAlignment)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("tabalign"));

            if (xmlBar.HasAttribute("showtab"))
                m_AlwaysDisplayDockTab = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("showtab"));

            // TODO: Menu Merge Implementation
            //if(xmlBar.HasAttribute("merge"))
            //	m_MergeEnabled=System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("merge"));

            if (xmlBar.HasAttribute("hidein"))
                m_HideFloatingInactive = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("hidein"));

            if (xmlBar.HasAttribute("themes"))
            {
                m_ThemeAware = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("themes"));
                m_ItemContainer.ThemeAware = m_ThemeAware;
            }

            if (xmlBar.HasAttribute("tabnav"))
                m_TabNavigation = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("tabnav"));

            if (xmlBar.HasAttribute("tooltips"))
                m_ShowToolTips = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("tooltips"));
            //			else
            //				m_ShowToolTips=true;

            if (xmlBar.HasAttribute("overflowmenu"))
                m_ItemContainer.MoreItemsOnMenu = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("overflowmenu"));
            //			else
            //				m_ItemContainer.MoreItemsOnMenu=false;

            if (xmlBar.HasAttribute("autocaptionmenu"))
                m_AutoCreateCaptionMenu = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("autocaptionmenu"));
            //			else
            //				m_AutoCreateCaptionMenu=true;

            if (xmlBar.HasAttribute("autocaptionsync"))
                this.AutoSyncBarCaption = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("autocaptionsync"));
            //			else
            //				this.AutoSyncBarCaption=false;

            if (xmlBar.HasAttribute("style"))
            {
                string sty = xmlBar.GetAttribute("style");
                //if (sty == "5")
                //    this.Style = eDotNetBarStyle.Office2007;
                //else
                this.Style = (eDotNetBarStyle)System.Xml.XmlConvert.ToInt32(sty);
            }

            // Load font information if it exists
            if (xmlBar.HasAttribute("fontname"))
            {
                string FontName = xmlBar.GetAttribute("fontname");
                float FontSize = System.Xml.XmlConvert.ToSingle(xmlBar.GetAttribute("fontemsize"));
                System.Drawing.FontStyle FontStyle = (System.Drawing.FontStyle)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("fontstyle"));
                try
                {
                    this.Font = new Font(FontName, FontSize, FontStyle);
                }
                catch (Exception)
                {
                    this.Font = SystemFonts.MenuFont; // System.Windows.Forms.SystemInformation.MenuFont.Clone() as Font;
                }
                m_CustomFont = true;
            }

            if (xmlBar.HasAttribute("ahanim"))
                m_AutoHideAnimationTime = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("ahanim"));
            //			else
            //				m_AutoHideAnimationTime=100;

            if (xmlBar.HasAttribute("savelayout"))
                m_SaveLayoutChanges = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("savelayout"));
            //			else
            //				m_SaveLayoutChanges=true;
        }
Beispiel #3
0
 internal void SetBarState(eBarState state)
 {
     m_BarState = state;
     if (m_BarState != eBarState.Popup && m_DropShadow != null)
     {
         m_DropShadow.Hide();
         m_DropShadow.Dispose();
         m_DropShadow = null;
     }
 }
Beispiel #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);
        }
Beispiel #5
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();
            }
        }
Beispiel #6
0
        private System.Drawing.Size RecalcSizeOffice(bool bCalculateOnly, System.Drawing.Size objFrameSize, eOrientation barOrientation, eBarState barState, bool bWrapItems)
        {
            System.Drawing.Size thisSize = System.Drawing.Size.Empty;

            int iTopMargin = 0, iBottomMargin = 0, iLeftMargin = 0, iRightMargin = 0, iRightTabMargin = 0;
            int iOrgWidth = 0, iOrgHeight = 0;
            eOrientation oldOrientation = m_ItemContainer.Orientation;
            eBarState thisBarState = m_BarState;
            bool bOldStretch = m_ItemContainer.Stretch;
            bool bOldWrapItems = m_ItemContainer.WrapItems;
            m_ItemContainer.IsRightToLeft = (this.RightToLeft == RightToLeft.Yes);
            if (bCalculateOnly)
            {
                m_ItemContainer.Orientation = barOrientation;
                thisBarState = barState;
                m_ItemContainer.WrapItems = bWrapItems;
                if (barState == eBarState.Docked)
                    m_ItemContainer.Stretch = m_DockStretch;
                else
                {
                    if (m_ItemContainer.LayoutType == eLayoutType.DockContainer)
                        m_ItemContainer.Stretch = m_DockStretch;
                    else
                        m_ItemContainer.Stretch = false;
                }
            }

            if (thisBarState == eBarState.Docked)
            {
                if (m_DockedBorder != eBorderType.None)
                {
                    iTopMargin = 2;
                    iBottomMargin = 2;
                    iLeftMargin = 2;
                    iRightMargin = 2;
                }
            }
            else if (thisBarState == eBarState.Floating)
            {
                iTopMargin = 22;
                iLeftMargin = 4;
                iRightMargin = 4;
                iBottomMargin = 4;
            }
            else
            {
                iTopMargin = this.ClientMarginTop;
                iLeftMargin = this.ClientMarginLeft;
                iRightMargin = this.ClientMarginRight;
                iBottomMargin = this.ClientMarginBottom;
            }

            int iTop = iTopMargin, iLeft = iLeftMargin;

            if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && !m_AutoHideState && GetDockTabVisible())
            {
                if (m_ItemContainer.VisibleSubItems > 1 || m_AlwaysDisplayDockTab && m_ItemContainer.VisibleSubItems == 1 && m_BarState != eBarState.Floating)
                {
                    switch (m_DockTabAlignment)
                    {
                        case eTabStripAlignment.Top:
                            {
                                iTop += DockTabStripHeight;
                                break;
                            }
                        case eTabStripAlignment.Left:
                            {
                                iLeft += DockTabStripHeight;
                                break;
                            }
                        case eTabStripAlignment.Right:
                            {
                                iRightTabMargin = DockTabStripHeight;
                                break;
                            }
                        default:
                            {
                                iBottomMargin += DockTabStripHeight;
                                break;
                            }
                    }
                }
            }

            // Take in account the side bar picture
            if (thisBarState == eBarState.Popup && m_SideBarImage.Picture != null)
                iLeft += m_SideBarImage.Picture.Width;
            else if (thisBarState == eBarState.Docked || this.BarState == eBarState.AutoHide)
            {
                // Show grab handles if any selected
                if (m_GrabHandleStyle != eGrabHandleStyle.None)
                {
                    if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
                        iLeft += GrabHandleOfficeWidth;
                    else
                    {
                        if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
                            iTop += GetGrabHandleCaptionHeight();
                        else if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
                            iTop += GetGrabHandleTaskPaneHeight();
                        else
                            iTop += GrabHandleOfficeWidth;
                    }
                }
            }

            if (!bCalculateOnly)
            {
                m_ItemContainer.TopInternal = iTop;
                m_ItemContainer.LeftInternal = iLeft;
            }
            else
            {
                iOrgHeight = m_ItemContainer.HeightInternal;
                iOrgWidth = m_ItemContainer.WidthInternal;
            }

            if (!bCalculateOnly)
            {
                if (thisBarState == eBarState.Popup)
                    m_ItemContainer.WidthInternal = m_InitialContainerWidth;
                else
                {
                    m_ItemContainer.WidthInternal = objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin; //m_ItemContainer.WidthInternal=this.Width-iLeft-iRightMargin;
                    m_ItemContainer.HeightInternal = objFrameSize.Height - iTop - iBottomMargin; //m_ItemContainer.HeightInternal=this.Height-iTop-iBottomMargin;
                }
            }
            else
            {
                m_ItemContainer.WidthInternal = objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin;
                m_ItemContainer.HeightInternal = objFrameSize.Height - iTop - iBottomMargin;
            }

            if (m_ItemContainer.VisibleSubItems == 0)
            {
                m_ItemContainer.WidthInternal = 36;
                m_ItemContainer.HeightInternal = 24;
            }
            else
                m_ItemContainer.RecalcSize();

            iTop += m_ItemContainer.HeightInternal;

            if (!bCalculateOnly)
                m_ClientRect = new Rectangle(iLeft, iTopMargin, m_ItemContainer.WidthInternal, iTop);

            if (!bCalculateOnly)
            {
                if ((thisBarState == eBarState.Docked || this.BarState == eBarState.AutoHide) && m_GrabHandleStyle != eGrabHandleStyle.None)
                {
                    if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
                    {
                        m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, 12, iTop);
                    }
                    else
                    {
                        if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
                            m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, GetGrabHandleCaptionHeight());
                        else if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
                            m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, GetGrabHandleTaskPaneHeight());
                        else
                            m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, 12);
                    }
                }
                else if (thisBarState == eBarState.Floating)
                {
                    if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane)
                        m_GrabHandleRect = new Rectangle(4, 4, m_ItemContainer.WidthInternal + iRightTabMargin, GetGrabHandleTaskPaneHeight());
                    else
                        m_GrabHandleRect = new Rectangle(4, 4, m_ItemContainer.WidthInternal + iRightTabMargin, 15);
                    if (this.CanHideResolved)
                        m_GrabHandleRect.Width -= 14;
                }

                if (thisBarState == eBarState.Popup && m_SideBarImage.Picture != null)
                    m_SideBarRect = new Rectangle(iLeft - m_SideBarImage.Picture.Width, iTopMargin, m_SideBarImage.Picture.Width, iTop - iTopMargin);
                //this.ClientSize=new Size(iLeft+m_ItemContainer.Width+iRightMargin,iTop+iBottomMargin);
                thisSize = new Size(iLeft + m_ItemContainer.WidthInternal + iRightMargin + iRightTabMargin, iTop + iBottomMargin);
            }
            else
            {
                thisSize = new Size(iLeft + m_ItemContainer.WidthInternal + iRightMargin + iRightTabMargin, iTop + iBottomMargin);
                m_ItemContainer.WidthInternal = iOrgWidth;
                m_ItemContainer.HeightInternal = iOrgHeight;
                m_ItemContainer.Orientation = oldOrientation;
                m_ItemContainer.WrapItems = bOldWrapItems;
                m_ItemContainer.Stretch = bOldStretch;
                m_ItemContainer.RecalcSize();
            }
            return thisSize;
        }
Beispiel #7
0
        private System.Drawing.Size RecalcSizeDotNet(bool bCalculateOnly, System.Drawing.Size objFrameSize, eOrientation barOrientation, eBarState barState, bool bWrapItems)
        {
            System.Drawing.Size thisSize = System.Drawing.Size.Empty;
            int iTopMargin = 0, iBottomMargin = 0, iLeftMargin = 0, iRightMargin = 0, iRightTabMargin = 0;
            int iOrgWidth = 0, iOrgHeight = 0;
            eOrientation oldOrientation = m_ItemContainer.Orientation;
            eBarState thisBarState = m_BarState;
            bool bOldStretch = m_ItemContainer.Stretch;
            bool bOldWrapItems = m_ItemContainer.WrapItems;
            m_ItemContainer.IsRightToLeft = (this.RightToLeft == RightToLeft.Yes);
            if (bCalculateOnly)
            {
                m_ItemContainer.Orientation = barOrientation;
                thisBarState = barState;
                m_ItemContainer.WrapItems = bWrapItems;
                if (barState == eBarState.Docked)
                    m_ItemContainer.Stretch = m_DockStretch;
                else
                {
                    if (m_ItemContainer.LayoutType == eLayoutType.DockContainer)
                        m_ItemContainer.Stretch = m_DockStretch;
                    else
                        m_ItemContainer.Stretch = false;
                }
            }

            if (thisBarState == eBarState.Docked)
            {
                if (m_DockedBorder != eBorderType.None)
                {
                    iTopMargin = 3;
                    iBottomMargin = 3;
                    iLeftMargin = 3;
                    iRightMargin = 3;
                }
            }
            else if (thisBarState == eBarState.Floating)
            {
                if (this.IsThemed || this.DrawThemedCaption)
                {
                    if (m_ThemeWindowMargins.IsEmpty)
                        this.RefreshThemeMargins();
                    iTopMargin = m_ThemeWindowMargins.Top;
                    iLeftMargin = m_ThemeWindowMargins.Left;
                    iRightMargin = m_ThemeWindowMargins.Right;
                    iBottomMargin = m_ThemeWindowMargins.Bottom;
                    if (this.GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane)
                        iTopMargin = GetGrabHandleTaskPaneHeight() + m_ThemeWindowMargins.Bottom;
                }
                else
                {
                    if (this.GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane)
                        iTopMargin = GetGrabHandleTaskPaneHeight() + 4;
                    else
                        iTopMargin = GetNonClientHeight();
                    iLeftMargin = 2;
                    iRightMargin = 2;
                    iBottomMargin = 3;
                }
            }
            else
            {
                iTopMargin = this.ClientMarginTop;
                iLeftMargin = this.ClientMarginLeft;
                iRightMargin = this.ClientMarginRight;
                iBottomMargin = this.ClientMarginBottom;
            }

            int iTop = iTopMargin, iLeft = iLeftMargin;

            if (BarType == eBarType.StatusBar && BarFunctions.IsOffice2007Style(m_ItemContainer.EffectiveStyle))
                iTop += 2;

            if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && !m_AutoHideState && GetDockTabVisible())
            {
                if (m_ItemContainer.VisibleSubItems > 1 || m_AlwaysDisplayDockTab && m_ItemContainer.VisibleSubItems == 1 && m_BarState != eBarState.Floating)
                {
                    switch (m_DockTabAlignment)
                    {
                        case eTabStripAlignment.Top:
                            {
                                iTop += DockTabStripHeight;
                                break;
                            }
                        case eTabStripAlignment.Left:
                            {
                                iLeft += DockTabStripHeight;
                                break;
                            }
                        case eTabStripAlignment.Right:
                            {
                                iRightTabMargin = DockTabStripHeight;
                                break;
                            }
                        default:
                            {
                                iBottomMargin += DockTabStripHeight;
                                break;
                            }
                    }
                }
            }

            // Take in account the side bar picture
            if (thisBarState == eBarState.Popup && m_SideBarImage.Picture != null)
                iLeft += m_SideBarImage.Picture.Width;
            else if (thisBarState == eBarState.Docked || this.BarState == eBarState.AutoHide)
            {
                // Show grab handles if any selected
                if (m_GrabHandleStyle != eGrabHandleStyle.None)
                {
                    if (m_GrabHandleStyle == eGrabHandleStyle.ResizeHandle)
                    {
                        // Leave space for the window sizer at the right
                        if (this.RightToLeft == RightToLeft.Yes)
                            iLeft += GrabHandleResizeWidth;
                        else
                            iRightMargin += GrabHandleResizeWidth;
                    }
                    else
                    {
                        if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType == eLayoutType.Toolbar)
                        {

                            if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
                                iLeft += GetGrabHandleCaptionHeight();
                            else
                            {
                                if (this.RightToLeft == RightToLeft.Yes)
                                    iRightMargin += GrabHandleDotNetWidth;
                                else
                                    iLeft += GrabHandleDotNetWidth;
                            }
                        }
                        else
                        {
                            if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
                                iTop += GetGrabHandleCaptionHeight();
                            else if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
                                iTop += GetGrabHandleTaskPaneHeight();
                            else
                                iTop += GrabHandleDotNetWidth;
                        }
                    }
                }
            }

            if (!bCalculateOnly)
            {
                m_ItemContainer.TopInternal = iTop;
                m_ItemContainer.LeftInternal = iLeft;
            }
            else
            {
                iOrgHeight = m_ItemContainer.HeightInternal;
                iOrgWidth = m_ItemContainer.WidthInternal;
            }

            // Suspend Layout while setting suggested size
            m_ItemContainer.SuspendLayout = true;
            if (!bCalculateOnly)
            {
                if (thisBarState == eBarState.Popup)
                    m_ItemContainer.WidthInternal = m_InitialContainerWidth;
                else
                {
                    m_ItemContainer.WidthInternal = objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin; //m_ItemContainer.WidthInternal=this.Width-iLeft-iRightMargin;
                    m_ItemContainer.HeightInternal = objFrameSize.Height - iTop - iBottomMargin; //m_ItemContainer.HeightInternal=this.Height-iTop-iBottomMargin;
                }
            }
            else
            {
                m_ItemContainer.WidthInternal = objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin;
                m_ItemContainer.HeightInternal = objFrameSize.Height - iTop - iBottomMargin;
            }
            m_ItemContainer.SuspendLayout = false;

            if (m_ItemContainer.VisibleSubItems == 0 || (m_ItemContainer.SubItems.Count == 1 && m_ItemContainer.SubItems[0] is CustomizeItem && !m_ItemContainer.SubItems[0].Visible))
            {
                m_ItemContainer.RecalcSize();
                if (this.LayoutType != eLayoutType.DockContainer && this.DockSide != eDockSide.Document)
                {
                    m_ItemContainer.WidthInternal = 36;
                    m_ItemContainer.HeightInternal = 24;
                }
            }
            else
                m_ItemContainer.RecalcSize();

            iTop += m_ItemContainer.HeightInternal;
            if (IsGradientStyle && this.LayoutType == eLayoutType.Toolbar && !this.MenuBar && !this.IsThemed && BarType != eBarType.StatusBar)
                iTop++;

            if (!bCalculateOnly)
            {
                if (this.RightToLeft == RightToLeft.Yes)
                {
                    if (this.LayoutType == eLayoutType.Toolbar && m_ItemContainer.WidthInternal < objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin && this.Stretch)
                    {
                        m_ItemContainer.LeftInternal = objFrameSize.Width - iRightMargin - m_ItemContainer.WidthInternal;
                        m_ItemContainer.RecalcSize();
                    }
                    m_ClientRect = new Rectangle(m_ItemContainer.LeftInternal, iTopMargin, m_ItemContainer.WidthInternal, iTop);
                }
                else
                    m_ClientRect = new Rectangle(iLeft, iTopMargin, m_ItemContainer.WidthInternal, iTop);
            }

            if (!bCalculateOnly)
            {
                if ((thisBarState == eBarState.Docked || thisBarState == eBarState.AutoHide) && m_GrabHandleStyle != eGrabHandleStyle.None && m_GrabHandleStyle != eGrabHandleStyle.ResizeHandle)
                {
                    if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType == eLayoutType.Toolbar)
                    {
                        if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
                            m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, GetGrabHandleCaptionHeight(), iTop);
                        else
                        {
                            if (this.RightToLeft == RightToLeft.Yes)
                                m_GrabHandleRect = new Rectangle(m_ItemContainer.WidthInternal + iLeft + iLeftMargin, iTopMargin, 10, iTop);
                            else
                                m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, 10, iTop);
                        }
                    }
                    else
                    {
                        if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
                            m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, GetGrabHandleCaptionHeight());
                        else if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
                            m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, GetGrabHandleTaskPaneHeight());
                        else
                        {
                            //if (this.RightToLeft == RightToLeft.Yes)
                            //    m_GrabHandleRect = new Rectangle(objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, 10);
                            //else
                            m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, 10);
                        }
                    }
                }
                else if (thisBarState == eBarState.Floating)
                {
                    if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane)
                    {
                        m_GrabHandleRect = new Rectangle(iLeftMargin, ((this.IsThemed || this.DrawThemedCaption) ? m_ThemeWindowMargins.Bottom : 2), m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, GetGrabHandleTaskPaneHeight());
                    }
                    else
                    {
                        m_GrabHandleRect = new Rectangle(2, 2, m_ItemContainer.WidthInternal + iRightTabMargin, GetGrabHandleCaptionHeight());
                        if (this.CanHideResolved)
                            m_GrabHandleRect.Width -= 14;
                    }
                }

                if (thisBarState == eBarState.Popup && m_SideBarImage.Picture != null)
                    m_SideBarRect = new Rectangle(iLeft - m_SideBarImage.Picture.Width, iTopMargin, m_SideBarImage.Picture.Width, iTop - iTopMargin);

                //if(iLeft+m_ItemContainer.Width+iRightMargin!=this.ClientSize.Width || this.ClientSize.Height!=iTop+iBottomMargin)
                //	this.ClientSize=new Size(iLeft+m_ItemContainer.Width+iRightMargin,iTop+iBottomMargin);
                thisSize = new Size(iLeft + m_ItemContainer.WidthInternal + iRightMargin + iRightTabMargin, iTop + iBottomMargin);
            }
            else
            {
                //if(m_BarState==eBarState.Floating)
                thisSize = new Size(iLeft + m_ItemContainer.WidthInternal + iRightMargin + iRightTabMargin, iTop + iBottomMargin);
                //else
                //	thisSize=new Size(iLeft+m_ItemContainer.WidthInternal+iRightMargin+iRightTabMargin+14,iTop+iBottomMargin);
                m_ItemContainer.WidthInternal = iOrgWidth;
                m_ItemContainer.HeightInternal = iOrgHeight;
                m_ItemContainer.Orientation = oldOrientation;
                m_ItemContainer.WrapItems = bOldWrapItems;
                m_ItemContainer.Stretch = bOldStretch;
                m_ItemContainer.RecalcSize();
            }
            return thisSize;
        }
Beispiel #8
0
 private System.Drawing.Size RecalcSizeOnly(System.Drawing.Size objFrameSize, eOrientation barOrientation, eBarState barState, bool bWrapItems)
 {
     if (m_ItemContainer.SubItems.Count > 0)
     {
         if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
             return RecalcSizeOffice(true, objFrameSize, barOrientation, barState, bWrapItems);
         else
             return RecalcSizeDotNet(true, objFrameSize, barOrientation, barState, bWrapItems);
     }
     return System.Drawing.Size.Empty;
 }