Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

What's the size of the window

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
K Viltersten - 16 Feb 2008 20:03 GMT
Just for fun i tested to draw a diagonal
line and discovered that
   int w = this.Width, h = this.Height;
   g.drawLine (0, 0, w, h);
doesn't shoot right. It seems that the
line start at the right position but it
reaches the bottom part before it comes
to touch the right edge...

In Swing there was an actual set of
components constituting a window. Is
this the case with C# as well? How do i
obtain the actual limits of what i see
as the drawable part of the form?

--
Regards
Konrad Viltersten
--------------------------------
sleep    - a substitute for coffee for the poor
ambition - lack of sense to be lazy
Jeroen Mostert - 16 Feb 2008 20:19 GMT
> Just for fun i tested to draw a diagonal
> line and discovered that    int w = this.Width, h = this.Height;
[quoted text clipped - 3 lines]
> reaches the bottom part before it comes
> to touch the right edge...

.Width gives the total width of a control, including the non-client area
(title bar, scrollbars, edges, etc.) Since you're only painting in the
client area, you'll want that instead: Control.ClientRectangle.Width and
Control.ClientRectangle.Height, respectively.

Signature

J.

K Viltersten - 16 Feb 2008 20:58 GMT
>> Just for fun i tested to draw a diagonal
>> line and discovered that    int w = this.Width, h = this.Height;
[quoted text clipped - 10 lines]
> Width and Control.ClientRectangle.Height,
> respectively.

Great! Thank you.

Of course, i needed to retract the height of the
status strip but that one was obvious, once i've
seen the image appearing.

--
Regards
Konrad Viltersten
--------------------------------
sleep    - a substitute for coffee for the poor
ambition - lack of sense to be lazy
Jeroen Mostert - 16 Feb 2008 21:03 GMT
>>> Just for fun i tested to draw a diagonal
>>> line and discovered that    int w = this.Width, h = this.Height;
[quoted text clipped - 14 lines]
> status strip but that one was obvious, once i've
> seen the image appearing.

If I can be Captain Obvious for a moment: why don't you just use an
auto-resize Image control instead of molesting the Form directly? That way
you know exactly what the size of your area is and don't need to factor in
other controls. If an Image is too heavy for you, you could still use a
Panel or custom control or somesuch. The basic point is that your job is a
lot easier if your entire area is dedicated to painting.

Signature

J.

K Viltersten - 16 Feb 2008 21:35 GMT
>>>> Just for fun i tested to draw a diagonal
>>>> line and discovered that    int w = this.Width, h = this.Height;
[quoted text clipped - 21 lines]
> Panel or custom control or somesuch. The basic point is that your job is a
> lot easier if your entire area is dedicated to painting.

Mostly, because i started that way and i WILL show
the stupid computer that it CAN be done.

After that, i'll extend a panel, yes. Never the less,
than you for the observation.

Also - "auto-resize Image control" seems not to be
there on my toolbar. Do i miss it or was it just a
description of a functionality that can be applied
for an e.g. panel?

--
Regards
Konrad Viltersten
--------------------------------
sleep    - a substitute for coffee for the poor
ambition - lack of sense to be lazy
Jeroen Mostert - 16 Feb 2008 21:50 GMT
<snip>
> Also - "auto-resize Image control" seems not to be
> there on my toolbar. Do i miss it or was it just a
> description of a functionality that can be applied
> for an e.g. panel?

I'm sorry, I'm getting my frameworks confused. What I'm talking about is
called a PictureBox in .NET (Image is the class that actually represents
images; PictureBox is a control for holding images). It's commonly used for
static or loaded images, but it works just as well for dynamic images.

However, it's not as appropriate for images that need to dynamically repaint
if they're resized (PaintBox can do bitmap-based resizing, but that's
usually not pretty). For continuous repainting it's easier to just
appropriate the client area of a Panel control, or write your own control if
you really want to get fancy. Directly painting on the Form, while an
obvious technique, is not as comfortable.

Signature

J.

K Viltersten - 16 Feb 2008 22:31 GMT
>> Also - "auto-resize Image control" seems not to be
>> there on my toolbar. Do i miss it or was it just a
[quoted text clipped - 5 lines]
> It's commonly used for static or loaded images, but
> it works just as well for dynamic images.

I believe we're talking about different kind of
painting. I'll be performing computations and the
results of these will be graphically presented to the
user. So, it's not so much a photo i'll be drawing
but rather two, three axis and a graph.

As far i've seen, there are no packages available for
charting that are open source and will do what i wish
them to do. So, i'll be writing an own.

> Directly painting on the Form, while an obvious
> technique, is not as comfortable.

I agree bu tas i pointed out above, there will be no
other way, as far as my current understanding is.
Please feel welcome to correct me if i'm mistaken.

--
Regards
Konrad Viltersten
--------------------------------
sleep    - a substitute for coffee for the poor
ambition - lack of sense to be lazy
Jeroen Mostert - 16 Feb 2008 23:30 GMT
>>> Also - "auto-resize Image control" seems not to be
>>> there on my toolbar. Do i miss it or was it just a
[quoted text clipped - 7 lines]
> I believe we're talking about different kind of
> painting.

I don't think so. "Painting" is just the general Windows term for "drawing
stuff on the screen whenever Windows asks you to". The source of what you're
painting doesn't matter.

> I'll be performing computations and the results of these will be
> graphically presented to the user. So, it's not so much a photo i'll be
> drawing but rather two, three axis and a graph.

Yes, but you could draw that on an Image in a PictureBox exactly as you
would draw it on a Form (they're both just "things to draw on", and they
both use a Graphics to draw). However, like I said, if your image needs to
change every time you resize it (and if you're drawing a chart, that seems
likely) then using an Image in a PictureBox isn't appropriate, because
resizing that all the time is inefficient.

> As far i've seen, there are no packages available for charting that are
> open source and will do what i wish them to do.

Did you run down the entire list at
http://csharp-source.net/open-source/charting-and-reporting? :-)

> So, i'll be writing an own.

That's fine, but then you'll definitely want to create a ChartControl or
something along those lines, so you can draw to your heart's content without
bothering other controls. This control will have its own client area, so you
won't have to bother with computing effective areas anymore.

It's then a matter of dropping that ChartControl on your form and away you
go. It won't matter whether the form has scrollbars, strips, status areas or
whatever.

>> Directly painting on the Form, while an obvious technique, is not as
>> comfortable.
>
> I agree bu tas i pointed out above, there will be no
> other way, as far as my current understanding is.
> Please feel welcome to correct me if i'm mistaken.

I think you are. At the very least, you could draw on a control that's fully
dedicated to displaying your content, rather than a Form. Like I said, you
could also abuse a separate empty Panel for this, which is at least
marginally easier.

Signature

J.

christery@gmail.com - 16 Feb 2008 23:56 GMT
> I think you are. At the very least, you could draw on a control that's fully
> dedicated to displaying your content, rather than a Form. Like I said, you
[quoted text clipped - 3 lines]
> --
> J.

I agree, I wrote a chart drawing program from scratch, comparing it
with ms chart for a school project, and just get it to scale right as
in 5-73 are the value span it should do 0-100 or 0- 75 and then the
spacing, 5,10 for the axis and so on is easy
but if 0,1-0,73 then zero at 0, top at 1, and the dividers at 0,1...
opps forgot about that (said in the project)
got it mostly right but it was not that easy with the maths...
logics, twips, deadline...
//CY
K Viltersten - 17 Feb 2008 00:33 GMT
> Did you run down the entire list at
> http://csharp-source.net/open-source/charting-and-reporting? :-)

Yes. I didn't exactly went to the verge of
extreme scrutiny but as far i could see,
not what i need. Thanks for trying, though.

>> So, i'll be writing an own.
>>
> That's fine, but then you'll definitely want
> to create a ChartControl or something...

I'll inherit a Panel and give it some methods
and instance variables for data handling and
storing. Would that be wise in your opinion?

>> I agree but as i pointed out above, there will be no
>> other way, as far as my current understanding is.
[quoted text clipped - 5 lines]
> also abuse a separate empty Panel for this, which is
> at least marginally easier.

I ment: correct me if i'm wrong in my view that
there are no advanced charting tools with open
source code. The ones that would fit are
provided expensively or at least only compiled.

--
Regards
Konrad Viltersten
--------------------------------
sleep    - a substitute for coffee for the poor
ambition - lack of sense to be lazy
Jeroen Mostert - 17 Feb 2008 01:01 GMT
>>> So, i'll be writing an own.
>>>
[quoted text clipped - 4 lines]
> and instance variables for data handling and
> storing. Would that be wise in your opinion?

No, since your chart is not a Panel. You'll want to inherit from a base
class like Control or ScrollableControl instead. Luckily, there's lots of
information out there on creating custom controls.

> I ment: correct me if i'm wrong in my view that
> there are no advanced charting tools with open
> source code. The ones that would fit are provided expensively or at
> least only compiled.

Oh, yes, I'm sure you checked that well enough. There are probably some
great open source solutions in C++ or Java, which will be of little use to
you since you're using C# -- the latest new thing we can all rewrite our
existing code in. :-)

Signature

J.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.