473,792 Members | 2,796 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 7372
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
1112
by: sector119 | last post by:
How am I able to draw a sting with some angle on image?
5
3131
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
3078
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
1641
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
1069
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
4350
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
1797
by: sernamar | last post by:
Hi, I have the following base class class UnitOfMeasure { public: //... std::string& GetName() {return _uomName;}; //... protected:
2
1507
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
9670
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
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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
10159
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
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
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4111
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

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.