Polygon Update...

Coordinator
Feb 4, 2009 at 9:16 PM
Updated Polygon to generically accept Brush for it's Fill property.  With FillColor we were limited the API to only accepted SolidColorBrush.  As an example of the enhancement, the Prototype Bermuda Triangle now sports a RadialGradientBrush. 

The Polygon.Fill API is now more consistent with the Fill API's on other Silverlight Framework UIElements.  If you were using FillColor, make sure change your call to call Polygon.Fill and pass in a SolidColorBrush, if that is what you still want to do.
polygon.FillColor = Colors.Green;  //Prior code without Brush Choice or reuse

polygon.Fill = new SolidColorBrush(Colors.Green);  //Current code with options for Brush type and resuse.

This has a potential performance benefit as well.  Previously, a new SolidColorBrush was created with each geometry.  Now if reusing the same color, you keep a variable reference to the brush and resuse it.


Feb 5, 2009 at 7:28 PM

Hi,

Interesting update for polygon “Updated Polygon to generically accept Brush for it's Fill property. “

I am playing a bit with ImageBrush and VideoBrush

            ImageBrush test = new ImageBrush();

            test.ImageSource = new BitmapImage(new Uri(@"Resources/MODAL2_M_AER_OD.png", UriKind.Relative));

polygon.Fill = test;

shapeLayer.Add(polygon);

Works, my only problem is working out the EPSG:4326 to 900913

However, I’m not so successful on VideoBrush:

            MediaElement me = new MediaElement();

            me.Source = new Uri(@"Resources/o3-movie.mpg", UriKind.Relative);

            VideoBrush video = new VideoBrush();

            video.SetSource(me);

            polygon.Fill = video;

            shapeLayer.Add(polygon);

            me.Play();

I’m not sure where my  problem is.

rkgeorge

From: RoadWarrior [mailto:notifications@codeplex.com]
Sent: Wednesday, February 04, 2009 2:16 PM
To: rkgeorge@cadmaps.com
Subject: Polygon Update... [deepearth:46250]

From: RoadWarrior

Updated Polygon to generically accept Brush for it's Fill property. With FillColor we were limited the API to only accepted SolidColorBrush. As an example of the enhancement, the Prototype Bermuda Triangle now sports a RadialGradientBrush.

The Polygon.Fill API is now more consistent with the Fill API's on other Silverlight Framework UIElements. If you were using FillColor, make sure change your call to call Polygon.Fill and pass in a SolidColorBrush, if that is what you still want to do.

polygon.FillColor = Colors.Green; //Prior code without Brush Choice or reuse

polygon.Fill = new SolidColorBrush(Colors.Green); //Current code with options for Brush type and resuse.

This has a potential performance benefit as well. Previously, a new SolidColorBrush was created with each geometry. Now if reusing the same color, you keep a variable reference to the brush and resuse it.

Read the full discussion online.

To add a post to this discussion, reply to this email (deepearth@discussions.codeplex.com)

To start a new discussion for this project, email deepearth@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Developer
Feb 6, 2009 at 8:08 AM
Edited Feb 6, 2009 at 8:10 AM
To get a video brush to work/play for me 
  • I had to move the code to the map.Loaded event.
  • I used the "SourceName" property on the VideoBrush.
This snippet loads a video file from Silverlight.net web site so may take a moment to start playing.

below is my simple test code snippet, is in the Prototype Page.cs file

          public Page()

        {

            InitializeComponent();

 

            //Choose your startup provider

            map.BaseLayer.Source = new VeTileSource(VeMapModes.VeHybrid);

            //map.BaseLayer.Source = new OsmTileSource(OsmMapModes.Mapnik);

            //map.BaseLayer.Source = new OamTileSource(OamMapModes.OAM);

 

            GeometryLayerTest();

 

            GeometryAnchorTest();

 

            map.Loaded += map_Loaded;

 

        }

 

        void map_Loaded(object sender, RoutedEventArgs e)

        {

            const string mediaElementName = "demoPolyVideo";

            const string mediaElementUrl = "http://download.microsoft.com/download/2/0/5/205d8c39-3d55-4032-8195-7b0e6eda4cb6/WinVideo-SL-InstallExperience.wmv";

 

            //Video Triangle is drawn on a GeometryLayer with TransformUpdate

            GeometryLayer videoTransformLayer = new GeometryLayer(map) { UpdateMode = GeometryLayer.UpdateModes.TransformUpdate, Opacity = 0.5 };

 

            map.Layers.Add(videoTransformLayer);

 

            Polygon videoPolygon = new Polygon();

            videoTransformLayer.Add(videoPolygon);

            videoPolygon.Points = new ObservableCollection<Point> { new Point(-60, 40), new Point(0, 40), new Point(-30, -30) };

 

            MediaElement mediaElement = new MediaElement { Name = mediaElementName, Height = 0, Width = 0, Source = new Uri(mediaElementUrl, UriKind.Absolute) };

 

            LayoutRoot.Children.Add(mediaElement);

            VideoBrush videoFillBrush = new VideoBrush { SourceName = mediaElementName };

            videoPolygon.Fill = videoFillBrush;

            System.Windows.Controls.ToolTipService.SetToolTip(videoPolygon, "Demo VideoBrush Triangle");

 

            videoTransformLayer.MouseEnter += videoTransformLayer_MouseEnter;

            videoTransformLayer.MouseLeave += videoTransformLayer_MouseLeave;

        }

 

        void videoTransformLayer_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)

        {

            var videoTransformLayer = sender as GeometryLayer;

            if(videoTransformLayer != null)

            {

                videoTransformLayer.Opacity = 0.5;

            }

        }

 

        void videoTransformLayer_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)

        {

            var videoTransformLayer = sender as GeometryLayer;

            if(videoTransformLayer != null)

            {

                videoTransformLayer.Opacity = 1.0;

            }

        }