Click here to Skip to main content
16,007,111 members
Home / Discussions / C#
   

C#

 
GeneralRe: Databinding problem Pin
ejbing11-Mar-07 12:34
ejbing11-Mar-07 12:34 
QuestionTrying to draw using System.Drawing.Drawing2D Pin
laura13161-Mar-07 12:18
laura13161-Mar-07 12:18 
AnswerRe: Trying to draw using System.Drawing.Drawing2D Pin
Christian Graus1-Mar-07 12:33
protectorChristian Graus1-Mar-07 12:33 
GeneralRe: Trying to draw using System.Drawing.Drawing2D Pin
laura13161-Mar-07 12:39
laura13161-Mar-07 12:39 
GeneralRe: Trying to draw using System.Drawing.Drawing2D Pin
Luc Pattyn1-Mar-07 12:42
sitebuilderLuc Pattyn1-Mar-07 12:42 
GeneralRe: Trying to draw using System.Drawing.Drawing2D Pin
laura13161-Mar-07 12:50
laura13161-Mar-07 12:50 
GeneralRe: Trying to draw using System.Drawing.Drawing2D Pin
Christian Graus1-Mar-07 12:55
protectorChristian Graus1-Mar-07 12:55 
GeneralRe: Trying to draw using System.Drawing.Drawing2D Pin
Luc Pattyn1-Mar-07 13:30
sitebuilderLuc Pattyn1-Mar-07 13:30 
Hi,

in the form's paint handler I would do:

Graphics g=e.Graphics; // e=PaintEventArgs
g.DrawRectangle(Pens.Black, 15, 25, w, h);


now what are the right values for w and h ?
for a point (or a very small square), set them both to 1 or 2.
for an exact size, it is complex:
- first you must assume that your system settings are correct, i.e. the right dpi
have been set (by default a monitor gets installed at 96 dpi, which is less than what
the average modern monitor is showing). You can change them to the correct value by first
calculating the value, then setting it interactively under Display Properties/Settings/
Advanced/DPI Settings: select custom settings, and then enter the number as a
percentage of 96 dpi.
remark: everything will look smaller now (except for the desktop, which now can hold
much more stuff); you may want to increase the system's default font size, icon size,
etc.
- then your program should find out what the system's dpi settings are, by calling
something like
Bitmap bitmap=new Bitmap(100, 100);
Graphics gBM=Graphics.FromImage(bitmap);
int Dpi=gBM.DpiX;
gBM.Dispose();

This has to be done only once in a program (unless you want to cope with a change
in the setting while the program is running...)
you dont have to worry about DpiY, it will equal DpiX (you could only enter an
overall dpi value in the previous step, so best is to calculate it diagonally !)
Now you can calculate how many pixels are needed to travel 1 cm, and that's the
right value for w and h.

remark: if your system settings are incorrect, dont bother calling gBM.DpiX, since
everything would be based on a lie, hence wrong.

Smile | :)



Luc Pattyn

[My Articles]

GeneralRe: Trying to draw using System.Drawing.Drawing2D Pin
Christian Graus1-Mar-07 13:33
protectorChristian Graus1-Mar-07 13:33 
GeneralRe: Trying to draw using System.Drawing.Drawing2D Pin
Luc Pattyn1-Mar-07 13:46
sitebuilderLuc Pattyn1-Mar-07 13:46 
AnswerRe: Trying to draw using System.Drawing.Drawing2D Pin
Luc Pattyn1-Mar-07 12:40
sitebuilderLuc Pattyn1-Mar-07 12:40 
QuestionHow do I pass and reference a Panel? Pin
dino20941-Mar-07 12:05
dino20941-Mar-07 12:05 
AnswerRe: How do I pass and reference a Panel? Pin
Dawid Mazuruk1-Mar-07 12:17
Dawid Mazuruk1-Mar-07 12:17 
GeneralRe: How do I pass and reference a Panel? Pin
dino20941-Mar-07 12:21
dino20941-Mar-07 12:21 
GeneralRe: How do I pass and reference a Panel? Pin
Christian Graus1-Mar-07 12:37
protectorChristian Graus1-Mar-07 12:37 
GeneralRe: How do I pass and reference a Panel? Pin
Luc Pattyn1-Mar-07 12:32
sitebuilderLuc Pattyn1-Mar-07 12:32 
GeneralRe: How do I pass and reference a Panel? Pin
Christian Graus1-Mar-07 12:36
protectorChristian Graus1-Mar-07 12:36 
AnswerRe: How do I pass and reference a Panel? Pin
Christian Graus1-Mar-07 12:38
protectorChristian Graus1-Mar-07 12:38 
QuestionSaving data in access database Pin
conemajstor1-Mar-07 11:22
conemajstor1-Mar-07 11:22 
QuestionImage Formats Pin
Dobromir Dimitrov1-Mar-07 11:16
Dobromir Dimitrov1-Mar-07 11:16 
AnswerRe: Image Formats Pin
Christian Graus1-Mar-07 12:35
protectorChristian Graus1-Mar-07 12:35 
AnswerRe: Image Formats Pin
Luc Pattyn1-Mar-07 12:37
sitebuilderLuc Pattyn1-Mar-07 12:37 
AnswerRe: Image Formats Pin
Hayder Marzouk1-Mar-07 22:19
Hayder Marzouk1-Mar-07 22:19 
QuestionBuild Problem1 Pin
greekius1-Mar-07 10:22
greekius1-Mar-07 10:22 
AnswerRe: Build Problem1 Pin
Luc Pattyn1-Mar-07 10:59
sitebuilderLuc Pattyn1-Mar-07 10:59 

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.