[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

GetHardMargins Actual Height Paper

JZ

9/27/2004 9:21:00 AM

Hi,

I've found the GetHardMargins code written by Ron Allen.
I have it working...

But I've not exactly sure what to do with it.

I simple want to paint a drawing over 2 pages.
The 2 bits of paper would then be trimmed and stuck together with tape.

I think the easiest thing for me to do is do derive a number which will all
me to pass in an offset into my drawing function.

Any suggestions how I can do this?

--
JZ

Heres the code I've got...
Dim lLeft As Single

Dim lTop As Single

Dim lRight As Single

Dim lBottom As Single

Dim hdcPtr As IntPtr

Dim gr As Graphics =
PrintDocument1.PrinterSettings.CreateMeasurementGraphics()

hdcPtr = gr.GetHdc

GetHardMargins(hdcPtr, lLeft, lTop, lRight, lBottom)

gr.ReleaseHdc(hdcPtr)

Private Declare Function GetDeviceCaps Lib "gdi32.dll" (ByVal hdc As IntPtr,
ByVal nIndex As Int32) As Int32

Private Sub GetHardMargins(ByVal hDC As IntPtr, ByRef Left As Single, ByRef
Top As Single, ByRef Right As Single, ByRef Bottom As Single)



Const PHYSICALOFFSETX As Int32 = 112

Const PHYSICALOFFSETY As Int32 = 113

Const HORZRES As Int32 = 8

Const VERTRES As Int32 = 10

Const HORZSIZE As Int32 = 4

Const VERTSIZE As Int32 = 6

Dim offx As Single = Convert.ToSingle(GetDeviceCaps(hDC, PHYSICALOFFSETX))

Dim offy As Single = Convert.ToSingle(GetDeviceCaps(hDC, PHYSICALOFFSETY))

Dim resx As Single = Convert.ToSingle(GetDeviceCaps(hDC, HORZRES))

Dim resy As Single = Convert.ToSingle(GetDeviceCaps(hDC, VERTRES))

Dim hsz As Single = Convert.ToSingle(GetDeviceCaps(hDC, HORZSIZE)) / 25.4F '
Screen width in inches.

Dim vsz As Single = Convert.ToSingle(GetDeviceCaps(hDC, VERTSIZE)) / 25.4F '
Screen height in inches.

Dim ppix As Single = resx / hsz

Dim ppiy As Single = resy / vsz

Left = (offx / ppix) * 100.0F

Top = (offy / ppix) * 100.0F

Bottom = Top + (vsz * 100.0F)

Right = Left + (hsz * 100.0F)

End Sub


10 Answers

Ron Allen

9/27/2004 1:10:00 PM

0

JZ,
GetHardMargins is just used to return the hard printer margins so you
can correctly offset your drawing area. You can get the vertical drawing
height by subtracting the top margin from the bottom one and get the width
in the same way.
Now you will have to organize your drawing to do only parts or just draw
the whole drawing on the first page after translating -left, -top to get
offsets correct and then on the second page do a translate
by -left, -(bottom - top) and then draw the whole thing again. This should
get the two parts shown correctly as the items outside the page boundaries
will be ignored.

Ron Allen
"JZ" <jj@anon.anon.com> wrote in message
news:4157db6c$0$20244$cc9e4d1f@news-text.dial.pipex.com...
> Hi,
>
> I''ve found the GetHardMargins code written by Ron Allen.
> I have it working...
>
> But I''ve not exactly sure what to do with it.
>
> I simple want to paint a drawing over 2 pages.
> The 2 bits of paper would then be trimmed and stuck together with tape.
>
> I think the easiest thing for me to do is do derive a number which will
> all
> me to pass in an offset into my drawing function.
>
> Any suggestions how I can do this?
>
> --
> JZ
>
> Heres the code I''ve got...
> Dim lLeft As Single
>
> Dim lTop As Single
>
> Dim lRight As Single
>
> Dim lBottom As Single
>
> Dim hdcPtr As IntPtr
>
> Dim gr As Graphics =
> PrintDocument1.PrinterSettings.CreateMeasurementGraphics()
>
> hdcPtr = gr.GetHdc
>
> GetHardMargins(hdcPtr, lLeft, lTop, lRight, lBottom)
>
> gr.ReleaseHdc(hdcPtr)
>
> Private Declare Function GetDeviceCaps Lib "gdi32.dll" (ByVal hdc As
> IntPtr,
> ByVal nIndex As Int32) As Int32
>
> Private Sub GetHardMargins(ByVal hDC As IntPtr, ByRef Left As Single,
> ByRef
> Top As Single, ByRef Right As Single, ByRef Bottom As Single)
>
>
>
> Const PHYSICALOFFSETX As Int32 = 112
>
> Const PHYSICALOFFSETY As Int32 = 113
>
> Const HORZRES As Int32 = 8
>
> Const VERTRES As Int32 = 10
>
> Const HORZSIZE As Int32 = 4
>
> Const VERTSIZE As Int32 = 6
>
> Dim offx As Single = Convert.ToSingle(GetDeviceCaps(hDC, PHYSICALOFFSETX))
>
> Dim offy As Single = Convert.ToSingle(GetDeviceCaps(hDC, PHYSICALOFFSETY))
>
> Dim resx As Single = Convert.ToSingle(GetDeviceCaps(hDC, HORZRES))
>
> Dim resy As Single = Convert.ToSingle(GetDeviceCaps(hDC, VERTRES))
>
> Dim hsz As Single = Convert.ToSingle(GetDeviceCaps(hDC, HORZSIZE)) / 25.4F
> ''
> Screen width in inches.
>
> Dim vsz As Single = Convert.ToSingle(GetDeviceCaps(hDC, VERTSIZE)) / 25.4F
> ''
> Screen height in inches.
>
> Dim ppix As Single = resx / hsz
>
> Dim ppiy As Single = resy / vsz
>
> Left = (offx / ppix) * 100.0F
>
> Top = (offy / ppix) * 100.0F
>
> Bottom = Top + (vsz * 100.0F)
>
> Right = Left + (hsz * 100.0F)
>
> End Sub
>
>


JZ

9/27/2004 1:39:00 PM

0

Hi,

Thanks for your reply.

What are the values that I need to look at in relation to the print document
or print preview?

I just call printdocument.print from print preview.

I''m not too bothered if the print preview doesn''t look quite right, as long
as it prints ok.

I currently pass in an offset for the second page, so the drawing starts
half way across.
So I just need to subtract a little from that.

--
JZ


JZ

9/27/2004 2:03:00 PM

0

Hi,

I guess what I really need to know is how to convert the hard left margin
value into something I subtract from the default drawing number format.

?

--
JZ


Ron Allen

9/27/2004 5:14:00 PM

0

JZ,
To compensate for margins you can call
e.Graphics.TranslateTransform(-left, -top) where left and top are the values
returned for the hard left and top margins respectively and e is the
PrintPageEventArgs parameter for PrintPage.
Calling GetHardMargins at the beginning of printing or for each
PrintPage should return 0 for a print preview and the actual values in
1/100ths of an inch when going out to the printer.

Ron Allen
"JZ" <jj@anon.anon.com> wrote in message
news:41581d89$0$20246$cc9e4d1f@news-text.dial.pipex.com...
> Hi,
>
> I guess what I really need to know is how to convert the hard left margin
> value into something I subtract from the default drawing number format.
>
> ?
>
> --
> JZ
>
>


JZ

9/28/2004 12:23:00 PM

0

Hi,

Thanks...

Yes I do tranform already.

I''m sorry to over complicate things.
I presumed that I''d have the convert the values some how.
I wasn''t expecting everything to be done for me.

Thanks.

--
JZ


Emily Short

12/6/2007 12:10:00 AM

0

On Dec 5, 2:20 pm, "David Fisher" <davidfis...@australiaonline.net.au>
wrote:

> Mike Snyder wrote in his review of Orevore Courier
> (http://www.sidneymerk.com/comp07/ore...):
>
> In many ways, my own voting guidelines are rubbish. I've tried to
> describe what makes a game deserving of a given score by outlining
> what I look for in a good game. One like Orevore Courier can
> hardly be faulted for featuring a story without any real depth when
> it's supposed to be a puzzle box, not thought-provoking literature.

I don't have this codified into a numerical guideline, but I mostly
vote depending on

-- how well the work (whether game or story) achieves its goals
-- whether those goals were a) clear and b) worthwhile in the first
place

Everything else is commentary. As we've seen extensively this year
(Lost Pig, Deadline Enchanter), a specific vision can partly or wholly
suspend the usual standards about technical writing finesse or
implementation depth. Other elements -- the presence and quality of
puzzles, complexity of setting, characterization of NPCs -- are even
more dependent on what the author is trying to do.

David Fisher

12/6/2007 1:03:00 AM

0

"Emily Short" <emshort@mindspring.com> wrote in message
news:84b5feb4-7ee4-40f9-be94-151bd403d2d9@p69g2000hsa.googlegroups.com...
>
> I don't have this codified into a numerical guideline, but I mostly
> vote depending on
>
> -- how well the work (whether game or story) achieves its goals
> -- whether those goals were a) clear and b) worthwhile in the
> first place

Trying to think like a lawyer, I can't see any immediate "loopholes" in this
system ... b) sounds like it catches the cases where something might be
extremely well done but uninteresting.

It seems risky for IF Comp entries to be too experimental, since half of the
audience might not think the experiment was worthwhile. On the other hand,
being creative and original seems to be a highly sought after goal ...

It may be impossible to answer, but do some experimental directions seem
safer than others (in terms of not losing the audience)?

David Fisher


George Oliver

12/6/2007 1:42:00 AM

0

On Dec 5, 4:09 pm, Emily Short <emsh...@mindspring.com> wrote:
>
> I don't have this codified into a numerical guideline, but I mostly
> vote depending on
>
> -- how well the work (whether game or story) achieves its goals
> -- whether those goals were a) clear and b) worthwhile in the first
> place
>
> Everything else is commentary. As we've seen extensively this year
> (Lost Pig, Deadline Enchanter), a specific vision can partly or wholly
> suspend the usual standards about technical writing finesse or
> implementation depth. Other elements -- the presence and quality of
> puzzles, complexity of setting, characterization of NPCs -- are even
> more dependent on what the author is trying to do.


I do try to vote with consistent criteria for every game -- when my
judging is spread out over a month or more I need some kind of
baseline. Though I've noticed some judges play all the games in such
little time that maybe they don't need any formal criteria.

My criteria are creativity (a catch-all for imagination, ideas, what
the IF is about), execution (how well the game plays), and WTF,
basically how far the author is pushing the envelope.

dave

12/6/2007 4:20:00 PM

0

On Dec 5, 2:20 pm, "David Fisher" <davidfis...@australiaonline.net.au>
wrote:
> "dave" <dgengl...@hotmail.com> wrote in message
>
> news:b8abad19-e67e-446c-919b-f109479d447b@s8g2000prg.googlegroups.com...
>
>
>
> > When I rate games for the competition, I score in four
> > categories:
>
> > The quality of the writing
> > The technical quality of the games
> > The depth of implementation
> > Over all enjoyment of the game
>
> Sounds fair ...
>
> Do you ever come across a game that doesn't fit well with your scoring
> system? (I guess all types of game can have good or bad writing ... could
> you give 10/10 to a game with "average" technical quality or depth of
> implementation, or are they both absolute requirements for any game?)
>
snip

I can't claim that my scoring in the four categories you quoted
above are entirely independent of one another. If I really enjoy a
game, I might be willing to overlook weakness in the implementation,
which I would penalize severely in another game. But I try to be
consistent, and there is usually at least one game in a competition
which excells in all of these specific categories. So I couldn't
bring myself to give 10/10 to an otherwise enjoyable game which
doesn't.

Dave

jokerjesterknave

12/9/2007 6:38:00 AM

0

"David Fisher"

> The depth of implementation: Ideally, the map should cover a wide
> area, and every object in the game should be examinable down to its
> smallest part. Since comp games are limited to two hours, I don't
> expect every map to be quite as sprawling as it was in this year's
> Chinese Room, however in these less sprawling games, I expect a
> correspondingly deeper level of implementation within those few
> locations (as we saw in this year's Lord Bellwater).

Just a couple of things to note:

Comp games aren't actually limited to two hours. The final score must
be awarded at the two hour mark, but I feel that having a game longer
than two hours is not a problem at all. In fact, if your game has a
richly implemented, deep world, then you can really hurt your game by
trying to cram all of this in two hours.

"every object in the game should be examinable down to its smallest
part" I agree with this statement whole-heartedly. Nothing breaks my
concentration and enjoyment of a game more than "I don't know
(noun)." Default message or not, if a noun is mentioned at ANY point
in game, it MUST be recognized by the game to avoid losing points in
my opinion. If you don't want to implement many nouns, then don't
fill your descriptions with nouns. Please note that I mean ALL nouns,
down to the nth level of detail.

That being said, if you don't want to implement the screwheads holding
the coffeemaker of dhoom together, that's fine. Just don't mention
them in any descriptive text.

just a few thoughts,
joker