?? dockingmanager.cs
字號:
_insideFill = (bool)Convert.ToBoolean(insideFill);
_innerMinimum = ConversionHelper.StringToSize(innerSize);
ContentCollection cc = new ContentCollection();
do
{
// Read the next Element
if (!xmlIn.Read())
throw new ArgumentException("An element was expected but could not be read in");
// Have we reached the end of root element?
if ((xmlIn.NodeType == XmlNodeType.EndElement) && (xmlIn.Name == "DockingConfig"))
break;
// Is the element name 'Content'
if (xmlIn.Name == "Content")
{
// Process this Content element
cc.Insert(0, new Content(xmlIn, formatVersion));
}
else
{
// Must have reached end of our code, let the custom handler deal with this
OnLoadCustomConfig(xmlIn);
// Ignore anything else that might be in the XML
xmlIn.Close();
// Exit
break;
}
} while(!xmlIn.EOF);
xmlIn.Close();
// Reduce flicker during window operations
_container.SuspendLayout();
// Hide all the current content items
HideAllContents();
// Attempt to apply loaded settings
foreach(Content loaded in cc)
{
Content c = _contents[loaded.Title];
// Do we have any loaded information for this item?
if (c != null)
{
// Copy across the loaded values of interest
c.Docked = loaded.Docked;
c.AutoHidden = loaded.AutoHidden;
c.CaptionBar = loaded.CaptionBar;
c.CloseButton = loaded.CloseButton;
c.DisplaySize = loaded.DisplaySize;
c.DisplayLocation = loaded.DisplayLocation;
c.AutoHideSize = loaded.AutoHideSize;
c.FloatingSize = loaded.FloatingSize;
c.DefaultRestore = loaded.DefaultRestore;
c.AutoHideRestore = loaded.AutoHideRestore;
c.DockingRestore = loaded.DockingRestore;
c.FloatingRestore = loaded.FloatingRestore;
// Allow the Restore objects a chance to rehook into object instances
c.ReconnectRestore();
// Was the loaded item visible?
if (loaded.Visible)
{
// Make it visible now
ShowContent(c);
}
}
}
// Reapply any fill style required
AddInnerFillStyle();
// Reduce flicker during window operations
_container.ResumeLayout();
// If any AutoHostPanel's have become visible we need to force a repaint otherwise
// the area not occupied by the TabStub instances will be painted the correct color
_ahpLeft.Invalidate();
_ahpRight.Invalidate();
_ahpTop.Invalidate();
_ahpBottom.Invalidate();
}
public void PropogateNameValue(PropogateName name, object value)
{
foreach(Control c in _container.Controls)
{
Zone z = c as Zone;
// Only interested in our Zones
if (z != null)
z.PropogateNameValue(name, value);
}
// If the docking manager is created for a Container that does not
// yet have a parent control then we need to double check before
// trying to enumerate the owned forms.
if (_container.FindForm() != null)
{
foreach(Form f in _container.FindForm().OwnedForms)
{
FloatingForm ff = f as FloatingForm;
// Only interested in our FloatingForms
if (ff != null)
ff.PropogateNameValue(name, value);
}
}
// Propogate into the AutoHidePanel objects
_ahpTop.PropogateNameValue(name, value);
_ahpLeft.PropogateNameValue(name, value);
_ahpRight.PropogateNameValue(name, value);
_ahpBottom.PropogateNameValue(name, value);
}
public virtual bool OnContentHiding(Content c)
{
CancelEventArgs cea = new CancelEventArgs();
if (_surpressVisibleEvents == 0)
{
// Allow user to prevent hide operation
if (ContentHiding != null)
ContentHiding(c, cea);
}
// Was action cancelled?
return cea.Cancel;
}
public virtual void OnContentHidden(Content c)
{
if (_surpressVisibleEvents == 0)
{
// Notify operation has completed
if (ContentHidden != null)
ContentHidden(c, EventArgs.Empty);
}
}
public virtual void OnContentShown(Content c)
{
if (_surpressVisibleEvents == 0)
{
// Notify operation has completed
if (ContentShown != null)
ContentShown(c, EventArgs.Empty);
}
}
public virtual void OnTabControlCreated(Magic.Controls.TabControl tabControl)
{
// Notify interested parties about creation of a new TabControl instance
if (TabControlCreated != null)
TabControlCreated(tabControl);
}
public virtual void OnSaveCustomConfig(XmlTextWriter xmlOut)
{
// Notify interested parties that they can add their own custom data
if (SaveCustomConfig != null)
SaveCustomConfig(xmlOut);
}
public virtual void OnLoadCustomConfig(XmlTextReader xmlIn)
{
// Notify interested parties that they can add their own custom data
if (LoadCustomConfig != null)
LoadCustomConfig(xmlIn);
}
protected virtual void OnContentsClearing()
{
_container.SuspendLayout();
// Remove each Content from any WindowContent it is inside
foreach(Content c in _contents)
{
// Is the Content inside a WindowContent?
if (c.ParentWindowContent != null)
c.ParentWindowContent.Contents.Remove(c);
}
_container.ResumeLayout();
}
protected virtual void OnContentRemoved(int index, object value)
{
_container.SuspendLayout();
Content c = value as Content;
if (c != null)
{
// Is the Content inside a WindowContent?
if (c.ParentWindowContent != null)
c.ParentWindowContent.Contents.Remove(c);
}
_container.ResumeLayout();
}
protected virtual void OnContentClose(object sender, EventArgs e)
{
WindowDetailCaption wdc = sender as WindowDetailCaption;
// Was Close generated by a Caption detail?
if (wdc != null)
{
WindowContentTabbed wct = wdc.ParentWindow as WindowContentTabbed;
// Is the Caption part of a WindowContentTabbed object?
if (wct != null)
{
// Find the Content object that is the target
Content c = wct.CurrentContent;
if (c != null)
{
// Was action cancelled?
if (!OnContentHiding(c))
wct.HideCurrentContent();
}
}
}
}
protected virtual void OnInvertAutoHide(object sender, EventArgs e)
{
// Do not generate hiding/hidden/shown events
_surpressVisibleEvents++;
WindowDetail detail = sender as WindowDetail;
// Get access to Content that initiated AutoHide for its Window
WindowContent wc = detail.ParentWindow as WindowContent;
// Create a collection of the Content in the same window
ContentCollection cc = new ContentCollection();
// Add all Content into collection
foreach(Content c in wc.Contents)
cc.Add(c);
// Add to the correct AutoHidePanel
AutoHideContents(cc, wc.State);
// Enable generate hiding/hidden/shown events
_surpressVisibleEvents--;
}
internal AutoHidePanel AutoHidePanelForState(State state)
{
AutoHidePanel ahp = null;
// Grab the correct hosting panel
switch(state)
{
case State.DockLeft:
ahp = _ahpLeft;
break;
case State.DockRight:
ahp = _ahpRight;
break;
case State.DockTop:
ahp = _ahpTop;
break;
case State.DockBottom:
ahp = _ahpBottom;
break;
}
return ahp;
}
internal void AutoHideContents(ContentCollection cc, State state)
{
// Hide all the Content instances. This will cause the restore objects to be
// created and so remember the docking positions for when they are restored
foreach(Content c in cc)
HideContent(c);
AutoHidePanel ahp = AutoHidePanelForState(state);
// Pass management of Contents into the panel
ahp.AddContentsAsGroup(cc);
}
internal AutoHidePanel AutoHidePanelForContent(Content c)
{
if (_ahpLeft.ContainsContent(c))
return _ahpLeft;
if (_ahpRight.ContainsContent(c))
return _ahpRight;
if (_ahpTop.ContainsContent(c))
return _ahpTop;
if (_ahpBottom.ContainsContent(c))
return _ahpBottom;
return null;
}
internal int SurpressVisibleEvents
{
get { return _surpressVisibleEvents; }
set { _surpressVisibleEvents = value; }
}
protected void AddAutoHidePanels()
{
// Create an instance for each container edge (they default to being hidden)
_ahpTop = new AutoHidePanel(this, DockStyle.Top);
_ahpLeft = new AutoHidePanel(this, DockStyle.Left);
_ahpBottom = new AutoHidePanel(this, DockStyle.Bottom);
_ahpRight = new AutoHidePanel(this, DockStyle.Right);
_ahpTop.Name = "Top";
_ahpLeft.Name = "Left";
_ahpBottom.Name = "Bottom";
_ahpRight.Name = "Right";
// Add to the end of the container we manage
_container.Controls.AddRange(new Control[]{_ahpBottom, _ahpTop, _ahpRight, _ahpLeft});
}
protected void RepositionControlBefore(Control target, Control source)
{
// Find indexs of the two controls
int targetPos = _container.Controls.IndexOf(target);
int sourcePos = _container.Controls.IndexOf(source);
// If the source is being moved further up the list then we must decrement the target index
// as the move is carried out in two phases. First the source control is removed from the
// collection and then added at the given requested index. So when insertion point needs
// ahjusting to reflec the fact the control has been removed before being inserted.
if (targetPos >= sourcePos)
targetPos--;
_container.Controls.SetChildIndex(source, targetPos);
}
protected virtual void OnRestore(object sender, EventArgs e)
{
WindowDetailCaption wdc = sender as WindowDetailCaption;
// Was Restore generated by a Caption detail?
if (wdc != null)
{
RemoveAnyFillStyle();
WindowContent wc = wdc.ParentWindow as WindowContent;
// Is the Caption part of a WindowContent object?
if (wc != null)
{
ContentCollection copy = new ContentCollection();
// Make every Content of the WindowContent record its
// current position and remember it for when the future
foreach(Content c in wc.Contents)
{
c.RecordRestore();
// Invert docked status
c.Docked = (c.Docked == false);
copy.Add(c);
}
int copyCount = copy.Count;
// Must have at least one!
if (copyCount >= 1)
{
// Remove from current WindowContent and restore its position
HideContent(copy[0], false, true);
ShowContent(copy[0]);
// Any other content to be moved along with it?
if (copyCount >= 2)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -