Ejemplo n.º 1
0
        private List <MapDatabase.Layer> SaveLayers()
        {
            List <MapDatabase.Layer> _Layers = new List <MapDatabase.Layer>();

            foreach (InkCanvas _InkCanvas in _canvasList.Children)
            {
                MapDatabase.Layer _Layer = new MapDatabase.Layer();
                foreach (Image _Image in _InkCanvas.Children.OfType <Image>())
                {
                    Image             img       = _Image;
                    ImageSource       imgSource = img.Source;
                    BitmapImage       bmp       = imgSource as BitmapImage;
                    string            path      = bmp.UriSource.OriginalString;
                    double            x         = InkCanvas.GetLeft(_Image);
                    double            y         = InkCanvas.GetTop(_Image);
                    double            width     = _Image.ActualWidth;
                    double            height    = _Image.ActualHeight;
                    MapDatabase.Image imga      = new MapDatabase.Image
                    {
                        Path   = path,
                        X      = x,
                        Y      = y,
                        Width  = width,
                        Height = height
                    };

                    _Layer.Images.Add(imga);
                }

                List <MapDatabase.Polygon> _Polygons = _Layer.Polygons;
                foreach (Stroke _Stroke in _InkCanvas.Strokes)
                {
                    List <Point> _Points = new List <Point>();
                    foreach (StylusPoint _StylusPoint in _Stroke.StylusPoints)
                    {
                        Point _Point = new Point();
                        _Point.X = (int)_StylusPoint.X;
                        _Point.Y = (int)_StylusPoint.Y;
                        _Points.Add(_Point);
                    }
                    MapDatabase.Polygon _Polygon = new MapDatabase.Polygon();
                    _Polygon.Color  = _Stroke.DrawingAttributes.Color;
                    _Polygon.Points = _Points;
                    _Polygons.Add(_Polygon);
                }
                _Layers.Add(_Layer);
            }
            return(_Layers);
        }
        private List<MapDatabase.Layer> SaveLayers()
        {
            List<MapDatabase.Layer> _Layers = new List<MapDatabase.Layer>();
            foreach (InkCanvas _InkCanvas in _canvasList.Children)
            {
                MapDatabase.Layer _Layer = new MapDatabase.Layer();
                foreach (Image _Image in _InkCanvas.Children.OfType<Image>())
                {
                    Image img = _Image;
                    ImageSource imgSource = img.Source;
                    BitmapImage bmp = imgSource as BitmapImage;
                    string path = bmp.UriSource.OriginalString;
                    double x = InkCanvas.GetLeft(_Image);
                    double y = InkCanvas.GetTop(_Image);
                    double width = _Image.ActualWidth;
                    double height = _Image.ActualHeight;
                    MapDatabase.Image imga = new MapDatabase.Image
                    {
                        Path = path,
                        X = x,
                        Y = y,
                        Width = width,
                        Height = height
                    };

                    _Layer.Images.Add(imga);
                }

                List<MapDatabase.Polygon> _Polygons = _Layer.Polygons;
                foreach (Stroke _Stroke in _InkCanvas.Strokes)
                {
                    List<Point> _Points = new List<Point>();
                    foreach (StylusPoint _StylusPoint in _Stroke.StylusPoints)
                    {
                        Point _Point = new Point();
                        _Point.X = (int)_StylusPoint.X;
                        _Point.Y = (int)_StylusPoint.Y;
                        _Points.Add(_Point);
                    }
                    MapDatabase.Polygon _Polygon = new MapDatabase.Polygon();
                    _Polygon.Color = _Stroke.DrawingAttributes.Color;
                    _Polygon.Points = _Points;
                    _Polygons.Add(_Polygon);
                }
                _Layers.Add(_Layer);
            }
            return _Layers;
        }