HighTechTalks DotNet Forums  

Draw Rectangle directly to client (ie - without bitmap?)

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Draw Rectangle directly to client (ie - without bitmap?) in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
=?Utf-8?B?TmF0aGFuQw==?=
 
Posts: n/a

Default Draw Rectangle directly to client (ie - without bitmap?) - 06-08-2007 , 11:44 AM






I am trying to draw a rectangle for every record in a dataset.
The drawing function will occur within a For Each loop and each record has a
different XY position, so the idea is that the final result will have a
single image with multiple rectangles. I have tried using bitmap methodology
of doing this, but that doesn't get multiple objects on the image - only the
final item is saved and displayed.

Is there a way that I can draw the rectangle directly to the client, and
then next iteration through the loop, draw a different rectangle in a new
location without losing the last image?

Thanks,

Reply With Quote
  #2  
Old   
Bob Powell [MVP]
 
Posts: n/a

Default Re: Draw Rectangle directly to client (ie - without bitmap?) - 06-08-2007 , 01:02 PM






I'm assuming that your drawing to the screen and your stuff is disappearing
between draw cycles.

Are you respecting the laws of GetGraphics? (See the GDI+ FAQ)

Perhaps you should draw your rectangles to an image in memory and then
display that instead.

--
--
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.


"NathanC" <NathanC (AT) discussions (DOT) microsoft.com> wrote

Quote:
I am trying to draw a rectangle for every record in a dataset.
The drawing function will occur within a For Each loop and each record has
a
different XY position, so the idea is that the final result will have a
single image with multiple rectangles. I have tried using bitmap
methodology
of doing this, but that doesn't get multiple objects on the image - only
the
final item is saved and displayed.

Is there a way that I can draw the rectangle directly to the client, and
then next iteration through the loop, draw a different rectangle in a new
location without losing the last image?

Thanks,


Reply With Quote
  #3  
Old   
=?Utf-8?B?TmF0aGFuQw==?=
 
Posts: n/a

Default Re: Draw Rectangle directly to client (ie - without bitmap?) - 06-08-2007 , 01:13 PM



I'll look into that - here is my code:

Dim i As Int32
For i = 0 To dvGetSeatsByScreen.Count - 1

dvGetSeatStatus.RowFilter = "id='" &
dsGetSeatsByScreen.Tables("Table").Rows(i).Item("s eat_status").ToString() &
"'"
fore_color = dvGetSeatStatus(0)("fore_color").ToString()
back_color = dvGetSeatStatus(0)("back_color").ToString()
status_legend = dvGetSeatStatus(0)("status_legend").ToString()

fore_color = Drawing.Color.FromArgb(fore_color)
back_color = Drawing.Color.FromArgb(back_color)

xpos =
Convert.ToInt32(dsGetSeatsByScreen.Tables("Table") .Rows(i).Item("xpos").ToString())
ypos =
Convert.ToInt32(dsGetSeatsByScreen.Tables("Table") .Rows(i).Item("xpos").ToString())

seat.DrawRectangle(Drawing.Pens.Black, xpos, ypos, 5, 10)
seat.FillRectangle(Drawing.Brushes.Crimson, xpos, ypos, 5, 10)

Next

Response.ContentType = "image/gif"
bitmap.Save("C:\Inetpub\wwwroot\Tessitura\images\" &
ViewSelection.SelectedItem.Text & ".gif", Drawing.Imaging.ImageFormat.Gif)

"Bob Powell [MVP]" wrote:

Quote:
I'm assuming that your drawing to the screen and your stuff is disappearing
between draw cycles.

Are you respecting the laws of GetGraphics? (See the GDI+ FAQ)

Perhaps you should draw your rectangles to an image in memory and then
display that instead.

--
--
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.


"NathanC" <NathanC (AT) discussions (DOT) microsoft.com> wrote in message
news:E9B4D871-5909-476F-9D90-42E78DFA4570 (AT) microsoft (DOT) com...
I am trying to draw a rectangle for every record in a dataset.
The drawing function will occur within a For Each loop and each record has
a
different XY position, so the idea is that the final result will have a
single image with multiple rectangles. I have tried using bitmap
methodology
of doing this, but that doesn't get multiple objects on the image - only
the
final item is saved and displayed.

Is there a way that I can draw the rectangle directly to the client, and
then next iteration through the loop, draw a different rectangle in a new
location without losing the last image?

Thanks,



Reply With Quote
  #4  
Old   
=?Utf-8?B?TmF0aGFuQw==?=
 
Posts: n/a

Default Re: Draw Rectangle directly to client (ie - without bitmap?) - 06-08-2007 , 01:22 PM



I'm an idiot - I was calling seat.Clear earlier in the code - that fixed it.
What a dummy.

Thanks,

"NathanC" wrote:

Quote:
I'll look into that - here is my code:

Dim i As Int32
For i = 0 To dvGetSeatsByScreen.Count - 1

dvGetSeatStatus.RowFilter = "id='" &
dsGetSeatsByScreen.Tables("Table").Rows(i).Item("s eat_status").ToString() &
"'"
fore_color = dvGetSeatStatus(0)("fore_color").ToString()
back_color = dvGetSeatStatus(0)("back_color").ToString()
status_legend = dvGetSeatStatus(0)("status_legend").ToString()

fore_color = Drawing.Color.FromArgb(fore_color)
back_color = Drawing.Color.FromArgb(back_color)

xpos =
Convert.ToInt32(dsGetSeatsByScreen.Tables("Table") .Rows(i).Item("xpos").ToString())
ypos =
Convert.ToInt32(dsGetSeatsByScreen.Tables("Table") .Rows(i).Item("xpos").ToString())

seat.DrawRectangle(Drawing.Pens.Black, xpos, ypos, 5, 10)
seat.FillRectangle(Drawing.Brushes.Crimson, xpos, ypos, 5, 10)

Next

Response.ContentType = "image/gif"
bitmap.Save("C:\Inetpub\wwwroot\Tessitura\images\" &
ViewSelection.SelectedItem.Text & ".gif", Drawing.Imaging.ImageFormat.Gif)

"Bob Powell [MVP]" wrote:

I'm assuming that your drawing to the screen and your stuff is disappearing
between draw cycles.

Are you respecting the laws of GetGraphics? (See the GDI+ FAQ)

Perhaps you should draw your rectangles to an image in memory and then
display that instead.

--
--
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.


"NathanC" <NathanC (AT) discussions (DOT) microsoft.com> wrote in message
news:E9B4D871-5909-476F-9D90-42E78DFA4570 (AT) microsoft (DOT) com...
I am trying to draw a rectangle for every record in a dataset.
The drawing function will occur within a For Each loop and each record has
a
different XY position, so the idea is that the final result will have a
single image with multiple rectangles. I have tried using bitmap
methodology
of doing this, but that doesn't get multiple objects on the image - only
the
final item is saved and displayed.

Is there a way that I can draw the rectangle directly to the client, and
then next iteration through the loop, draw a different rectangle in a new
location without losing the last image?

Thanks,



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.