Reputation: 5920
Here is my code:
Graphics g = Graphics.FromImage(newImage);
var myBrush = new SolidBrush(Color.FromArgb(32, 205, 205, 205));
g.DrawString(label, new Font("verdana", 10, GraphicsUnit.Pixel), myBrush, 10,10);
It doesn't work very well about put the string on the image. This code can write very well but I couldn't put the string from left buttom corner to right upper corner. Do you have any suggestion?
Upvotes: 1
Views: 2414
Reputation: 4280
g.RotateTransform(45f);
and only after that
g.DrawString(label, new Font("verdana", 10, GraphicsUnit.Pixel), myBrush, 10,10);
But that would only rotate by 45 degrees. Depending on size of your button and length of your text which can be calculated using MeasureString
method, you will need to adjust the angle and position of the text. I hope you like geometry.
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.rotatetransform(v=vs.100).aspx
In order to move the position where the string is drawn, you'll need to use the TranslateTransform(dx,dy) method of your graphics object.
http://msdn.microsoft.com/en-us/library/6a1d65f4(v=vs.100).aspx
So to draw string in center, you'd call translate then rotate then draw. If that doesn't work well try changing the order of rotate and translate.
Upvotes: 1
Reputation: 12815
If you find an image of a diagonal line (which shouldn't be hard), just set the Button's background image property to the image. The code for it is similar to this:
button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.img2));
I believe there are properties to set for stretching the image and stuff in case it doesn't quite line up properly.
Upvotes: 0