Click here to Skip to main content
15,915,873 members
Home / Discussions / C#
   

C#

 
AnswerRe: Import Excal file into Mysql Pin
dan!sh 5-May-09 19:26
professional dan!sh 5-May-09 19:26 
AnswerRe: Import Excal file into Mysql Pin
Mycroft Holmes5-May-09 20:08
professionalMycroft Holmes5-May-09 20:08 
QuestionC# Globalhook(WH_CALLWNDPROC) Pin
hongkunjiang5-May-09 17:59
hongkunjiang5-May-09 17:59 
AnswerRe: C# Globalhook(WH_CALLWNDPROC) Pin
stancrm5-May-09 20:40
stancrm5-May-09 20:40 
GeneralRe: C# Globalhook(WH_CALLWNDPROC) Pin
hongkunjiang5-May-09 21:23
hongkunjiang5-May-09 21:23 
AnswerRe: C# Globalhook(WH_CALLWNDPROC) Pin
S. Senthil Kumar6-May-09 9:33
S. Senthil Kumar6-May-09 9:33 
QuestionPolygon Rendering Performance Optimization Pin
StarBP5-May-09 16:50
StarBP5-May-09 16:50 
QuestionI want to know Pin
dileeparuwan5-May-09 16:32
dileeparuwan5-May-09 16:32 
AnswerRe: I want to know Pin
Christian Graus5-May-09 16:57
protectorChristian Graus5-May-09 16:57 
GeneralRe: I want to know Pin
dileeparuwan5-May-09 21:39
dileeparuwan5-May-09 21:39 
QuestionHow to select && or || within formula at run time Pin
MAW305-May-09 16:32
MAW305-May-09 16:32 
Questionodbc firebird C# Pin
mark_me5-May-09 16:03
mark_me5-May-09 16:03 
AnswerRe: odbc firebird C# Pin
Giorgi Dalakishvili5-May-09 20:03
mentorGiorgi Dalakishvili5-May-09 20:03 
QuestionEasy way to create a save/load functionality to an Application Pin
sodevrom5-May-09 13:47
sodevrom5-May-09 13:47 
AnswerRe: Easy way to create a save/load functionality to an Application Pin
Dave Kreskowiak5-May-09 17:23
mveDave Kreskowiak5-May-09 17:23 
QuestionWinForms Comboboxes Pin
Illegal Operation5-May-09 13:32
Illegal Operation5-May-09 13:32 
AnswerRe: WinForms Comboboxes Pin
dotnetmember5-May-09 16:42
dotnetmember5-May-09 16:42 
AnswerRe: WinForms Comboboxes Pin
Mycroft Holmes5-May-09 17:24
professionalMycroft Holmes5-May-09 17:24 
QuestionTo Dispose() or not Dispose(), that is the question. Pin
Peter Trevor5-May-09 13:02
Peter Trevor5-May-09 13:02 
Okay, I’m confused on what to Dispose and when. Below is a subroutine called from a loop. First time through it is okay, the second time through it throws a System.Exception “Parameter is not valid” on the DrawString line. But if I remove all the Dispose commands at the bottom I can call this subroutine a dozen times without error.

Obviously in this instance I can just remove the Dispose commands and move on but I want to understand when I should or shouldn’t call Dispose. (After all I might be missing some Dispose calls elsewhere in my program.)

private void DrawRotatedText(Graphics Canvas, string text, Rectangle DestRect)
{
    //Create temp workspace
    Bitmap bmp = new Bitmap(500, 500, PixelFormat.Format64bppArgb);
    Graphics g = Graphics.FromImage(bmp);
    g.Clear(Color.White);

    //Write on it
    Font font = new Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Pixel);
    Brush brush = Brushes.Black;
    StringFormat stringFormat = new StringFormat();
    stringFormat.Alignment = StringAlignment.Center;
    stringFormat.LineAlignment = StringAlignment.Center;
    g.DrawString(text, font, brush, (bmp.Width / 2), (bmp.Height / 2), stringFormat);

    //Rotate image here
    Bitmap bmp2 = Rotator.RotateImage(bmp, (360 - 45));

    // Set the transparency color key based on the upper-left pixel of the image.
    ImageAttributes attr = new ImageAttributes();
    attr.SetColorKey(bmp.GetPixel(0, 0), bmp.GetPixel(0, 0));

    // Draw the image using the image attributes.
    Rectangle SrcRect = new Rectangle((bmp2.Width / 2) - (DestRect.Width / 2),
      (bmp2.Height / 2) - (DestRect.Height / 2), DestRect.Width, DestRect.Height);
    Canvas.DrawImage(bmp2, DestRect, SrcRect.Left, SrcRect.Top, SrcRect.Width,
      SrcRect.Height, GraphicsUnit.Pixel, attr);

    //Tidy up
    bmp.Dispose();
    font.Dispose();
    brush.Dispose();
    stringFormat.Dispose();
    bmp2.Dispose();
    attr.Dispose();
    g.Dispose();
}

AnswerRe: To Dispose() or not Dispose(), that is the question. Pin
Luc Pattyn5-May-09 13:25
sitebuilderLuc Pattyn5-May-09 13:25 
GeneralRe: To Dispose() or not Dispose(), that is the question. Pin
fly9045-May-09 14:22
fly9045-May-09 14:22 
GeneralRe: To Dispose() or not Dispose(), that is the question. Pin
Luc Pattyn5-May-09 14:47
sitebuilderLuc Pattyn5-May-09 14:47 
JokeRe: To Dispose() or not Dispose(), that is the question. Pin
fly9045-May-09 15:24
fly9045-May-09 15:24 
GeneralRe: To Dispose() or not Dispose(), that is the question. Pin
Luc Pattyn5-May-09 15:42
sitebuilderLuc Pattyn5-May-09 15:42 
QuestionExpose Property of Constituent Control in UserControl Pin
xfitr25-May-09 11:18
xfitr25-May-09 11:18 

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.