Beispiel #1
0
 private GeoImage GetGeoImage(NorthArrowMapTool northArrowMapTool)
 {
     if (northArrowMapTool.ImagePath.StartsWith("pack:"))
     {
         return(GetGeoImage((northArrowMapTool.Content as Image).Source as BitmapImage));
     }
     else if (File.Exists(northArrowMapTool.ImagePath))
     {
         var imgStream = new MemoryStream(File.ReadAllBytes(northArrowMapTool.ImagePath));
         imgStream.Seek(0, SeekOrigin.Begin);
         return(new GeoImage(imgStream));
     }
     else
     {
         var         image       = northArrowMapTool.Content as Image;
         BitmapImage bitmapImage = null;
         if (image != null && (bitmapImage = image.Source as BitmapImage) != null)
         {
             return(GetGeoImage(bitmapImage));
         }
         else
         {
             return(new GeoImage(new MemoryStream()));
         }
     }
 }
        private void Apply()
        {
            NorthArrowMapTool northArrowMapTool = GisEditor.ActiveMap.MapTools.OfType <NorthArrowMapTool>().FirstOrDefault();

            if (northArrowMapTool == null)
            {
                northArrowMapTool = new NorthArrowMapTool();
                GisEditor.ActiveMap.MapTools.Add(northArrowMapTool);
            }
            SetPropertiesForNorthArrowMapTool(northArrowMapTool);
        }
        public NorthArrowViewModel()
        {
            ArrowLocation = AdornmentLocation.LowerRight;
            ArrowSize     = LogoSizeMode.Auto;
            images        = new ObservableCollection <string>();
            for (int i = 0; i < 16; i++)
            {
                images.Add(string.Format(gridImagePath, i));
            }
            SelectedImage = Images[0];

            NorthArrowMapTool northMapTool = GisEditor.ActiveMap.MapTools.OfType <NorthArrowMapTool>().FirstOrDefault();

            if (northMapTool != null)
            {
                SetProperties(northMapTool);
            }
        }
        public void SetPropertiesForNorthArrowMapTool(NorthArrowMapTool northArrowMapTool)
        {
            int width  = ArrowSize == LogoSizeMode.Auto ? 0 : (int)ArrowWidth;
            int height = ArrowSize == LogoSizeMode.Auto ? 0 : (int)ArrowHeight;

            northArrowMapTool.Content = new Image()
            {
                Source = ImageHelper.GetImageSource(ActualImagePath, width, height)
            };
            northArrowMapTool.ImagePath = ActualImagePath;
            if (PreviewImage != null)
            {
                double originalWidth  = ((Image)northArrowMapTool.Content).Source.Width;
                double originalHeight = ((Image)northArrowMapTool.Content).Source.Height;
                northArrowMapTool.Width  = ArrowSize == LogoSizeMode.Auto ? originalWidth : ArrowWidth;
                northArrowMapTool.Height = ArrowSize == LogoSizeMode.Auto ? originalHeight : ArrowHeight;
            }

            northArrowMapTool.HorizontalAlignment = GetHorizontalAlignment(ArrowLocation);
            northArrowMapTool.VerticalAlignment   = GetVerticalAlignment(ArrowLocation);
            northArrowMapTool.Margin = new Thickness(ArrowLeft, ArrowTop, -ArrowLeft, -ArrowTop);
        }
        private void SetProperties(NorthArrowMapTool maptool)
        {
            Image image = maptool.Content as Image;

            if (image != null)
            {
                if (image.Source == null)
                {
                    ArrowSize = LogoSizeMode.Auto;
                }
                else
                {
                    //make the SelectedItem of ListBox unselected
                    SelectedImage = null;
                    if (!string.IsNullOrEmpty(maptool.ImagePath) && Regex.IsMatch(maptool.ImagePath, pattern))
                    {
                        Match match = Regex.Match(maptool.ImagePath, pattern);
                        SelectedImage = string.Format(CultureInfo.InvariantCulture, gridImagePath, Convert.ToInt32(match.Value));
                    }
                    else
                    {
                        SelectedImage = maptool.ImagePath;
                    }
                    ArrowSize = (maptool.Width == image.Source.Width && maptool.Height == image.Source.Height) ? LogoSizeMode.Auto : LogoSizeMode.FixedSize;
                }

                if (ArrowSize == LogoSizeMode.FixedSize)
                {
                    ArrowWidth  = maptool.Width;
                    ArrowHeight = maptool.Height;
                }
            }

            ArrowLocation = GetAdornmentLocation(maptool.HorizontalAlignment, maptool.VerticalAlignment);
            ArrowLeft     = maptool.Margin.Left;
            ArrowTop      = maptool.Margin.Top;
        }
Beispiel #6
0
 public ImagePrinterLayerAdapter(NorthArrowMapTool northArrowMapTool)
 {
     this.northArrowMapTool = northArrowMapTool;
 }