Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
GeneralRe: Cannot convert from ref decimal? to ref decimal Pin
Kevin Marois18-Jan-18 6:23
professionalKevin Marois18-Jan-18 6:23 
AnswerRe: Cannot convert from ref decimal? to ref decimal Pin
Gerry Schmitz19-Jan-18 7:38
mveGerry Schmitz19-Jan-18 7:38 
QuestionBest Performance Datagrid for WinForms Pin
Burhu18-Jan-18 3:54
professionalBurhu18-Jan-18 3:54 
AnswerRe: Best Performance Datagrid for WinForms Pin
Dave Kreskowiak18-Jan-18 4:42
mveDave Kreskowiak18-Jan-18 4:42 
QuestionC# Remote Desktop Using C# .Net Pin
Babiiii18-Jan-18 2:27
Babiiii18-Jan-18 2:27 
AnswerRe: C# Remote Desktop Using C# .Net Pin
OriginalGriff18-Jan-18 2:30
mveOriginalGriff18-Jan-18 2:30 
QuestionHow can I put an triangle and square shape in the center using c# in image processing Pin
Member 1363007218-Jan-18 0:41
Member 1363007218-Jan-18 0:41 
AnswerRe: How can I put an triangle and square shape in the center using c# in image processing Pin
OriginalGriff18-Jan-18 0:52
mveOriginalGriff18-Jan-18 0:52 
For starters, look at your code:
if (opf.ShowDialog() == DialogResult.OK)
{
    pictureBox1.Image = Image.FromFile(opf.FileName);
}
Bitmap bmp = new Bitmap(opf.FileName);
pictureBox1.Image = Image.FromFile(opf.FileName);
Why are you doing that? Any of that, really?
If the OK button is pressed you load an image from a file. Then you load it again, and throw that away. Then you load it again and stuff it over the top of the first one you loaded.
If the Cancel button is pressed, you load the image (which will probably fail because there is no filename in the dialog) throw that away, and load it again (failing again) and muck up your picture box anyway...

Throw away the last two lines of that code. Then if and only if the user pressed OK
1) Load the image from the file
2) Copy the image into a new image and Dispose the original
3) Then set the copy as the PictureBox.Image

The reason for that is that when you create an image from a file, it locks the file until the Image is Disposed - so you need to work with a copy 99% of the time or your code fails in interesting ways later!

Then handle the PictureBox.Paint event. Inside that, you can use the supplied Graphics Context to draw over the Image using:
Graphics.DrawLine Method (Pen, Point, Point) (System.Drawing)[^] Call it three times fro your triangle.
Graphics.DrawRectangle Method (Pen, Int32, Int32, Int32, Int32) (System.Drawing)[^] Call it once to draw your rectangle.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

GeneralRe: How can I put an triangle and square shape in the center using c# in image processing Pin
Member 1363007218-Jan-18 1:09
Member 1363007218-Jan-18 1:09 
GeneralRe: How can I put an triangle and square shape in the center using c# in image processing Pin
OriginalGriff18-Jan-18 1:49
mveOriginalGriff18-Jan-18 1:49 
AnswerRe: How can I put an triangle and square shape in the center using c# in image processing Pin
V.18-Jan-18 20:18
professionalV.18-Jan-18 20:18 
QuestionHow to show customer data and order count using EF & LINQ Pin
Mou_kol17-Jan-18 23:52
Mou_kol17-Jan-18 23:52 
AnswerRe: How to show customer data and order count using EF & LINQ Pin
Pete O'Hanlon18-Jan-18 1:08
mvePete O'Hanlon18-Jan-18 1:08 
GeneralRe: How to show customer data and order count using EF & LINQ Pin
Mou_kol18-Jan-18 1:47
Mou_kol18-Jan-18 1:47 
GeneralRe: How to show customer data and order count using EF & LINQ Pin
Richard Deeming18-Jan-18 5:19
mveRichard Deeming18-Jan-18 5:19 
GeneralRe: How to show customer data and order count using EF & LINQ Pin
Mou_kol18-Jan-18 21:05
Mou_kol18-Jan-18 21:05 
QuestionDo you know C# graphic library like Qt Desiner QCostumPlot Pin
Emrah Duatepe17-Jan-18 20:15
Emrah Duatepe17-Jan-18 20:15 
QuestionHow do I open a flush from the resource folder in C # Pin
Member 1362111717-Jan-18 11:46
Member 1362111717-Jan-18 11:46 
AnswerRe: How do I open a flush from the resource folder in C # Pin
OriginalGriff17-Jan-18 20:10
mveOriginalGriff17-Jan-18 20:10 
GeneralRe: How do I open a flush from the resource folder in C # Pin
Member 1362111718-Jan-18 4:50
Member 1362111718-Jan-18 4:50 
GeneralRe: How do I open a flush from the resource folder in C # Pin
Member 1362111718-Jan-18 5:56
Member 1362111718-Jan-18 5:56 
AnswerRe: How do I open a flush from the resource folder in C # Pin
Pete O'Hanlon17-Jan-18 21:00
mvePete O'Hanlon17-Jan-18 21:00 
GeneralRe: How do I open a flush from the resource folder in C # Pin
Member 1362111718-Jan-18 4:52
Member 1362111718-Jan-18 4:52 
QuestionHow to generate auto no for property Pin
Mou_kol16-Jan-18 22:08
Mou_kol16-Jan-18 22:08 
AnswerRe: How to generate auto no for property Pin
OriginalGriff16-Jan-18 23:10
mveOriginalGriff16-Jan-18 23:10 

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.