Text Justification

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Rigor69
Posts: 18
Joined: 05 Oct 2009, 18:31

Text Justification

Post by Rigor69 » 15 Oct 2009, 21:07

The StringFormat argument of stringformat does not seem to work.
Text justified to center on the screen appears justified Left on DXF.

Is there any way around this?

Best Regards,

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Text Justification

Post by support » 20 Oct 2009, 17:52

Hello.
Please specify the way you set justification of the texts.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Rigor69
Posts: 18
Joined: 05 Oct 2009, 18:31

Re: Text Justification

Post by Rigor69 » 24 Oct 2009, 13:56

OK, This is it:

Code: Select all

String Name = "name";
StringFormat Nameformat = new StringFormat();
Nameformat.Alignment = StringAlignment.Center;
graphicsObj.DrawString(Name, font, Brushes.SandyBrown, Pos.X , Pos.Y,Nameformat);
String comes out left-aligned.

Best regards,

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Text Justification

Post by support » 27 Oct 2009, 17:45

System.Drawing.StringAlignment specifies the alignment of a text sting relative its layout rectangle. Please pay attention to Far (as Near) value can set left or right position depends on layout direction. Try to change different alignments and you will see what text justification is ok.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Rigor69
Posts: 18
Joined: 05 Oct 2009, 18:31

Re: Text Justification

Post by Rigor69 » 29 Oct 2009, 10:02

Sorry, still i cant make it work.
If i use the syntax from above, the text appears justified to center on the form , but appears justified Left on the DXF.
If i use the Drawstring argument with Rectangle, the text within the rectangle appears Left justified withing the rectangle.
Do you support text justification?
Can you provide some code on how to justify text to center (or Right)?
Best Regards,

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Text Justification

Post by support » 02 Nov 2009, 15:56

Hello.
We have built the new version of DXF Export .NET package. It can be downloaded via a link:
http://www.cadsofttools.com/download/be ... t_beta.zip

The text justification is modified. Please try to use this new version.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Rigor69
Posts: 18
Joined: 05 Oct 2009, 18:31

Re: Text Justification

Post by Rigor69 » 02 Nov 2009, 20:21

Thanks for the new version. It looks promising, as the texts now show when dxf is opened with autocad.
However something has changed in this build so that I cannot any longer pass the Graphics object of the MetaForm to my Draw() function.

Code: Select all

MetaForm mf1 = new MetaForm();
Draw(ref mf1.Graphics);
Gives me : Error 1 A property or indexer may not be passed as an out or ref parameter
In the last build this was possible.
I think it is vital to be able to pass the "Graphics" object because otherwise I have to build separate Draw-functions for showing the graphics on a form, and for printing to DXF. Lots of duplicated code in other words.
I cannot use your MetaForm.Graphics object in my main application for Visual presentation as is requires that it is disposed before showing the graphics. That is why i need to keep another Graphics object for my main Visual presentation.
Have i got it wrong? Is there another way of doing this so that I can use a the same Draw() for a Both my Graphics objects?
Best Regards,

Rigor69
Posts: 18
Joined: 05 Oct 2009, 18:31

Re: Text Justification

Post by Rigor69 » 15 Nov 2009, 20:19

Dear Support.

I'd like to know if you are considering to change the code to comply with my last post, or if not. If you are not, I will have to look for another solution.
Best Regards

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Text Justification

Post by support » 16 Nov 2009, 11:18

Hello.

We are not going to change the description of the properties MetaForm.Graphics in the future.
And we do not quite understand the purpose of the transfer parameter as a reference.

Anton.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Rigor69
Posts: 18
Joined: 05 Oct 2009, 18:31

Re: Text Justification

Post by Rigor69 » 16 Nov 2009, 13:14

OK, Than I will have to look elsewhere.

For the sake of clarity i would anyhow like to explain the reasoning behind my request.
You have a function in your lib that makes it possible to print a "Form" to DXF.
I think this is very useful! Consider if there is an existing application that does advanced graphical presentation on a windows form.
In a Object oriented approach you would probably let each "object"(called x) on the form draw itself. I'm sure you agree with that.
So, to let each object draw itself you would pass the "Graphics" as a reference to the object x, Let x draw on it, and pass it to the next object (y).

Now, this was the Form presentation. If I would for some reason want to add "Printing to DXF", It would be easy to pass another Graphics object insted (Your Graphics object), and let each object draw itself on it.
This way each object does not need to know if it is to be represented on the screen or on a DXF drawing, and no special code would need to be written for DXF Printing.

I found this very appealing in you last version, and started to build my application around it, but this possibility is gone in the last version.

I am not an expert programmer, so forgive(and please enlighten) me if I am overlooking a better solution here.

Best Regards,

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Text Justification

Post by support » 30 Nov 2009, 12:04

Hello.
The only reason to transmit Graphics object as a reference to your object is changing your object within Draw method. In any other situation using of reference doesn't necessary. Is your Draw method includes such functional?

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Rigor69
Posts: 18
Joined: 05 Oct 2009, 18:31

Re: Text Justification

Post by Rigor69 » 30 Nov 2009, 12:14

Well Yes, My draw method draws directly to the "Graphics" object.

Best Regards,

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Text Justification

Post by support » 30 Nov 2009, 12:37

Ok, but I asked if your Draw method changes objects x, y and so on. Only this situation requires transfer Graphics object as the reference.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Rigor69
Posts: 18
Joined: 05 Oct 2009, 18:31

Re: Text Justification

Post by Rigor69 » 30 Nov 2009, 12:46

Well, Each Object x, y, .. have their own Draw method. When the graphics object is passed to the Draw method, the object draws to the Graphics object.
I am not sure what you mean by "changes"

Best Regards,

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Text Justification

Post by support » 30 Nov 2009, 16:39

But in our demo we transfer Graphics object to our Draw method not as the reference. If every of your objects have its own Draw method, why can't you do the same?

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply