Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Potential_Software.Win32;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Design;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
- using System.Windows.Forms.Design;
- namespace Visual_Studio_Theme.Controls
- {
- [Designer(typeof(AbideTabControlDesigner))]
- public class AbideTabControl : Control
- {
- //Properties
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
- public AbideTabPageCollection TabPages
- {
- get { return tabPages; }
- protected set { tabPages = value; }
- }
- [Browsable(false)]
- public AbideTabPage TabPage
- {
- get { if (selectedIndex == -1) { return null; } else { return TabPages[selectedIndex]; } }
- }
- [Browsable(false)]
- public int SelectedIndex
- {
- get { return selectedIndex; }
- set { selectedIndex = value; OnSelectedIndexChanged(new EventArgs()); }
- }
- [Browsable(false)]
- int HighlightedIndex
- {
- get { return highlightedIndex; }
- set { highlightedIndex = value; Refresh(); }
- }
- //Events
- public event TabPageAddedEventHandler TabPageAdded;
- public event EventHandler TabPageChanged;
- public event EventHandler TabPageRemoved;
- public event EventHandler SelectedIndexChanged;
- //Fields
- List<HitTestItem> tabAreas = new List<HitTestItem>();
- List<HitTestItem> closeAreas = new List<HitTestItem>();
- HitTestItem CloseItem = null;
- HitTestItem ClientArea = null;
- AbideTabPageCollection tabPages;
- Image closeDisplayImg = new Bitmap(1, 1);
- int selectedIndex = 0;
- int highlightedIndex = -1;
- int closeHighlightIndex = -1;
- int closePressedIndex = -1;
- //Methods
- public AbideTabControl()
- {
- this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
- this.DoubleBuffered = true;
- this.BackColor = Color.Transparent;
- this.selectedIndex = -1;
- base.Text = string.Empty;
- if (tabPages == null)
- this.tabPages = new AbideTabPageCollection(this);
- ClientArea = new HitTestItem(new Rectangle(3, 24, ClientSize.Width - 6, ClientSize.Height - 27), WinUser.HTCLIENT);
- CloseItem = new HitTestItem(new Rectangle(Width - 23, 4, 20, 20), WinUser.HTCLIENT);
- }
- //Overrides...
- protected override void WndProc(ref Message m)
- {
- Point MousePt = Point.Empty;
- Messages Msg = (Messages)m.Msg;
- if (DesignMode)
- {
- switch (Msg)
- {
- case Messages.WM_NCHITTEST:
- //Set Default
- m.Result = (IntPtr)WinUser.HTCLIENT;
- //Get Cursor Location...
- MousePt = PointToClient(new Point(m.LParam.ToInt32()));
- //Check...
- if (CloseItem != null && CloseItem.HitRegion.IsVisible(MousePt) && CloseItem.Active)
- {
- m.Result = (IntPtr)CloseItem.TestReturn;
- }
- if (ClientArea != null && ClientArea.HitRegion.IsVisible(MousePt) && ClientArea.Active)
- {
- m.Result = (IntPtr)ClientArea.TestReturn;
- }
- foreach (HitTestItem Item in tabAreas)
- {
- if (Item.HitRegion.IsVisible(MousePt))
- {
- m.Result = (IntPtr)Item.TestReturn;
- }
- }
- foreach (HitTestItem Item in closeAreas)
- {
- if (Item.HitRegion.IsVisible(MousePt))
- {
- m.Result = (IntPtr)Item.TestReturn;
- }
- }
- break;
- default:
- base.WndProc(ref m);
- break;
- }
- return;
- }
- switch (Msg)
- {
- case Messages.WM_NCHITTEST:
- //Set Default Result...
- m.Result = (IntPtr)WinUser.HTTRANSPARENT;
- //Get Cursor Location...
- MousePt = PointToClient(new Point(m.LParam.ToInt32()));
- //Check...
- if (CloseItem != null && CloseItem.HitRegion.IsVisible(MousePt) && CloseItem.Active)
- {
- m.Result = (IntPtr)CloseItem.TestReturn;
- }
- if (ClientArea != null && ClientArea.HitRegion.IsVisible(MousePt) && ClientArea.Active)
- {
- m.Result = (IntPtr)ClientArea.TestReturn;
- }
- foreach (HitTestItem Item in tabAreas)
- {
- if (Item.HitRegion.IsVisible(MousePt))
- {
- m.Result = (IntPtr)Item.TestReturn;
- }
- }
- break;
- default:
- base.WndProc(ref m);
- break;
- }
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- //Prepare Brushes & Pens
- Brush Edge = new SolidBrush(Color.FromArgb(0x00, 0x7a, 0xcc));
- Brush BackColor = new SolidBrush(this.BackColor);
- //Clear Background
- if (DesignMode)
- e.Graphics.Clear(this.BackColor);
- //Create Client Rectangle;
- Rectangle ControlArea = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height);
- Rectangle ContentArea = new Rectangle(0, 19, ClientSize.Width, ClientSize.Height - 19);
- Rectangle InnerContentArea = new Rectangle(0, 21, ClientSize.Width, ClientSize.Height - 21);
- //Update Hit Area
- ClientArea = new HitTestItem(ContentArea, WinUser.HTCLIENT);
- //Get Tab Count...
- int TabCount = (Width - 30) / 120;
- int VisibleTabCount = 0;
- if (tabPages.Count == 0 || TabCount == 0)
- CloseItem.Active = false;
- //Loop through each tab...
- for (int i = 0; i < tabPages.Count; i++)
- {
- if (i <= TabCount - 1)
- {
- int x = (i * 120);
- int y = 0;
- int width = 120;
- int height = 20;
- OnPaintTab(new TabPaintEventArgs(e.Graphics, new Rectangle(x, y, width, height), i));
- VisibleTabCount++;
- }
- }
- //Fill
- e.Graphics.FillRectangle(Edge, ContentArea);
- e.Graphics.FillRectangle(BackColor, InnerContentArea);
- //Cleanup
- Edge.Dispose();
- BackColor.Dispose();
- //Default Painting...
- base.OnPaint(e);
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- for (int i = 0; i < closeAreas.Count; i++)
- {
- if (closeAreas[i].HitRegion.IsVisible(e.Location) && closeAreas[i].Active)
- {
- if (this.closeHighlightIndex != i)
- {
- this.closeHighlightIndex = i;
- Refresh();
- }
- break;
- }
- else
- {
- if (this.closeHighlightIndex == i)
- {
- this.closeHighlightIndex = -1;
- Refresh();
- }
- }
- }
- foreach (HitTestItem item in tabAreas)
- {
- if (item.HitRegion.IsVisible(e.Location) && item.Active)
- {
- if (item.Tag != null && item.Tag is int)
- {
- int Index = (int)item.Tag;
- if (HighlightedIndex != Index)
- {
- HighlightedIndex = Index;
- }
- break;
- }
- }
- }
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- HighlightedIndex = -1;
- closeHighlightIndex = -1;
- closePressedIndex = -1;
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- for (int i = 0; i < closeAreas.Count; i++)
- {
- if (closeAreas[i].HitRegion.IsVisible(e.Location) && closeAreas[i].Active)
- {
- if (this.closePressedIndex != i)
- {
- this.closePressedIndex = i;
- Refresh();
- }
- break;
- }
- else
- {
- if (this.closePressedIndex == i)
- {
- this.closePressedIndex = -1;
- Refresh();
- }
- }
- }
- foreach (HitTestItem item in tabAreas)
- {
- if (item.HitRegion.IsVisible(e.Location) && item.Active)
- {
- if (item.Tag != null && item.Tag is int)
- {
- int Index = (int)item.Tag;
- this.SelectedIndex = Index;
- break;
- }
- }
- }
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- if (!DesignMode)
- {
- for (int i = 0; i < closeAreas.Count; i++)
- {
- if (closeAreas[i].HitRegion.IsVisible(e.Location) && closeAreas[i].Active)
- {
- if (closeAreas[i].Tag != null && closeAreas[i].Tag is int)
- {
- closeAreas.RemoveAt(i);
- tabAreas.RemoveAt(i);
- tabPages.RemoveAt(i);
- }
- }
- }
- }
- closeHighlightIndex = -1;
- closePressedIndex = -1;
- Refresh();
- }
- protected override void OnSizeChanged(EventArgs e)
- {
- base.OnSizeChanged(e);
- //Get Tab Count...
- int TabCount = (Width - 30) / 120;
- for (int i = TabCount; i < tabAreas.Count; i++)
- {
- tabAreas[i].Active = false;
- }
- if (selectedIndex + 1 > TabCount)
- selectedIndex = TabCount - 1;
- if (selectedIndex < 0 && this.tabPages.Count > 0)
- selectedIndex = 0;
- if (SelectedIndexChanged != null)
- SelectedIndexChanged(this, e);
- //Refresh...
- Refresh();
- }
- protected override void Dispose(bool disposing)
- {
- base.Dispose(disposing);
- }
- protected override void OnControlRemoved(ControlEventArgs e)
- {
- base.OnControlRemoved(e);
- if (e.Control is AbideTabPage)
- {
- tabPages.Remove((AbideTabPage)e.Control);
- }
- }
- //Virtuals...
- protected virtual void OnTabPageAdded(TabPageAddedEventArgs e)
- {
- if (TabPageAdded != null)
- TabPageAdded(this, e);
- //Set Index
- selectedIndex = tabPages.IndexOf(e.TabPage);
- //Change Selected Index
- OnSelectedIndexChanged(new EventArgs());
- //Reference Rectangle
- Rectangle InnerContentArea = new Rectangle(0, 21, ClientSize.Width, ClientSize.Height - 21);
- //Add Panel...
- SuspendLayout();
- AbideTabPage TabCtrl = tabPages[selectedIndex];
- TabCtrl.Size = new Size(InnerContentArea.Width - 2, InnerContentArea.Height - 2);
- TabCtrl.Location = new Point(InnerContentArea.X + 1, InnerContentArea.Y + 1);
- TabCtrl.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
- TabCtrl.Hide();
- Controls.Add(TabCtrl);
- if (selectedIndex == Controls.IndexOf(TabCtrl))
- TabCtrl.Show();
- ResumeLayout();
- //Check Count
- if (tabPages.Count > 0)
- {
- SelectedIndex = tabPages.IndexOf(e.TabPage);
- }
- //Refresh
- this.Refresh();
- }
- protected virtual void OnTabPageRemoved(EventArgs e)
- {
- //Trigger Event
- if (TabPageRemoved != null)
- TabPageRemoved(this, e);
- //Edit Selection Index
- if (selectedIndex >= tabPages.Count)
- selectedIndex = tabPages.Count - 1;
- //Change Selected Index...
- OnSelectedIndexChanged(e);
- }
- protected virtual void OnTabPageChanged(EventArgs e)
- {
- if (TabPageChanged != null)
- TabPageChanged(this, e);
- //Refresh
- this.Refresh();
- }
- protected virtual void OnPaintTab(TabPaintEventArgs e)
- {
- //Prepare Brushes & Pens
- Brush Active = new SolidBrush(Color.FromArgb(0x00, 0x7a, 0xcc));
- Brush Inactive = new SolidBrush(Color.FromArgb(0x2d, 0x2d, 0x30));
- Brush Hot = new SolidBrush(Color.FromArgb(0x1c, 0x97, 0xea));
- Brush TextBrush = new SolidBrush(Color.White);
- //Prepare Gfx
- e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
- //Get rounded Rectangle...
- Rectangle TabRect = e.ClipRectangle;
- Rectangle CloseRect = new Rectangle(TabRect.X + (TabRect.Width - 18), 3, 15, 15);
- //Fill...
- if (e.TabIndex == selectedIndex)
- {
- e.Graphics.FillRectangle(Active, TabRect);
- }
- else if (e.TabIndex == highlightedIndex)
- {
- e.Graphics.FillRectangle(Hot, TabRect);
- }
- else
- {
- e.Graphics.FillRectangle(Inactive, TabRect);
- }
- //Draw Close Image
- if (!DesignMode)
- {
- if (e.TabIndex == selectedIndex)
- {
- if (closePressedIndex == e.TabIndex)
- e.Graphics.DrawImage(Properties.Resources.CloseSelected_Down, CloseRect);
- else if (closeHighlightIndex == e.TabIndex)
- e.Graphics.DrawImage(Properties.Resources.CloseSelected_Hot, CloseRect);
- else
- e.Graphics.DrawImage(Properties.Resources.CloseSelected_Normal, CloseRect);
- }
- else if (e.TabIndex == highlightedIndex)
- {
- if (closePressedIndex == e.TabIndex)
- e.Graphics.DrawImage(Properties.Resources.CloseHot_Pressed, CloseRect);
- else if (closeHighlightIndex == e.TabIndex)
- e.Graphics.DrawImage(Properties.Resources.CloseHot_Hot, CloseRect);
- else
- e.Graphics.DrawImage(Properties.Resources.CloseHot_Normal, CloseRect);
- }
- }
- //Prepare
- RectangleF TextRect = new RectangleF(e.ClipRectangle.X + 4, e.ClipRectangle.Y, e.ClipRectangle.Width - 18, e.ClipRectangle.Height);
- StringFormat format = new StringFormat();
- format.LineAlignment = StringAlignment.Center;
- format.Alignment = StringAlignment.Near;
- //Measure String
- Size textSize = TextRenderer.MeasureText(tabPages[e.TabIndex].Text, this.Font);
- string Text = string.Empty;
- if (textSize.Width < 120) { Text = tabPages[e.TabIndex].Text; } else { Text = tabPages[e.TabIndex].Text.Substring(0, 12) + "..."; }
- //Draw
- e.Graphics.DrawString(Text, Font, TextBrush, TextRect, format);
- //Cleanup
- format.Dispose();
- Active.Dispose();
- Inactive.Dispose();
- Active.Dispose();
- Hot.Dispose();
- //Create Close HitTest...
- HitTestItem closeItem = new HitTestItem(CloseRect, WinUser.HTCLIENT);
- closeItem.Tag = e.TabIndex;
- closeItem.Label = tabPages[e.TabIndex].Text;
- if (closeAreas.Count > e.TabIndex)
- {
- closeAreas[e.TabIndex] = closeItem;
- }
- else
- {
- closeAreas.Add(closeItem);
- }
- //Create Tab HitTest...
- HitTestItem tabItem = new HitTestItem(TabRect, WinUser.HTCLIENT);
- tabItem.Tag = e.TabIndex;
- tabItem.Label = tabPages[e.TabIndex].Text;
- if (tabAreas.Count > e.TabIndex)
- {
- tabAreas[e.TabIndex] = tabItem;
- }
- else
- {
- tabAreas.Add(tabItem);
- }
- }
- protected virtual void OnSelectedIndexChanged(EventArgs e)
- {
- //Redraw
- Refresh();
- //Suspend
- SuspendLayout();
- //Check...
- HideAll();
- Show(selectedIndex);
- //Resume
- ResumeLayout();
- //Event
- if (SelectedIndexChanged != null)
- SelectedIndexChanged(this, e);
- }
- //Functions...
- public void Clear()
- {
- //Clear All Pages
- Controls.Clear();
- }
- private void HideAll()
- {
- for (int i = 0; i < Controls.Count; i++)
- {
- Controls[i].Hide();
- }
- }
- private void Show(int Index)
- {
- if (Index > -1 && Index < Controls.Count)
- {
- Controls[Index].Show();
- }
- }
- //Nested Types
- public new class ControlCollection : Control.ControlCollection
- {
- AbideTabControl TabControlOwner
- {
- get { return this.Owner as AbideTabControl; }
- }
- public ControlCollection(AbideTabControl owner)
- : base(owner) { }
- public override void Add(Control value)
- {
- if (value.GetType() == typeof(object))
- {
- TabControlOwner.tabPages.Add(value as AbideTabPage);
- }
- else
- {
- base.Add(value);
- }
- }
- public override void Remove(Control value)
- {
- if (value.GetType() == typeof(object))
- {
- TabControlOwner.tabPages.Remove(value as AbideTabPage);
- }
- else
- {
- base.Add(value);
- }
- }
- }
- internal class HitTestItem : IDisposable
- {
- public string Label
- {
- get { return label; }
- set { label = value; }
- }
- public object Tag
- {
- get;
- set;
- }
- public GraphicsPath HitRegion
- {
- get { return hitRegion; }
- }
- public int TestReturn
- {
- get { return hitResult; }
- }
- public bool Active
- {
- get { return active; }
- set { active = value; }
- }
- string label = string.Empty;
- bool active = true;
- GraphicsPath hitRegion = null;
- int hitResult = WinUser.HTCLIENT;
- public HitTestItem(GraphicsPath Region, int ReturnValue)
- {
- this.hitRegion = Region;
- this.hitResult = ReturnValue;
- }
- public HitTestItem(Rectangle Region, int ReturnValue)
- {
- this.hitRegion = new GraphicsPath();
- hitRegion.AddRectangle(Region);
- this.hitResult = ReturnValue;
- }
- public override string ToString()
- {
- return label;
- }
- public void Dispose()
- {
- hitRegion.Dispose();
- }
- }
- public class AbideTabPageCollection : IList, ICollection, IEnumerable
- {
- ArrayList InnerList;
- AbideTabControl owner;
- public AbideTabPageCollection(AbideTabControl Owner)
- {
- this.InnerList = new ArrayList(new List<AbideTabPage>());
- this.owner = Owner;
- }
- bool IList.IsReadOnly
- {
- get { return InnerList.IsReadOnly; }
- }
- public bool IsReadOnly
- {
- get { return InnerList.IsReadOnly; }
- }
- object IList.this[int index]
- {
- get { return InnerList[index]; }
- set { InnerList[index] = value; owner.OnTabPageChanged(new EventArgs()); }
- }
- public AbideTabPage this[int index]
- {
- get { return InnerList[index] as AbideTabPage; }
- set { InnerList[index] = value; }
- }
- int IList.Add(object value)
- {
- return InnerList.Add(value);
- }
- public void Add(AbideTabPage page)
- {
- InnerList.Add(page);
- owner.OnTabPageAdded(new TabPageAddedEventArgs(page));
- }
- public void Add(string text)
- {
- InnerList.Add(new AbideTabPage(text));
- owner.OnTabPageAdded(new TabPageAddedEventArgs(new AbideTabPage(text)));
- }
- public void AddRange(AbideTabPage[] pages)
- {
- InnerList.AddRange(pages);
- foreach (AbideTabPage page in pages)
- {
- owner.OnTabPageAdded(new TabPageAddedEventArgs(page));
- }
- }
- void IList.Clear()
- {
- InnerList.Clear();
- }
- public void Clear()
- {
- InnerList.Clear();
- }
- bool IList.Contains(object value)
- {
- return InnerList.Contains(value);
- }
- public bool Contains(AbideTabPage page)
- {
- return InnerList.Contains(page);
- }
- IEnumerator IEnumerable.GetEnumerator()
- {
- return InnerList.GetEnumerator();
- }
- public IEnumerator GetEnumerator()
- {
- return InnerList.GetEnumerator();
- }
- int IList.IndexOf(object value)
- {
- return InnerList.IndexOf(value);
- }
- public int IndexOf(AbideTabPage page)
- {
- return InnerList.IndexOf(page);
- }
- void IList.Insert(int index, object value)
- {
- InnerList.Insert(index, value);
- }
- public void Insert(int index, AbideTabPage page)
- {
- InnerList.Insert(index, page);
- }
- public void Insert(int index, string text)
- {
- InnerList.Insert(index, new AbideTabPage(text));
- }
- bool IList.IsFixedSize
- {
- get { return InnerList.IsFixedSize; }
- }
- void IList.Remove(object value)
- {
- InnerList.Remove(value);
- }
- public bool Remove(AbideTabPage page)
- {
- if (InnerList.Contains(page))
- {
- InnerList.Remove(page);
- owner.Controls.Remove(page);
- owner.OnTabPageRemoved(new EventArgs());
- return true;
- }
- else
- return false;
- }
- void IList.RemoveAt(int index)
- {
- InnerList.RemoveAt(index);
- }
- public void RemoveAt(int index)
- {
- InnerList.RemoveAt(index);
- owner.OnTabPageRemoved(new EventArgs());
- }
- int ICollection.Count
- {
- get { return InnerList.Count; }
- }
- public int Count
- {
- get { return InnerList.Count; }
- }
- void ICollection.CopyTo(Array array, int index)
- {
- InnerList.CopyTo(array, index);
- }
- bool ICollection.IsSynchronized
- {
- get { return InnerList.IsSynchronized; }
- }
- object ICollection.SyncRoot
- {
- get { return InnerList.SyncRoot; }
- }
- }
- internal class AbideTabControlDesigner : ControlDesigner
- {
- protected override bool GetHitTest(Point point)
- {
- AbideTabControl Control = (AbideTabControl)this.Control;
- Point LocalPoint = Control.PointToClient(point);
- bool ReturnValue = false;
- foreach (HitTestItem Item in Control.tabAreas)
- {
- if (Item.HitRegion.IsVisible(LocalPoint))
- {
- ReturnValue = true;
- }
- }
- if (ReturnValue == false) { Control.highlightedIndex = -1; Control.Refresh(); }
- return ReturnValue;
- }
- }
- //Delegates
- public delegate void TabPageAddedEventHandler(object sender, TabPageAddedEventArgs e);
- }
- [ToolboxItem(false), Designer(typeof(AbideTabPageDesigner))]
- public class AbideTabPage : Panel
- {
- /// <summary>
- /// Gets or sets the text for this tab.
- /// </summary>
- [Browsable(true)]
- [Category("Appearance")]
- public override string Text
- {
- get { return base.Text; }
- set { base.Text = value; }
- }
- [Browsable(false)]
- public new Size Size
- {
- get { return base.Size; }
- set { base.Size = value; }
- }
- [Browsable(false)]
- public new Point Location
- {
- get { return base.Location; }
- set { base.Location = value; }
- }
- [Browsable(false)]
- public new AnchorStyles Anchor
- {
- get { return base.Anchor; }
- set { base.Anchor = value; }
- }
- [Browsable(false)]
- public new DockStyle Dock
- {
- get { return base.Dock; }
- set { base.Dock = value; }
- }
- public event EventHandler Closing;
- public AbideTabPage()
- : base()
- {
- this.DoubleBuffered = true;
- this.SetStyle(ControlStyles.FixedHeight, true);
- this.SetStyle(ControlStyles.FixedWidth, true);
- }
- public AbideTabPage(string Text)
- : base()
- {
- this.Text = Text;
- this.DoubleBuffered = true;
- this.SetStyle(ControlStyles.FixedHeight, true);
- this.SetStyle(ControlStyles.FixedWidth, true);
- }
- protected override void InitLayout()
- {
- if (this.Parent.GetType() != typeof(AbideTabControl))
- throw new ArgumentException(string.Format("{0} cannot be added to {1}. It can only be added to {2}",
- typeof(AbideTabPage).ToString(),
- this.Parent.GetType().ToString(),
- typeof(AbideTabControl).ToString()));
- base.InitLayout();
- }
- public override string ToString()
- {
- return Text;
- }
- public virtual void OnClosing(EventArgs e)
- {
- if (Closing != null)
- Closing(this, e);
- this.Dispose();
- }
- internal class AbideTabPageDesigner : ControlDesigner
- {
- public override SelectionRules SelectionRules
- {
- get
- {
- return SelectionRules.None;
- }
- }
- }
- }
- public class TabPaintEventArgs : PaintEventArgs
- {
- public int TabIndex
- {
- get { return tabIndex; }
- }
- int tabIndex = 0;
- public TabPaintEventArgs(Graphics graphics, Rectangle clipRect, int TabIndex)
- : base(graphics, clipRect)
- {
- tabIndex = TabIndex;
- }
- }
- public class TabPageAddedEventArgs : EventArgs
- {
- public AbideTabPage TabPage
- {
- get;
- protected set;
- }
- public TabPageAddedEventArgs(AbideTabPage TabPage)
- {
- this.TabPage = TabPage;
- }
- }
- /// <summary>
- /// Provides data from the WM_NCCALCSIZE Window Message.
- /// </summary>
- public class NonClientCalcSizeEventArgs : EventArgs
- {
- #region Fields
- RECT windowRect;
- RECT clientRect;
- #endregion
- #region Properties
- /// <summary>
- /// Gets the proposed Client Rectangle
- /// </summary>
- public Rectangle ClientRectangle
- {
- get
- {
- return new Rectangle(
- clientRect.left - windowRect.left,
- clientRect.top - windowRect.top,
- (clientRect.right - clientRect.left) - windowRect.left,
- (clientRect.bottom - clientRect.top) - windowRect.top);
- }
- }
- /// <summary>
- /// Gets a rectangle that represents the Window size and position.
- /// </summary>
- public Rectangle WindowRectangle
- {
- get { return new Rectangle(windowRect.left, windowRect.right, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top); }
- }
- /// <summary>
- /// Sets the distance (in pixels) of the top of the client area from the window.
- /// Ex. 0 will remove the caption
- /// </summary>
- public int Top
- {
- get { return (int)(clientRect.top - windowRect.top); }
- set { clientRect.top = (windowRect.top + value); }
- }
- /// <summary>
- /// Sets the distance (int pixels) of the bottom of the client area from the window.
- /// Ex. 0 will remove the bottom border
- /// </summary>
- public int Bottom
- {
- get { return (int)(windowRect.bottom - clientRect.bottom); }
- set { clientRect.bottom = (windowRect.bottom - value); }
- }
- /// <summary>
- /// Sets the distance (int pixels) of the left of the client area from the window.
- /// Ex. 0 will remove the left border
- /// </summary>
- public int Left
- {
- get { return (int)(clientRect.left - windowRect.left); }
- set { clientRect.left = (windowRect.left + value); }
- }
- /// <summary>
- /// Sets the distance (int pixels) of the right of the client area from the window.
- /// Ex. 0 will remove the right border
- /// </summary>
- public int Right
- {
- get { return (int)(windowRect.right - clientRect.right); }
- set { clientRect.right = (windowRect.right - value); }
- }
- #endregion
- #region Constructor
- public NonClientCalcSizeEventArgs(RECT WindowRect, RECT ClientRect)
- {
- this.clientRect = ClientRect;
- this.windowRect = WindowRect;
- }
- #endregion
- #region Methods
- /// <summary>
- /// Removes the non-client area
- /// </summary>
- public void RemoveNonClientArea()
- {
- clientRect.top = windowRect.top;
- clientRect.bottom = windowRect.bottom;
- clientRect.left = windowRect.left;
- clientRect.right = windowRect.right;
- }
- /// <summary>
- /// Used to retrieve the RECT that represents the Client Area...
- /// </summary>
- /// <returns>RECT that represents the Client Area.</returns>
- public RECT GetClientRECT()
- {
- return clientRect;
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement