We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Diagram has changed event ?

Thread ID:

Created:

Updated:

Platform:

Replies:

50398 Oct 11,2006 04:09 AM Apr 19,2007 11:03 AM Windows Forms 8
loading
Tags: Diagram
Joerg Spengler
Asked On October 11, 2006 04:09 AM

I''m working on a diagram application where i would like to show the user a warning message to save the diagram before leaving the diagram form.

Is there any event which is fired after changes have made to the diagram content ?

Thanks in advance,

Joerg

J.Nagarajan [Syncfusion]
Replied On October 11, 2006 10:44 AM

Hi Joerge,

If your intention is to show the user a warning message to save the diagram before leaving the diagram form then you can use "DiagramForm_Closing" event. Please refer to our Diagram Builder sample(C:\Program Files\Syncfusion\Essential Studio\4.3.0.30\Windows\Diagram.Windows\Samples\In Depth\DiagramBuilder). In this sample when you close the Diagram Form you can get a warning message box to save the Diagram. Please kindly refer to it and let me know if you have any questions.

Currently our Diagram control supports ChildrenChangeComplete event which is fired after changes have made to the diagram content. Please let me know if this helps for you.If this doesn''''t helps please give us some more details about your requirement.

Thanks for your interest in Essential Diagram.

Regards,
Nagaraj

Joerg Spengler
Replied On October 12, 2006 03:42 AM

Hi Nagarajan,

i have looked into the code of the "DiagramForm_Closing" method in the DiagramBuilder sample, but i do not understand it, specially the usage of the propertyeditor object.

In my application i have a form with 2 textboxes and 1 diagram. The TextChanged events of the 2 textboxes and the ChildrenChangeComplete and some other events of the diagram are handled in a method of the form, where i enable the save baritem and mark the document as changed. In the form closing event i check if the document was changed & saved, otherwise the user will get a warning message box.

Actually this works fine, with the exception that no event is fired, if the size of a node has changed(resizing symbol with mouse or in the property grid).

Best regards,

Joerg

J.Nagarajan [Syncfusion]
Replied On October 12, 2006 04:43 PM

Hi Joerg,

Sorry for the inconvenience caused. Actually our Diagram Builder sample is a MDI application. The usage of the propertyeditor object in the Form_Closing event of DiagramForm.cs is to release the property editor.If your intention is to show the user a warning message to save the diagram before leaving the diagram form then you can use the following code snippet in Form closing event

//In Diagram Form closing event
if (this.diagram1.Model.Modified)
{
DialogResult res = MessageBox.Show(this, "The diagram has been modified. Save changes?", "Save changes", MessageBoxButtons.YesNoCancel);
if (res == DialogResult.Yes)
{
if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
{
this.diagram1.SaveBinary(this.saveFileDialog1.FileName);
MessageBox.Show("The Digram has been stored successfully");
}
else
{
e.Cancel = true;
}
}
else if (res == DialogResult.Cancel)
{
e.Cancel = true;
}
}

I have attached the sample which demonstrate this completely. In this sample when you close the diagram form after made ame changes on diagram a message box will alert you to save teh diagram.

I hope this will meet your requirement. Please let me know if you have any questions.

Regards,
Nagaraj

DiagramClosingIssue.zip

Joerg Spengler
Replied On October 13, 2006 12:20 AM

Thanks a lot for this fast and simple solution.

Best regards,

Joerg

J.Nagarajan [Syncfusion]
Replied On October 25, 2006 12:33 PM

Hi Jeorg,

Thanks for the update. Please feel free to contact us if you have any other concerns.

Thanks for your interest in Essential Diagram.

Regards,
Nagaraj

Lan Mo
Replied On April 18, 2007 02:43 PM

Hi,
V4.4.0.51 & VS2003

I use following code to load diagram from IMAGE field in SQL SERVER. I found the line this.diagram.LoadBinary(ms);
always make this.diagram.Model.Modified=true. That caused always ask user to save the diagram even it has not been modified since it was loaded. In form close event, I prompt user to save diagram when this.diagram.Model.Modified=true
How can I avoid it?

by the way, I found this.diagram1.LoadBinary(this.openFileDialog1.FileName)-- load from a file make this.diagram.Model.Modified to false. That is correct.

Thanks,

Lan




//Notes: Diagram has been saved as binary stream in "IMAGE" field in a SQLServer table.
private void LoadTree()
{
this.diagram.Model.Clear(); //this make this.diagram.Model.Modified=false
// Load diagram from a "IMAGE" field in a SQLServer table.
byte[] MyData=new byte[0];
DataView dvTree=dtTree.DefaultView;
dvTree.RowFilter=string.Format("tree_set={0} and pavetype={1} and funcls={2}",
mTreeSet,mPaveType,mFuncClass);
if (dvTree.Count==1)
{
DataRowView myRow=dvTree[0];
if (myRow["diagram"]!=DBNull.Value)
{
MyData =(byte[])myRow["diagram"];
// memorystream
MemoryStream ms=new MemoryStream(MyData,0,MyData.Length);
this.diagram.LoadBinary(ms); //this make this.diagram.Model.Modified=true
}
}
}

J.Nagarajan [Syncfusion]
Replied On April 18, 2007 07:47 PM

Hi Lan,

You can just resolve this issue by setting false value to Model.Modified property after the LoadBinary() method. Please refer to the following code snippet

if (myRow["diagram"]!=DBNull.Value)
{
MyData =(byte[])myRow["diagram"];
// memorystream
MemoryStream ms=new MemoryStream(MyData,0,MyData.Length);

this.diagram.LoadBinary(ms);
this.diagram.Model.Modified=false;
}

Please test on your side with this code and let me know if you have any poblem.

Thanks,
Nagaraj

Lan Mo
Replied On April 19, 2007 11:03 AM

Hi Nagaraj,
Thanks for help. It works for me.

Actually, I've made simple stupid mistake regarding the property 'diagram.Model.Modified'. When I read its help info "Flag indicating if the model has been monidifed", I thought it is read-only property and never tried to reset it to false.

Thanks again. Have a great day!

Lan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;