Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic copy mindfusion canves and its nodes and populate node properties to another WPF window (Read 2053 times)
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
copy mindfusion canves and its nodes and populate node properties to another WPF window
Apr 26th, 2017 at 6:34pm
Print Post  
In main window I have mindfusion canvas, so it contains few Nodes(shape) each of this Node properties different to each other,

Ex: I have 4 Rectangles each of these, colors are different.

Main Window




Question 1:

How to redraw(populate) same design on another window once I click button on Main Window

Question 2:

how to populate each of above node's properties in separate section, on second window like following picture




  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: copy mindfusion canves and its nodes and populate node properties to another WPF window
Reply #1 - Apr 27th, 2017 at 9:32am
Print Post  
1. Clone the nodes and add them to second diagram -

Code
Select All
foreach (var node in diagram.Nodes)
	diagram2.Nodes.Add(node.Clone(false)); 



2. You could set diagram.Nodes as ItemsSource of a listview / listbox kind of control -

Code
Select All
listNodes.ItemsSource = diagram.Nodes;

<ListBox Name="listNodes" >
	<ListBox.ItemTemplate>
		<DataTemplate>
			<StackPanel Orientation="Vertical">
				<TextBlock Text="{Binding Text}" />
				<TextBlock Text="{Binding Brush}" />
			</StackPanel>
		</DataTemplate>
	</ListBox.ItemTemplate>
</ListBox> 

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


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: copy mindfusion canves and its nodes and populate node properties to another WPF window
Reply #2 - Apr 27th, 2017 at 10:35am
Print Post  
Sorry I unable to mentioned it, Actually I want to clone main window to second window

with all nodes X, Y coordinates and parent diagram canvas all properties (width, height, )

so I tried following

// this is button click on Main window
 

      private void Button_Click(object sender, EventArgs e)
{

var popupDialog = new childWindowPopUp(this);
popupDialog.ShowDialog();
}


// bind diagram to 2nd diagram
// child window code behind file

public partial class childWindowPopUp : Window
{
private readonly MainMindfusionDiragram _mw;
           
public childWindowPopUp()
{
InitializeComponent();

}

public childWindowPopUp(MainMindfusionDiragram mw)
{
InitializeComponent();
_mw = mw;
diagram2.LoadFromString(_mw.diagram1.ToString());
}
}

but this is not bind the digram1 with digram2

getting this error with above

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

« Last Edit: Apr 27th, 2017 at 11:45am by kelum »  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: copy mindfusion canves and its nodes and populate node properties to another WPF window
Reply #3 - Apr 27th, 2017 at 12:24pm
Print Post  
You've meant to call _mw.diagram1.SaveToString() instead of ToString().
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint