示例#1
0
		public void ShowToolTip()
		{
			if (!this.IsHandleCreated)
				this.CreateControl();

            Size sz = Size.Empty;
			// Calculate Size of the window
			Graphics g=this.CreateGraphics();

            if (m_AntiAlias)
            {
                g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            }

            try
            {
                g.PageUnit = GraphicsUnit.Pixel;
                if (m_TextMarkup == null)
                    sz = TextDrawing.MeasureString(g, GetDrawText(), this.Font, Screen.PrimaryScreen.WorkingArea.Size, GetStringFormat());
                else
                {
                    TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, this.Font, SystemColors.Control, (this.RightToLeft == RightToLeft.Yes));
                    m_TextMarkup.Measure(Screen.PrimaryScreen.WorkingArea.Size, d);
                    sz = m_TextMarkup.Bounds.Size;
                    m_TextMarkup.Arrange(new Rectangle(Point.Empty, sz), d);
                }
            }
            finally
            {
                g.SmoothingMode = SmoothingMode.Default;
                g.TextRenderingHint = TextRenderingHint.SystemDefault;
                g.Dispose();
            }
			g=null;

			Point mousePosition=System.Windows.Forms.Control.MousePosition;
			Rectangle r=new Rectangle(System.Windows.Forms.Control.MousePosition.X,System.Windows.Forms.Control.MousePosition.Y,(int)sz.Width,(int)sz.Height);
			r.Inflate(2,2);
			r.Offset(12,24);

			ScreenInformation screen=BarFunctions.ScreenFromPoint(mousePosition);
			if(screen!=null)
			{
				System.Drawing.Size layoutArea=screen.WorkingArea.Size;
				layoutArea.Width-=(int)(layoutArea.Width*.2f);

                if (r.Right > screen.WorkingArea.Right)
                {
                    r.X = r.Left - (r.Right - screen.WorkingArea.Right);
                }

                if (r.Bottom > screen.Bounds.Bottom)
                {
                    if (ReferenceRectangle.IsEmpty)
                        r.Y = mousePosition.Y - r.Height;
                    else
                    {
                        r.Y = ReferenceRectangle.Y - r.Height - 1;
                    }
                }
				
				if(r.Contains(System.Windows.Forms.Control.MousePosition.X,System.Windows.Forms.Control.MousePosition.Y))
				{
					// We have to move it out of mouse position
                    if (r.Height + System.Windows.Forms.Control.MousePosition.Y + 1 <= screen.WorkingArea.Height && (ReferenceRectangle.IsEmpty || !ReferenceRectangle.IntersectsWith(new Rectangle(r.X, System.Windows.Forms.Control.MousePosition.Y + 1, r.Width, r.Height))))
						r.Y=System.Windows.Forms.Control.MousePosition.Y+1;
					else
						r.Y=System.Windows.Forms.Control.MousePosition.Y-r.Height-1;
				}
			}

			this.Location=r.Location;
			this.ClientSize=r.Size;

			if(NativeFunctions.ShowDropShadow)
			{
				if(m_DropShadow==null)
				{
					m_DropShadow=new PopupShadow(NativeFunctions.AlphaBlendingSupported);
					m_DropShadow.CreateControl();
				}
				//m_DropShadow.Location=new Point(r.Left+4,r.Top+4);
				//m_DropShadow.Size=r.Size;
				// TODO: Bug Cannot set size and location correctly using the Size and Location because Form caption is hidden
				m_DropShadow.Hide();
			}
			NativeFunctions.SetWindowPos(this.Handle,new IntPtr(NativeFunctions.HWND_TOP),0,0,0,0,NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOSIZE | NativeFunctions.SWP_NOACTIVATE | NativeFunctions.SWP_NOMOVE);
			if(m_DropShadow!=null)
			{
				NativeFunctions.SetWindowPos(m_DropShadow.Handle,this.Handle,r.Left+5,r.Top+5,r.Width-2,r.Height-2,NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE);
				m_DropShadow.UpdateShadow();
			}
		}
示例#2
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();
                }
			}
		}
示例#3
0
        /// <summary>
        /// Shows tooltip at specified screen coordinates.
        /// </summary>
        /// <param name="x">X coordinate</param>
        /// <param name="y">Y coordinate</param>
        /// <param name="enforceScreenPosition">Indicates whether to enforce the screen position of tooltip if tooltip falls out of screen bounds.</param>
        public void ShowTooltip(SuperTooltipInfo info, int x, int y, bool enforceScreenPosition)
        {
            UpdateWithSuperTooltipInfo(info);
            if (info.CustomSize.Width > ElementStyleLayout.HorizontalStyleWhiteSpace(GetStyle()) + 4 && info.CustomSize.Height == 0)
                this.Size = GetFixedWidthSize(info.CustomSize.Width);
            else if (info.CustomSize.IsEmpty || info.CustomSize.Width < ElementStyleLayout.HorizontalStyleWhiteSpace(GetStyle()) + 4 ||
                info.CustomSize.Height < ElementStyleLayout.VerticalStyleWhiteSpace(GetStyle()) + 4)
            {
                this.RecalcSize();
                if (m_MaximumWidth > 0 && this.Size.Width > m_MaximumWidth)
                {
                    // Enforce maximum width
                    this.Size = GetFixedWidthSize(m_MaximumWidth);
                }
            }
            else
                this.Size = info.CustomSize;

            bool setLocation = true;

            if (enforceScreenPosition)
            {
                Point mousePosition = Control.MousePosition;
                ScreenInformation screen = BarFunctions.ScreenFromPoint(mousePosition);
                if (screen != null)
                {
                    Rectangle r = new Rectangle(x, y, this.Width, this.Height);
                    System.Drawing.Size layoutArea = screen.WorkingArea.Size;
                    layoutArea.Width -= (int)(layoutArea.Width * .2f);

                    if (r.Right > screen.WorkingArea.Right)
                        r.X=r.X - (r.Right - screen.WorkingArea.Right);
                    if (r.Bottom > screen.Bounds.Bottom)
                        r.Y = screen.Bounds.Bottom - r.Height;

                    if (r.Contains(System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y))
                    {
                        // We have to move it out of mouse position
                        if (r.Height + System.Windows.Forms.Control.MousePosition.Y + 1 <= screen.WorkingArea.Height)
                            r.Y = System.Windows.Forms.Control.MousePosition.Y + SystemInformation.CursorSize.Height;
                        else
                            r.Y = System.Windows.Forms.Control.MousePosition.Y - r.Height - SystemInformation.CursorSize.Height;
                    }

                    this.Bounds = r;
                    setLocation = false;
                }
            }

            if (!this.IsHandleCreated)
                this.CreateControl();

            Point p = Point.Empty;
            if (setLocation)
            {
                p = new Point(x, y);
                this.Location = p;
            }
            else
                p = this.Location;

            if (NativeFunctions.ShowDropShadow)
            {
                if (m_DropShadow == null)
                {
                    m_DropShadow = new PopupShadow(NativeFunctions.AlphaBlendingSupported);
                    m_DropShadow.CreateControl();
                }
                m_DropShadow.Hide();
            }
            if (NativeFunctions.ShowDropShadow && Environment.OSVersion.Version.Major >= 5 && !NativeFunctions.IsTerminalSession())
            {
                NativeFunctions.AnimateWindow(this.Handle, BarFunctions.ANIMATION_INTERVAL, NativeFunctions.AW_BLEND);
            }
            else
                NativeFunctions.SetWindowPos(this.Handle, new IntPtr(NativeFunctions.HWND_TOP), 0, 0, 0, 0, NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOSIZE | NativeFunctions.SWP_NOACTIVATE | NativeFunctions.SWP_NOMOVE);
            if (m_DropShadow != null)
            {
                NativeFunctions.SetWindowPos(m_DropShadow.Handle, this.Handle, p.X + 3, p.Y + 3, this.Width, this.Height, NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE);
                m_DropShadow.UpdateShadow();
            }
        }
示例#4
0
		public new void Show()
		{
			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);
			}
			base.Show();
		}
示例#5
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();
        }