// Set the creation info so we are ready to create.
        private void SetCreateInfo()
        {
            createEventInfo.title                 = eventTitlePage.titleText.Text;
            createEventInfo.eventFileName         = GetEventFullPath();
            createEventInfo.mapType               = MapType;
            createEventInfo.mapFileName           = MapFileName;
            createEventInfo.scale                 = MapScale;
            createEventInfo.allControlsPrintScale = DefaultPrintScale;
            createEventInfo.dpi       = bitmapScalePage.dpi;
            createEventInfo.firstCode = (int)numberingPage.startingCodeNumericUpDown.Value;
            createEventInfo.disallowInvertibleCodes = numberingPage.disallowInvertibleCheckBox.Checked;
            createEventInfo.descriptionLangId       = null; // use default description language.
            createEventInfo.mapStandard             = standardsPage.radioButtonMap2017.Checked ? "2017" : "2000";
            createEventInfo.descriptionStandard     = standardsPage.radioButtonDescriptions2018.Checked ? "2018" : "2004";

            PrintArea printArea = new PrintArea();

            printArea.autoPrintArea      = true;
            printArea.restrictToPageSize = true;
            printArea.pageWidth          = paperSizePage.paperSizeControl.PaperSize.Width;
            printArea.pageHeight         = paperSizePage.paperSizeControl.PaperSize.Height;
            printArea.pageMargins        = paperSizePage.paperSizeControl.MarginSize;
            printArea.pageLandscape      = paperSizePage.paperSizeControl.Landscape;
            createEventInfo.printArea    = printArea;
        }
Exemple #2
0
        /// <summary>
        /// Constructs a URL used to export a map image using the specified parameters.
        /// </summary>
        /// <param name="layer">An object of the type <see cref="T:Geocrest.Model.ArcGIS.Tasks.Layer" />.</param>
        /// <param name="area">Parameters used for generating the actual image.</param>
        /// <param name="ctxuri">A reference to the requesting url.</param>
        /// <param name="dpi">The dpi to use when generating the image.</param>
        /// <returns>
        /// Returns a URL that can be used to generate a map image.
        /// </returns>
        private static string GetUrl(this Layer layer, PrintArea area, Uri ctxuri, int dpi)
        {
            string        url      = layer.ServiceUrl;
            string        format   = layer.Format;
            string        layers   = layer.LayerIDs;
            bool          useproxy = layer.UseProxy;
            StringBuilder uri      = new StringBuilder();

            if (useproxy)
            {
                uri.AppendFormat("{0}?", ctxuri.Scheme + "://" +
                                 ctxuri.Authority + VirtualPathUtility.ToAbsolute("~/areas/mapimage/proxy.ashx"));
            }
            uri.AppendFormat("{0}/export?", url);
            uri.AppendFormat(System.Globalization.CultureInfo.InvariantCulture,
                             "bbox={0},{1},{2},{3}", area.XMin, area.YMin, area.XMax, area.YMax);
            uri.AppendFormat("&size={0},{1}", area.Width, area.Height);
            uri.Append("&format=" + (!string.IsNullOrEmpty(format) ? format : "png32"));
            uri.AppendFormat("&dpi={0}", dpi);
            uri.Append("&transparent=true");
            if (!string.IsNullOrEmpty(layers))
            {
                uri.AppendFormat("&layers=show:{0}", layers);
            }
            if (area.SpatialReferenceID.HasValue)
            {
                uri.AppendFormat("&imageSR={0}&bboxSR={0}", area.SpatialReferenceID);
            }
            uri.Append("&f=image");
            return(uri.ToString());
        }
 internal SetPrintAreaDialog(MainFrame mainFrame, Controller controller, PrintAreaKind printAreaKind)
 {
     InitializeComponent();
     this.mainFrame     = mainFrame;
     this.controller    = controller;
     this.printAreaKind = printAreaKind;
     this.printArea     = PrintArea.DefaultPrintArea;
 }
        private void SetPrintArea(Workbook workbook)
        {
            #region radspreadprocessing-features-worksheetpagesetup_1
            PrintArea printArea = workbook.ActiveWorksheet.WorksheetPageSetup.PrintArea;

            printArea.SetPrintArea(new CellRange[]
            {
                new CellRange(0, 0, 4, 8),
                new CellRange(1, 1, 25, 3)
            });
            #endregion
        }
        private void PrintAreaExample()
        {
            #region radspreadsheet-ui-print-area-example_02
            PrintArea printArea = this.radSpreadsheet.ActiveWorksheet.WorksheetPageSetup.PrintArea;

            printArea.SetPrintArea(new CellRange[]
            {
                new CellRange(0, 0, 4, 8),
                new CellRange(1, 1, 25, 3)
            });

            #endregion
        }
 private void updateTimer_Tick(object sender, EventArgs e)
 {
     if (checkBoxAutomatic.Checked)
     {
         // Every 1/2 second, we check to see if the rectangle has moved away from the default position,
         // and clear the automatic option if so.
         PrintArea defaultPrintArea = (PrintArea)printArea.Clone();
         defaultPrintArea.autoPrintArea = true;
         RectangleF defaultRectangle = controller.GetPrintAreaRectangle(printAreaKind, defaultPrintArea);
         if (controller.SetPrintAreaCurrentRectangle() != defaultRectangle)
         {
             updateInProgress          = true;
             checkBoxAutomatic.Checked = false;
             updateInProgress          = false;
         }
     }
 }
Exemple #7
0
        // Give a map file name, get the default print area.
        public static PrintArea GetDefaultPrintArea(string mapFileName, float printScaleRatio)
        {
            float scale, dpi;
            Size bitmapSize;
            RectangleF mapBounds;
            MapType mapType;
            string errorMessageText;

            // If this failes, mapBounds will be empty rectangle, which is what we want to pass to GetDefaultPageSize;
            ValidateMapFile(mapFileName, out scale, out dpi, out bitmapSize, out mapBounds, out mapType, out errorMessageText);

            PrintArea printArea = new PrintArea();
            printArea.autoPrintArea = true;
            printArea.restrictToPageSize = true;
            GetDefaultPageSize(mapBounds, printScaleRatio, out printArea.pageWidth, out printArea.pageHeight, out printArea.pageMargins, out printArea.pageLandscape);
            return printArea;

        }
Exemple #8
0
        /// <summary>
        /// Gets the image.
        /// </summary>
        /// <param name="layer">The <see cref="T:Geocrest.Model.ArcGIS.Tasks.Layer" /> for
        /// which to obtain an image.</param>
        /// <param name="ctxuri">The <see cref="T:System.Uri" /> containing the scheme and authority for the request.</param>
        /// <param name="area">The print area parameter.</param>
        /// <param name="dpi">The dpi to use when generating the image.</param>
        /// <returns>
        /// Returns an <see cref="T:System.Drawing.Image" />.
        /// </returns>
        /// <exception cref="T:System.InvalidOperationException">Unable to retrieve image from the following url:  +
        ///                     url</exception>
        /// <exception cref="T:System.InvalidOperationException">If the image was unable to be retrieved.</exception>
        public static Image GetImage(this Layer layer, Uri ctxuri, PrintArea area, int dpi)
        {
            string url = "";

            try
            {
                WebClient client = new WebClient();
                url = layer.GetUrl(area, ctxuri, dpi);
                Uri    uri  = new Uri(url);
                byte[] data = client.DownloadData(uri);
                using (var sr = new StreamReader(new MemoryStream(data)))
                {
                    var s = sr.ReadToEnd();
                    var t = s;
                }
                return(data.ToImage());
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Unable to retrieve image from the following url: " +
                                                    url, ex);
            }
        }
Exemple #9
0
        // Get the area of the map we want to print, in map coordinates, and the print scale.
        // if the courseId is None, do all controls.
        // If asked for, crop to a single page size.
        RectangleF GetPrintAreaForCourse(CourseDesignator courseDesignator, out bool landscape, out PaperSize paperSize, out int margins, out float scaleRatio, out string description)
        {
            // Get the course view to get the scale ratio.
            CourseView courseView = CourseView.CreatePositioningCourseView(eventDB, courseDesignator);

            scaleRatio  = courseView.ScaleRatio;
            description = courseView.CourseFullName;

            RectangleF printRectangle = controller.GetCurrentPrintAreaRectangle(courseDesignator);
            PrintArea  printArea      = controller.GetCurrentPrintArea(courseDesignator);

            landscape = printArea.pageLandscape;
            paperSize = new PaperSize("", printArea.pageWidth, printArea.pageHeight);
            margins   = printArea.pageMargins;

            if (cropLargePrintArea)
            {
                // Crop the print area to a single page, portrait or landscape.
                // Try to keep CourseObjects in view as much as possible.
                CourseLayout layout = new CourseLayout();
                CourseFormatter.FormatCourseToLayout(symbolDB, courseView, appearance, layout, 0);
                RectangleF courseObjectsArea = layout.BoundingRect();
                courseObjectsArea.Intersect(printRectangle);

                // We may need to crop the print area to fit.
                float      areaCovered;
                RectangleF printableArea    = GetPrintablePageArea(landscape, paperSize, margins);
                RectangleF croppedRectangle = CropPrintArea(printRectangle, courseObjectsArea, GetScaledPrintableSizeInMapUnits(printableArea, scaleRatio), out areaCovered);

                return(croppedRectangle);
            }
            else
            {
                return(printRectangle);
            }
        }
Exemple #10
0
 public TemplateModel(PrintArea area, PrinterSettings settings)
     : this(settings)
 {
     PrintArea = area;
     Extents   = null;
 }