?? autohidepanel.cs
字號:
// Pass onto any current Panel object
if (_currentPanel != null)
_currentPanel.PropogateNameValue(name, value);
}
public override Color BackColor
{
get { return base.BackColor; }
set
{
if (this.BackColor != value)
{
_defaultColor = (value == SystemColors.Control);
base.BackColor = value;
Invalidate();
}
}
}
protected override void OnSystemColorsChanged(EventArgs e)
{
if (_defaultColor)
Invalidate();
}
protected void CreateTimers()
{
// Define the Sliding timer
_slideTimer = new Timer();
_slideTimer.Interval = _slideInterval;
_slideTimer.Tick += new EventHandler(OnSlideTick);
// Define the Dismiss timer
_dismissTimer = new Timer();
_dismissTimer.Interval = _dismissInterval;
_dismissTimer.Tick += new EventHandler(OnDismissTick);
}
protected void StartDismissTimer()
{
// If dismiss timer not running, then start it off
if (!_dismissRunning)
{
// Start the dismiss timer
_dismissRunning = true;
_dismissTimer.Start();
}
}
protected void StopDismissTimer()
{
// Stop the dismiss timer from reoccuring
_dismissRunning = false;
_dismissTimer.Stop();
}
protected void StartSlideTimer()
{
// If slide timer not running, then start it off
if (!_slideRunning)
{
// Start the dismiss timer
_slideStep = 0;
_slideRunning = true;
_slideTimer.Start();
}
}
protected void StopSlideTimer()
{
// Stop the slide timer from reoccuring
_slideRunning = false;
_slideTimer.Stop();
}
public bool ContainsContent(Content c)
{
return (TabStubForContent(c) != null);
}
protected TabStub TabStubForContent(Content c)
{
// Test each of the TabStub child controls
foreach(TabStub ts in this.Controls)
{
// Test each page inside the TabStub
foreach(Crownwood.Magic.Controls.TabPage page in ts.TabPages)
{
if (c.Title == (page.Tag as Content).Title)
return ts;
}
}
return null;
}
public void BringContentIntoView(Content c)
{
// Test each of the TabStub child controls
foreach(TabStub ts in this.Controls)
{
// Test each page inside the TabStub
foreach(Crownwood.Magic.Controls.TabPage page in ts.TabPages)
{
if (c.Title == (page.Tag as Content).Title)
{
// Remove any existing window
RemoveShowingWindow();
// Use existing method to cause content to be displayed
OnPageClicked(ts, ts.TabPages.IndexOf(page));
return;
}
}
}
}
public Restore RestoreObjectForContent(Content c)
{
StringCollection next = new StringCollection();
StringCollection previous = new StringCollection();
StringCollection nextAll = new StringCollection();
StringCollection previousAll = new StringCollection();
// Which group has the marked content?
TabStub marked = TabStubForContent(c);
// Have we found the marked group yet?
bool foundGroup = false;
// Found the content in the marked group yet?
bool foundContent = false;
int controlCount = this.Controls.Count;
// Process each TabStub in turn
for(int controlIndex=controlCount-1; controlIndex>=0; controlIndex--)
{
TabStub ts = this.Controls[controlIndex] as TabStub;
// Process each Page in the TabStub
foreach(Crownwood.Magic.Controls.TabPage page in ts.TabPages)
{
Content content = page.Tag as Content;
// Is this the marked group
if (marked == ts)
{
// Add into the 'nextAll' rather than 'previousAll' groups from now on
foundGroup = true;
// No need to save ourself in our best friends list!
if (content.Title == c.Title)
{
// Add into the 'next' rather than 'previous' contents now
foundContent = true;
}
else
{
if (!foundContent)
previous.Add(content.Title);
else
next.Add(content.Title);
}
}
else
{
if (!foundGroup)
previousAll.Add(content.Title);
else
nextAll.Add(content.Title);
}
}
}
// Calculate state from docking value
State windowState = State.DockLeft;
// Define stub settings based on our docking position
switch(this.Dock)
{
case DockStyle.Left:
windowState = State.DockLeft;
break;
case DockStyle.Right:
windowState = State.DockRight;
break;
case DockStyle.Top:
windowState = State.DockTop;
break;
case DockStyle.Bottom:
windowState = State.DockBottom;
break;
}
return new RestoreAutoHideAffinity(null, windowState, c, next, previous, nextAll, previousAll);
}
public void AddContent(Content content,
StringCollection next,
StringCollection previous,
StringCollection nextAll,
StringCollection previousAll)
{
int nextIndex = 0;
int previousIndex = 0;
TabStub nextTabStub = null;
TabStub previousTabStub = null;
TabStub nextAllTabStub = null;
TabStub previousAllTabStub = null;
int controlCount = this.Controls.Count;
// Process each TabStub in turn
for(int controlIndex=controlCount-1; controlIndex>=0; controlIndex--)
{
TabStub ts = this.Controls[controlIndex] as TabStub;
// Process each Page in the TabStub
foreach(Crownwood.Magic.Controls.TabPage page in ts.TabPages)
{
Content c = page.Tag as Content;
// Always use the last 'previous' discovered
if (previous.Contains(c.Title))
{
previousIndex = ts.TabPages.IndexOf(page);
previousTabStub = ts;
}
// Only remember the first 'next' discovered
if (next.Contains(c.Title))
{
if (nextTabStub == null)
{
nextIndex = ts.TabPages.IndexOf(page);
nextTabStub = ts;
}
}
// Always use the last 'previousAll' discovered
if (previousAll.Contains(c.Title))
previousAllTabStub = ts;
// Only remember the first 'next' discovered
if (nextAll.Contains(c.Title))
{
if (nextAllTabStub == null)
nextAllTabStub = ts;
}
}
}
// If no matches at all found
if ((previousTabStub == null) && (nextTabStub == null))
{
// Default to inserting at end of list
int insertIndex = Controls.Count;
// If found some friends contents, then insert relative to them
if (previousAllTabStub != null)
insertIndex = Controls.IndexOf(previousAllTabStub);
else
{
if (nextAllTabStub != null)
insertIndex = Controls.IndexOf(nextAllTabStub) + 1;
}
ContentCollection cs = new ContentCollection();
cs.Add(content);
// Add at end of current list of TabStubs
AddContentsAsGroup(cs, insertIndex);
}
else
{
if (previousTabStub != null)
AddContentIntoTabStub(content, previousTabStub, previousIndex + 1);
else
AddContentIntoTabStub(content, nextTabStub, nextIndex);
}
}
public void AddContentIntoTabStub(Content content, TabStub ts, int index)
{
// Is focus leaving the entire WindowContentTabbed control?
if ((_currentWCT != null) && (_currentWCT == ts.WindowContentTabbed))
{
// Remove Panel/WCT from display and stop timers
RemoveDisplayedWindow();
}
// Create a new tab page
Crownwood.Magic.Controls.TabPage page = new Crownwood.Magic.Controls.TabPage();
// Copy across the visual properties
page.Title = content.Title;
page.ImageList = content.ImageList;
page.ImageIndex = content.ImageIndex;
// Remember reference to Content it represents
page.Tag = content;
// Add into the stub
ts.TabPages.Insert(index, page);
// Mark Content as being in AutoHide mode
content.AutoHidePanel = this;
content.AutoHidden = true;
// Add content into the WCT of the TabStub
ts.WindowContentTabbed.Contents.Insert(index, content);
// Make sure this AutoHidePanel is visible
if (!this.Visible)
this.Show();
Invalidate();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -