public static ValidateMapFile ( string mapFileName, float &scale, float &dpi, |
||
mapFileName | string | |
scale | float | |
dpi | float | |
bitmapSize | ||
mapBounds | ||
mapType | MapType | |
errorMessageText | string | |
Результат | bool |
private void button1_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) { containingWizard.MapFileName = mapFileNameTextBox.Text = openFileDialog.FileName; mapFileDisplay.Visible = true; string errorMessageText; float dpi; // not used here. float mapScale; MapType mapType; Size bitmapSize; RectangleF mapBounds; if (MapUtil.ValidateMapFile(containingWizard.MapFileName, out mapScale, out dpi, out bitmapSize, out mapBounds, out mapType, out errorMessageText)) { // map file is OK. containingWizard.MapScale = mapScale; containingWizard.MapType = mapType; containingWizard.BitmapSize = bitmapSize; containingWizard.mapBounds = mapBounds; errorDisplayPanel.Visible = false; infoDisplayPanel.Visible = true; ((Control)ParentForm.AcceptButton).Focus(); } else { // map file is not OK. Show message. errorMessage.Text = errorMessageText; infoDisplayPanel.Visible = false; errorDisplayPanel.Visible = true; } } }
// The map file name has been updated. void UpdateMapFile() { if (mapFile == null || mapFile == "") { // No map file. errorDisplayPanel.Visible = false; panelScaleDpi.Visible = false; } else { // Validate the map file. string errorMessageText; float dpi, mapScale; Size bitmapSize; RectangleF mapBounds; bool ok = MapUtil.ValidateMapFile(mapFile, out mapScale, out dpi, out bitmapSize, out mapBounds, out mapType, out errorMessageText); if (ok) { if (mapType == MapType.OCAD) { panelScaleDpi.Visible = false; errorDisplayPanel.Visible = false; textBoxScale.Text = mapScale.ToString(); } else if (mapType == MapType.Bitmap) { panelScaleDpi.Visible = true; errorDisplayPanel.Visible = false; labelDpi.Visible = labelDpi2.Visible = textBoxDpi.Visible = true; textBoxDpi.Text = dpi.ToString(); } else if (mapType == MapType.PDF) { panelScaleDpi.Visible = true; errorDisplayPanel.Visible = false; labelDpi.Visible = labelDpi2.Visible = textBoxDpi.Visible = false; } else { Debug.Fail("unexpected map type."); } } else { errorMessage.Text = errorMessageText; panelScaleDpi.Visible = false; errorDisplayPanel.Visible = true; } } mapFileNameTextBox.Text = mapFile; UpdateOKButton(); }