silverlight中图片旋转问题

0

`private void init()        {            rnd = new Random();            for (int i = 0; i < butnum; i++)            {                int p = rnd.Next((int)Pictures.PointArrow.右,(int)Pictures.PointArrow.右上);                Image img = new Image();                img.Source = new BitmapImage(new Uri("img/point.png",UriKind.Relative));                TransformImage(img,(Pictures.PointArrow)p);                borderroundControl bc = new borderroundControl();                Border bdr = bc.FindName("borderround") as Border;                Canvas can = bc.FindName("can") as Canvas;                can.Children.Add(img);                bdr.Child = can;                canvasround.Children.Add(bc);                Canvas.SetLeft(bc, i * (bc.Width+4)+10);                Canvas.SetTop(bc,1);            }        }        private void TransformImage(Image img,Pictures.PointArrow p)        {                       RotateTransform rt = new RotateTransform();            switch (p)            {                case Pictures.PointArrow.右:                    rt.Angle = 0;                    break;                case Pictures.PointArrow.下:                    rt.Angle = 90;                    break;                case Pictures.PointArrow.左:                    rt.Angle = 180;                    break;                case Pictures.PointArrow.上:                    rt.Angle = 270;                    break;                case Pictures.PointArrow.右下:                    rt.Angle = 45;                    break;                case Pictures.PointArrow.左下:                    rt.Angle = 135;                    break;                case Pictures.PointArrow.左上:                    rt.Angle = 225;                    break;                case Pictures.PointArrow.右上:                    rt.Angle = 315;                    break;                default:                    rt.Angle = 0;                    break;            }            MessageBox.Show(rt.Angle.ToString());            rt.CenterX = 12;            rt.CenterY = 12;            img.RenderTransform=rt;        }    }`

0

您需要登录以后才能回答，未注册用户请先注册