📄 windowcontenttabbed.cs
字号:
{
WindowDetailCaption wdc = wd as WindowDetailCaption;
if (wdc != null)
{
hotArea = wdc.RectangleToScreen(wdc.ClientRectangle);
hotArea.Inflate(_hotAreaInflate, _hotAreaInflate);
break;
}
}
if (nullZone)
collection.Add(new HotZoneNull(hotArea));
else
collection.Add(new HotZoneTabbed(hotArea, newSize, this, itself));
}
protected void OnDoubleClickTab(Magic.Controls.TabControl tc, Magic.Controls.TabPage page)
{
Content c = (Content)page.Tag;
// Make Content record its current position and remember it for the future
c.RecordRestore();
// Invert docked status
c.Docked = (c.Docked == false);
// Remove from current WindowContent and restore its position
_manager.HideContent(c, false, true);
_manager.ShowContent(c);
}
protected void OnPageDragStart(object sender, MouseEventArgs e)
{
if (this.RedockAllowed)
{
// There must be a selected page for this event to occur
Magic.Controls.TabPage page = _tabControl.SelectedTab;
// Event page must specify its Content object
Content c = page.Tag as Content;
// Remember the position of the tab before it is removed
_dragPageIndex = _tabControl.TabPages.IndexOf(page);
// Remove page from TabControl
_tabControl.TabPages.Remove(page);
// Force the entire window to redraw to ensure the Redocker does not start drawing
// the XOR indicator before the window repaints itself. Otherwise the repainted
// control will interfere with the XOR indicator.
this.Refresh();
// Start redocking activity for the single Content of this WindowContent
_redocker = new RedockerContent(_tabControl, c, this, new Point(e.X, e.Y));
}
}
protected void OnPageDragMove(object sender, MouseEventArgs e)
{
// Redocker object needs mouse movements
if (_redocker != null)
_redocker.OnMouseMove(e);
}
protected void OnPageDragEnd(object sender, MouseEventArgs e)
{
// Are we currently in a redocking state?
if (_redocker != null)
{
// Let the redocker finish off
bool moved = _redocker.OnMouseUp(e);
// If the tab was not positioned somewhere else
if (!moved)
{
// Put back the page that was removed when dragging started
RestoreDraggingPage();
}
// No longer need the object
_redocker = null;
}
}
protected void OnPageDragQuit(object sender, MouseEventArgs e)
{
// Are we currently in a redocking state?
if (_redocker != null)
{
// Put back the page that was removed when dragging started
RestoreDraggingPage();
// No longer need the object
_redocker = null;
}
}
protected override void OnContentChanged(Content obj, Content.Property prop)
{
// Find the matching TabPage entry
foreach(Magic.Controls.TabPage page in _tabControl.TabPages)
{
// Does this page manage our Content?
if (page.Tag == obj)
{
// Property specific processing
switch(prop)
{
case Content.Property.Control:
page.Control = obj.Control;
break;
case Content.Property.Title:
page.Title = obj.Title;
break;
case Content.Property.FullTitle:
// Title changed for the current page?
if (_tabControl.SelectedTab == page)
{
// Update displayed caption text
NotifyFullTitleText(obj.FullTitle);
}
break;
case Content.Property.ImageList:
page.ImageList = obj.ImageList;
break;
case Content.Property.ImageIndex:
page.ImageIndex = obj.ImageIndex;
break;
case Content.Property.CaptionBar:
// Property changed for the current page?
if (_tabControl.SelectedTab == page)
{
Content target = page.Tag as Content;
// TODO
NotifyShowCaptionBar(target.CaptionBar);
}
break;
case Content.Property.CloseButton:
// Property changed for the current page?
if (_tabControl.SelectedTab == page)
{
Content target = page.Tag as Content;
NotifyCloseButton(target.CloseButton);
}
break;
case Content.Property.HideButton:
// Property changed for the current page?
if (_tabControl.SelectedTab == page)
{
Content target = page.Tag as Content;
NotifyHideButton(target.HideButton);
}
break;
}
break;
}
}
}
protected override void OnResize(EventArgs e)
{
// Inform each Content of its actual displayed size
foreach(Content c in _contents)
{
switch(_state)
{
case State.DockLeft:
case State.DockRight:
if (this.Dock != DockStyle.Fill)
{
// Only update the remembered width
c.DisplaySize = new Size(this.ClientSize.Width, c.DisplaySize.Height);
}
break;
case State.DockTop:
case State.DockBottom:
if (this.Dock != DockStyle.Fill)
{
// Only update the remembered height
c.DisplaySize = new Size(c.DisplaySize.Width, this.ClientSize.Height);
}
break;
case State.Floating:
{
Form f = this.FindForm();
// Update width and height
if (f == null)
c.DisplaySize = this.ClientSize;
else
c.DisplaySize = f.Size;
}
break;
}
}
base.OnResize(e);
}
public override Restore RecordRestore(object child)
{
// Child of a WindowContent must be a Content object
Content c = child as Content;
StringCollection next = new StringCollection();
StringCollection previous = new StringCollection();
bool before = true;
// Fill collections with list of Content before and after parameter
foreach(Content content in _contents)
{
if (content == c)
before = false;
else
{
if (before)
previous.Add(content.Title);
else
next.Add(content.Title);
}
}
bool selected = false;
// Is there a selected tab?
if (_tabControl.SelectedIndex != -1)
{
// Get access to the selected Content
Content selectedContent = _tabControl.SelectedTab.Tag as Content;
// Need to record if it is selected
selected = (selectedContent == c);
}
// Create a Restore object to handle this WindowContent
Restore thisRestore = new RestoreWindowContent(null, c, next, previous, selected);
// Do we have a Zone as our parent?
if (_parentZone != null)
{
// Get the Zone to prepend its own Restore knowledge
thisRestore = _parentZone.RecordRestore(this, child, thisRestore);
}
return thisRestore;
}
public bool PreFilterMessage(ref Message m)
{
// Has a key been pressed?
if (m.Msg == (int)Win32.Msgs.WM_KEYDOWN)
{
// Is it the ESCAPE key?
if ((int)m.WParam == (int)Win32.VirtualKeys.VK_ESCAPE)
{
// Are we in redocking mode?
if (_redocker != null)
{
// Cancel the redocking activity
_redocker.QuitTrackingMode(null);
// Put back the page that was removed when dragging started
RestoreDraggingPage();
// No longer need the object
_redocker = null;
return true;
}
}
}
return false;
}
protected void RestoreDraggingPage()
{
// Create TabPage to represent the Content
Magic.Controls.TabPage newPage = new Magic.Controls.TabPage();
Content content = _redocker.Content;
// Reflect the Content properties int the TabPage
newPage.Title = content.Title;
newPage.ImageList = content.ImageList;
newPage.ImageIndex = content.ImageIndex;
newPage.Control = content.Control;
newPage.Tag = content;
newPage.Selected = true;
// Put it back where it came from
_tabControl.TabPages.Insert(_dragPageIndex, newPage);
// Update the title displayed
NotifyFullTitleText(content.FullTitle);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -