Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Problem with version 2.3.3 (Read 3236 times)
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Problem with version 2.3.3
Jun 9th, 2010 at 2:26pm
Print Post  
Hi,

We have just installed version 2.3.3.

We were using TextWrapping and TextTrimming when text length is greater than the Node's Width and Node's Height, it was working fine with version 2.3.

In version 2.3.3, MeasureString() method's signature has changed and it takes 3 arguments. we have Implemented ITextAttributes to fill the second argument value but still we are not getting larger text in two lines.

Previous code was:

Code
Select All
while (node.Font.Size > 9 && !isGotFit)
		    {
			  Rect bounds = node.Bounds;
			  double textAreaW = bounds.Width * 58 / 100; // the width of the text area
			  double textAreaH = bounds.Height * 60 / 100; // the height of the text area

			  StringFormat stringFormat = node.TextFormat.Clone() as StringFormat;
			  stringFormat.Trimming = StringTrimming.None;
			  Size size = diagram.MeasureString((node.Text, node.Font, (int)Math.Ceiling(textAreaW), stringFormat);

			  if ((size.Height > textAreaH))
			  {
				node.Font.Size -= 1;
				node.Repaint(false);
			  }
			  else
			  {
				isGotFit = true;
			  }
		    }  



And present code is:

Code
Select All
TextAttribute textAttribute = new TextAttribute();
		    textAttribute.FontFamily = node.FontFamily;
		    textAttribute.FontSize = node.FontSize;
		    textAttribute.FontStretch = node.FontStretch;
		    textAttribute.FontStyle = node.FontStyle;
		    textAttribute.FontWeight = node.FontWeight;
		    textAttribute.TextAlignment = node.TextAlignment;
		    textAttribute.TextDecorations = node.TextDecorations;
		    textAttribute.TextPadding = node.TextPadding;
		    textAttribute.TextTrimming = TextTrimming.None;
		    textAttribute.TextVerticalAlignment = node.TextVerticalAlignment;
		    textAttribute.TextWrapping = node.TextWrapping;

		    while (node.Font.Size > 9 && !isGotFit)
		    {
			  Rect bounds = node.Bounds;
			  double textAreaW = bounds.Width * 58 / 100; // the width of the text area
			  double textAreaH = bounds.Height * 60 / 100; // the height of the text area

			  Size size = diagram.MeasureString(node.Text, textAttribute, (int)Math.Ceiling(textAreaW));

			  if ((size.Height > textAreaH))
			  {
				node.Font.Size -= 1;
				node.Repaint(false);
			  }
			  else
			  {
				isGotFit = true;
			  }
		    } 



Please let us know, what additional changes we need to make it work?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with version 2.3.3
Reply #1 - Jun 9th, 2010 at 2:48pm
Print Post  
Hi,

If you are trying to measure how much text will fit on a single line, try setting the TextWrapping value to NoWrap. Also we have recently added a TextPadding property, whose value you might have to add to the size returned by MeasureString.

There's a TextAttributes class coming with the control that implements that interface, so you don't have to do that. DiagramItem also implement it, and you can pass the node instance to MeasureString, instead of a separate object.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with version 2.3.3
Reply #2 - Jun 9th, 2010 at 2:49pm
Print Post  
Additionally, try changing the "node.Font.Size" references in your code to "node.FontSize".
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Problem with version 2.3.3
Reply #3 - Jun 11th, 2010 at 11:10am
Print Post  
Hello, Stoyan.
Have a problem. I draw the diagram, save it into zipped xml. After that I restore diagram from this file and open an edit dialog to change properties of the node. I never change and press Ok. After that I try to modify node and create the ChangeItemCmd object. And after that program craches:
A first chance exception of type 'System.NullReferenceException' occurred in MindFusion.Diagramming.Wpf.dll
Step into: Stepping over method without symbols 'System.Windows.Threading.ExceptionWrapper.TryCatchWhen'
Step into: Stepping over method without symbols 'System.Windows.Threading.ExceptionWrapper.TryCatchWhen'
An unhandled exception of type 'System.NullReferenceException' occurred in MindFusion.Diagramming.Wpf.dll

Here is a code fragment:
Code
Select All
dlg.WindowStartupLocation = WindowStartupLocation.CenterScreen;
			  if ((bool)dlg.ShowDialog())
			  {
				m_UndoMngrChItemCompositeCmd = new ChangeItemCmd(node, "Изменение входов и выходов");
 


Where is a problem?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with version 2.3.3
Reply #4 - Jun 11th, 2010 at 12:00pm
Print Post  
Hi,

Could you send the diagram xml file to support@mindfusion.eu?

Thanks,
Stoyan
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Problem with version 2.3.3
Reply #5 - Jun 11th, 2010 at 12:09pm
Print Post  
Yes, I could do this. But there is some problem. I use ShapeNode as base class for my derived. And that's why I have in this class my functions SaveToXml and LoadFromXml defined as
Code
Select All
	  /// <summary>
	  /// Saves the item content into an XML element
	  /// </summary>
	  /// <param name="xmlElement">An XmlElement the item's data should be stored into</param>
	  /// <param name="context">An XmlPersistContext object providing contextual information about the serialization process and some helper serialization methods</param>
	  protected override void SaveToXml(XmlElement xmlElement, XmlPersistContext context)
	  {
		base.SaveToXml(xmlElement, context);
		context.WriteInt(OutputNumber, "OutputNumber", xmlElement);
		context.WriteInt(InputNumber, "InputNumber", xmlElement);
		context.WriteUShort((ushort)Type, "ElementType", xmlElement);
		context.WriteBool(m_ShadowProps.ShowShadows, "ShowShadows", xmlElement);
		context.WriteDouble(m_ShadowProps.ShadowDepth, "ShadowDepth", xmlElement);
		context.WriteColor(m_ShadowProps.ShadowColor, "ShadowColor", xmlElement);
		context.WriteBool(m_bShowAnchorIdxs, "ShowAnchorIdxs", xmlElement);
	  }
	  /// <summary>
	  /// Loads the item content from an XML element
	  /// </summary>
	  /// <param name="xmlElement">An XmlElement containing the item's data</param>
	  /// <param name="context">An XmlPersistContext object providing contextual information about the serialization process and some helper serialization methods</param>
	  protected override void LoadFromXml(XmlElement xmlElement, XmlPersistContext context)
	  {
		base.LoadFromXml(xmlElement, context);
		OutputNumber = context.ReadInt("OutputNumber", xmlElement);
		InputNumber = context.ReadInt("InputNumber", xmlElement);
		Type = (NodeType)context.ReadUShort("ElementType", xmlElement);
		m_ShadowProps.ShowShadows = context.ReadBool("ShowShadows", xmlElement);
		m_ShadowProps.ShadowDepth = context.ReadDouble("ShadowDepth", xmlElement);
		m_ShadowProps.ShadowColor = context.ReadColor("ShadowColor", xmlElement);
		m_bShowAnchorIdxs = context.ReadBool("ShowAnchorIdxs", xmlElement);
	  }
 


And I don't sure that you can Load this file. May be it would be easy for you if I send you my application source code whith this file?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with version 2.3.3
Reply #6 - Jun 11th, 2010 at 12:17pm
Print Post  
The Xml should be enough, we'll change the custom nodes to ShapeNodes. Does the custom type override the SaveProperties and RestoreProperties methods?
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Problem with version 2.3.3
Reply #7 - Jun 11th, 2010 at 12:28pm
Print Post  
No
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint