コード例 #1
0
        internal void SetProperties(PrinterLayer printerLayer)
        {
            ImagePrinterLayer imagePrinterLayer = printerLayer as ImagePrinterLayer;

            if (imagePrinterLayer != null)
            {
                viewModel.BackgroundStyle = imagePrinterLayer.BackgroundMask;
                string imagePrinterLayerPathFilename = imagePrinterLayer.Image.PathFilename;
                if (File.Exists(imagePrinterLayerPathFilename))
                {
                    viewModel.SelectedImage = File.ReadAllBytes(imagePrinterLayerPathFilename);
                }
                else if (imagePrinterLayer.Image.GetImageStream() == null)
                {
                    System.Windows.Forms.MessageBox.Show(string.Format(CultureInfo.InvariantCulture,
                                                                       GisEditor.LanguageManager.GetStringResource("FileNotExistsAlert"),
                                                                       imagePrinterLayerPathFilename),
                                                         GisEditor.LanguageManager.GetStringResource("DataNotFoundlAlertTitle"));
                }
                else
                {
                    var stream = imagePrinterLayer.Image.GetImageStream();
                    stream.Seek(0, SeekOrigin.Begin);
                    byte[] bytes = new byte[stream.Length];
                    stream.Read(bytes, 0, bytes.Length);
                    viewModel.SelectedImage = bytes;
                }

                viewModel.DragMode   = imagePrinterLayer.DragMode;
                viewModel.ResizeMode = imagePrinterLayer.ResizeMode;
            }
        }
コード例 #2
0
        private void toolBoxItem_Click(object sender, RoutedEventArgs e)
        {
            PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"];
            PrinterLayer printerLayer = null;

            if (sender == btnAddLabel)
            {
                printerLayer = new LabelPrinterLayer();
                printerLayer.SetPosition(2, 1, 0, 0, PrintingUnit.Inch);
            }
            else if (sender == btnAddImage)
            {
                printerLayer = new ImagePrinterLayer();
            }
            else if (sender == btnAddScaleLine)
            {
                MessageBox.Show("NotImplemented");
            }
            else if (sender == btnAddScaleBar)
            {
                MessageBox.Show("NotImplemented");
            }
            else if (sender == btnAddDataGrid)
            {
                printerLayer = new DataGridPrinterLayer();
                printerLayer.SetPosition(1, 1, 0, 0, PrintingUnit.Inch);
            }

            //if (ShowPrinterLayerProperties(printerLayer) == DialogResult.OK)
            if (ShowPrinterLayerProperties(printerLayer) == true)
            {
                printerInteractiveOverlay.PrinterLayers.Add(printerLayer);
                Map1.Refresh();
            }
        }
コード例 #3
0
 public static void LoadFromViewModel(this ImagePrinterLayer imagePrinterLayer, ImageElementViewModel imageElementEntity)
 {
     //GeoImage image = new GeoImage(imageElementEntity.SelectedImage);
     //imagePrinterLayer.Image = image;
     if (imageElementEntity.BackgroundStyle != null)
     {
         imagePrinterLayer.BackgroundMask = imageElementEntity.BackgroundStyle;
     }
     imagePrinterLayer.ResizeMode = imageElementEntity.ResizeMode;
     imagePrinterLayer.DragMode   = imageElementEntity.DragMode;
 }
コード例 #4
0
        protected override PrinterLayer GetPrinterLayerFromActiveMapCore(RectangleShape boudingBox)
        {
            if ((northArrowMapTool != null && !string.IsNullOrEmpty(northArrowMapTool.ImagePath)) ||
                (adornmentLogo != null && !string.IsNullOrEmpty(adornmentLogo.LogoPath)))
            {
                GeoImage geoImage = null;

                double widthInPixel = 0, heightInPixel = 0;

                if (northArrowMapTool != null && !string.IsNullOrEmpty(northArrowMapTool.ImagePath))
                {
                    geoImage      = GetGeoImage(northArrowMapTool);
                    widthInPixel  = (int)northArrowMapTool.Width;
                    heightInPixel = (int)northArrowMapTool.Height;
                }
                else if (adornmentLogo != null && !string.IsNullOrEmpty(adornmentLogo.LogoPath))
                {
                    geoImage      = GetGeoImage(adornmentLogo);
                    widthInPixel  = (int)adornmentLogo.Width;
                    heightInPixel = (int)adornmentLogo.Height;
                }

                ImagePrinterLayer imagePrinterLayer = new ImagePrinterLayer(geoImage, 0, 0, PrintingUnit.Inch)
                {
                    DrawingExceptionMode = DrawingExceptionMode.DrawException
                };
                imagePrinterLayer.Open();
                AdornmentLocation location          = GetLocation();
                double            width             = PrinterHelper.ConvertLength((double)widthInPixel, PrintingUnit.Point, PrintingUnit.Inch);
                double            height            = PrinterHelper.ConvertLength((double)heightInPixel, PrintingUnit.Point, PrintingUnit.Inch);
                double            left              = 0;
                double            top               = 0;
                if (northArrowMapTool != null)
                {
                    left = PrinterHelper.ConvertLength(northArrowMapTool.Margin.Left, PrintingUnit.Point, PrintingUnit.Inch);
                    top  = PrinterHelper.ConvertLength(northArrowMapTool.Margin.Top, PrintingUnit.Point, PrintingUnit.Inch);
                }
                if (adornmentLogo != null)
                {
                    left = PrinterHelper.ConvertLength(adornmentLogo.Left, PrintingUnit.Point, PrintingUnit.Inch);
                    top  = PrinterHelper.ConvertLength(adornmentLogo.Top, PrintingUnit.Point, PrintingUnit.Inch);
                }
                SetPosition(location, boudingBox, imagePrinterLayer, width, height, left, top);
                return(imagePrinterLayer);
            }
            else
            {
                return(null);
            }
        }
コード例 #5
0
        private void AddLogoImage()
        {
            //Load the image to a GeoImage and then create the ImagePrinterLayer using that image
            GeoImage          compassGeoImage   = new GeoImage(@"..\..\..\Resources\Compass.png");
            ImagePrinterLayer imagePrinterLayer = new ImagePrinterLayer(compassGeoImage);

            // Set the imagePrinterLayer position offset from the page center and .75 inches wide and .75 inches tall
            RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch);

            imagePrinterLayer.SetPosition(.75, .75, pageBoundingbox.GetCenterPoint().X + 3.5, pageBoundingbox.GetCenterPoint().Y - 2.0, PrintingUnit.Inch);

            // Add the imagePrinterLayer to the PrinterInteractiveOverlay
            PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"];

            printerInteractiveOverlay.PrinterLayers.Add("ImageLayer", imagePrinterLayer);
        }
コード例 #6
0
        protected override void LoadFromActiveMapCore(PrinterLayer printerlayer)
        {
            ImagePrinterLayer imagePrinterLayer = null;

            if ((imagePrinterLayer = printerlayer as ImagePrinterLayer) != null)
            {
                var logoTool  = GisEditor.ActiveMap.MapTools.OfType <AdornmentLogo>().FirstOrDefault();
                var northTool = GisEditor.ActiveMap.MapTools.OfType <NorthArrowMapTool>().FirstOrDefault();
                if (northTool != null && !string.IsNullOrEmpty(northTool.ImagePath))
                {
                    imagePrinterLayer.Image = GetGeoImage(northTool);
                }
                else if (logoTool != null && !string.IsNullOrEmpty(logoTool.LogoPath))
                {
                    imagePrinterLayer.Image = GetGeoImage(logoTool);
                }
            }
        }
コード例 #7
0
        internal static PrinterLayer GetImagePrinterLayer(double width, double height, double centerX, double centerY)
        {
            ImageElementViewModel imageEntity = new ImageElementViewModel();
            GeoImage geoImage = null;

            geoImage = new GeoImage(new MemoryStream(imageEntity.SelectedImage));
            ImagePrinterLayer imagePrinterLayer = new ImagePrinterLayer(geoImage, 0, 0, PrintingUnit.Inch)
            {
                DrawingExceptionMode = DrawingExceptionMode.DrawException
            };

            imagePrinterLayer.LoadFromViewModel(imageEntity);
            var imgWidth  = imagePrinterLayer.Image.Width;
            var imgHeight = imagePrinterLayer.Image.Height;

            imagePrinterLayer.Open();
            imagePrinterLayer.SetPosition(width, height, centerX, centerY, PrintingUnit.Inch);
            return(imagePrinterLayer);
        }
コード例 #8
0
        public ImagePrinterLayerProperty(ImagePrinterLayer imagePrinterLayer)
        {
            InitializeComponent();

            this.imagePrinterLayer = imagePrinterLayer;
        }