示例#1
0
		public void ShowShadow()
		{
			if(m_ShowDropShadow)
			{
				if(m_DropShadow!=null)
				{
					m_DropShadow.Hide();
					m_DropShadow.Dispose();
                    m_DropShadow = null;
				}

                if (this.Width > 5 && this.Height > 5)
                {
                    m_DropShadow = new PopupShadow(true);
                    m_DropShadow.CreateControl();
                    NativeFunctions.SetWindowPos(m_DropShadow.Handle, new IntPtr(NativeFunctions.HWND_NOTOPMOST), this.Left + SHADOW_OFFSET, this.Top + SHADOW_OFFSET, this.Width - 2, this.Height - 2, NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE);
                    m_DropShadow.UpdateShadow();
                }
			}
		}
示例#2
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();
        }