473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Keeping the draw on an image

I am currently placing a "+" sign on a picture previously loaded in a
PictureBox by coding these below in an OnMouseDown event.

System.Drawing.Graphics formGraphics = PictureBox.CreateGraphics ( );
string drawString = "+";
System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);
System.Drawing.SolidBrush drawBrush = new
System.Drawing.SolidBrush(System.Drawing.Color.Bla ck);
float x = e.X - 10;
float y = e.Y - 10;
formGraphics.DrawString(drawString, drawFont, drawBrush, x, y);
drawFont.Dispose();
drawBrush.Dispose();
formGraphics.Dispose();
isPlacing = false;
PictureBox.Cursor = Cursors.Default;
PlaceObjButton.Enabled = false;
Up to this point everything is fine. But when I bring another running window
front and then return my software back I see that the mark is gone. How can I
keep the mark until I want to delete it?
--
Utku Ozan ÇANKAYA
Nov 17 '05 #1
2 1787

"utkuozan" <ut******@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...
I am currently placing a "+" sign on a picture previously loaded in a
PictureBox by coding these below in an OnMouseDown event.

System.Drawing.Graphics formGraphics = PictureBox.CreateGraphics ( );
string drawString = "+";
System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);
System.Drawing.SolidBrush drawBrush = new
System.Drawing.SolidBrush(System.Drawing.Color.Bla ck);
float x = e.X - 10;
float y = e.Y - 10;
formGraphics.DrawString(drawString, drawFont, drawBrush, x, y);
drawFont.Dispose();
drawBrush.Dispose();
formGraphics.Dispose();
isPlacing = false;
PictureBox.Cursor = Cursors.Default;
PlaceObjButton.Enabled = false;
Up to this point everything is fine. But when I bring another running
window
front and then return my software back I see that the mark is gone. How
can I
keep the mark until I want to delete it?
--
Utku Ozan ÇANKAYA

Hi Utku,
You need to do all your drawings in the onpaint event - then from a
method you would call invalidate as it changes -

James Jenkins
www.tamarsolutions.co.uk
Nov 17 '05 #2
See the GDI+ FAQ for why using CreateGraphics will cause you nothing but
pain, how to draw on an image and how to correctly use the PictureBox.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

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.

"utkuozan" <ut******@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...
I am currently placing a "+" sign on a picture previously loaded in a
PictureBox by coding these below in an OnMouseDown event.

System.Drawing.Graphics formGraphics = PictureBox.CreateGraphics ( );
string drawString = "+";
System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);
System.Drawing.SolidBrush drawBrush = new
System.Drawing.SolidBrush(System.Drawing.Color.Bla ck);
float x = e.X - 10;
float y = e.Y - 10;
formGraphics.DrawString(drawString, drawFont, drawBrush, x, y);
drawFont.Dispose();
drawBrush.Dispose();
formGraphics.Dispose();
isPlacing = false;
PictureBox.Cursor = Cursors.Default;
PlaceObjButton.Enabled = false;
Up to this point everything is fine. But when I bring another running
window
front and then return my software back I see that the mark is gone. How
can I
keep the mark until I want to delete it?
--
Utku Ozan ÇANKAYA

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: midtoad | last post by:
I'm trying to display a GIF image in a label as the central area to a Tkinter GUI. The image does not appear, though a space is made for it. Why is this so? I notice that I can display a GIF...
1
by: Daewon YOON | last post by:
Hi. I'm a newbie to this python world. PIL has 'text(position, string, options)' method in its ImageDraw module. Does this work with unicode or other 2byte encoded string? It seems not working...
4
by: Steve Peterson | last post by:
Hi I've been beating my head against the wall trying to get this done, with little to no success so I thought I would turn to the .Net community for some help. I have an .NET app in which the...
3
by: Stimp | last post by:
I've been hacking at this for 15 mins, but haven't really got too much time to spend on it today, so maybe someone here can suggest a quick fix or suggest if there is a function built into asp.net...
2
by: myjpa1 | last post by:
Hi, all, I want to draw image directly onto top of screen, which simulates the OSD(on screen display) effects. However, class Graphics must link to certain controls, that cannot be used to draw...
6
by: Mark Denardo | last post by:
My question is similar to one someone posted a few months back, but I don't see any replies. Basically I want to be able to have users upload photos and save them in a database (as byte data)...
0
by: benfly08 | last post by:
Hi, guys. I have a program to draw bar/pie chart based on the data i hard coded in it. However, my image comes with "BLACK" background color. I don't know how to fix this. The code snippet is...
7
by: HxRLxY | last post by:
I am trying to write a simple program which will allow users to view pictures. I am loading an image as an icon, then assigning that ImageIcon to an Image object. Then i get the graphics context of...
4
by: neovantage | last post by:
Hey geeks, i want to draw a jpeg image of pattern chess. I can draw solid color image using gd libraray and here is my code //$t_im having image path, $t_wt,$t_ht is specified width and...
5
by: AndrewBuchan | last post by:
Thank you for your patience Gary, I followed your advice and have got this functioning. Just a side note, if you do not mind. The text and lines I am adding are position specific - that is to...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.