Page Index Toggle Pages: 1 ... 3 4 [5]  Send TopicPrint
Very Hot Topic (More than 25 Replies) Starting with a Default Node (Read 39467 times)
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #60 - Aug 30th, 2011 at 11:22am
Print Post  
Hi,

The template usually contains objects of standard WPF classes and you should check their properties in the MSDN library. The Rectangle from the tutorial's template is a System.Windows.Shapes.Rectangle instance, and the Border element from your template corresponds to System.Windows.Controls.Border.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #61 - Aug 30th, 2011 at 2:58pm
Print Post  
Hi Stoyo,

ok, I have to understand some elementary concepts of XAML first...

On the other hand I found out the reason why my TemplatedNode did not work.
The ResourceDictionary was not found. I need to write it in the App.xaml:
Code
Select All
<Application x:Class="MyNamespace.MyApplication"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             Startup="AppStartup"
             xmlns:local="clr-namespace:MyNamespace" >
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="MindFusion\MyTemplatedNode.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
 



In the Tutorial3 the generic.xaml is in the themes directory and will be found per default there which is not the case in my application.

Regards,
Pontius
  
Back to top
 
IP Logged
 
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #62 - Sep 5th, 2011 at 10:30am
Print Post  
Hi Stoyo,

my TemplatedNode now works fine btw.

I have a question with respect to serialization of the Diagram. I have an XML file format.

There are methods like like Diagram.SaveToXML and Diagram.LoadFromXML that provide serialization to a string that may reside in an XML document.

In my application I'm going to have several CtrlDiagramViews each containing a CtrlDiagram (derived from UserControl) with a Diagram member.

It is hard to acces the Views members (the Diagram) when serializing (and it's ugly code too).

Rather than serializing the Diagram that is of type Control and is member of my class CtrlDiagram I would like to serialize a DataContext object related to the Diagram.

From my point of view a separation between the control (Diagram) and the data behind the control (DataContext) would fit perfectly into WPF thinking.

In the MindFusion reference I cant find such a separation. Or is there any?

Or do you recommend a different architecture for handling several Diagram instances than what I described above?

Regards,
Pontius
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #63 - Sep 6th, 2011 at 10:51am
Print Post  
Hi,

If you want to use MVVM architecture, you can keep the Diagram strictly as a private member of the view. Then expose some bindable property from the view class that binds to elements of your model and converts them to diagram objects. E.g. you can use the IList DataItems property from this class as a starting point:
http://mindfusion.eu/Forum/YaBB.pl?board=wpfdg_disc;action=display;num=130641288...

Which reminds me - we hope to make this forum useful for other people too, so please start new topics when you have new questions to keep things easier to find Smiley

Thank you,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #64 - Sep 17th, 2011 at 10:02am
Print Post  
I have traced through the test project - the routing problem happens because RecreateLinks returns the links that were removed from the diagram, instead of the newly created ones. Then when you call Router.RouteLinks after the // Error1 comment, it routes the links that are no longer in the diagram, while Diagram.RouteAllLinks will route the new ones.

I can't understand at all why you need to recreate the links each time a node is moved, but if you absolutely need to do that and want to use router.RouteLinks, make your RecreateLink method return the new link, and change this loop:

Code
Select All
foreach (DiagramLink link in linkLists[id])
{
	RecreateLink(row, link);
	linksStillExisting.Add(link);
} 



to

Code
Select All
foreach (DiagramLink link in linkLists[id])
{
	var newLink = RecreateLink(row, link);
	linksStillExisting.Add(newLink);
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #65 - Sep 17th, 2011 at 11:38am
Print Post  
To enable two way binding, add this to VivaldiNode:

protected override void OnUpdateBounds()
{
     base.OnUpdateBounds();
     SetValue(BoundsProperty, GetBounds());
}

and change this line in NodeData.Bounds setter from

OnPropertyChanged("Description");

to

OnPropertyChanged("Bounds");

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #66 - Sep 19th, 2011 at 9:34am
Print Post  
Hi Stoyo,

thanks for tracking my code.

"I can't understand at all why you need to recreate the links each time a node is moved"

The code I sent to you is a 5% extract of my full code. I just moved the functionality to the diagram_NodeModified(...) method to reduce the complexity of the sample code. So I don't have to write hundert lines of text how to run into the error.
In the full code of course I do not recreate links each time a node is moved. I receate the links after a TableNode has been updated by the user having some new Rows added and some old Rows deleted. Then I 1. save the old links connected to the TableNode, 2. rebuild the TableNode due to the user interaction (i.e. deleting old Rows and creating new Rows) 3. recreate the links for the Rows that are the same as before 4. reroute the links connected to that TableNode.

Your solution is right and it is absolutely my bad. I changed it the way you suggested and it works fine.

On the other hand in the diagram_Loaded(...) code the links are created the first time and they are diagonal without having passed the code above. There is no recreation of obsolete links and the links are diagonal from the very beginning. Do you have any idea why that happens?

More about two way binding later.

Regards,
Pontius
  
Back to top
 
IP Logged
 
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #67 - Sep 19th, 2011 at 11:00am
Print Post  
Hi Stoyo,

thanks again. The code lines

Code
Select All
protected override void OnUpdateBounds()
{
     base.OnUpdateBounds();
     SetValue(BoundsProperty, GetBounds());
}
 


resolve my problem and now I have the two way binding I wanted.

On the other hand I would have expected the line SetValue(BoundsProperty, GetBound()) to be implemented in the base implementation of OnUpdateBounds() already.

Is it a purposeful concept of the Mindfusion Diagramming WPF module to not have implemented it in the base class?
Or is it missing by an oversight so that I can expect it to be implemented in a newer version of Mindfusion Diagramming WPF already?

Regards,
Pontius
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #68 - Sep 20th, 2011 at 6:10am
Print Post  
Hi,

It seems you are getting diagonal links in diagram_Loaded because setting DestinationAnchor moves the last point to a new location, after CreateDiagramLink has routed the link. You can call link.Route() after setting the anchor points to get the cascading shape again.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 ... 3 4 [5] 
Send TopicPrint