學習筆記:Silverlight 三種動畫 圖片截取 迴圈給二維數組賦值

來源:互聯網
上載者:User
移動
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];

        }

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.