?? tabbedgroups.cs
字號:
// *****************************************************************************
//
// (c) Crownwood Consulting Limited 2002
// All rights reserved. The software and associated documentation
// supplied hereunder are the proprietary information of Crownwood Consulting
// Limited, Haxey, North Lincolnshire, England and are supplied subject to
// licence terms.
//
// Magic Version 1.7 www.dotnetmagic.com
// *****************************************************************************
using System;
using System.IO;
using System.Xml;
using System.Text;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Crownwood.Magic.Win32;
using Crownwood.Magic.Common;
using Crownwood.Magic.Controls;
namespace Crownwood.Magic.Controls
{
[ToolboxBitmap(typeof(TabbedGroups))]
public class TabbedGroups : UserControl, ISupportInitialize, IMessageFilter
{
public class DragProvider
{
protected object _tag;
public DragProvider()
{
_tag = null;
}
public DragProvider(object tag)
{
_tag = tag;
}
public object Tag
{
get { return _tag; }
set { _tag = value; }
}
}
public enum DisplayTabModes
{
HideAll,
ShowAll,
ShowActiveLeaf,
ShowMouseOver,
ShowActiveAndMouseOver
}
public enum CompactFlags
{
RemoveEmptyTabLeaf = 1,
RemoveEmptyTabSequence = 2,
ReduceSingleEntries = 4,
ReduceSameDirection = 8,
All = 15
}
// Instance fields
protected int _numLeafs;
protected int _defMinWidth;
protected int _defMinHeight;
protected string _closeMenuText;
protected string _prominentMenuText;
protected string _rebalanceMenuText;
protected string _movePreviousMenuText;
protected string _moveNextMenuText;
protected string _newVerticalMenuText;
protected string _newHorizontalMenuText;
protected ImageList _imageList;
protected bool _dirty;
protected bool _autoCalculateDirty;
protected bool _saveControls;
protected bool _initializing;
protected bool _atLeastOneLeaf;
protected bool _autoCompact;
protected bool _compacting;
protected bool _resizeBarLock;
protected int _resizeBarVector;
protected Color _resizeBarColor;
protected Shortcut _closeShortcut;
protected Shortcut _prominentShortcut;
protected Shortcut _rebalanceShortcut;
protected Shortcut _movePreviousShortcut;
protected Shortcut _moveNextShortcut;
protected Shortcut _splitVerticalShortcut;
protected Shortcut _splitHorizontalShortcut;
protected Shortcut _nextTabShortcut;
protected CompactFlags _compactOptions;
protected DisplayTabModes _displayTabMode;
protected TabGroupLeaf _prominentLeaf;
protected TabGroupLeaf _activeLeaf;
protected TabGroupSequence _root;
protected VisualStyle _style;
// Delegates for events
public delegate void TabControlCreatedHandler(TabbedGroups tg, Controls.TabControl tc);
public delegate void PageCloseRequestHandler(TabbedGroups tg, TGCloseRequestEventArgs e);
public delegate void PageContextMenuHandler(TabbedGroups tg, TGContextMenuEventArgs e);
public delegate void GlobalSavingHandler(TabbedGroups tg, XmlTextWriter xmlOut);
public delegate void GlobalLoadingHandler(TabbedGroups tg, XmlTextReader xmlIn);
public delegate void PageSavingHandler(TabbedGroups tg, TGPageSavingEventArgs e);
public delegate void PageLoadingHandler(TabbedGroups tg, TGPageLoadingEventArgs e);
public delegate void ExternalDropHandler(TabbedGroups tg, TabGroupLeaf tgl, Controls.TabControl tc, DragProvider dp);
// Instance events
public event TabControlCreatedHandler TabControlCreated;
public event PageCloseRequestHandler PageCloseRequest;
public event PageContextMenuHandler PageContextMenu;
public event GlobalSavingHandler GlobalSaving;
public event GlobalLoadingHandler GlobalLoading;
public event PageSavingHandler PageSaving;
public event PageLoadingHandler PageLoading;
public event EventHandler ProminentLeafChanged;
public event EventHandler ActiveLeafChanged;
public event EventHandler DirtyChanged;
public event ExternalDropHandler ExternalDrop;
public TabbedGroups()
{
InternalConstruct(VisualStyle.IDE);
}
public TabbedGroups(VisualStyle style)
{
InternalConstruct(style);
}
protected void InternalConstruct(VisualStyle style)
{
// Prevent flicker with double buffering and all painting inside WM_PAINT
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
// We want to act as a drop target
this.AllowDrop = true;
// Remember parameters
_style = style;
// Define initial state
_numLeafs = 0;
_compacting = false;
_initializing = false;
// Create the root sequence that always exists
_root = new TabGroupSequence(this);
// Define default settings
ResetProminentLeaf();
ResetResizeBarVector();
ResetResizeBarColor();
ResetResizeBarLock();
ResetCompactOptions();
ResetDefaultGroupMinimumWidth();
ResetDefaultGroupMinimumHeight();
ResetActiveLeaf();
ResetAutoCompact();
ResetAtLeastOneLeaf();
ResetCloseMenuText();
ResetProminentMenuText();
ResetRebalanceMenuText();
ResetMovePreviousMenuText();
ResetMoveNextMenuText();
ResetNewVerticalMenuText();
ResetNewHorizontalMenuText();
ResetCloseShortcut();
ResetProminentShortcut();
ResetRebalanceShortcut();
ResetMovePreviousShortcut();
ResetMoveNextShortcut();
ResetSplitVerticalShortcut();
ResetSplitHorizontalShortcut();
ResetImageList();
ResetDisplayTabMode();
ResetSaveControls();
ResetAutoCalculateDirty();
ResetDirty();
// Add ourself to the application filtering list
// (to snoop for shortcut combinations)
Application.AddMessageFilter(this);
}
[Category("TabbedGroups")]
[DefaultValue(typeof(VisualStyle), "IDE")]
public VisualStyle Style
{
get { return _style; }
set
{
if (_style != value)
{
_style = value;
// Propogate to all children
Notify(TabGroupBase.NotifyCode.StyleChanged);
}
}
}
public void ResetStyle()
{
Style = VisualStyle.IDE;
}
[Browsable(false)]
public TabGroupSequence RootSequence
{
get { return _root; }
}
[Category("TabbedGroups")]
[DefaultValue(-1)]
public int ResizeBarVector
{
get { return _resizeBarVector; }
set
{
if (_resizeBarVector != value)
{
_resizeBarVector = value;
// Propogate to all children
Notify(TabGroupBase.NotifyCode.ResizeBarVectorChanged);
}
}
}
public void ResetResizeBarVector()
{
ResizeBarVector = -1;
}
[Category("TabbedGroups")]
public Color ResizeBarColor
{
get { return _resizeBarColor; }
set
{
if (!_resizeBarColor.Equals(value))
{
_resizeBarColor = value;
// Propogate to all children
Notify(TabGroupBase.NotifyCode.ResizeBarColorChanged);
}
}
}
protected bool ShouldSerializeResizeBackColor()
{
return _resizeBarColor != base.BackColor;
}
public void ResetResizeBarColor()
{
ResizeBarColor = base.BackColor;
}
[Category("TabbedGroups")]
[DefaultValue(false)]
public bool ResizeBarLock
{
get { return _resizeBarLock; }
set { _resizeBarLock = value; }
}
public void ResetResizeBarLock()
{
ResizeBarLock = false;
}
[Category("TabbedGroups")]
public TabGroupLeaf ProminentLeaf
{
get { return _prominentLeaf; }
set
{
if (_prominentLeaf != value)
{
_prominentLeaf = value;
// Mark layout as dirty
if (_autoCalculateDirty)
_dirty = true;
// Propogate to all children
Notify(TabGroupBase.NotifyCode.ProminentChanged);
OnProminentLeafChanged(EventArgs.Empty);
}
}
}
public void ResetProminentLeaf()
{
ProminentLeaf = null;
}
[Category("TabbedGroups")]
[DefaultValue(typeof(CompactFlags), "All")]
public CompactFlags CompactOptions
{
get { return _compactOptions; }
set { _compactOptions = value; }
}
public void ResetCompactOptions()
{
CompactOptions = CompactFlags.All;
}
[Category("TabbedGroups")]
[DefaultValue(4)]
public int DefaultGroupMinimumWidth
{
get { return _defMinWidth; }
set
{
if (_defMinWidth != value)
{
_defMinWidth = value;
// Propogate to all children
Notify(TabGroupBase.NotifyCode.MinimumSizeChanged);
}
}
}
public void ResetDefaultGroupMinimumWidth()
{
DefaultGroupMinimumWidth = 4;
}
[Category("TabbedGroups")]
[DefaultValue(4)]
public int DefaultGroupMinimumHeight
{
get { return _defMinHeight; }
set
{
if (_defMinHeight != value)
{
_defMinHeight = value;
// Propogate to all children
Notify(TabGroupBase.NotifyCode.MinimumSizeChanged);
}
}
}
public void ResetDefaultGroupMinimumHeight()
{
DefaultGroupMinimumHeight = 4;
}
[Localizable(true)]
[Category("Text String")]
[DefaultValue("&Close")]
public string CloseMenuText
{
get { return _closeMenuText; }
set { _closeMenuText = value; }
}
public void ResetCloseMenuText()
{
CloseMenuText = "&Close";
}
[Localizable(true)]
[Category("Text String")]
[DefaultValue("Pro&minent")]
public string ProminentMenuText
{
get { return _prominentMenuText; }
set { _prominentMenuText = value; }
}
public void ResetProminentMenuText()
{
ProminentMenuText = "Pro&minent";
}
[Localizable(true)]
[Category("Text String")]
[DefaultValue("&Rebalance")]
public string RebalanceMenuText
{
get { return _rebalanceMenuText; }
set { _rebalanceMenuText = value; }
}
public void ResetRebalanceMenuText()
{
RebalanceMenuText = "&Rebalance";
}
[Localizable(true)]
[Category("Text String")]
[DefaultValue("Move to &Previous Tab Group")]
public string MovePreviousMenuText
{
get { return _movePreviousMenuText; }
set { _movePreviousMenuText = value; }
}
public void ResetMovePreviousMenuText()
{
MovePreviousMenuText = "Move to &Previous Tab Group";
}
[Localizable(true)]
[Category("Text String")]
[DefaultValue("Move to &Next Tab Group")]
public string MoveNextMenuText
{
get { return _moveNextMenuText; }
set { _moveNextMenuText = value; }
}
public void ResetMoveNextMenuText()
{
MoveNextMenuText = "Move to &Next Tab Group";
}
[Localizable(true)]
[Category("Text String")]
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -