Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic problem while selecting node (Read 5428 times)
ayushneema
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Sep 23rd, 2009
problem while selecting node
Sep 30th, 2009 at 10:04am
Print Post  
Hi
I am using following code to add a node in my diagram:
Code
Select All
private void AddStickyNode(StickyNoteInfo note)
	  {
		ShapeNode mainNode = new ShapeNode(diagram);
		int height = 30;
		int width = 30;


		    var format = new StringFormat();
		    format.Alignment = StringAlignment.Center;
		    format.LineAlignment = StringAlignment.Far;
		    format.FormatFlags = StringFormatFlags.NoWrap;
		    format.Trimming =		     StringTrimming.EllipsisCharacter;

		    mainNode.EnableStyledText = true;
		    mainNode.PolygonalTextLayout = false;
		    mainNode.TextFormat = format;
		    mainNode.ClipToBounds = true;
		    mainNode.DragEnter += new		     DragEventHandler(mainNode_DragEnter);

mainNode.AnchorPattern = null;
		    mainNode.HandlesStyle = HandlesStyle.EasyMove;
		    mainNode.EnabledHandles =		   AdjustmentHandles.Move|AdjustmentHandles.ResizeHandles;

diagram.Nodes.Add(mainNode);
		    NodeInfo nodeInfo = new NodeInfo();
		    mainNode.Shape = stickyNoteShape;
		    height = note.ObjectHeight;
		    width = note.ObjectWidth;

		    if (width == 30)
		    {
			  width += note.XPos;
			  height += note.YPos;
		    }

		    mainNode.Bounds = new Rect(new Point(note.XPos + xOffset, note.YPos + yOffset)
				, new Size(width - note.XPos, height - note.YPos));

	  mainNode.ZIndex = 0;

		    //Fill the NodeInfo object with device related information
		    nodeInfo.AbstractionType = AbstractionType.absStickyNote;
		    nodeInfo.ParentObjectID = note.ParentID;
		    nodeInfo.ObjectID = note.NoteID;
		    nodeInfo.ImageUri = uri;
		    nodeInfo.Shape = mainNode.Shape;
		    nodeInfo.NodeType = NodeType.LooseNode;
		    nodeInfo.IsDirty = false;
		    nodeInfo.Bounds = mainNode.Bounds;
		    nodeInfo.NoteDescription = note.NoteDesc;
		    nodeInfo.LastModified = note.LastModified;
		    nodeInfo.NoteName = note.NoteName;
		    //Attach NodeInfo object to the diagram mode tag
		    mainNode.Tag = nodeInfo;
		    mainNode.ZLevelDown();

		    nodeList.Add(note.NoteID, mainNode);



	  } 



I can resize this node. so i expend this node in such a way that it overlap other nodes of the diagram. I named this node a "sticky note". This sticky note create problem when it contain some other node(by expanding it). I select "stick note" after that when i select another node of the diagram which is inside this "sticky note" then  sticky node should be unselected. but "sticky note" still selected so there are two node selected at the same time.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem while selecting node
Reply #1 - Sep 30th, 2009 at 11:01am
Print Post  
I could not reproduce this. Perhaps you are selecting another node programmatically  in response to some mouse-related event?
  
Back to top
 
IP Logged
 
ayushneema
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Sep 23rd, 2009
Re: problem while selecting node
Reply #2 - Sep 30th, 2009 at 12:00pm
Print Post  
I handle the diagram_NodeClicked event
  
Back to top
 
IP Logged
 
ayushneema
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Sep 23rd, 2009
Re: problem while selecting node
Reply #3 - Sep 30th, 2009 at 12:03pm
Print Post  
i think followomg code might reproduce issue.
i have add initnode() method in that.
Code
Select All
 private void AddStickyNode(StickyNoteInfo note)
	  {
		ShapeNode mainNode = new ShapeNode(diagram);
		int height = 30;
		int width = 30;

		try
		{
		    InitNodes(mainNode);

		    var format = new StringFormat();
		    format.Alignment = StringAlignment.Center;
		    format.LineAlignment = StringAlignment.Far;
		    format.FormatFlags = StringFormatFlags.NoWrap;
		    format.Trimming = StringTrimming.EllipsisCharacter;

		    mainNode.EnableStyledText = true;
		    mainNode.PolygonalTextLayout = false;
		    mainNode.TextFormat = format;
		    mainNode.ClipToBounds = true;
		    mainNode.DragEnter += new DragEventHandler(mainNode_DragEnter);
		    mainNode.AnchorPattern = null;
		    mainNode.HandlesStyle = HandlesStyle.EasyMove;
		    mainNode.EnabledHandles = AdjustmentHandles.Move|AdjustmentHandles.ResizeHandles;
		    diagram.Nodes.Add(mainNode);
		    NodeInfo nodeInfo = new NodeInfo();
		    mainNode.Shape = stickyNoteShape;
		    height = note.ObjectHeight;
		    width = note.ObjectWidth;

		    if (width == 30)
		    {
			  width += note.XPos;
			  height += note.YPos;
		    }

		    mainNode.Bounds = new Rect(new Point(note.XPos + xOffset, note.YPos + yOffset)
				, new Size(width - note.XPos, height - note.YPos));
		    mainNode.Brush = new SolidColorBrush(Color.FromArgb(95, 211, 211, 211));
		    mainNode.Pen = new Pen(new SolidColorBrush(Color.FromRgb(189, 186, 105)), 1);
		    Uri uri = new Uri(MainWin.GetImagesPath() + cStickyNote);
		    mainNode.Image = new BitmapImage(uri);
		    mainNode.ImageAlign = ImageAlign.TopLeft;
		    mainNode.Text = note.NoteName;
		    mainNode.TextBrush = Brushes.Black;
		    mainNode.ZIndex = 0;

		    //Fill the NodeInfo object with device related information
		    nodeInfo.AbstractionType = AbstractionType.absStickyNote;
		    nodeInfo.ParentObjectID = note.ParentID;
		    nodeInfo.ObjectID = note.NoteID;
		    nodeInfo.ImageUri = uri;
		    nodeInfo.Shape = mainNode.Shape;
		    nodeInfo.NodeType = NodeType.LooseNode;
		    nodeInfo.IsDirty = false;
		    nodeInfo.Bounds = mainNode.Bounds;
		    nodeInfo.NoteDescription = note.NoteDesc;
		    nodeInfo.LastModified = note.LastModified;
		    nodeInfo.NoteName = note.NoteName;
		    //Attach NodeInfo object to the diagram mode tag
		    mainNode.Tag = nodeInfo;
		    mainNode.ZLevelDown();
		    nodeList.Add(note.NoteID, mainNode);
		}

		catch (Exception ex)
		{

		}

	  }


private void InitNodes(ShapeNode node)
	  {

		try
		{
		    node.EnabledHandles = AdjustmentHandles.Move;
		    node.HandlesStyle = HandlesStyle.Custom;
		    node.EnableStyledText = false;
		    Font nodeFont = new Font("Calibri", 12);
		    node.Font = nodeFont;
		    node.TextFormat.Alignment = StringAlignment.Center;
		    node.TextFormat.LineAlignment = StringAlignment.Center;
		    node.TextFormat.Trimming = StringTrimming.EllipsisCharacter;
		    AnchorPattern aPattern = new AnchorPattern(new AnchorPoint[]
	  {
	  new AnchorPoint(93,30,false,false,MarkStyle.Circle,new SolidColorBrush(Colors.Brown))
	  });
		    node.AnchorPattern = aPattern;
		    ToolTipService.SetIsEnabled(node, true);
		    node.ToolTip = "";
		    node.MouseMove += new MouseEventHandler(node_MouseMove);
		    EventManager.RegisterClassHandler(typeof(ShapeNode),
		    ToolTipService.ToolTipOpeningEvent, new RoutedEventHandler(ShapeNode_ToolTipOpening));
		}
		catch (Exception ex)
		{

		}
	  } 


  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem while selecting node
Reply #4 - Sep 30th, 2009 at 4:02pm
Print Post  
It doesn't. What code do you have in the node_MouseMove and mainNode_DragEnter handlers? You could add a SelectionChanged event handler, set a breakpoint there, and run through the debugger to see what exactly adds the second node to the selection.

Stoyan
  
Back to top
 
IP Logged
 
ayushneema
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Sep 23rd, 2009
Re: problem while selecting node
Reply #5 - Oct 1st, 2009 at 4:57am
Print Post  
i am doing nothing in mainNode_DragEnter(block is empty) and in node_MouseMove i have following code:
Code
Select All
private void node_MouseMove(object sender, MouseEventArgs e)

  {


ShapeNode source = sender as ShapeNode;


if (source != null)


{



diagram.ShowAnchors = ShowAnchors.Auto;



Rect rect = new Rect(source.Bounds.X + source.Bounds.Width * .90, source.Bounds.Y + source.Bounds.Height * .15, 8, 8);



  Point point = System.Windows.Input.Mouse.GetPosition(diagram.DocumentPlane);



  if (rect.Contains(point))



  {




diagram.OverrideCursor = Cursors.Pen;



  }



  else



  {




diagram.OverrideCursor = null;



  }


    }

   }
 


  
Back to top
 
IP Logged
 
ayushneema
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Sep 23rd, 2009
Re: problem while selecting node
Reply #6 - Oct 5th, 2009 at 5:01am
Print Post  
hi stoyo,
could please suggest me, how to solve the problem.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem while selecting node
Reply #7 - Oct 6th, 2009 at 5:25am
Print Post  
I think I've already done that. Add a SelectionChanged event handler, place a debugger breakpoint there, and check the callstack when you see there are two nodes in the selection. You might add a condition to the breakpoint so that it breaks only when diagram.Selection.Nodes.Count == 2. Then in the call-stack window you should be able to see what exactly adds the second node.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint