学习笔记: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];

        }

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值