Click here to Skip to main content
15,908,626 members
Home / Discussions / C#
   

C#

 
QuestionWrite program Wpf C# calculator (OEE ) Pin
Member 146803725-Dec-19 21:39
Member 146803725-Dec-19 21:39 
QuestionRe: Write program Wpf C# calculator (OEE ) Pin
Richard MacCutchan5-Dec-19 22:32
mveRichard MacCutchan5-Dec-19 22:32 
AnswerRe: Write program Wpf C# calculator (OEE ) Pin
OriginalGriff5-Dec-19 22:41
mveOriginalGriff5-Dec-19 22:41 
AnswerRe: Write program Wpf C# calculator (OEE ) Pin
Crimson1st24-Jan-22 13:18
Crimson1st24-Jan-22 13:18 
QuestionC# Passing password to Web API Pin
Kevin Marois5-Dec-19 9:00
professionalKevin Marois5-Dec-19 9:00 
AnswerRe: C# Passing password to Web API Pin
Richard Deeming5-Dec-19 9:06
mveRichard Deeming5-Dec-19 9:06 
QuestionNaudio C# ASP.net Using MPG Video Pin
Member 1394308729-Nov-19 23:45
Member 1394308729-Nov-19 23:45 
AnswerRe: Naudio C# ASP.net Using MPG Video Pin
Gerry Schmitz2-Dec-19 5:15
mveGerry Schmitz2-Dec-19 5:15 
AnswerRe: Naudio C# ASP.net Using MPG Video Pin
jkirkerx2-Dec-19 9:30
professionaljkirkerx2-Dec-19 9:30 
QuestionDrawString with opacity option not print properly Pin
Le@rner29-Nov-19 19:19
Le@rner29-Nov-19 19:19 
AnswerRe: DrawString with opacity option not print properly Pin
OriginalGriff29-Nov-19 20:17
mveOriginalGriff29-Nov-19 20:17 
GeneralRe: DrawString with opacity option not print properly Pin
Le@rner29-Nov-19 20:28
Le@rner29-Nov-19 20:28 
AnswerRe: DrawString with opacity option not print properly Pin
OriginalGriff29-Nov-19 21:16
mveOriginalGriff29-Nov-19 21:16 
GeneralRe: DrawString with opacity option not print properly Pin
Le@rner29-Nov-19 21:23
Le@rner29-Nov-19 21:23 
GeneralRe: DrawString with opacity option not print properly Pin
OriginalGriff29-Nov-19 21:29
mveOriginalGriff29-Nov-19 21:29 
GeneralRe: DrawString with opacity option not print properly Pin
Le@rner29-Nov-19 21:30
Le@rner29-Nov-19 21:30 
GeneralRe: DrawString with opacity option not print properly Pin
OriginalGriff29-Nov-19 21:30
mveOriginalGriff29-Nov-19 21:30 
GeneralRe: DrawString with opacity option not print properly Pin
Le@rner29-Nov-19 21:35
Le@rner29-Nov-19 21:35 
GeneralRe: DrawString with opacity option not print properly Pin
OriginalGriff29-Nov-19 21:41
mveOriginalGriff29-Nov-19 21:41 
GeneralRe: DrawString with opacity option not print properly Pin
Le@rner29-Nov-19 22:06
Le@rner29-Nov-19 22:06 
GeneralRe: DrawString with opacity option not print properly Pin
OriginalGriff29-Nov-19 22:33
mveOriginalGriff29-Nov-19 22:33 
GeneralRe: DrawString with opacity option not print properly Pin
OriginalGriff29-Nov-19 22:39
mveOriginalGriff29-Nov-19 22:39 
If I bodge up your code (fix the errors, use substitutes for external bits I don't have) it works ok in preview for me:
C#
private void FrmMain_Shown(object sender, EventArgs e)
     {
     PrintDocument pd = new PrintDocument();
     pd.PrintPage += Pd_PrintPage;
     PrintPreviewDialog pdi = new PrintPreviewDialog { Document = pd };
     pdi.ShowDialog();
     }
 private void Pd_PrintPage(object sender, PrintPageEventArgs pe)
     {
     int X = 0;
     int Y = 0;

     RectangleF rect2 = panel2.ClientRectangle;

     float image_draw_wd = panel2.Width;

     float image_draw_ht = panel2.Height;

     Brush myBrush = new SolidBrush(Color.FromArgb(128, Color.Blue));

     StringFormat stringFormat = new StringFormat();
     stringFormat.Alignment = StringAlignment.Center;
     stringFormat.FormatFlags = StringFormatFlags.LineLimit;
     stringFormat.Trimming = StringTrimming.Word;

     SizeF sz = pe.Graphics.MeasureString("A line of text to display", Font, (int)image_draw_wd, stringFormat);


     double angle = 0;
     double angleRadians = Math.Atan2(image_draw_ht, image_draw_wd);
     angle = angleRadians * 180.0 / Math.PI;

     pe.Graphics.TranslateTransform((rect2.Location.X + rect2.Width / 2), (rect2.Location.Y + rect2.Height / 2));
     pe.Graphics.RotateTransform((float)angle);// + flip180Image);
     pe.Graphics.TranslateTransform(-(rect2.Location.X + rect2.Width / 2), -(rect2.Location.Y + rect2.Height / 2));


     X = 10;// (int)(panel2.Width - sz.Width) / 2;
     Y = 10; // (int)(panel2.Height - sz.Height) / 2;

     RectangleF dr_rect = new RectangleF(new Point(X, Y), new Size((int) image_draw_wd, ((int)sz.Height) + 10));

     pe.Graphics.DrawString("A line of text to display", Font, myBrush, dr_rect, stringFormat);
     }

"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!

GeneralRe: DrawString with opacity option not print properly Pin
Le@rner29-Nov-19 23:20
Le@rner29-Nov-19 23:20 
GeneralRe: DrawString with opacity option not print properly Pin
OriginalGriff29-Nov-19 23:23
mveOriginalGriff29-Nov-19 23:23 
GeneralRe: DrawString with opacity option not print properly Pin
OriginalGriff29-Nov-19 23:29
mveOriginalGriff29-Nov-19 23:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.