Browse Source
Hiding of main menu refactored. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@455 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
5 changed files with 219 additions and 99 deletions
@ -0,0 +1,148 @@
@@ -0,0 +1,148 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui |
||||
{ |
||||
public class AutoHideContainer: Panel |
||||
{ |
||||
protected Control control; |
||||
|
||||
protected bool autoHide = true; |
||||
protected bool showOnMouseMove = true; |
||||
protected bool showOnMouseDown = true; |
||||
protected int activatorHeight = 1; |
||||
|
||||
protected bool mouseIn; |
||||
|
||||
public virtual bool AutoHide { |
||||
get { |
||||
return autoHide; |
||||
} |
||||
set { |
||||
autoHide = value; |
||||
RefreshSize(); |
||||
} |
||||
} |
||||
|
||||
protected virtual void RefreshSize() |
||||
{ |
||||
if (autoHide) { |
||||
this.Height = activatorHeight; |
||||
this.Controls.Clear(); |
||||
} else { |
||||
this.Height = PreferredHeight; |
||||
control.Dock = DockStyle.Fill; |
||||
this.Controls.Add(control); |
||||
} |
||||
} |
||||
|
||||
protected virtual int PreferredHeight { |
||||
get { |
||||
return control.PreferredSize.Height; |
||||
} |
||||
} |
||||
|
||||
public bool ShowOnMouseMove { |
||||
get { |
||||
return showOnMouseMove; |
||||
} |
||||
set { |
||||
showOnMouseMove = value; |
||||
} |
||||
} |
||||
|
||||
public bool ShowOnMouseDown { |
||||
get { |
||||
return showOnMouseDown; |
||||
} |
||||
set { |
||||
showOnMouseDown = value; |
||||
} |
||||
} |
||||
|
||||
public Color ActivatorColor { |
||||
get { |
||||
return this.ForeColor; |
||||
} |
||||
set { |
||||
this.ForeColor = value; |
||||
} |
||||
} |
||||
|
||||
public int ActivatorHeight { |
||||
get { |
||||
return activatorHeight; |
||||
} |
||||
set { |
||||
activatorHeight = value; |
||||
} |
||||
} |
||||
|
||||
public AutoHideContainer(Control control) |
||||
{ |
||||
if (control == null) { |
||||
throw new ArgumentNullException("control"); |
||||
} |
||||
this.control = control; |
||||
RefreshSize(); |
||||
this.MouseMove += OnPanelMouseMove; |
||||
this.MouseDown += OnPanelMouseDown; |
||||
control.MouseEnter += OnControlMouseEnter; |
||||
control.MouseLeave += OnControlMouseLeave; |
||||
} |
||||
|
||||
protected virtual void OnPanelMouseMove(object sender, MouseEventArgs e) |
||||
{ |
||||
if (showOnMouseMove && autoHide) { |
||||
ShowOverlay(); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnPanelMouseDown(object sender, MouseEventArgs e) |
||||
{ |
||||
if (showOnMouseDown && autoHide) { |
||||
ShowOverlay(); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnControlMouseEnter(object sender, EventArgs e) |
||||
{ |
||||
mouseIn = true; |
||||
} |
||||
|
||||
protected virtual void OnControlMouseLeave(object sender, EventArgs e) |
||||
{ |
||||
mouseIn = false; |
||||
HideOverlay(); |
||||
} |
||||
|
||||
public virtual void ShowOverlay() |
||||
{ |
||||
control.Dock = DockStyle.None; |
||||
control.Size = new Size(this.Width, control.PreferredSize.Height); |
||||
if (this.Dock != DockStyle.Bottom) { |
||||
control.Location = new Point(this.Left, this.Top); |
||||
} else { |
||||
control.Location = new Point(this.Left, this.Top - control.PreferredSize.Height + 1); |
||||
} |
||||
Parent.Controls.Add(control); |
||||
control.BringToFront(); |
||||
} |
||||
|
||||
public virtual void HideOverlay() |
||||
{ |
||||
if (Parent.Controls.Contains(control)) { |
||||
Parent.Controls.Remove(control); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// AutoHideStatusStripContainer can be used instead of StatusStrip to get a status strip
|
||||
/// which is automaticaly hiden and shown. It is especially useful in fullscreen.
|
||||
/// </summary>
|
||||
public class AutoHideStatusStripContainer: AutoHideContainer |
||||
{ |
||||
public AutoHideStatusStripContainer(StatusStrip statusStrip): base(statusStrip) |
||||
{ |
||||
statusStrip.AutoSize = false; |
||||
statusStrip.MouseMove += StatusStripMouseMove; |
||||
} |
||||
|
||||
void StatusStripMouseMove(object sender, MouseEventArgs e) |
||||
{ |
||||
if (e.Y < control.Height - 3) { |
||||
HideOverlay(); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue