?? autohidepanel.cs
字號:
_currentWCT.Width = _slideRect.Width;
_currentWCT.Height = _slideRect.Height;
Size barSize = _currentPanel.ResizeBarSize();
// Set the initial size/location of Panel and hosted WCT
switch(this.Dock)
{
case DockStyle.Left:
_currentPanel.Size = new Size(0, this.Height);
_currentPanel.Location = new Point(this.Right, this.Top);
_currentWCT.Height = this.Height;
break;
case DockStyle.Right:
_currentPanel.Size = new Size(0, this.Height);
_currentPanel.Location = new Point(this.Left, this.Top);
_currentWCT.Height = this.Height;
break;
case DockStyle.Top:
_currentPanel.Size = new Size(this.Width, 0);
_currentPanel.Location = new Point(this.Left, this.Bottom);
_currentWCT.Width = this.Width;
break;
case DockStyle.Bottom:
_currentPanel.Size = new Size(this.Width, 0);
_currentPanel.Location = new Point(this.Left, this.Top);
_currentWCT.Width = this.Width;
break;
}
// Finally we are ready to show it
_currentPanel.Show();
// We want to snoop of changes of focus to and from Panel and its children
MonitorPanel(true);
// We are showing and not hiding with the timer
_slideOut = true;
// Kick off the slide timer
StartSlideTimer();
}
protected void OnPagesLeave(TabStub sender)
{
// Do we have anything to dismiss?
if ((_currentPanel != null) && (_currentWCT != null))
{
// Only dimiss if the panel does not have focus
if (!_currentPanel.ContainsFocus)
StartDismissTimer();
}
}
public void RemoveContent(Content c)
{
TabStub targetTS = null;
Crownwood.Magic.Controls.TabPage targetPage = null;
// Find the TabStub group this content is inside
foreach(TabStub ts in this.Controls)
{
// Test each page of the TabStub control
foreach(Crownwood.Magic.Controls.TabPage page in ts.TabPages)
{
Content pageC = page.Tag as Content;
if (pageC == c)
{
// Remember found target
targetTS = ts;
targetPage = page;
break;
}
}
}
// Found a target?
if ((targetTS != null) && (targetPage != null))
{
// Are we removing the last entry in the WCT?
if (targetTS.TabPages.Count == 1)
{
int count = targetTS.WindowContentTabbed.Contents.Count;
// Remove all contents from the WCT
for(int i=0; i<count; i++)
targetTS.WindowContentTabbed.Contents.RemoveAt(0);
// If any panel/WCT showing
if (targetTS.WindowContentTabbed == _currentWCT)
{
// Remove Panel/WCT from display and stop timers
KillDisplayedWindow();
}
// Remove the WCT from TabStub
ControlHelper.Remove(targetTS.Controls, targetTS.WindowContentTabbed);
// Remove the stub from this panel
ControlHelper.Remove(this.Controls, targetTS);
// Cleanup gracefully
targetTS.Dispose();
}
else
{
// Currently showing some pages?
if (targetTS.WindowContentTabbed == _currentWCT)
{
bool found = false;
// Is it our page?
foreach(Content cWCT in _currentWCT.Contents)
{
if (cWCT == c)
{
// Remove our page from view
found = true;
break;
}
}
// Remove unwanted page
if (found)
{
// Find its position index
int index = _currentWCT.Contents.IndexOf(c);
// Remove just the selected entry from stub
targetTS.TabPages.RemoveAt(index);
// Remove the selected entry from WCT
_currentWCT.Contents.RemoveAt(index);
}
}
// Remove just the selected entry from stub
targetTS.TabPages.Remove(targetPage);
}
// No longer inside an auto hidden panel
c.AutoHidePanel = null;
}
// If no more contents remain then hide
if (this.Controls.Count == 0)
this.Hide();
}
protected void OnPageClose(object sender, EventArgs e)
{
// Find the TabStub instance for the showing WCT
foreach(TabStub ts in this.Controls)
{
// Does this stub match the one showing?
if (ts.WindowContentTabbed == _currentWCT)
{
ContentCollection cc = new ContentCollection();
// Get access to Content instance being hidden
Content current = _currentWCT.Contents[ts.SelectedIndex];
// Check if the hide button is allowed to work
if (!_manager.OnContentHiding(current))
{
// Are we removing the last entry in the WCT?
if (ts.TabPages.Count == 1)
{
// We need to update AutoHide property for all of them
foreach(Content c in _currentWCT.Contents)
cc.Add(c);
// Remove Panel/WCT from display and stop timers
KillDisplayedWindow();
// Remove the WCT from the WCT
ControlHelper.Remove(ts.Controls, ts.WindowContentTabbed);
// Remove the stub from this panel
ControlHelper.Remove(this.Controls, ts);
// Cleanup gracefully
ts.Dispose();
}
else
{
// Which entry in the stub is currently selected?
int index = ts.SelectedIndex;
// Need to update AutoHide property for removed content
cc.Add(_currentWCT.Contents[index]);
// Remove just the selected entry from stub
ts.TabPages.RemoveAt(index);
// Remove the selected entry from WCT
_currentWCT.Contents.RemoveAt(index);
}
// Content instances no longer in AutoHidden state
foreach(Content c in cc)
{
// Remember this AutoHide state for persistence
c.RecordAutoHideRestore();
// No longer in the auto hidden mode
c.AutoHidden = false;
c.AutoHidePanel = null;
}
}
// Generate hidden event now content is not visible
_manager.OnContentHidden(current);
break;
}
}
// If no more contents remain then hide
if (this.Controls.Count == 0)
this.Hide();
}
protected void OnPageAutoHide(object sender, EventArgs e)
{
// Do not generate hiding/hidden/shown events
_manager.SurpressVisibleEvents += 1;
// Find the TabStub instance for the showing WCT
foreach(TabStub ts in this.Controls)
{
// Does this stub match the one showing?
if (ts.WindowContentTabbed == _currentWCT)
{
int count = ts.TabPages.Count;
// Record the auto hide state in reverse order, must record the state
// before 'KillDisplayedWindow' as the process of recording state requires
// the content to be inside a WindowContent instance
for(int i=count-1; i>=0; i--)
{
// Get access to the content the page represents
Content c = ts.TabPages[i].Tag as Content;
// Remember this AutoHide state for persistence
c.RecordAutoHideRestore();
}
// Remove Panel/WCT from display and stop timers
KillDisplayedWindow();
// Remove the stub from this panel
ControlHelper.Remove(this.Controls, ts);
// Now that the Window/Panel have been killed we are ready to
// alter the AutoHidden state of each content and restore state
for(int i=count-1; i>=0; i--)
{
// Get access to the content the page represents
Content c = ts.TabPages[i].Tag as Content;
// No longer in the auto hidden mode
c.AutoHidden = false;
c.AutoHidePanel = null;
// Restore into normal docked state
_manager.ShowContent(c);
}
break;
}
}
// If no more contents remain then hide
if (this.Controls.Count == 0)
this.Hide();
// Enable generation hiding/hidden/shown events
_manager.SurpressVisibleEvents -= 1;
}
protected void OnPageContextMenu(Point screenPos)
{
_manager.OnShowContextMenu(screenPos);
}
protected void OnSlideTick(object sender, EventArgs e)
{
// Is the slide timer supposed to be running?
if (_slideRunning)
{
// Safety check that timer does not expire after our death
if (this.IsDisposed || _currentPanel.IsDisposed || _currentWCT.IsDisposed)
{
StopSlideTimer();
return;
}
// Use the current size/location as the starting point for changes
Rectangle rect = new Rectangle(_currentPanel.Left, _currentPanel.Top,
_currentPanel.Width, _currentPanel.Height);
// How big is the resize bar inside the Panel?
Size barSize = _currentPanel.ResizeBarSize();
// Is this the last sliding step?
// (increase test by 1 because we have not yet incremented it)
bool lastStep = ((_slideStep+1) >= _slideSteps);
// Bringing the Panel into view?
if (_slideOut)
{
// Bring Panel another step into full view
switch(this.Dock)
{
case DockStyle.Left:
if (lastStep)
rect.Width = _slideRect.Width + barSize.Width;
else
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -