PageSettings Continue to Modify Unexpectedly

It seems that you can save the PrinterSettings settings file as well as PageSettings, they are Serializable, etc. Fine! Everything went fine until I tried to save my pages and fields. Each time I change the fields, save the settings, and then reload them back to PageSetupDialog.PageSettings - they have been changed. Does anyone know why this happened? Is this something that the driver or Windows does? Its freaky, see below:

Here I show the dialog:

PageSetupDialog psd = new PageSetupDialog();
psd.PageSettings = MySettings.Default.pageSettings;

    if (psd.ShowDialog() == DialogResult.OK)

alt text

I manually change the values ​​to 5.

Then I save the changes:

MySettings.Default.pageSettings = psd.PageSettings;

When I reload the dialog and load the settings from the settings file, the values ​​have changed to 2 !?

alt text

UPDATE:

, - PageSetupDialog , 10 . , , :

alt text

, 100, , , 10, .. 10 , , , 100 , , 10 .

5 OK - :

if (psd.ShowDialog() == DialogResult.OK)

pageSettingDialog, , 5 ( 50, , 10 100, . ). :

alt text

, , , - . , , , . 50 20?, , ? , .

+3
2

100 (= 1 ). 5 0,199645455 , 0,20. 0.20 100 20. . MSDN.

, . , , . , , , .

, , , , . , . - :

PageSetupDialog psd = new PageSetupDialog();
Margins currentMargins =  MySettings.Default.pageSettings.Margins;
psd.PageSettings.Margins = new Margins(
   ConvInchToMm(currentMargins.Left), ConvInchToMm(currentMargins.Right), 
   ConvInchToMm(currentMargins.Top), ConvInchToMm(currentMargins.Bottom));

private int ConvInchToMm(int hundrInch) 
{
   return (int)(hundrInch * 2.54);
}

PageSetupDialog EnableMetric, . . . .

PageSetupDialog psd = new PageSetupDialog();
psd.EnableMetric = true;
+4

, " ".

, 2 . 5, 2 - . , , .

-, .

, , , , "2", - .

0

Source: https://habr.com/ru/post/1777079/


All Articles