移动
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];
}