473,854 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I to draw a string at an arbitrary angle

Val
When I am using Graphics.DrawSt ring, I can only draw a string either
horizontally or vertically. Is the a way to draw under arbitrary angle -
parallel to some line?

I would appreciate a code sample.

Thanks,

Val

Nov 17 '05 #1
4 7376
The GDI+ FAQ shows you how.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Val" <Va*@discussion s.microsoft.com > wrote in message
news:78******** *************** ***********@mic rosoft.com...
When I am using Graphics.DrawSt ring, I can only draw a string either
horizontally or vertically. Is the a way to draw under arbitrary angle -
parallel to some line?

I would appreciate a code sample.

Thanks,

Val

Nov 17 '05 #2
You can use Matrix.RotateAt method
the sample ( works with framework 1.1) :
http://winfx.msdn.microsoft.com/libr...m/rotateat.asp

Val a écrit :
When I am using Graphics.DrawSt ring, I can only draw a string either
horizontally or vertically. Is the a way to draw under arbitrary angle -
parallel to some line?

I would appreciate a code sample.

Thanks,

Val

Nov 17 '05 #3
Bob Powell [MVP] wrote:
The GDI+ FAQ shows you how.

Yes, but I note in the sample output provided that the rotation of the
text appears to be around the upper left corner of the text 'frame'; is
there a convenient manner in which the rotation can occur based on the
centre left of the text 'frame', so that the text drawn at zero (0) and
180 degrees are aaligned?

-ken
Nov 17 '05 #4
As with all matrix operations things are best done around the origin.

You can rotate around any point drawing the text at a position that orients
it correctly.

For example...

Matrix mx=new Matrix(1,0,0,1, 0,0);

mx.Rotate(45,Ma trixOrder.Appen d);

mx.Translate(th is.ClientRectan gle.Width/2,
this.ClientRect angle.Height/2,MatrixOrder.A ppend);

e.Graphics.Tran sform=mx;

SizeF sz=e.Graphics.M easureString("H ello
World!!",this.F ont,1024,String Format.GenericT ypographic);

e.Graphics.Draw String("Hello
World!!",this.F ont,Brushes.Bla ck,-sz.Width/2,-sz.Height/2,StringFormat. GenericTypograp hic);

return;
--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Ken Allen" <ke******@sympa tico.ca> wrote in message
news:uF******** *******@TK2MSFT NGP12.phx.gbl.. .
Bob Powell [MVP] wrote:
The GDI+ FAQ shows you how.

Yes, but I note in the sample output provided that the rotation of the
text appears to be around the upper left corner of the text 'frame'; is
there a convenient manner in which the rotation can occur based on the
centre left of the text 'frame', so that the text drawn at zero (0) and
180 degrees are aaligned?

-ken

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1113
by: sector119 | last post by:
How am I able to draw a sting with some angle on image?
5
3133
by: Darren Grant | last post by:
Hi there, I've attempted to implement an Angle class. An Angle is a subset of an integer, where the range is [0,360). All other operations should be permitted. The code works, I think... except (for example) a = b + 10; needs to be a = b + (Angle) 10; Could some kind soul comment on my code and show me how it could be
21
3086
by: DraguVaso | last post by:
Hi, I have an inherited DataGrid, that does lots of extra stuff. For exemple drawing a backgroundimage in every cell. The problem is that it's taking too much time (using gdi+), so I want to do it using DirectX. I downloaded already the DSK etc, but I can't find how I need to draw an image on a given position. I don't need stuff to write advanced 3D-games, just painting that image. Can anybody help me with this? I'm already looking for...
4
9640
by: Shalley | last post by:
Hello, there, I have no idea how to draw an ellipse with an rotated angle. For example, the ellipse's center is (20.0, 50.0), two conjugate diameter pairs end-point are (35.0, 35.0), (25.0, 55.0). I hope to use win32 API functions to finish this drawing. Is it possible? Please help me giving your suggestion. Tks.
3
1642
by: Tom | last post by:
Hi Hi i am trying to draw on top of a button on a standard toolbar. All i want to do is draw a small rectangle on the button to represent the selected color. I have tried the folowing code in the toolbar's parent control, which is fired when the selected color is changed: Dim r As Rectangle = FontColorButton.Rectangle
0
1073
by: Carl Gilbert | last post by:
Hi I am trying to draw a pie like shape on a form in the paint event. I am then trying to draw a line running down the center of the pie. The code I have attached at the bottom of this post does just this but there is something wrong somewhere as when I resize the form, the line does not stay over the center of the pie as expected. I should imagine its just a case of something round the wrong way but I just can't find what could be...
1
4357
by: zxo102 | last post by:
Hi everyone, I have tried two days to figure out how to draw the image in wx.BufferedDC on the page created by AddPage of wx.Notebook but still got no clue. The attached example works fine. If I click the menu "Draw" --"New Drawing". The image with wx.BufferedDC/wx.BufferedPaintDC can move around on the frame. But If I uncomment those three commented lines in "class TestFrame" to add a new page (from wx.Notebook) with a tag and modify...
3
1799
by: sernamar | last post by:
Hi, I have the following base class class UnitOfMeasure { public: //... std::string& GetName() {return _uomName;}; //... protected:
2
1509
by: Smokey Grindel | last post by:
I want to draw a string that is at a 90 degree angle instead of left to right it would be rotated 90 degrees... how would you go about doing this? thanks!
0
9901
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11024
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10679
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7914
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5741
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5941
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4559
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4154
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.