/// <summary> /// Constructs a sheet by calling <see cref="M:Northwoods.Go.GoSheet.CreatePaper" />, /// <see cref="M:Northwoods.Go.GoSheet.CreateBackgroundImage" />, and <see cref="M:Northwoods.Go.GoSheet.CreateGrid" />. /// </summary> public GoSheet() { base.Initializing = true; myPaper = CreatePaper(); Add(myPaper); myBackgroundImage = CreateBackgroundImage(); Add(myBackgroundImage); myGrid = CreateGrid(); Add(myGrid); myLeft = MakeBoundary(); Add(myLeft); myRight = MakeBoundary(); Add(myRight); myTop = MakeBoundary(); Add(myTop); myBottom = MakeBoundary(); Add(myBottom); base.Initializing = false; LayoutChildren(null); }
/// <summary> /// Create and initialize a <see cref="T:Northwoods.Go.GoImage" /> or a <see cref="T:Northwoods.Go.GoDrawing" /> to act as the node's icon. /// </summary> /// <param name="res"> /// Provides the <c>ResourceManager</c> holding an <c>Image</c> resource named by /// <paramref name="iconname" />. If this parameter is null, /// <see cref="P:Northwoods.Go.GoImage.DefaultResourceManager" /> is used instead. /// </param> /// <param name="iconname"> /// <para> /// The name of the <c>Image</c> resource in the <c>ResourceManager</c> /// given by <paramref name="res" />, or else a file name if no resource manager /// can be used (i.e., when both <paramref name="res" /> is null and /// <see cref="P:Northwoods.Go.GoImage.DefaultResourceManager" /> is null). /// </para> /// <para> /// If the value is an empty string, the <c>Image</c> will be blank; /// you can set <see cref="P:Northwoods.Go.GoIconicNode.Image" />.<see cref="P:Northwoods.Go.GoImage.Name" /> to show or change /// the image displayed by the <see cref="T:Northwoods.Go.GoImage" /> that is the <see cref="P:Northwoods.Go.GoIconicNode.Image" />. /// </para> /// <para> /// If the value is null, the <see cref="P:Northwoods.Go.GoIconicNode.Icon" /> is not a <see cref="T:Northwoods.Go.GoImage" /> /// but a <see cref="T:Northwoods.Go.GoDrawing" />; you can then set the <see cref="P:Northwoods.Go.GoIconicNode.Figure" /> /// to change the shape shown as the icon. /// </para> /// </param> /// <returns> /// a <see cref="T:Northwoods.Go.GoImage" /> /// </returns> /// <example> /// If you override this method, you may want the definition to do /// some of the things that the standard definition does: /// <code> /// protected virtual GoObject CreateIcon(ResourceManager res, String iconname) { /// if (iconname != null) { /// GoImage img = new GoImage(); /// if (res != null) /// img.ResourceManager = res; /// img.Name = iconname; /// img.Selectable = false; /// img.Resizable = false; /// return img; /// } else { /// GoDrawing rect = new GoDrawing(GoFigure.Rectangle); /// rect.Selectable = false; /// rect.Resizable = false; /// rect.Size = new SizeF(40, 40); /// return rect; /// } /// } /// </code> /// </example> protected virtual GoObject CreateIcon(ResourceManager res, string iconname) { if (iconname != null) { GoImage goImage = new GoImage(); if (res != null) { goImage.ResourceManager = res; } goImage.Name = iconname; goImage.Selectable = false; goImage.Resizable = false; return(goImage); } return(new GoDrawing(GoFigure.Rectangle) { Selectable = false, Resizable = false, Size = new SizeF(40f, 40f) }); }
/// <summary> /// Update the internal reference fields when a child object is removed. /// </summary> /// <param name="obj"></param> public override bool Remove(GoObject obj) { bool result = base.Remove(obj); if (obj == myPaper) { myPaper = null; return(result); } if (obj == myBackgroundImage) { myBackgroundImage = null; return(result); } if (obj == myGrid) { myGrid = null; return(result); } if (obj == myLeft) { myLeft = null; return(result); } if (obj == myRight) { myRight = null; return(result); } if (obj == myTop) { myTop = null; return(result); } if (obj == myBottom) { myBottom = null; } return(result); }