Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Inheritance from DiagramLink (Read 2182 times)
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Inheritance from DiagramLink
Oct 5th, 2010 at 6:20am
Print Post  
Hello, Stoyo!
I need to do the following. I need show the tooltip when mouse is over the diagram link. To do this I plan to inherit the class from DiagramLink and add 2 properties: Desription and HyperLink on the image which will shown when tooltip opens. So I create the class:
Code
Select All
    public class TPDEDiagramLink: DiagramLink
    {
        #region Properties
        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        /// <value>The description.</value>
        public String Description
        {
            get { return m_sDescription; }
            set { m_sDescription = value; }
        }
        /// <summary>
        /// Gets or sets the image hyperlink.
        /// </summary>
        /// <value>The image hyperlink.</value>
        public String ImageHLink
        {
            get { return m_sImgHLink; }
            set { m_sImgHLink = value; }
        }
        /// <summary>
        /// Gets or sets the index of the image.
        /// </summary>
        /// <value>The index of the image.</value>
        public int ImageIndex
        {
            get { return m_nImgIdxInDb; }
            set { m_nImgIdxInDb = value; }
        }
        #endregion //Properties
     }
 


And I need to serialize this properties and save them into database. I need to override functions SaveToXml(), LoadFromXml() and Clone() for make possible to copy this objects and paste them into the diagram. And the question is following: what type of DiagramLink constructor I need use in the Clone() method?
Thanks.
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Inheritance from DiagramLink
Reply #1 - Oct 5th, 2010 at 7:01am
Print Post  
Oh! Sorry, I understood! Is it correct:
Code
Select All
	  /// <summary>
	  /// Clones the specified clipboard.
	  /// </summary>
	  /// <param name="clipboard">if set to <c>true</c> clipboard.</param>
	  /// <returns></returns>
	  public override DiagramItem Clone(bool clipboard)
	  {
		TPDEDiagramLink link = base.Clone(clipboard) as TPDEDiagramLink;
		link.Description = Description;
		link.ImageHLink = ImageHLink;
		link.ImageIndex = ImageIndex;
		return link;
	  }
 

  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Inheritance from DiagramLink
Reply #2 - Oct 5th, 2010 at 11:17am
Print Post  
I set in the constructor of my user control the following:
Code
Select All
void InitLinks()
	  {
		m_Diagram.LinkCascadeOrientation = MindFusion.Diagramming.Wpf.Orientation.Auto;
		m_Diagram.LinkSegments = 15;
		m_Diagram.Behavior = Behavior.Custom;
		m_Diagram.CustomLinkType = typeof(TPDEDiagramLink);
		m_Diagram.CustomBehavior = new LinkBehavior(m_Diagram);
		m_Diagram.LinkHeadShape = ArrowHeads.Triangle;
		m_Diagram.LinkHeadShapeSize = 10;
		m_Diagram.LinkBrush = Brushes.Black;
		m_Diagram.LinkShape = LinkShape.Cascading;
		m_Diagram.LinksSnapToBorders = false;
		m_Diagram.SnapToAnchor = SnapToAnchor.OnCreateOrModify;
	  }
 


But when I draw link in is created as DiagramLink but not as TPDEDiagramLink. What's wrong?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Inheritance from DiagramLink
Reply #3 - Oct 5th, 2010 at 11:22am
Print Post  
Hi,

If you assign an instance of your own behavior class to CustomBehavior, it should override the CreateLink method to return a TPDEDiagramLink.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Inheritance from DiagramLink
Reply #4 - Oct 5th, 2010 at 11:53am
Print Post  
Yes, it helps. Thanks.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint