protected override void OnVisibleChanged(EventArgs e) { base.OnVisibleChanged(e); if(!this.Visible && m_DropShadow!=null) { m_DropShadow.Hide(); m_DropShadow.Dispose(); m_DropShadow=null; } }
protected override void Dispose(bool disposing) { if(m_DropShadow!=null) { m_DropShadow.Hide(); m_DropShadow.Dispose(); m_DropShadow=null; } base.Dispose(disposing); }
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(); } }
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(); } } }
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(); }
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(); }
/// <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(); } }
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; } }
protected override void Dispose(bool disposing) { IsDisposing = true; if (m_ParentMsgHandlerRegistered) { DotNetBarManager.UnRegisterOwnerParentMsgHandler(this, null); m_ParentMsgHandlerRegistered = false; } if (m_Float != null && disposing) { try { if (m_Float.Controls.Contains(this)) m_Float.Controls.Remove(this); m_Float.Close(); m_Float.Dispose(); m_Float = null; } catch (Exception) { } } if (m_Owner is DotNetBarManager && ((DotNetBarManager)m_Owner).IgnoreLoadedControlDispose) this.Controls.Clear(); if (this.Parent != null) { try { this.Parent.Controls.Remove(this); } catch (Exception) { } } Microsoft.Win32.SystemEvents.UserPreferenceChanged -= new Microsoft.Win32.UserPreferenceChangedEventHandler(PreferenceChanged); if (m_TabDockItems != null) { m_TabDockItems.Dispose(); m_TabDockItems = null; } if (m_DropShadow != null) { m_DropShadow.Hide(); m_DropShadow.Dispose(); m_DropShadow = null; } if (m_FilterInstalled) { MessageHandler.UnregisterMessageClient(this); m_FilterInstalled = false; } RestoreContainer(); m_Owner = null; m_ParentItem = null; m_OldContainer = null; //m_OldParent=null; if (m_ItemContainer != null) m_ItemContainer.Dispose(); m_ItemContainer = null; base.Dispose(disposing); IsDisposing = false; }
protected override void OnVisibleChanged(EventArgs e) { if (this.IsHandleCreated) m_IsVisible = base.Visible; // Restore bar order when docked to the side. WinForms can change it's order which // creates problem for docking... if (m_BarShowIndex >= 0) { if (this.Parent is DockSite && this.Parent.Controls.IndexOf(this) != m_BarShowIndex) { this.Parent.Controls.SetChildIndex(this, m_BarShowIndex); } m_BarShowIndex = -1; } // 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. IOwner owner = m_Owner as IOwner; if (owner != null) { 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(); } } base.OnVisibleChanged(e); // m_DockingInProgress check is needed becouse we don't want RecalcLayout to be called from // DockSite.AddBar. The visible change event will fire when from that procedure Bar is added // to the Dock Site. if (m_BarState == eBarState.Docked && !m_DockingInProgress && this.Visible) { if (this.LayoutType == eLayoutType.DockContainer && m_AlwaysDisplayDockTab) RefreshDockTab(false); this.RecalcLayout(); } if (!this.Visible && m_DropShadow != null) { m_DropShadow.Hide(); m_DropShadow.Dispose(); m_DropShadow = null; } if (!this.Visible && m_CustomizeMenu != null && m_CustomizeMenu.Expanded) m_CustomizeMenu.Expanded = false; }
protected override void OnVisibleChanged(EventArgs e) { base.OnVisibleChanged(e); if(!this.Visible && m_DropShadow!=null) { m_DropShadow.Hide(); m_DropShadow.Dispose(); m_DropShadow=null; } if(!this.Visible && this.Parent!=null && this.Parent is PopupContainer) { this.Parent.Visible=false; } if(!this.Visible && m_ScrollTimer!=null) { m_ScrollTimer.Stop(); m_ScrollTimer.Dispose(); m_ScrollTimer=null; } if(m_AccessibleObjectCreated) { MenuPanel.PopupMenuAccessibleObject acc=this.AccessibilityObject as PopupMenuAccessibleObject; if(acc!=null) { if(m_ParentItem!=null) { foreach(BaseItem item in m_ParentItem.SubItems) acc.GenerateEvent(item,AccessibleEvents.Destroy); } if(!this.Visible) { acc.GenerateEvent(AccessibleEvents.SystemMenuPopupEnd); acc.GenerateEvent(AccessibleEvents.StateChange); } } } }
protected override void Dispose(bool disposing) { if(this.Parent!=null && this.Parent is PopupContainer) { Control parent=this.Parent; this.Parent.Controls.Remove(this); parent.Dispose(); parent=null; } if(m_AccessibleObjectCreated) { PopupMenuAccessibleObject acc=this.AccessibilityObject as PopupMenuAccessibleObject; if(acc!=null) acc.GenerateEvent(AccessibleEvents.Destroy); } if(m_DropShadow!=null) { m_DropShadow.Hide(); m_DropShadow.Dispose(); m_DropShadow=null; } this.Font = null; RestoreContainer(); m_ParentItem=null; base.Dispose(disposing); }