Hi,
First, make sure GoView.CanInsertObjects() is true for the destination GoView. (Check that no one turns off the AllowInsert property.)
Second, check that there isn't any Control.DragOver (or DragEnter) event handler that is setting the DragEventArgs.Effect to disallow a drop.I checked the 3 aspects
this.Label.AddObserver(this);
this.Label.Alignment = GoText.TopCenter;
this.Label.StringTrimming = StringTrimming.EllipsisCharacter;
this.Label.AutoResizes = false;
this.Label.Clipping = true;
this.Label.Multiline = false;
this.Label.Wrapping = false;
this.Label.Width = 150;
this.Label.Editable = false;
this.Label.Copyable = true;
if ( ! userObject.IsInstantiated )
{
layoutAuthoringSubgraph();
}
this.Copyable = true;
setAppearance();
this.LayoutPort();
}
#endregion
#region Properties
public string InstanceName
{
get
{
return instanceName;
}
set
{
instanceName = value;
unsavedInstanceName = "" + value;
}
}
public string UnsavedInstanceName
{
get
{
return unsavedInstanceName;
}
}
#endregion
#region Methods
public void setAppearance()
{
if ( ((Component)this.UserObject).IsInstantiated )
{
this.BorderPen.DashStyle = DashStyle.Solid;
}
else
{
this.BorderPen.DashStyle = DashStyle.Custom;
this.BorderPen.DashPattern = customDashPattern;
}
if ( ((Component)this.UserObject).IsSaved )
{
this.Label.Text = this.instanceName;
}
else
{
this.Label.Text = this.unsavedInstanceName;
}
this.atomNode.setAppearance( Color.Empty, this.BorderPen.DashStyle );
}
private void layoutAuthoringSubgraph()
{
this.fillRectangle = new GoRectangle();
this.fillRectangle.Size =
new SizeF( preferredSize.Width - (marginSize.Width2),
preferredSize.Height - this.Label.Height - (marginSize.Height2) );
this.fillRectangle.Selectable = false;
this.fillRectangle.Visible = false;
// These location offsets are a function of the label size…
PointF loc = new PointF(Location.X-40, Location.Y+80);
this.fillRectangle.Location = loc;
this.fillRectangle.Copyable = true;
this.addMargin();
this.Add(this.fillRectangle);
}
public void addMargin()
{
this.TopLeftMargin = this.marginSize;
this.BottomRightMargin = this.marginSize;
}
public override void Collapse()
{
base.Collapse ();
this.Handle.Position = new System.Drawing.PointF(this.Position.X+4, this.Position.Y+4);
PointF loc = new PointF( this.Location.X - 4, this.Location.Y - 4 );
this.Position = loc;
this.Label.Visible = false;
}
public override void Expand()
{
base.Expand ();
this.LayoutPort();
this.Label.Visible = true;
if ( ! ((Component)UserObject).IsInstantiated )
{
this.fillRectangle.Visible = false;
}
}
public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
{
RectangleF newRect = ComputeResize(origRect, newPoint, whichHandle, min, max, true);
if ( evttype == GoInputState.Finish )
{
this.fillRectangle.Width = newRect.Width - marginSize.Width2;
this.fillRectangle.Height = newRect.Height - this.Label.Height - marginSize.Height*2;
PointF location =
new PointF( newRect.Location.X + marginSize.Width,
newRect.Location.Y + this.Label.Height + marginSize.Height );
this.fillRectangle.Location = location;
this.fillRectangle.Visible = false;
}
}
public override bool CanCopy()
{
bool retVal = base.CanCopy ();
return retVal;
}
public override GoObject CopyObject(GoCopyDictionary env)
{
return base.CopyObject (env);
}
///
/// this method is overloaded when components are created during authoring. It is important
/// to register the parent child relationships of the component objects during this action.
/// this override performs just that.
///
///
///
///
public override IGoCollection AddCollection(IGoCollection coll, bool reparentLinks)
{
Component thisComponent = (Component)this.UserObject;
Component childComponent = null;
foreach (GoObject childComponentView in coll)
{
if(childComponentView is HmsSubGraph)
{
childComponent = (Component)((HmsSubGraph)childComponentView).UserObject;
}
if(childComponentView is AtomNode)
{
childComponent = (Component)((AtomNode)childComponentView).UserObject;
}
thisComponent.addChild(childComponent);
}
return base.AddCollection (coll, reparentLinks);
}
public override bool OnContextClick( GoInputEventArgs evt, GoView view )
{
/** If a menu exists for a clicked component, display it.
/
GoContextMenu menu = ((Component)this.UserObject).getMenu( view );
if ( menu != null )
{
menu.Show( view, view.PointToClient(Control.MousePosition ));
}
return true;
}
protected override void OnObservedChanged(GoObject observed, int subhint, int oldI, object oldVal, RectangleF oldRect, int newI, object newVal, RectangleF newRect)
{
base.OnObservedChanged (observed, subhint, oldI, oldVal, oldRect, newI, newVal, newRect);
switch ( subhint )
{
case GoText.ChangedText:
atomNode.InstanceNameText.Text = newVal.ToString();
break;
}
}
#endregion
#region Events
#endregion
}
}
this.view.FinishTransaction(component.InstanceName);
Console.Out.WriteLine(“component added”);
return true;
}
I’m sorry, but I can’t read what you posted.
So it sounds like your code that constructs a subgraph from a collection of objects isn’t doing the right things.
Ah, that’s not what I meant. You’re just filling in an array of references to GoObjects.
Hmmm. That wasn’t the result I expected – I was anticipating that during the copying of the document there would be an exception that you could track down.
Ok. that makes sense. When I set the user object to null it seems to work.
Regarding serialization, you can test it using the code I suggest in http://www.nwoods.com/forum/forum_posts.asp?TID=880.