Zum Hauptinhalt gehen

Dynamic Print Template

Kommentare

1 Kommentar

  • Permanently deleted user

    Figured this out if anyone is interested. Here is the script:

    using System;

     

    using System.Drawing;

     

    using System.Text;

     

    using System.Windows.Forms;

     

    using System.Data;

    //script checks map scale and if it is a small scale map, hides

     

    //the vicinity map as it is not needed.

     

    public void Detail1_Format()

     

    {

     

    //get references to overviewmap and mapscale page elements

     

    ARControl overviewmap = rpt.Sections["Detail1"].Controls["OverviewMap"];

     

    TextBox  mapscale = (TextBox )rpt.Sections["Detail1"].Controls["MapScale"];

     

    //remove comma (if there is one) from scale text, so that it can be converted to an integer

     

    string cleanscale = mapscale.Text.Replace(",", "");

     

    //convert scale text to numeric value

     

    int numScale = 0;

     

    int.TryParse(cleanscale, out numScale);

     

    //test current scale against scale threshold and set visibility of overview map accordingly.

     

    if (numScale > 40000)

     

    {

     

      overviewmap.Visible = false;

     

    }

     

    }

    Pretty simple once I figured out how to get a reference to the different layout elements in the report. To make this work the overview map must be placed such that its absence does not look odd. I just moved it out of the legend area and into another corner of the map. If the scale is smaller than 1:40k, the overview map disapears, which still looks ok for the layout.

    What I'd really like to do is provide the user with an interface for selecting which map elements they want and then use this technique to dynamically generate the map. This way they could choose legend, overview map, disclaimer, title, etc.... From what I can see, it does not appear like you can add fields to the print dialog though. I suppose this could be done as a workflow, but would rather stick with something closer to the default behavior.

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.