微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

学习笔记:Silverlight 三种动画 图片截取 循环给二维数组赋值

移动
Storyboard storyboard = new Storyboard();
//创建X轴方向动画
DoubleAnimation doubleAnimation = new DoubleAnimation(0,100,new Duration(TimeSpan.FromMilliseconds(500)));
Storyboard.SetTarget(doubleAnimation,rect);
Storyboard.SetTargetProperty(doubleAnimation,new PropertyPath("(Canvas.Left)"));
storyboard.Children.Add(doubleAnimation);
storyboard.Begin(); 

//注册界面刷新事件Loaded

CompositionTarget.Rendering +=newEventHandler(Timer_Tick);      //匀速

rivatevoid Timer_Tick(object sender,EventArgs e) {            }

 

//定义线程   循环

 dispatcherTimer dispatcherTimer =newdispatcherTimer(dispatcherPriority.normal);

 dispatcherTimer.Tick +=newEventHandler(Timer_Tick);

 dispatcherTimer.Interval =TimeSpan.FromMilliseconds(50);//重复间隔

 dispatcherTimer.Start();

 -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------------------------------

图片截取

image.soruce=new BitmapImage(new Uri(@"Player\" + count + ".png",UriKind.Relative));

private BitmapSource cutimage(string imgaddress,int x,int y,int width,int height)
 {
      return new CroppedBitmap(

                BitmapFrame.Create(new Uri(imgaddress,UriKind.Relative)),new Int32Rect(x,y,width,height)

                );

}


 

循环给二维数组赋值

privatebyte[,] Matrix = newbyte[1024,1024];

for (int y = 0; y < Matrix.GetUpperBound(1); y++) {

                for (int x = 0; x < Matrix.GetUpperBound(0); x++) {

                    Matrix[x,y] = 1;

                }

  }

 

SL光标

public static Cursor[] GameCursors = new Cursor[4];

        ///<summary>

        ///返回指定标号光标

        ///</summary>

        ///<param name="sign">标号</param>

        ///<returns>光标</returns>

        public static Cursor getCursor(int sign) {

            if (GameCursors[sign] == null) {

                GameCursors[sign] = new Cursor(new FileStream(string.Format(@"Cursors\{0}.ani",sign),FileMode.Open,FileAccess.Read,FileShare.Read));

            }

            return GameCursors[sign];

        }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐