Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Custom Saving (Read 5307 times)
Sachin
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 85
Joined: Mar 14th, 2009
Custom Saving
Mar 30th, 2009 at 11:05am
Print Post  
HI
in my application created  custom no de  and saved in string
while calling load string method throwing Value cannot be null error



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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Saving
Reply #1 - Mar 30th, 2009 at 12:52pm
Print Post  
Are your custom nodes controls hosted in ControlNodes, or they are DiagramNode-derived types?
  
Back to top
 
IP Logged
 
Sachin
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 85
Joined: Mar 14th, 2009
Re: Custom Saving
Reply #2 - Mar 31st, 2009 at 5:22am
Print Post  
HI

Yes i am using controlNodes to host my control

then saving ,

How to load the string
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Saving
Reply #3 - Mar 31st, 2009 at 10:18am
Print Post  
The properties of your hosted controls are not saved and loaded automatically, you must handle the Serialize/DeserializeControl events to do that. You might get an exception if you don't handle the events and the custom controls expects some of its values to be != null.

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


I love YaBB 1G - SP1!

Posts: 85
Joined: Mar 14th, 2009
Re: Custom Saving
Reply #4 - Mar 31st, 2009 at 12:54pm
Print Post  
In Serializae and deserialize event what i have to write can u give one example
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Saving
Reply #5 - Mar 31st, 2009 at 3:04pm
Print Post  
Check the SerializeControl help topic.

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


I love YaBB 1G - SP1!

Posts: 85
Joined: Mar 14th, 2009
Re: Custom Saving
Reply #6 - Apr 1st, 2009 at 6:52am
Print Post  
HI

In my serialization event  below code i written
DragDropControl is a custom control  this comtrol converted and  hosting to controlNode
=======
DragAndDropControl control = e.Node.Control as DragAndDropControl ;
           e.Handled = true;
           e.Context.WriteXaml(control, "DragDrop", e.XmlElement);
==========
in save click saving the diagram ,
private void save_Click(object sender, RoutedEventArgs e)
       {
          s =   this.DiagramLight.SaveToString(SaveToStringFormat. Base64);
          this.DiagramLight.ClearAll();
       }


here i am provided another button to retive the diagram so how to deserialize and retrive the diagram
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Saving
Reply #7 - Apr 1st, 2009 at 8:45am
Print Post  
WriteXaml remains from the WPF version of the control, but seems we haven't implemented it because there is no XamlWriter available in Silverlight. You'll have to serialize your properties using the Linq for XML API, or using methods such as e.Context.WriteString to save individual properties.

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


I love YaBB 1G - SP1!

Posts: 85
Joined: Mar 14th, 2009
Re: Custom Saving
Reply #8 - Apr 1st, 2009 at 9:23am
Print Post  
hi

really i am not getting , can u  able to write  the code for serialize and deserialize for this problem,
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Saving
Reply #9 - Apr 1st, 2009 at 2:51pm
Print Post  
Suppose your control looks like this:

Code
Select All
<UserControl x:Class="TestApp.CustomControl"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	Width="50" Height="50">
	<Grid x:Name="LayoutRoot" Background="BurlyWood">
		<ComboBox Name="cmBox" Visibility="Visible"
			HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,0,0,0" Width="50" Height="30">
			<ComboBoxItem IsSelected="True" Content="1"></ComboBoxItem>
			<ComboBoxItem Content="2"></ComboBoxItem>
			<ComboBoxItem Content="3"></ComboBoxItem>
		</ComboBox>
		<TextBox Margin="0,0,0,0" Name="txBx" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
			Height="20" Padding="0" TextWrapping="Wrap">
		</TextBox>
	</Grid>
</UserControl>
 



You could save and load its properties like this:
Code
Select All
private void Diagram_SerializeControl(object sender, MindFusion.Diagramming.Silverlight.ControlNodeEventArgs e)
{
	e.Handled = true;

	e.Context.WriteBrush((e.Node.Control as CustomControl).Background, "Brush", e.XmlElement);
	e.Context.WriteInt((e.Node.Control as CustomControl).SelectedIndex, "SelectedIndex", e.XmlElement);
	e.Context.WriteString((e.Node.Control as CustomControl).Text, "Text", e.XmlElement);
}

private void Diagram_DeserializeControl(object sender, MindFusion.Diagramming.Silverlight.ControlNodeEventArgs e)
{
	e.Handled = true;
	XElement controlElement = e.XmlElement;

	Brush brush = e.Context.ReadBrush("Brush", controlElement);
	int index = e.Context.ReadInt("SelectedIndex", controlElement);
	string text = e.Context.ReadString("Text", controlElement);

	CustomControl control = new CustomControl();
	//control.ParentNode = e.Node;
	control.Text = text;
	control.SelectedIndex = index;
	control.Background = brush;

	e.Node.Control = control;
}
 



If you are using more than one type of custom controls, you could save their type name, say as an attribute of the parent XElement given as an argument to those events.

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


I love YaBB 1G - SP1!

Posts: 85
Joined: Mar 14th, 2009
Re: Custom Saving
Reply #10 - Apr 14th, 2009 at 1:17pm
Print Post  
HI Stoyo

in my application is complex one so many diagrams will come , saving is very difficult what u said last post , also retriving also  need to  implement  this functionality  another one is need to save in database second time it should come from database . very urgent requirement ,

curently we are implemented WIndows application using Go diagram Tool  it is support lot of features,

same thing need to except from diagram light discussion going on to buy diagramlight so please try to implement as most of the functionality , if u have any clarification we will chat directly

thank you

Sachin



  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint