Morning all,

 

I'm probably doing something silly, but I can't seem to get the
following code to work.

 

I'm extending the TextView Class to make rotatable text.

 

public class RotatingTextView : TextView

    {

        private int _RotationDegrees;

        private int _RotationPointX;

        private int _RotationPointY;

 

        public int RotationDegrees

        {

            get

            {

                return _RotationDegrees;

            }

            set

            {

              _RotationDegrees = value;

            }

        }

 

        public int RotationPointX

        {

            get

            {

                return _RotationPointX;

            }

            set

            {

              _RotationPointX = value;

            }

        }

 

        public int RotationPointY

        {

            get

            {

                return _RotationPointY;

            }

            set

            {

              _RotationPointY = value;

            }

        }

 

        public RotatingTextView(IntPtr doNotUse)

            : base(doNotUse)

        {

            

        }

        public RotatingTextView(Context context)

            : base(context)

        {

            

        }

        public RotatingTextView(Context context,
Android.Util.IAttributeSet attrs)

            : base(context, attrs)

        {

            

        }

        public RotatingTextView(Context context,
Android.Util.IAttributeSet attrs, int defStyle)

            : base(context, attrs, defStyle)

        {

            

        }        

 

        protected override void OnDraw(Android.Graphics.Canvas canvas)

        {

            canvas.Save();

            Log.Debug("RotatingTextView.OnDraw", String.Format("Debug:
Rotating TextView {0}:{1} by {2} - {3} - {4}", Tag, Id,
_RotationDegrees, _RotationPointX, _RotationPointY));

            canvas.Rotate((float)_RotationDegrees,
(float)_RotationPointX, (float)_RotationPointY);

              base.OnDraw(canvas);

            canvas.Restore();

        }

    }

 

I'm using the Class in a fairly simple way:

 

RotatingTextView textView = new RotatingTextView();

                textView.RotationDegrees = 20;

                textView.RotationPointX = 100;

                textView.RotationPointY = 100;

  textView.Id = 10000;

                textView.Tag = "test";

(snipped other properties)

 

 

The Class works fine other than the "_Rotation*" properties are always
Zero.....I added a Debug print to output them in adb logcat and they are
all 0.....the "Tag" and "Id" are shown correctly though.

 

 

I'm stumped as to what I'm doing wrong, anybody any ideas?

 

 

Thanks,

 

Martyn

 


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
______________________________________________________________________
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to