示例#1
0
        /// <summary>
        /// Stamp an image at the current turtle position.
        /// If the offsets are zero, the top left corner of the image will be placed at the turtle's hotspot.
        /// </summary>
        /// <param name="imgSrc">The image to be stamped</param>
        /// <param name="hotspotX">X offset of image that will be aligned to turtle's current X position.</param>
        /// <param name="hotspotY">Y offset of image that will be aligned to turtle's current Y position.</param>
        /// <param name="useRotation">If true, the image will be rotated to the same heading as the turtle.</param>
        /// <returns></returns>
        public virtual Footprint Stamp(ImageSource imgSrc, double hotspotX = 0.0, double hotspotY = 0.0, bool useRotation = false)
        {
            Image img = new Image()
            {
                Source = imgSrc
            };
            TransformGroup tfg = buildCurrentTurtleTransform();

            if (!useRotation)
            {
                tfg.Children.RemoveAt(0);
            }
            if (hotspotX != 0.0 || hotspotY != 0.0)
            {
                tfg.Children.Insert(0, new TranslateTransform(-hotspotX, -hotspotY));
            }
            img.RenderTransform = tfg;

            Canvas.SetZIndex(img, footprintlayer);
            Footprint fp = new Footprint(img);

            Footprints.Add(fp);
            pumpAnimation();
            return(fp);
        }
示例#2
0
        /// <summary>
        /// Stamp a string at the current turtle position.
        /// </summary>
        /// <param name="str">The text to be written</param>
        /// <param name="offsetX">Relative X offset of text from turtle's current position.</param>
        /// <param name="offsetY">Relative Y offset of text from turtle's current position.</param>
        /// <param name="useRotation">If true, the text will rotate to the same heading as the turtle.</param>
        /// <returns></returns>
        public virtual Footprint Stamp(string str, double offsetX = 0.0, double offsetY = 0.0, bool useRotation = false)
        {
            Label lbl = new Label()
            {
                Content    = str,
                FontFamily = TextFontFamily,
                FontSize   = TextFontSize,
                FontWeight = TextFontWeight,
                Foreground = TextBrush
            };
            TransformGroup tfg = buildCurrentTurtleTransform();

            if (!useRotation)
            {
                tfg.Children.RemoveAt(0);
            }
            if (offsetX != 0.0 || offsetY != 0.0)
            {
                tfg.Children.Insert(0, new TranslateTransform(offsetX, offsetY));
            }
            lbl.RenderTransform = tfg;

            Canvas.SetZIndex(lbl, footprintlayer);
            Footprint fp = new Footprint(lbl);

            Footprints.Add(fp);
            pumpAnimation();
            return(fp);
        }
示例#3
0
        /// <summary>
        /// Stamp a uiElement at the current position, as a footprint.   The opacity settings for footprints are not applied here.
        /// </summary>
        /// <param name="theUIE"></param>
        /// <returns>The Footprint that was created.</returns>
        public virtual Footprint Stamp(UIElement theUIE)
        {
            TransformGroup tfg = theUIE.RenderTransform as TransformGroup;

            if (tfg == null)
            {
                tfg = new TransformGroup();
            }

            tfg.Children.Add(new RotateTransform(heading));
            tfg.Children.Add(new TranslateTransform(Position.X, Position.Y));
            theUIE.RenderTransform = tfg;

            Canvas.SetZIndex(theUIE, footprintlayer);
            Footprint fp = new Footprint(theUIE);

            Footprints.Add(fp);
            pumpAnimation();
            return(fp);
        }