?? windowdetailcaption.cs
字號:
_closeButton.ImageAttributes = _activeAttr;
else
_closeButton.ImageAttributes = _inactiveAttr;
if (_showHideButton && !_ignoreHideButton)
_hideButton.ImageAttributes = _activeAttr;
else
_hideButton.ImageAttributes = _inactiveAttr;
if (_maxButton != null)
{
if (_maxInterface.IsMaximizeAvailable())
_maxButton.ImageAttributes = _activeAttr;
else
_maxButton.ImageAttributes = _inactiveAttr;
bool maximized = _maxInterface.IsWindowMaximized(this.ParentWindow);
if (_maxInterface.Direction == Direction.Vertical)
{
if (maximized)
_maxButton.ImageIndexEnabled = (int)ImageIndex.EnabledVerticalMin;
else
_maxButton.ImageIndexEnabled = (int)ImageIndex.EnabledVerticalMax;
}
else
{
if (maximized)
_maxButton.ImageIndexEnabled = (int)ImageIndex.EnabledHorizontalMin;
else
_maxButton.ImageIndexEnabled = (int)ImageIndex.EnabledHorizontalMax;
}
}
}
protected override void RecalculateButtons()
{
if (_dockLeft)
{
if (this.Dock != DockStyle.Left)
{
RemovedFromParent(this.ParentWindow);
this.Dock = DockStyle.Left;
AddedToParent(this.ParentWindow);
}
int iStart = _inset;
// Button position is fixed, regardless of our size
_closeButton.Location = new Point(_insetButton, iStart);
_closeButton.Anchor = AnchorStyles.Top;
_closeButton.Show();
iStart += _buttonHeight + _insetButton;
// Button position is fixed, regardless of our size
_hideButton.Location = new Point(_insetButton, iStart);
_hideButton.Anchor = AnchorStyles.Top;
_hideButton.Show();
iStart += _buttonHeight + _insetButton;
if (_maxButton != null)
{
// Button position is fixed, regardless of our size
_maxButton.Location = new Point(_insetButton, iStart);
_maxButton.Anchor = AnchorStyles.Top;
}
}
else
{
if (this.Dock != DockStyle.Top)
{
RemovedFromParent(this.ParentWindow);
this.Dock = DockStyle.Top;
AddedToParent(this.ParentWindow);
}
Size client = this.ClientSize;
int iStart = _inset;
// Button is positioned to right hand side of bar
_closeButton.Location = new Point(client.Width - iStart - _buttonWidth, _insetButton);
_closeButton.Anchor = AnchorStyles.Right;
_closeButton.Show();
iStart += _buttonWidth + _insetButton;
// Next the AutoHide button is positioned
_hideButton.Location = new Point(client.Width - iStart - _buttonWidth, _insetButton);
_hideButton.Anchor = AnchorStyles.Right;
_hideButton.Show();
iStart += _buttonWidth + _insetButton;
if (_maxButton != null)
{
// Button position is fixed, regardless of our size
_maxButton.Location = new Point(client.Width - iStart - _buttonWidth, _insetButton);
_maxButton.Anchor = AnchorStyles.Right;
}
}
UpdateMaximizeImage();
}
protected override void OnPaint(PaintEventArgs e)
{
Size ourSize = this.ClientSize;
Point[] light = new Point[4];
Point[] dark = new Point[4];
// Depends on orientation
if (_dockLeft)
{
int iBottom = ourSize.Height - _inset - 1;
int iRight = _offset + 2;
int iTop = _inset + _buttonOffset;
light[3].X = light[2].X = light[0].X = _offset;
light[2].Y = light[1].Y = light[0].Y = iTop;
light[1].X = _offset + 1;
light[3].Y = iBottom;
dark[2].X = dark[1].X = dark[0].X = iRight;
dark[3].Y = dark[2].Y = dark[1].Y = iBottom;
dark[0].Y = iTop;
dark[3].X = iRight - 1;
}
else
{
int iBottom = _offset + 2;
int iRight = ourSize.Width - (_inset + _buttonOffset);
light[3].X = light[2].X = light[0].X = _inset;
light[1].Y = light[2].Y = light[0].Y = _offset;
light[1].X = iRight;
light[3].Y = _offset + 1;
dark[2].X = dark[1].X = dark[0].X = iRight;
dark[3].Y = dark[2].Y = dark[1].Y = iBottom;
dark[0].Y = _offset;
dark[3].X = _inset;
}
using (Pen lightPen = new Pen(ControlPaint.LightLight(_manager.BackColor)),
darkPen = new Pen(ControlPaint.Dark(_manager.BackColor)))
{
e.Graphics.DrawLine(lightPen, light[0], light[1]);
e.Graphics.DrawLine(lightPen, light[2], light[3]);
e.Graphics.DrawLine(darkPen, dark[0], dark[1]);
e.Graphics.DrawLine(darkPen, dark[2], dark[3]);
// Shift coordinates to draw section grab bar
if (_dockLeft)
{
for(int i=0; i<4; i++)
{
light[i].X += 4;
dark[i].X += 4;
}
}
else
{
for(int i=0; i<4; i++)
{
light[i].Y += 4;
dark[i].Y += 4;
}
}
e.Graphics.DrawLine(lightPen, light[0], light[1]);
e.Graphics.DrawLine(lightPen, light[2], light[3]);
e.Graphics.DrawLine(darkPen, dark[0], dark[1]);
e.Graphics.DrawLine(darkPen, dark[2], dark[3]);
}
base.OnPaint(e);
}
}
public class WindowDetailCaptionIDE : WindowDetailCaption
{
protected enum ImageIndex
{
Close = 0,
EnabledVerticalMax = 1,
EnabledVerticalMin = 2,
AutoHide = 3,
AutoShow = 4
}
// Class constants
protected const int _yInset = 3;
protected const int _yInsetExtra = 3;
protected const int _imageWidth = 12;
protected const int _imageHeight = 11;
protected const int _buttonWidth = 14;
protected const int _buttonHeight = 13;
protected const int _buttonSpacer = 3;
// Class fields
protected static int _fixedLength;
static WindowDetailCaptionIDE()
{
// Create a strip of images by loading an embedded bitmap resource
_images = ResourceHelper.LoadBitmapStrip(Type.GetType("Crownwood.Magic.Docking.WindowDetailCaptionIDE"),
"Crownwood.Magic.Resources.ImagesCaptionIDE.bmp",
new Size(_imageWidth, _imageHeight),
new Point(0,0));
}
public WindowDetailCaptionIDE(DockingManager manager,
EventHandler closeHandler,
EventHandler restoreHandler,
EventHandler invertAutoHideHandler,
ContextHandler contextHandler)
: base(manager,
new Size(_fixedLength, _fixedLength),
closeHandler,
restoreHandler,
invertAutoHideHandler,
contextHandler)
{
// Use specificed font in the caption
UpdateCaptionHeight(manager.CaptionFont);
}
public override void PropogateNameValue(PropogateName name, object value)
{
base.PropogateNameValue(name, value);
switch(name)
{
case PropogateName.CaptionFont:
UpdateCaptionHeight((Font)value);
break;
case PropogateName.ActiveTextColor:
case PropogateName.InactiveTextColor:
DefineButtonRemapping();
Invalidate();
break;
}
}
public override void WindowGotFocus()
{
SetButtonState();
Invalidate();
}
public override void WindowLostFocus()
{
SetButtonState();
Invalidate();
}
public override void NotifyFullTitleText(string title)
{
this.Text = title;
Invalidate();
}
public override void ParentStateChanged(State newState)
{
// Ignore the AutoHide feature when in floating form
_ignoreHideButton = (_parentWindow.State == State.Floating);
this.Dock = DockStyle.Top;
RecalculateButtons();
Invalidate();
}
public override void RemovedFromParent(Window parent)
{
if (parent != null)
{
Size minSize = parent.MinimalSize;
// Remove our height from the minimum size of the parent
minSize.Height -= _fixedLength;
minSize.Width -= _fixedLength;
parent.MinimalSize = minSize;
}
}
protected override void DefineButtonRemapping()
{
// Define use of current system colors
ColorMap activeMap = new ColorMap();
ColorMap inactiveMap = new ColorMap();
activeMap.OldColor = Color.Black;
activeMap.NewColor = _manager.ActiveTextColor;
inactiveMap.OldColor = Color.Black;
inactiveMap.NewColor = _manager.InactiveTextColor;
// Create remap attributes for use by button
_activeAttr.SetRemapTable(new ColorMap[]{activeMap}, ColorAdjustType.Bitmap);
_inactiveAttr.SetRemapTable(new ColorMap[]{inactiveMap}, ColorAdjustType.Bitmap);
}
public override void AddedToParent(Window parent)
{
if (parent != null)
{
Size minSize = parent.MinimalSize;
// Remove our height from the minimum size of the parent
minSize.Height += _fixedLength;
minSize.Width += _fixedLength;
parent.MinimalSize = minSize;
}
}
protected override void OnAddMaximizeInterface()
{
if (_maxButton != null)
{
// Set the correct size for the button
_maxButton.Size = new Size(_buttonWidth, _buttonHeight);
// Give the button a very thin button
_maxButton.BorderWidth = 1;
// Define correct color setup
_maxButton.BackColor = this.BackColor;
_maxButton.ImageAttributes = _inactiveAttr;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -