Hi,
When I select a different page size, I would like to scale every printer layer accordingly. The below code is successful, except for printing elements that I currently have selected do not scale. Is there anyway to manually deselect printer layers?
private void cmbPaperSize_SelectedIndexChanged(object sender, EventArgs e)
{
if (!loaded)
return;
RectangleShape oldShape = pagePrinterLayer.GetBoundingBox();
pagePrinterLayer.PageSize = printerPageSizes[cmbPaperSize.SelectedItem.ToString()];
RectangleShape newShape = pagePrinterLayer.GetBoundingBox();
double widthRatio = newShape.Width / oldShape.Width;
double heightRatio = newShape.Height / oldShape.Height;
foreach (PrinterLayer printerLayer in printerOverlay.PrinterLayers)
{
if (!pagePrinterLayer.Equals(printerLayer))
RefitLayer(printerLayer, widthRatio, heightRatio);
}
MapRefresh();
}
private void RefitLayer(PrinterLayer printerLayer, double widthRatio, double heightRatio)
{
RectangleShape oldTransform = printerLayer.GetBoundingBox();
printerLayer.SetPosition(oldTransform.Width * widthRatio, oldTransform.Height * heightRatio,
new PointShape(oldTransform.GetCenterPoint().X * widthRatio, oldTransform.GetCenterPoint().Y * heightRatio),
PrintingUnit.Point);
}