Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Overriding DiagramNodeAdapter (Read 2665 times)
kai-uwe.zoland
YaBB Newbies
*
Offline



Posts: 18
Joined: Sep 5th, 2008
Overriding DiagramNodeAdapter
Sep 23rd, 2008 at 8:54am
Print Post  
Hi,

we are overriding DiagramNodeAdapter as MyDiagramNodeAdapter. The derived class just adds two new properties.

When we now catch the "NodeSelected" event, we fail with casting NodeEventArgs e.Node to MyDiagramNodeAdapter.

Code
Select All
      void m_mfDiagram_NodeSelected(object sender, NodeEventArgs e)
        {
            if (e.Node is MyDiagramNodeAdapter)
            {
                MyDiagramNodeAdapter _Node = (e.Node as MyDiagramNodeAdapter);
                _Node.Items.Items.MoveCurrentTo(_Node.Item);
            };
        } 



the node was added like that:

Code
Select All
  MyDiagramNodeAdapter _Node = new MyDiagramNodeAdapter(_DiagramItem as UIElement);

            _Node.Item = _DiagramItem;
            _Node.Items = this;


            _DiagramItem.mfDiagramItem = _Node as MyDiagramNodeAdapter;
            m_mfDiagram.NodeSelected += m_mfDiagram_NodeSelected;

            m_mfDiagram.Nodes.Add(_Node);
 



The class definition is like that:

Code
Select All
    internal class MyDiagramNodeAdapter : MindFusion.Diagramming.Wpf.DiagramNodeAdapter
    {
        public DiagramPanel.DiagramItem Item { get; set; }
        public ItemsControl Items { get; set; }

        public MyDiagramNodeAdapter(UIElement node)
            : base(node)
        {
        }

        protected MyDiagramNodeAdapter(MindFusion.Diagramming.Wpf.DiagramItem prototype)
            : base(prototype)
        {
            this.Item = (prototype as MyDiagramNodeAdapter).Item;
            this.Items = (prototype as MyDiagramNodeAdapter).Items;
        }

    }
 



Thank you for your help.
Best Regards
Kai-Uwe
  
Back to top
WWWYIM  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Overriding DiagramNodeAdapter
Reply #1 - Sep 23rd, 2008 at 10:50am
Print Post  
Hi,

I've changed this to add a Button control and it worked fine. What kind of control is that DiagramPanel.DiagramItem object? If you add a breakpoint to the NodeSelected handler and type e.Node in the Watch window, what's the type displayed for the node object?

Stoyan
  
Back to top
 
IP Logged
 
kai-uwe.zoland
YaBB Newbies
*
Offline



Posts: 18
Joined: Sep 5th, 2008
Re: Overriding DiagramNodeAdapter
Reply #2 - Sep 23rd, 2008 at 11:44am
Print Post  
Hi,

DiagramItem is derived from ContentControl. The content of DiagramItem is set with a xaml template.
And the type of e.Node in the NodeSelected handler is of DiagramNodeAdapter. The cast of e.Node to MyDiagramNodeAdapter returns NULL.

Did you change _DiagramItem to a button?

Thanks
  Kai-Uwe
  
Back to top
WWWYIM  
IP Logged
 
kai-uwe.zoland
YaBB Newbies
*
Offline



Posts: 18
Joined: Sep 5th, 2008
Re: Overriding DiagramNodeAdapter
Reply #3 - Sep 23rd, 2008 at 11:57am
Print Post  
Hi,

thank you for your help. I replaced _DiagramItem with a button and it works fine. Through this I found some other problem in my source, where the _Node was still created as DiagramNodeAdapter and not as MyDiagramNodeAdapter. Now it also works with some ContentControl inside _DiagramItem.  Thanks again for your help.

Regards
  Kai-Uwe
  
Back to top
WWWYIM  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint